ltmain.sh revision 89b0dc75
1eca46af7Smrg#! /bin/sh 2eca46af7Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3eca46af7Smrg## by inline-source v2014-01-03.01 42378475aSmrg 589b0dc75Smrg# libtool (GNU libtool) 2.4.6 6eca46af7Smrg# Provide generalized library-building support services. 72378475aSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 82378475aSmrg 989b0dc75Smrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 102378475aSmrg# This is free software; see the source for copying conditions. There is NO 112378475aSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 122378475aSmrg 132378475aSmrg# GNU Libtool is free software; you can redistribute it and/or modify 1495b296d0Smrg# it under the terms of the GNU General Public License as published by 1595b296d0Smrg# the Free Software Foundation; either version 2 of the License, or 1695b296d0Smrg# (at your option) any later version. 1795b296d0Smrg# 182378475aSmrg# As a special exception to the GNU General Public License, 192378475aSmrg# if you distribute this file as part of a program or library that 202378475aSmrg# is built using GNU Libtool, you may include this file under the 212378475aSmrg# same distribution terms that you use for the rest of that program. 222378475aSmrg# 232378475aSmrg# GNU Libtool is distributed in the hope that it will be useful, but 2495b296d0Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 2595b296d0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 2695b296d0Smrg# General Public License for more details. 2795b296d0Smrg# 2895b296d0Smrg# You should have received a copy of the GNU General Public License 29eca46af7Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30e6f085baSmrg 3195b296d0Smrg 3214330f12SmrgPROGRAM=libtool 3395b296d0SmrgPACKAGE=libtool 3489b0dc75SmrgVERSION=2.4.6 3589b0dc75Smrgpackage_revision=2.4.6 36ff89ac2bSmrg 37eca46af7Smrg 38eca46af7Smrg## ------ ## 39eca46af7Smrg## Usage. ## 40eca46af7Smrg## ------ ## 41eca46af7Smrg 42eca46af7Smrg# Run './libtool --help' for help with using this script from the 43eca46af7Smrg# command line. 44eca46af7Smrg 45eca46af7Smrg 46eca46af7Smrg## ------------------------------- ## 47eca46af7Smrg## User overridable command paths. ## 48eca46af7Smrg## ------------------------------- ## 49eca46af7Smrg 50eca46af7Smrg# After configure completes, it has a better idea of some of the 51eca46af7Smrg# shell tools we need than the defaults used by the functions shared 52eca46af7Smrg# with bootstrap, so set those here where they can still be over- 53eca46af7Smrg# ridden by the user, but otherwise take precedence. 54eca46af7Smrg 55eca46af7Smrg: ${AUTOCONF="autoconf"} 56eca46af7Smrg: ${AUTOMAKE="automake"} 57eca46af7Smrg 58eca46af7Smrg 59eca46af7Smrg## -------------------------- ## 60eca46af7Smrg## Source external libraries. ## 61eca46af7Smrg## -------------------------- ## 62eca46af7Smrg 63eca46af7Smrg# Much of our low-level functionality needs to be sourced from external 64eca46af7Smrg# libraries, which are installed to $pkgauxdir. 65eca46af7Smrg 66eca46af7Smrg# Set a version string for this script. 6789b0dc75Smrgscriptversion=2015-01-20.17; # UTC 68eca46af7Smrg 69eca46af7Smrg# General shell script boiler plate, and helper functions. 70eca46af7Smrg# Written by Gary V. Vaughan, 2004 71eca46af7Smrg 7289b0dc75Smrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 73eca46af7Smrg# This is free software; see the source for copying conditions. There is NO 74eca46af7Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 75eca46af7Smrg 76eca46af7Smrg# This program is free software; you can redistribute it and/or modify 77eca46af7Smrg# it under the terms of the GNU General Public License as published by 78eca46af7Smrg# the Free Software Foundation; either version 3 of the License, or 79eca46af7Smrg# (at your option) any later version. 80eca46af7Smrg 81eca46af7Smrg# As a special exception to the GNU General Public License, if you distribute 82eca46af7Smrg# this file as part of a program or library that is built using GNU Libtool, 83eca46af7Smrg# you may include this file under the same distribution terms that you use 84eca46af7Smrg# for the rest of that program. 85eca46af7Smrg 86eca46af7Smrg# This program is distributed in the hope that it will be useful, 87eca46af7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 88eca46af7Smrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 89eca46af7Smrg# General Public License for more details. 90eca46af7Smrg 91eca46af7Smrg# You should have received a copy of the GNU General Public License 92eca46af7Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 93eca46af7Smrg 94eca46af7Smrg# Please report bugs or propose patches to gary@gnu.org. 95eca46af7Smrg 96eca46af7Smrg 97eca46af7Smrg## ------ ## 98eca46af7Smrg## Usage. ## 99eca46af7Smrg## ------ ## 100eca46af7Smrg 101eca46af7Smrg# Evaluate this file near the top of your script to gain access to 102eca46af7Smrg# the functions and variables defined here: 103eca46af7Smrg# 104eca46af7Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 105eca46af7Smrg# 106eca46af7Smrg# If you need to override any of the default environment variable 107eca46af7Smrg# settings, do that before evaluating this file. 108eca46af7Smrg 109eca46af7Smrg 110eca46af7Smrg## -------------------- ## 111eca46af7Smrg## Shell normalisation. ## 112eca46af7Smrg## -------------------- ## 113eca46af7Smrg 114eca46af7Smrg# Some shells need a little help to be as Bourne compatible as possible. 115eca46af7Smrg# Before doing anything else, make sure all that help has been provided! 116eca46af7Smrg 117eca46af7SmrgDUALCASE=1; export DUALCASE # for MKS sh 118eca46af7Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 119ff89ac2bSmrg emulate sh 120ff89ac2bSmrg NULLCMD=: 121eca46af7Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 122ff89ac2bSmrg # is contrary to our usage. Disable this feature. 123ff89ac2bSmrg alias -g '${1+"$@"}'='"$@"' 12495b296d0Smrg setopt NO_GLOB_SUBST 125ff89ac2bSmrgelse 126eca46af7Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 12795b296d0Smrgfi 12814330f12Smrg 129eca46af7Smrg# NLS nuisances: We save the old values in case they are required later. 130eca46af7Smrg_G_user_locale= 131eca46af7Smrg_G_safe_locale= 132eca46af7Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 133ff89ac2bSmrgdo 134eca46af7Smrg eval "if test set = \"\${$_G_var+set}\"; then 135eca46af7Smrg save_$_G_var=\$$_G_var 136eca46af7Smrg $_G_var=C 137eca46af7Smrg export $_G_var 138eca46af7Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 139eca46af7Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 140ff89ac2bSmrg fi" 141ff89ac2bSmrgdone 142ff89ac2bSmrg 143eca46af7Smrg# CDPATH. 144eca46af7Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 1452378475aSmrg 146eca46af7Smrg# Make sure IFS has a sensible default 147eca46af7Smrgsp=' ' 148eca46af7Smrgnl=' 149eca46af7Smrg' 150eca46af7SmrgIFS="$sp $nl" 151eca46af7Smrg 152eca46af7Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 153eca46af7Smrgif test "${PATH_SEPARATOR+set}" != set; then 154eca46af7Smrg PATH_SEPARATOR=: 155eca46af7Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 156eca46af7Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 157eca46af7Smrg PATH_SEPARATOR=';' 158eca46af7Smrg } 159eca46af7Smrgfi 1602378475aSmrg 1612378475aSmrg 1622378475aSmrg 163eca46af7Smrg## ------------------------- ## 164eca46af7Smrg## Locate command utilities. ## 165eca46af7Smrg## ------------------------- ## 166eca46af7Smrg 167eca46af7Smrg 168eca46af7Smrg# func_executable_p FILE 169eca46af7Smrg# ---------------------- 170eca46af7Smrg# Check that FILE is an executable regular file. 171eca46af7Smrgfunc_executable_p () 172eca46af7Smrg{ 173eca46af7Smrg test -f "$1" && test -x "$1" 174eca46af7Smrg} 175eca46af7Smrg 176eca46af7Smrg 177eca46af7Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 178eca46af7Smrg# -------------------------------------------- 179eca46af7Smrg# Search for either a program that responds to --version with output 180eca46af7Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 181eca46af7Smrg# trying all the directories in PATH with each of the elements of 182eca46af7Smrg# PROGS_LIST. 183eca46af7Smrg# 184eca46af7Smrg# CHECK_FUNC should accept the path to a candidate program, and 185eca46af7Smrg# set $func_check_prog_result if it truncates its output less than 186eca46af7Smrg# $_G_path_prog_max characters. 187eca46af7Smrgfunc_path_progs () 188eca46af7Smrg{ 189eca46af7Smrg _G_progs_list=$1 190eca46af7Smrg _G_check_func=$2 191eca46af7Smrg _G_PATH=${3-"$PATH"} 192eca46af7Smrg 193eca46af7Smrg _G_path_prog_max=0 194eca46af7Smrg _G_path_prog_found=false 19589b0dc75Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 196eca46af7Smrg for _G_dir in $_G_PATH; do 197eca46af7Smrg IFS=$_G_save_IFS 198eca46af7Smrg test -z "$_G_dir" && _G_dir=. 199eca46af7Smrg for _G_prog_name in $_G_progs_list; do 200eca46af7Smrg for _exeext in '' .EXE; do 201eca46af7Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 202eca46af7Smrg func_executable_p "$_G_path_prog" || continue 203eca46af7Smrg case `"$_G_path_prog" --version 2>&1` in 204eca46af7Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 205eca46af7Smrg *) $_G_check_func $_G_path_prog 206eca46af7Smrg func_path_progs_result=$func_check_prog_result 207eca46af7Smrg ;; 208eca46af7Smrg esac 209eca46af7Smrg $_G_path_prog_found && break 3 210eca46af7Smrg done 211eca46af7Smrg done 212eca46af7Smrg done 213eca46af7Smrg IFS=$_G_save_IFS 214eca46af7Smrg test -z "$func_path_progs_result" && { 215eca46af7Smrg echo "no acceptable sed could be found in \$PATH" >&2 216eca46af7Smrg exit 1 217eca46af7Smrg } 218eca46af7Smrg} 219eca46af7Smrg 220eca46af7Smrg 221eca46af7Smrg# We want to be able to use the functions in this file before configure 222eca46af7Smrg# has figured out where the best binaries are kept, which means we have 223eca46af7Smrg# to search for them ourselves - except when the results are already set 224eca46af7Smrg# where we skip the searches. 225eca46af7Smrg 226eca46af7Smrg# Unless the user overrides by setting SED, search the path for either GNU 227eca46af7Smrg# sed, or the sed that truncates its output the least. 228eca46af7Smrgtest -z "$SED" && { 229eca46af7Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 230eca46af7Smrg for _G_i in 1 2 3 4 5 6 7; do 231eca46af7Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 232eca46af7Smrg done 233eca46af7Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 234eca46af7Smrg _G_sed_script= 235eca46af7Smrg 236eca46af7Smrg func_check_prog_sed () 237eca46af7Smrg { 238eca46af7Smrg _G_path_prog=$1 239eca46af7Smrg 240eca46af7Smrg _G_count=0 241eca46af7Smrg printf 0123456789 >conftest.in 242eca46af7Smrg while : 243eca46af7Smrg do 244eca46af7Smrg cat conftest.in conftest.in >conftest.tmp 245eca46af7Smrg mv conftest.tmp conftest.in 246eca46af7Smrg cp conftest.in conftest.nl 247eca46af7Smrg echo '' >> conftest.nl 248eca46af7Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 249eca46af7Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 250eca46af7Smrg _G_count=`expr $_G_count + 1` 251eca46af7Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 252eca46af7Smrg # Best one so far, save it but keep looking for a better one 253eca46af7Smrg func_check_prog_result=$_G_path_prog 254eca46af7Smrg _G_path_prog_max=$_G_count 255eca46af7Smrg fi 256eca46af7Smrg # 10*(2^10) chars as input seems more than enough 257eca46af7Smrg test 10 -lt "$_G_count" && break 258eca46af7Smrg done 259eca46af7Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 260eca46af7Smrg } 261eca46af7Smrg 262eca46af7Smrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 263eca46af7Smrg rm -f conftest.sed 264eca46af7Smrg SED=$func_path_progs_result 265eca46af7Smrg} 266eca46af7Smrg 267eca46af7Smrg 268eca46af7Smrg# Unless the user overrides by setting GREP, search the path for either GNU 269eca46af7Smrg# grep, or the grep that truncates its output the least. 270eca46af7Smrgtest -z "$GREP" && { 271eca46af7Smrg func_check_prog_grep () 272eca46af7Smrg { 273eca46af7Smrg _G_path_prog=$1 274eca46af7Smrg 275eca46af7Smrg _G_count=0 276eca46af7Smrg _G_path_prog_max=0 277eca46af7Smrg printf 0123456789 >conftest.in 278eca46af7Smrg while : 279eca46af7Smrg do 280eca46af7Smrg cat conftest.in conftest.in >conftest.tmp 281eca46af7Smrg mv conftest.tmp conftest.in 282eca46af7Smrg cp conftest.in conftest.nl 283eca46af7Smrg echo 'GREP' >> conftest.nl 284eca46af7Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 285eca46af7Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 286eca46af7Smrg _G_count=`expr $_G_count + 1` 287eca46af7Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 288eca46af7Smrg # Best one so far, save it but keep looking for a better one 289eca46af7Smrg func_check_prog_result=$_G_path_prog 290eca46af7Smrg _G_path_prog_max=$_G_count 291eca46af7Smrg fi 292eca46af7Smrg # 10*(2^10) chars as input seems more than enough 293eca46af7Smrg test 10 -lt "$_G_count" && break 294eca46af7Smrg done 295eca46af7Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 296eca46af7Smrg } 297eca46af7Smrg 298eca46af7Smrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 299eca46af7Smrg GREP=$func_path_progs_result 300eca46af7Smrg} 301eca46af7Smrg 302eca46af7Smrg 303eca46af7Smrg## ------------------------------- ## 304eca46af7Smrg## User overridable command paths. ## 305eca46af7Smrg## ------------------------------- ## 306eca46af7Smrg 307eca46af7Smrg# All uppercase variable names are used for environment variables. These 308eca46af7Smrg# variables can be overridden by the user before calling a script that 309eca46af7Smrg# uses them if a suitable command of that name is not already available 310eca46af7Smrg# in the command search PATH. 3112378475aSmrg 3122378475aSmrg: ${CP="cp -f"} 313eca46af7Smrg: ${ECHO="printf %s\n"} 314eca46af7Smrg: ${EGREP="$GREP -E"} 315eca46af7Smrg: ${FGREP="$GREP -F"} 3162378475aSmrg: ${LN_S="ln -s"} 3172378475aSmrg: ${MAKE="make"} 3182378475aSmrg: ${MKDIR="mkdir"} 3192378475aSmrg: ${MV="mv -f"} 3202378475aSmrg: ${RM="rm -f"} 3212378475aSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 32295b296d0Smrg 3232378475aSmrg 324eca46af7Smrg## -------------------- ## 325eca46af7Smrg## Useful sed snippets. ## 326eca46af7Smrg## -------------------- ## 32714330f12Smrg 328eca46af7Smrgsed_dirname='s|/[^/]*$||' 329eca46af7Smrgsed_basename='s|^.*/||' 33014330f12Smrg 331eca46af7Smrg# Sed substitution that helps us do robust quoting. It backslashifies 332eca46af7Smrg# metacharacters that are still active within double-quoted strings. 333eca46af7Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 33414330f12Smrg 335eca46af7Smrg# Same as above, but do not quote variable references. 336eca46af7Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 33714330f12Smrg 338eca46af7Smrg# Sed substitution that turns a string into a regex matching for the 339eca46af7Smrg# string literally. 340eca46af7Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 34114330f12Smrg 342eca46af7Smrg# Sed substitution that converts a w32 file name or path 343eca46af7Smrg# that contains forward slashes, into one that contains 344eca46af7Smrg# (escaped) backslashes. A very naive implementation. 345eca46af7Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 346eca46af7Smrg 347eca46af7Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 348eca46af7Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 349eca46af7Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 350eca46af7Smrg# expansion. Since each input '\' is now two '\'s, look for any number 351eca46af7Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 352eca46af7Smrg_G_bs='\\' 353eca46af7Smrg_G_bs2='\\\\' 354eca46af7Smrg_G_bs4='\\\\\\\\' 355eca46af7Smrg_G_dollar='\$' 356eca46af7Smrgsed_double_backslash="\ 357eca46af7Smrg s/$_G_bs4/&\\ 358eca46af7Smrg/g 359eca46af7Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 360eca46af7Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 361eca46af7Smrg s/\n//g" 36214330f12Smrg 36314330f12Smrg 364eca46af7Smrg## ----------------- ## 365eca46af7Smrg## Global variables. ## 366eca46af7Smrg## ----------------- ## 36714330f12Smrg 368eca46af7Smrg# Except for the global variables explicitly listed below, the following 369eca46af7Smrg# functions in the '^func_' namespace, and the '^require_' namespace 370eca46af7Smrg# variables initialised in the 'Resource management' section, sourcing 371eca46af7Smrg# this file will not pollute your global namespace with anything 372eca46af7Smrg# else. There's no portable way to scope variables in Bourne shell 373eca46af7Smrg# though, so actually running these functions will sometimes place 374eca46af7Smrg# results into a variable named after the function, and often use 375eca46af7Smrg# temporary variables in the '^_G_' namespace. If you are careful to 376eca46af7Smrg# avoid using those namespaces casually in your sourcing script, things 377eca46af7Smrg# should continue to work as you expect. And, of course, you can freely 378eca46af7Smrg# overwrite any of the functions or variables defined here before 379eca46af7Smrg# calling anything to customize them. 38014330f12Smrg 381eca46af7SmrgEXIT_SUCCESS=0 382eca46af7SmrgEXIT_FAILURE=1 383eca46af7SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 384eca46af7SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 38539713583Smrg 386eca46af7Smrg# Allow overriding, eg assuming that you follow the convention of 387eca46af7Smrg# putting '$debug_cmd' at the start of all your functions, you can get 388eca46af7Smrg# bash to show function call trace with: 389eca46af7Smrg# 390eca46af7Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 391eca46af7Smrgdebug_cmd=${debug_cmd-":"} 392eca46af7Smrgexit_cmd=: 3932378475aSmrg 394eca46af7Smrg# By convention, finish your script with: 395eca46af7Smrg# 396eca46af7Smrg# exit $exit_status 397eca46af7Smrg# 398eca46af7Smrg# so that you can set exit_status to non-zero if you want to indicate 399eca46af7Smrg# something went wrong during execution without actually bailing out at 400eca46af7Smrg# the point of failure. 401eca46af7Smrgexit_status=$EXIT_SUCCESS 40214330f12Smrg 403eca46af7Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 404eca46af7Smrg# is ksh but when the shell is invoked as "sh" and the current value of 405eca46af7Smrg# the _XPG environment variable is not equal to 1 (one), the special 406eca46af7Smrg# positional parameter $0, within a function call, is the name of the 407eca46af7Smrg# function. 408eca46af7Smrgprogpath=$0 4092378475aSmrg 410eca46af7Smrg# The name of this program. 411eca46af7Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 4122378475aSmrg 413eca46af7Smrg# Make sure we have an absolute progpath for reexecution: 4142378475aSmrgcase $progpath in 4152378475aSmrg [\\/]*|[A-Za-z]:\\*) ;; 4162378475aSmrg *[\\/]*) 417eca46af7Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 4182378475aSmrg progdir=`cd "$progdir" && pwd` 419eca46af7Smrg progpath=$progdir/$progname 4202378475aSmrg ;; 4212378475aSmrg *) 422eca46af7Smrg _G_IFS=$IFS 423eca46af7Smrg IFS=${PATH_SEPARATOR-:} 4242378475aSmrg for progdir in $PATH; do 425eca46af7Smrg IFS=$_G_IFS 4262378475aSmrg test -x "$progdir/$progname" && break 4272378475aSmrg done 428eca46af7Smrg IFS=$_G_IFS 4292378475aSmrg test -n "$progdir" || progdir=`pwd` 430eca46af7Smrg progpath=$progdir/$progname 4312378475aSmrg ;; 4322378475aSmrgesac 4332378475aSmrg 4342378475aSmrg 435eca46af7Smrg## ----------------- ## 436eca46af7Smrg## Standard options. ## 437eca46af7Smrg## ----------------- ## 43814330f12Smrg 439eca46af7Smrg# The following options affect the operation of the functions defined 440eca46af7Smrg# below, and should be set appropriately depending on run-time para- 441eca46af7Smrg# meters passed on the command line. 4422378475aSmrg 4432378475aSmrgopt_dry_run=false 4442378475aSmrgopt_quiet=false 4452378475aSmrgopt_verbose=false 4462378475aSmrg 447eca46af7Smrg# Categories 'all' and 'none' are always available. Append any others 448eca46af7Smrg# you will pass as the first argument to func_warning from your own 449eca46af7Smrg# code. 450eca46af7Smrgwarning_categories= 4512378475aSmrg 452eca46af7Smrg# By default, display warnings according to 'opt_warning_types'. Set 453eca46af7Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 454eca46af7Smrg# treat the next displayed warning as a fatal error. 455eca46af7Smrgwarning_func=func_warn_and_continue 4562378475aSmrg 457eca46af7Smrg# Set to 'all' to display all warnings, 'none' to suppress all 458eca46af7Smrg# warnings, or a space delimited list of some subset of 459eca46af7Smrg# 'warning_categories' to display only the listed warnings. 460eca46af7Smrgopt_warning_types=all 4612378475aSmrg 46214330f12Smrg 463eca46af7Smrg## -------------------- ## 464eca46af7Smrg## Resource management. ## 465eca46af7Smrg## -------------------- ## 4662378475aSmrg 467eca46af7Smrg# This section contains definitions for functions that each ensure a 468eca46af7Smrg# particular resource (a file, or a non-empty configuration variable for 469eca46af7Smrg# example) is available, and if appropriate to extract default values 470eca46af7Smrg# from pertinent package files. Call them using their associated 471eca46af7Smrg# 'require_*' variable to ensure that they are executed, at most, once. 472eca46af7Smrg# 473eca46af7Smrg# It's entirely deliberate that calling these functions can set 474eca46af7Smrg# variables that don't obey the namespace limitations obeyed by the rest 475eca46af7Smrg# of this file, in order that that they be as useful as possible to 476eca46af7Smrg# callers. 4772378475aSmrg 4782378475aSmrg 479eca46af7Smrg# require_term_colors 480eca46af7Smrg# ------------------- 481eca46af7Smrg# Allow display of bold text on terminals that support it. 482eca46af7Smrgrequire_term_colors=func_require_term_colors 483eca46af7Smrgfunc_require_term_colors () 4842378475aSmrg{ 485eca46af7Smrg $debug_cmd 486eca46af7Smrg 487eca46af7Smrg test -t 1 && { 488eca46af7Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 489eca46af7Smrg # precedence, because most terminfo databases neglect to describe 490eca46af7Smrg # whether color sequences are supported. 491eca46af7Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 492eca46af7Smrg 493eca46af7Smrg if test 1 = "$USE_ANSI_COLORS"; then 494eca46af7Smrg # Standard ANSI escape sequences 495eca46af7Smrg tc_reset='[0m' 496eca46af7Smrg tc_bold='[1m'; tc_standout='[7m' 497eca46af7Smrg tc_red='[31m'; tc_green='[32m' 498eca46af7Smrg tc_blue='[34m'; tc_cyan='[36m' 499eca46af7Smrg else 500eca46af7Smrg # Otherwise trust the terminfo database after all. 501eca46af7Smrg test -n "`tput sgr0 2>/dev/null`" && { 502eca46af7Smrg tc_reset=`tput sgr0` 503eca46af7Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 504eca46af7Smrg tc_standout=$tc_bold 505eca46af7Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 506eca46af7Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 507eca46af7Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 508eca46af7Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 509eca46af7Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 510eca46af7Smrg } 511eca46af7Smrg fi 512eca46af7Smrg } 5132378475aSmrg 514eca46af7Smrg require_term_colors=: 5152378475aSmrg} 5162378475aSmrg 5172378475aSmrg 518eca46af7Smrg## ----------------- ## 519eca46af7Smrg## Function library. ## 520eca46af7Smrg## ----------------- ## 521eca46af7Smrg 522eca46af7Smrg# This section contains a variety of useful functions to call in your 523eca46af7Smrg# scripts. Take note of the portable wrappers for features provided by 524eca46af7Smrg# some modern shells, which will fall back to slower equivalents on 525eca46af7Smrg# less featureful shells. 526eca46af7Smrg 527eca46af7Smrg 528eca46af7Smrg# func_append VAR VALUE 529eca46af7Smrg# --------------------- 530eca46af7Smrg# Append VALUE onto the existing contents of VAR. 531eca46af7Smrg 532eca46af7Smrg # We should try to minimise forks, especially on Windows where they are 533eca46af7Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 534eca46af7Smrg # being used: 535eca46af7Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 536eca46af7Smrg : ${_G_HAVE_ARITH_OP="yes"} 537eca46af7Smrg : ${_G_HAVE_XSI_OPS="yes"} 538eca46af7Smrg # The += operator was introduced in bash 3.1 539eca46af7Smrg case $BASH_VERSION in 540eca46af7Smrg [12].* | 3.0 | 3.0*) ;; 541eca46af7Smrg *) 542eca46af7Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 543eca46af7Smrg ;; 544eca46af7Smrg esac 545eca46af7Smrg fi 546eca46af7Smrg 547eca46af7Smrg # _G_HAVE_PLUSEQ_OP 548eca46af7Smrg # Can be empty, in which case the shell is probed, "yes" if += is 549eca46af7Smrg # useable or anything else if it does not work. 550eca46af7Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 551eca46af7Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 552eca46af7Smrg && _G_HAVE_PLUSEQ_OP=yes 553eca46af7Smrg 554eca46af7Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 555eca46af7Smrgthen 556eca46af7Smrg # This is an XSI compatible shell, allowing a faster implementation... 557eca46af7Smrg eval 'func_append () 558eca46af7Smrg { 559eca46af7Smrg $debug_cmd 560eca46af7Smrg 561eca46af7Smrg eval "$1+=\$2" 562eca46af7Smrg }' 563eca46af7Smrgelse 564eca46af7Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 565eca46af7Smrg func_append () 566eca46af7Smrg { 567eca46af7Smrg $debug_cmd 568eca46af7Smrg 569eca46af7Smrg eval "$1=\$$1\$2" 570eca46af7Smrg } 571eca46af7Smrgfi 572eca46af7Smrg 573eca46af7Smrg 574eca46af7Smrg# func_append_quoted VAR VALUE 575eca46af7Smrg# ---------------------------- 576eca46af7Smrg# Quote VALUE and append to the end of shell variable VAR, separated 577eca46af7Smrg# by a space. 578eca46af7Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 579eca46af7Smrg eval 'func_append_quoted () 580eca46af7Smrg { 581eca46af7Smrg $debug_cmd 582eca46af7Smrg 583eca46af7Smrg func_quote_for_eval "$2" 584eca46af7Smrg eval "$1+=\\ \$func_quote_for_eval_result" 585eca46af7Smrg }' 586eca46af7Smrgelse 587eca46af7Smrg func_append_quoted () 588eca46af7Smrg { 589eca46af7Smrg $debug_cmd 590eca46af7Smrg 591eca46af7Smrg func_quote_for_eval "$2" 592eca46af7Smrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 593eca46af7Smrg } 594eca46af7Smrgfi 595eca46af7Smrg 596eca46af7Smrg 597eca46af7Smrg# func_append_uniq VAR VALUE 598eca46af7Smrg# -------------------------- 599eca46af7Smrg# Append unique VALUE onto the existing contents of VAR, assuming 600eca46af7Smrg# entries are delimited by the first character of VALUE. For example: 601eca46af7Smrg# 602eca46af7Smrg# func_append_uniq options " --another-option option-argument" 603eca46af7Smrg# 604eca46af7Smrg# will only append to $options if " --another-option option-argument " 605eca46af7Smrg# is not already present somewhere in $options already (note spaces at 606eca46af7Smrg# each end implied by leading space in second argument). 607eca46af7Smrgfunc_append_uniq () 608eca46af7Smrg{ 609eca46af7Smrg $debug_cmd 610eca46af7Smrg 611eca46af7Smrg eval _G_current_value='`$ECHO $'$1'`' 612eca46af7Smrg _G_delim=`expr "$2" : '\(.\)'` 613eca46af7Smrg 614eca46af7Smrg case $_G_delim$_G_current_value$_G_delim in 615eca46af7Smrg *"$2$_G_delim"*) ;; 616eca46af7Smrg *) func_append "$@" ;; 617eca46af7Smrg esac 618eca46af7Smrg} 619eca46af7Smrg 620eca46af7Smrg 621eca46af7Smrg# func_arith TERM... 622eca46af7Smrg# ------------------ 623eca46af7Smrg# Set func_arith_result to the result of evaluating TERMs. 624eca46af7Smrg test -z "$_G_HAVE_ARITH_OP" \ 625eca46af7Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 626eca46af7Smrg && _G_HAVE_ARITH_OP=yes 627eca46af7Smrg 628eca46af7Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 629eca46af7Smrg eval 'func_arith () 630eca46af7Smrg { 631eca46af7Smrg $debug_cmd 632eca46af7Smrg 633eca46af7Smrg func_arith_result=$(( $* )) 634eca46af7Smrg }' 635eca46af7Smrgelse 636eca46af7Smrg func_arith () 637eca46af7Smrg { 638eca46af7Smrg $debug_cmd 639eca46af7Smrg 640eca46af7Smrg func_arith_result=`expr "$@"` 641eca46af7Smrg } 642eca46af7Smrgfi 643eca46af7Smrg 644eca46af7Smrg 645eca46af7Smrg# func_basename FILE 646eca46af7Smrg# ------------------ 647eca46af7Smrg# Set func_basename_result to FILE with everything up to and including 648eca46af7Smrg# the last / stripped. 649eca46af7Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 650eca46af7Smrg # If this shell supports suffix pattern removal, then use it to avoid 651eca46af7Smrg # forking. Hide the definitions single quotes in case the shell chokes 652eca46af7Smrg # on unsupported syntax... 653eca46af7Smrg _b='func_basename_result=${1##*/}' 654eca46af7Smrg _d='case $1 in 655eca46af7Smrg */*) func_dirname_result=${1%/*}$2 ;; 656eca46af7Smrg * ) func_dirname_result=$3 ;; 657eca46af7Smrg esac' 658eca46af7Smrg 659eca46af7Smrgelse 660eca46af7Smrg # ...otherwise fall back to using sed. 661eca46af7Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 662eca46af7Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 663eca46af7Smrg if test "X$func_dirname_result" = "X$1"; then 664eca46af7Smrg func_dirname_result=$3 665eca46af7Smrg else 666eca46af7Smrg func_append func_dirname_result "$2" 667eca46af7Smrg fi' 668eca46af7Smrgfi 669eca46af7Smrg 670eca46af7Smrgeval 'func_basename () 671eca46af7Smrg{ 672eca46af7Smrg $debug_cmd 673eca46af7Smrg 674eca46af7Smrg '"$_b"' 675eca46af7Smrg}' 676eca46af7Smrg 677eca46af7Smrg 678eca46af7Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 679eca46af7Smrg# ------------------------------------------- 680eca46af7Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 681eca46af7Smrg# otherwise set result to NONDIR_REPLACEMENT. 682eca46af7Smrgeval 'func_dirname () 683eca46af7Smrg{ 684eca46af7Smrg $debug_cmd 685eca46af7Smrg 686eca46af7Smrg '"$_d"' 687eca46af7Smrg}' 688eca46af7Smrg 689eca46af7Smrg 690eca46af7Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 691eca46af7Smrg# -------------------------------------------------------- 692eca46af7Smrg# Perform func_basename and func_dirname in a single function 693eca46af7Smrg# call: 694eca46af7Smrg# dirname: Compute the dirname of FILE. If nonempty, 695eca46af7Smrg# add APPEND to the result, otherwise set result 696eca46af7Smrg# to NONDIR_REPLACEMENT. 697eca46af7Smrg# value returned in "$func_dirname_result" 698eca46af7Smrg# basename: Compute filename of FILE. 699eca46af7Smrg# value retuned in "$func_basename_result" 700eca46af7Smrg# For efficiency, we do not delegate to the functions above but instead 701eca46af7Smrg# duplicate the functionality here. 702eca46af7Smrgeval 'func_dirname_and_basename () 703eca46af7Smrg{ 704eca46af7Smrg $debug_cmd 705eca46af7Smrg 706eca46af7Smrg '"$_b"' 707eca46af7Smrg '"$_d"' 708eca46af7Smrg}' 709eca46af7Smrg 710eca46af7Smrg 711eca46af7Smrg# func_echo ARG... 712eca46af7Smrg# ---------------- 713eca46af7Smrg# Echo program name prefixed message. 714eca46af7Smrgfunc_echo () 715eca46af7Smrg{ 716eca46af7Smrg $debug_cmd 717eca46af7Smrg 718eca46af7Smrg _G_message=$* 719eca46af7Smrg 720eca46af7Smrg func_echo_IFS=$IFS 721eca46af7Smrg IFS=$nl 722eca46af7Smrg for _G_line in $_G_message; do 723eca46af7Smrg IFS=$func_echo_IFS 724eca46af7Smrg $ECHO "$progname: $_G_line" 725eca46af7Smrg done 726eca46af7Smrg IFS=$func_echo_IFS 727eca46af7Smrg} 728eca46af7Smrg 729eca46af7Smrg 730eca46af7Smrg# func_echo_all ARG... 731eca46af7Smrg# -------------------- 732eca46af7Smrg# Invoke $ECHO with all args, space-separated. 733eca46af7Smrgfunc_echo_all () 734eca46af7Smrg{ 735eca46af7Smrg $ECHO "$*" 736eca46af7Smrg} 737eca46af7Smrg 738eca46af7Smrg 739eca46af7Smrg# func_echo_infix_1 INFIX ARG... 740eca46af7Smrg# ------------------------------ 741eca46af7Smrg# Echo program name, followed by INFIX on the first line, with any 742eca46af7Smrg# additional lines not showing INFIX. 743eca46af7Smrgfunc_echo_infix_1 () 744eca46af7Smrg{ 745eca46af7Smrg $debug_cmd 746eca46af7Smrg 747eca46af7Smrg $require_term_colors 748eca46af7Smrg 749eca46af7Smrg _G_infix=$1; shift 750eca46af7Smrg _G_indent=$_G_infix 751eca46af7Smrg _G_prefix="$progname: $_G_infix: " 752eca46af7Smrg _G_message=$* 753eca46af7Smrg 754eca46af7Smrg # Strip color escape sequences before counting printable length 755eca46af7Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 756eca46af7Smrg do 757eca46af7Smrg test -n "$_G_tc" && { 758eca46af7Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 759eca46af7Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 760eca46af7Smrg } 761eca46af7Smrg done 762eca46af7Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 763eca46af7Smrg 764eca46af7Smrg func_echo_infix_1_IFS=$IFS 765eca46af7Smrg IFS=$nl 766eca46af7Smrg for _G_line in $_G_message; do 767eca46af7Smrg IFS=$func_echo_infix_1_IFS 768eca46af7Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 769eca46af7Smrg _G_prefix=$_G_indent 770eca46af7Smrg done 771eca46af7Smrg IFS=$func_echo_infix_1_IFS 772eca46af7Smrg} 773eca46af7Smrg 774eca46af7Smrg 775eca46af7Smrg# func_error ARG... 776eca46af7Smrg# ----------------- 777eca46af7Smrg# Echo program name prefixed message to standard error. 778eca46af7Smrgfunc_error () 779eca46af7Smrg{ 780eca46af7Smrg $debug_cmd 781eca46af7Smrg 782eca46af7Smrg $require_term_colors 783eca46af7Smrg 784eca46af7Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 785eca46af7Smrg} 786eca46af7Smrg 787eca46af7Smrg 788eca46af7Smrg# func_fatal_error ARG... 789eca46af7Smrg# ----------------------- 790eca46af7Smrg# Echo program name prefixed message to standard error, and exit. 791eca46af7Smrgfunc_fatal_error () 792eca46af7Smrg{ 793eca46af7Smrg $debug_cmd 794eca46af7Smrg 795eca46af7Smrg func_error "$*" 796eca46af7Smrg exit $EXIT_FAILURE 797eca46af7Smrg} 798eca46af7Smrg 799eca46af7Smrg 800eca46af7Smrg# func_grep EXPRESSION FILENAME 801eca46af7Smrg# ----------------------------- 8022378475aSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 8032378475aSmrgfunc_grep () 8042378475aSmrg{ 805eca46af7Smrg $debug_cmd 806eca46af7Smrg 8072378475aSmrg $GREP "$1" "$2" >/dev/null 2>&1 8082378475aSmrg} 8092378475aSmrg 8102378475aSmrg 811eca46af7Smrg# func_len STRING 812eca46af7Smrg# --------------- 813eca46af7Smrg# Set func_len_result to the length of STRING. STRING may not 814eca46af7Smrg# start with a hyphen. 815eca46af7Smrg test -z "$_G_HAVE_XSI_OPS" \ 816eca46af7Smrg && (eval 'x=a/b/c; 817eca46af7Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 818eca46af7Smrg && _G_HAVE_XSI_OPS=yes 819eca46af7Smrg 820eca46af7Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 821eca46af7Smrg eval 'func_len () 822eca46af7Smrg { 823eca46af7Smrg $debug_cmd 824eca46af7Smrg 825eca46af7Smrg func_len_result=${#1} 826eca46af7Smrg }' 827eca46af7Smrgelse 828eca46af7Smrg func_len () 829eca46af7Smrg { 830eca46af7Smrg $debug_cmd 831eca46af7Smrg 832eca46af7Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 833eca46af7Smrg } 834eca46af7Smrgfi 835eca46af7Smrg 836eca46af7Smrg 837eca46af7Smrg# func_mkdir_p DIRECTORY-PATH 838eca46af7Smrg# --------------------------- 8392378475aSmrg# Make sure the entire path to DIRECTORY-PATH is available. 8402378475aSmrgfunc_mkdir_p () 8412378475aSmrg{ 842eca46af7Smrg $debug_cmd 8432378475aSmrg 844eca46af7Smrg _G_directory_path=$1 845eca46af7Smrg _G_dir_list= 8462378475aSmrg 847eca46af7Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 848eca46af7Smrg 849eca46af7Smrg # Protect directory names starting with '-' 850eca46af7Smrg case $_G_directory_path in 851eca46af7Smrg -*) _G_directory_path=./$_G_directory_path ;; 8522378475aSmrg esac 8532378475aSmrg 8542378475aSmrg # While some portion of DIR does not yet exist... 855eca46af7Smrg while test ! -d "$_G_directory_path"; do 8562378475aSmrg # ...make a list in topmost first order. Use a colon delimited 8572378475aSmrg # list incase some portion of path contains whitespace. 858eca46af7Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 8592378475aSmrg 8602378475aSmrg # If the last portion added has no slash in it, the list is done 861eca46af7Smrg case $_G_directory_path in */*) ;; *) break ;; esac 8622378475aSmrg 8632378475aSmrg # ...otherwise throw away the child directory and loop 864eca46af7Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 8652378475aSmrg done 866eca46af7Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 8672378475aSmrg 868eca46af7Smrg func_mkdir_p_IFS=$IFS; IFS=: 869eca46af7Smrg for _G_dir in $_G_dir_list; do 870eca46af7Smrg IFS=$func_mkdir_p_IFS 871eca46af7Smrg # mkdir can fail with a 'File exist' error if two processes 8722378475aSmrg # try to create one of the directories concurrently. Don't 8732378475aSmrg # stop in that case! 874eca46af7Smrg $MKDIR "$_G_dir" 2>/dev/null || : 8752378475aSmrg done 876eca46af7Smrg IFS=$func_mkdir_p_IFS 8772378475aSmrg 8782378475aSmrg # Bail out if we (or some other process) failed to create a directory. 879eca46af7Smrg test -d "$_G_directory_path" || \ 880eca46af7Smrg func_fatal_error "Failed to create '$1'" 8812378475aSmrg fi 8822378475aSmrg} 88395b296d0Smrg 88495b296d0Smrg 885eca46af7Smrg# func_mktempdir [BASENAME] 886eca46af7Smrg# ------------------------- 88795b296d0Smrg# Make a temporary directory that won't clash with other running 88895b296d0Smrg# libtool processes, and avoids race conditions if possible. If 889eca46af7Smrg# given, BASENAME is the basename for that directory. 89095b296d0Smrgfunc_mktempdir () 89195b296d0Smrg{ 892eca46af7Smrg $debug_cmd 893eca46af7Smrg 894eca46af7Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 89595b296d0Smrg 896eca46af7Smrg if test : = "$opt_dry_run"; then 89795b296d0Smrg # Return a directory name, but don't create it in dry-run mode 898eca46af7Smrg _G_tmpdir=$_G_template-$$ 89995b296d0Smrg else 90095b296d0Smrg 90195b296d0Smrg # If mktemp works, use that first and foremost 902eca46af7Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 90395b296d0Smrg 904eca46af7Smrg if test ! -d "$_G_tmpdir"; then 9052378475aSmrg # Failing that, at least try and use $RANDOM to avoid a race 906eca46af7Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 90795b296d0Smrg 908eca46af7Smrg func_mktempdir_umask=`umask` 9092378475aSmrg umask 0077 910eca46af7Smrg $MKDIR "$_G_tmpdir" 911eca46af7Smrg umask $func_mktempdir_umask 91295b296d0Smrg fi 91395b296d0Smrg 91495b296d0Smrg # If we're not in dry-run mode, bomb out on failure 915eca46af7Smrg test -d "$_G_tmpdir" || \ 916eca46af7Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 917eca46af7Smrg fi 918eca46af7Smrg 919eca46af7Smrg $ECHO "$_G_tmpdir" 920eca46af7Smrg} 921eca46af7Smrg 922eca46af7Smrg 923eca46af7Smrg# func_normal_abspath PATH 924eca46af7Smrg# ------------------------ 925eca46af7Smrg# Remove doubled-up and trailing slashes, "." path components, 926eca46af7Smrg# and cancel out any ".." path components in PATH after making 927eca46af7Smrg# it an absolute path. 928eca46af7Smrgfunc_normal_abspath () 929eca46af7Smrg{ 930eca46af7Smrg $debug_cmd 931eca46af7Smrg 932eca46af7Smrg # These SED scripts presuppose an absolute path with a trailing slash. 933eca46af7Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 934eca46af7Smrg _G_pathcdr='s|^/[^/]*||' 935eca46af7Smrg _G_removedotparts=':dotsl 936eca46af7Smrg s|/\./|/|g 937eca46af7Smrg t dotsl 938eca46af7Smrg s|/\.$|/|' 939eca46af7Smrg _G_collapseslashes='s|/\{1,\}|/|g' 940eca46af7Smrg _G_finalslash='s|/*$|/|' 941eca46af7Smrg 942eca46af7Smrg # Start from root dir and reassemble the path. 943eca46af7Smrg func_normal_abspath_result= 944eca46af7Smrg func_normal_abspath_tpath=$1 945eca46af7Smrg func_normal_abspath_altnamespace= 946eca46af7Smrg case $func_normal_abspath_tpath in 947eca46af7Smrg "") 948eca46af7Smrg # Empty path, that just means $cwd. 949eca46af7Smrg func_stripname '' '/' "`pwd`" 950eca46af7Smrg func_normal_abspath_result=$func_stripname_result 951eca46af7Smrg return 952eca46af7Smrg ;; 953eca46af7Smrg # The next three entries are used to spot a run of precisely 954eca46af7Smrg # two leading slashes without using negated character classes; 955eca46af7Smrg # we take advantage of case's first-match behaviour. 956eca46af7Smrg ///*) 957eca46af7Smrg # Unusual form of absolute path, do nothing. 958eca46af7Smrg ;; 959eca46af7Smrg //*) 960eca46af7Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 961eca46af7Smrg # and for example Cygwin uses it to access remote file shares 962eca46af7Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 963eca46af7Smrg func_normal_abspath_altnamespace=/ 964eca46af7Smrg ;; 965eca46af7Smrg /*) 966eca46af7Smrg # Absolute path, do nothing. 967eca46af7Smrg ;; 968eca46af7Smrg *) 969eca46af7Smrg # Relative path, prepend $cwd. 970eca46af7Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 971eca46af7Smrg ;; 972eca46af7Smrg esac 973eca46af7Smrg 974eca46af7Smrg # Cancel out all the simple stuff to save iterations. We also want 975eca46af7Smrg # the path to end with a slash for ease of parsing, so make sure 976eca46af7Smrg # there is one (and only one) here. 977eca46af7Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 978eca46af7Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 979eca46af7Smrg while :; do 980eca46af7Smrg # Processed it all yet? 981eca46af7Smrg if test / = "$func_normal_abspath_tpath"; then 982eca46af7Smrg # If we ascended to the root using ".." the result may be empty now. 983eca46af7Smrg if test -z "$func_normal_abspath_result"; then 984eca46af7Smrg func_normal_abspath_result=/ 985eca46af7Smrg fi 986eca46af7Smrg break 987eca46af7Smrg fi 988eca46af7Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 989eca46af7Smrg -e "$_G_pathcar"` 990eca46af7Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 991eca46af7Smrg -e "$_G_pathcdr"` 992eca46af7Smrg # Figure out what to do with it 993eca46af7Smrg case $func_normal_abspath_tcomponent in 994eca46af7Smrg "") 995eca46af7Smrg # Trailing empty path component, ignore it. 996eca46af7Smrg ;; 997eca46af7Smrg ..) 998eca46af7Smrg # Parent dir; strip last assembled component from result. 999eca46af7Smrg func_dirname "$func_normal_abspath_result" 1000eca46af7Smrg func_normal_abspath_result=$func_dirname_result 1001eca46af7Smrg ;; 1002eca46af7Smrg *) 1003eca46af7Smrg # Actual path component, append it. 1004eca46af7Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1005eca46af7Smrg ;; 1006eca46af7Smrg esac 1007eca46af7Smrg done 1008eca46af7Smrg # Restore leading double-slash if one was found on entry. 1009eca46af7Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1010eca46af7Smrg} 1011eca46af7Smrg 1012eca46af7Smrg 1013eca46af7Smrg# func_notquiet ARG... 1014eca46af7Smrg# -------------------- 1015eca46af7Smrg# Echo program name prefixed message only when not in quiet mode. 1016eca46af7Smrgfunc_notquiet () 1017eca46af7Smrg{ 1018eca46af7Smrg $debug_cmd 1019eca46af7Smrg 1020eca46af7Smrg $opt_quiet || func_echo ${1+"$@"} 1021eca46af7Smrg 1022eca46af7Smrg # A bug in bash halts the script if the last line of a function 1023eca46af7Smrg # fails when set -e is in force, so we need another command to 1024eca46af7Smrg # work around that: 1025eca46af7Smrg : 1026eca46af7Smrg} 1027eca46af7Smrg 1028eca46af7Smrg 1029eca46af7Smrg# func_relative_path SRCDIR DSTDIR 1030eca46af7Smrg# -------------------------------- 1031eca46af7Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1032eca46af7Smrgfunc_relative_path () 1033eca46af7Smrg{ 1034eca46af7Smrg $debug_cmd 1035eca46af7Smrg 1036eca46af7Smrg func_relative_path_result= 1037eca46af7Smrg func_normal_abspath "$1" 1038eca46af7Smrg func_relative_path_tlibdir=$func_normal_abspath_result 1039eca46af7Smrg func_normal_abspath "$2" 1040eca46af7Smrg func_relative_path_tbindir=$func_normal_abspath_result 1041eca46af7Smrg 1042eca46af7Smrg # Ascend the tree starting from libdir 1043eca46af7Smrg while :; do 1044eca46af7Smrg # check if we have found a prefix of bindir 1045eca46af7Smrg case $func_relative_path_tbindir in 1046eca46af7Smrg $func_relative_path_tlibdir) 1047eca46af7Smrg # found an exact match 1048eca46af7Smrg func_relative_path_tcancelled= 1049eca46af7Smrg break 1050eca46af7Smrg ;; 1051eca46af7Smrg $func_relative_path_tlibdir*) 1052eca46af7Smrg # found a matching prefix 1053eca46af7Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1054eca46af7Smrg func_relative_path_tcancelled=$func_stripname_result 1055eca46af7Smrg if test -z "$func_relative_path_result"; then 1056eca46af7Smrg func_relative_path_result=. 1057eca46af7Smrg fi 1058eca46af7Smrg break 1059eca46af7Smrg ;; 1060eca46af7Smrg *) 1061eca46af7Smrg func_dirname $func_relative_path_tlibdir 1062eca46af7Smrg func_relative_path_tlibdir=$func_dirname_result 1063eca46af7Smrg if test -z "$func_relative_path_tlibdir"; then 1064eca46af7Smrg # Have to descend all the way to the root! 1065eca46af7Smrg func_relative_path_result=../$func_relative_path_result 1066eca46af7Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 1067eca46af7Smrg break 1068eca46af7Smrg fi 1069eca46af7Smrg func_relative_path_result=../$func_relative_path_result 1070eca46af7Smrg ;; 1071eca46af7Smrg esac 1072eca46af7Smrg done 1073eca46af7Smrg 1074eca46af7Smrg # Now calculate path; take care to avoid doubling-up slashes. 1075eca46af7Smrg func_stripname '' '/' "$func_relative_path_result" 1076eca46af7Smrg func_relative_path_result=$func_stripname_result 1077eca46af7Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1078eca46af7Smrg if test -n "$func_stripname_result"; then 1079eca46af7Smrg func_append func_relative_path_result "/$func_stripname_result" 1080eca46af7Smrg fi 1081eca46af7Smrg 1082eca46af7Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 1083eca46af7Smrg if test -n "$func_relative_path_result"; then 1084eca46af7Smrg func_stripname './' '' "$func_relative_path_result" 1085eca46af7Smrg func_relative_path_result=$func_stripname_result 108695b296d0Smrg fi 108795b296d0Smrg 1088eca46af7Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 1089eca46af7Smrg 1090eca46af7Smrg : 1091eca46af7Smrg} 1092eca46af7Smrg 1093eca46af7Smrg 1094eca46af7Smrg# func_quote_for_eval ARG... 1095eca46af7Smrg# -------------------------- 1096eca46af7Smrg# Aesthetically quote ARGs to be evaled later. 1097eca46af7Smrg# This function returns two values: 1098eca46af7Smrg# i) func_quote_for_eval_result 1099eca46af7Smrg# double-quoted, suitable for a subsequent eval 1100eca46af7Smrg# ii) func_quote_for_eval_unquoted_result 1101eca46af7Smrg# has all characters that are still active within double 1102eca46af7Smrg# quotes backslashified. 1103eca46af7Smrgfunc_quote_for_eval () 1104eca46af7Smrg{ 1105eca46af7Smrg $debug_cmd 1106eca46af7Smrg 1107eca46af7Smrg func_quote_for_eval_unquoted_result= 1108eca46af7Smrg func_quote_for_eval_result= 1109eca46af7Smrg while test 0 -lt $#; do 1110eca46af7Smrg case $1 in 1111eca46af7Smrg *[\\\`\"\$]*) 1112eca46af7Smrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 1113eca46af7Smrg *) 1114eca46af7Smrg _G_unquoted_arg=$1 ;; 1115eca46af7Smrg esac 1116eca46af7Smrg if test -n "$func_quote_for_eval_unquoted_result"; then 1117eca46af7Smrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 1118eca46af7Smrg else 1119eca46af7Smrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 1120eca46af7Smrg fi 1121eca46af7Smrg 1122eca46af7Smrg case $_G_unquoted_arg in 1123eca46af7Smrg # Double-quote args containing shell metacharacters to delay 1124eca46af7Smrg # word splitting, command substitution and variable expansion 1125eca46af7Smrg # for a subsequent eval. 1126eca46af7Smrg # Many Bourne shells cannot handle close brackets correctly 1127eca46af7Smrg # in scan sets, so we specify it separately. 1128eca46af7Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1129eca46af7Smrg _G_quoted_arg=\"$_G_unquoted_arg\" 1130eca46af7Smrg ;; 1131eca46af7Smrg *) 1132eca46af7Smrg _G_quoted_arg=$_G_unquoted_arg 1133eca46af7Smrg ;; 1134eca46af7Smrg esac 1135eca46af7Smrg 1136eca46af7Smrg if test -n "$func_quote_for_eval_result"; then 1137eca46af7Smrg func_append func_quote_for_eval_result " $_G_quoted_arg" 1138eca46af7Smrg else 1139eca46af7Smrg func_append func_quote_for_eval_result "$_G_quoted_arg" 1140eca46af7Smrg fi 1141eca46af7Smrg shift 1142eca46af7Smrg done 1143eca46af7Smrg} 1144eca46af7Smrg 1145eca46af7Smrg 1146eca46af7Smrg# func_quote_for_expand ARG 1147eca46af7Smrg# ------------------------- 1148eca46af7Smrg# Aesthetically quote ARG to be evaled later; same as above, 1149eca46af7Smrg# but do not quote variable references. 1150eca46af7Smrgfunc_quote_for_expand () 1151eca46af7Smrg{ 1152eca46af7Smrg $debug_cmd 1153eca46af7Smrg 1154eca46af7Smrg case $1 in 1155eca46af7Smrg *[\\\`\"]*) 1156eca46af7Smrg _G_arg=`$ECHO "$1" | $SED \ 1157eca46af7Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 1158eca46af7Smrg *) 1159eca46af7Smrg _G_arg=$1 ;; 1160eca46af7Smrg esac 1161eca46af7Smrg 1162eca46af7Smrg case $_G_arg in 1163eca46af7Smrg # Double-quote args containing shell metacharacters to delay 1164eca46af7Smrg # word splitting and command substitution for a subsequent eval. 1165eca46af7Smrg # Many Bourne shells cannot handle close brackets correctly 1166eca46af7Smrg # in scan sets, so we specify it separately. 1167eca46af7Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1168eca46af7Smrg _G_arg=\"$_G_arg\" 1169eca46af7Smrg ;; 1170eca46af7Smrg esac 1171eca46af7Smrg 1172eca46af7Smrg func_quote_for_expand_result=$_G_arg 1173eca46af7Smrg} 1174eca46af7Smrg 1175eca46af7Smrg 1176eca46af7Smrg# func_stripname PREFIX SUFFIX NAME 1177eca46af7Smrg# --------------------------------- 1178eca46af7Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1179eca46af7Smrg# PREFIX and SUFFIX must not contain globbing or regex special 1180eca46af7Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 1181eca46af7Smrg# dot (in which case that matches only a dot). 1182eca46af7Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 1183eca46af7Smrg eval 'func_stripname () 1184eca46af7Smrg { 1185eca46af7Smrg $debug_cmd 1186eca46af7Smrg 1187eca46af7Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1188eca46af7Smrg # positional parameters, so assign one to ordinary variable first. 1189eca46af7Smrg func_stripname_result=$3 1190eca46af7Smrg func_stripname_result=${func_stripname_result#"$1"} 1191eca46af7Smrg func_stripname_result=${func_stripname_result%"$2"} 1192eca46af7Smrg }' 1193eca46af7Smrgelse 1194eca46af7Smrg func_stripname () 1195eca46af7Smrg { 1196eca46af7Smrg $debug_cmd 1197eca46af7Smrg 1198eca46af7Smrg case $2 in 1199eca46af7Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1200eca46af7Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1201eca46af7Smrg esac 1202eca46af7Smrg } 1203eca46af7Smrgfi 1204eca46af7Smrg 1205eca46af7Smrg 1206eca46af7Smrg# func_show_eval CMD [FAIL_EXP] 1207eca46af7Smrg# ----------------------------- 1208eca46af7Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1209eca46af7Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1210eca46af7Smrg# is given, then evaluate it. 1211eca46af7Smrgfunc_show_eval () 1212eca46af7Smrg{ 1213eca46af7Smrg $debug_cmd 1214eca46af7Smrg 1215eca46af7Smrg _G_cmd=$1 1216eca46af7Smrg _G_fail_exp=${2-':'} 1217eca46af7Smrg 1218eca46af7Smrg func_quote_for_expand "$_G_cmd" 1219eca46af7Smrg eval "func_notquiet $func_quote_for_expand_result" 1220eca46af7Smrg 1221eca46af7Smrg $opt_dry_run || { 1222eca46af7Smrg eval "$_G_cmd" 1223eca46af7Smrg _G_status=$? 1224eca46af7Smrg if test 0 -ne "$_G_status"; then 1225eca46af7Smrg eval "(exit $_G_status); $_G_fail_exp" 1226eca46af7Smrg fi 1227eca46af7Smrg } 1228eca46af7Smrg} 1229eca46af7Smrg 1230eca46af7Smrg 1231eca46af7Smrg# func_show_eval_locale CMD [FAIL_EXP] 1232eca46af7Smrg# ------------------------------------ 1233eca46af7Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1234eca46af7Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1235eca46af7Smrg# is given, then evaluate it. Use the saved locale for evaluation. 1236eca46af7Smrgfunc_show_eval_locale () 1237eca46af7Smrg{ 1238eca46af7Smrg $debug_cmd 1239eca46af7Smrg 1240eca46af7Smrg _G_cmd=$1 1241eca46af7Smrg _G_fail_exp=${2-':'} 1242eca46af7Smrg 1243eca46af7Smrg $opt_quiet || { 1244eca46af7Smrg func_quote_for_expand "$_G_cmd" 1245eca46af7Smrg eval "func_echo $func_quote_for_expand_result" 1246eca46af7Smrg } 1247eca46af7Smrg 1248eca46af7Smrg $opt_dry_run || { 1249eca46af7Smrg eval "$_G_user_locale 1250eca46af7Smrg $_G_cmd" 1251eca46af7Smrg _G_status=$? 1252eca46af7Smrg eval "$_G_safe_locale" 1253eca46af7Smrg if test 0 -ne "$_G_status"; then 1254eca46af7Smrg eval "(exit $_G_status); $_G_fail_exp" 1255eca46af7Smrg fi 1256eca46af7Smrg } 1257eca46af7Smrg} 1258eca46af7Smrg 1259eca46af7Smrg 1260eca46af7Smrg# func_tr_sh 1261eca46af7Smrg# ---------- 1262eca46af7Smrg# Turn $1 into a string suitable for a shell variable name. 1263eca46af7Smrg# Result is stored in $func_tr_sh_result. All characters 1264eca46af7Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1265eca46af7Smrg# if $1 begins with a digit, a '_' is prepended as well. 1266eca46af7Smrgfunc_tr_sh () 1267eca46af7Smrg{ 1268eca46af7Smrg $debug_cmd 1269eca46af7Smrg 1270eca46af7Smrg case $1 in 1271eca46af7Smrg [0-9]* | *[!a-zA-Z0-9_]*) 1272eca46af7Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1273eca46af7Smrg ;; 1274eca46af7Smrg * ) 1275eca46af7Smrg func_tr_sh_result=$1 1276eca46af7Smrg ;; 1277eca46af7Smrg esac 1278eca46af7Smrg} 1279eca46af7Smrg 1280eca46af7Smrg 1281eca46af7Smrg# func_verbose ARG... 1282eca46af7Smrg# ------------------- 1283eca46af7Smrg# Echo program name prefixed message in verbose mode only. 1284eca46af7Smrgfunc_verbose () 1285eca46af7Smrg{ 1286eca46af7Smrg $debug_cmd 1287eca46af7Smrg 1288eca46af7Smrg $opt_verbose && func_echo "$*" 1289eca46af7Smrg 1290eca46af7Smrg : 1291eca46af7Smrg} 1292eca46af7Smrg 1293eca46af7Smrg 1294eca46af7Smrg# func_warn_and_continue ARG... 1295eca46af7Smrg# ----------------------------- 1296eca46af7Smrg# Echo program name prefixed warning message to standard error. 1297eca46af7Smrgfunc_warn_and_continue () 1298eca46af7Smrg{ 1299eca46af7Smrg $debug_cmd 1300eca46af7Smrg 1301eca46af7Smrg $require_term_colors 1302eca46af7Smrg 1303eca46af7Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1304eca46af7Smrg} 1305eca46af7Smrg 1306eca46af7Smrg 1307eca46af7Smrg# func_warning CATEGORY ARG... 1308eca46af7Smrg# ---------------------------- 1309eca46af7Smrg# Echo program name prefixed warning message to standard error. Warning 1310eca46af7Smrg# messages can be filtered according to CATEGORY, where this function 1311eca46af7Smrg# elides messages where CATEGORY is not listed in the global variable 1312eca46af7Smrg# 'opt_warning_types'. 1313eca46af7Smrgfunc_warning () 1314eca46af7Smrg{ 1315eca46af7Smrg $debug_cmd 1316eca46af7Smrg 1317eca46af7Smrg # CATEGORY must be in the warning_categories list! 1318eca46af7Smrg case " $warning_categories " in 1319eca46af7Smrg *" $1 "*) ;; 1320eca46af7Smrg *) func_internal_error "invalid warning category '$1'" ;; 1321eca46af7Smrg esac 1322eca46af7Smrg 1323eca46af7Smrg _G_category=$1 1324eca46af7Smrg shift 1325eca46af7Smrg 1326eca46af7Smrg case " $opt_warning_types " in 1327eca46af7Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1328eca46af7Smrg esac 1329eca46af7Smrg} 1330eca46af7Smrg 1331eca46af7Smrg 1332eca46af7Smrg# func_sort_ver VER1 VER2 1333eca46af7Smrg# ----------------------- 1334eca46af7Smrg# 'sort -V' is not generally available. 1335eca46af7Smrg# Note this deviates from the version comparison in automake 1336eca46af7Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1337eca46af7Smrg# but this should suffice as we won't be specifying old 1338eca46af7Smrg# version formats or redundant trailing .0 in bootstrap.conf. 1339eca46af7Smrg# If we did want full compatibility then we should probably 1340eca46af7Smrg# use m4_version_compare from autoconf. 1341eca46af7Smrgfunc_sort_ver () 1342eca46af7Smrg{ 1343eca46af7Smrg $debug_cmd 1344eca46af7Smrg 1345eca46af7Smrg printf '%s\n%s\n' "$1" "$2" \ 1346eca46af7Smrg | 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 1347eca46af7Smrg} 1348eca46af7Smrg 1349eca46af7Smrg# func_lt_ver PREV CURR 1350eca46af7Smrg# --------------------- 1351eca46af7Smrg# Return true if PREV and CURR are in the correct order according to 1352eca46af7Smrg# func_sort_ver, otherwise false. Use it like this: 1353eca46af7Smrg# 1354eca46af7Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1355eca46af7Smrgfunc_lt_ver () 1356eca46af7Smrg{ 1357eca46af7Smrg $debug_cmd 1358eca46af7Smrg 1359eca46af7Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1360eca46af7Smrg} 1361eca46af7Smrg 1362eca46af7Smrg 1363eca46af7Smrg# Local variables: 1364eca46af7Smrg# mode: shell-script 1365eca46af7Smrg# sh-indentation: 2 1366eca46af7Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 1367eca46af7Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1368eca46af7Smrg# time-stamp-time-zone: "UTC" 1369eca46af7Smrg# End: 1370eca46af7Smrg#! /bin/sh 1371eca46af7Smrg 1372eca46af7Smrg# Set a version string for this script. 1373eca46af7Smrgscriptversion=2014-01-07.03; # UTC 1374eca46af7Smrg 1375eca46af7Smrg# A portable, pluggable option parser for Bourne shell. 1376eca46af7Smrg# Written by Gary V. Vaughan, 2010 1377eca46af7Smrg 137889b0dc75Smrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 1379eca46af7Smrg# This is free software; see the source for copying conditions. There is NO 1380eca46af7Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1381eca46af7Smrg 1382eca46af7Smrg# This program is free software: you can redistribute it and/or modify 1383eca46af7Smrg# it under the terms of the GNU General Public License as published by 1384eca46af7Smrg# the Free Software Foundation, either version 3 of the License, or 1385eca46af7Smrg# (at your option) any later version. 1386eca46af7Smrg 1387eca46af7Smrg# This program is distributed in the hope that it will be useful, 1388eca46af7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1389eca46af7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1390eca46af7Smrg# GNU General Public License for more details. 1391eca46af7Smrg 1392eca46af7Smrg# You should have received a copy of the GNU General Public License 1393eca46af7Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 1394eca46af7Smrg 1395eca46af7Smrg# Please report bugs or propose patches to gary@gnu.org. 1396eca46af7Smrg 1397eca46af7Smrg 1398eca46af7Smrg## ------ ## 1399eca46af7Smrg## Usage. ## 1400eca46af7Smrg## ------ ## 1401eca46af7Smrg 1402eca46af7Smrg# This file is a library for parsing options in your shell scripts along 1403eca46af7Smrg# with assorted other useful supporting features that you can make use 1404eca46af7Smrg# of too. 1405eca46af7Smrg# 1406eca46af7Smrg# For the simplest scripts you might need only: 1407eca46af7Smrg# 1408eca46af7Smrg# #!/bin/sh 1409eca46af7Smrg# . relative/path/to/funclib.sh 1410eca46af7Smrg# . relative/path/to/options-parser 1411eca46af7Smrg# scriptversion=1.0 1412eca46af7Smrg# func_options ${1+"$@"} 1413eca46af7Smrg# eval set dummy "$func_options_result"; shift 1414eca46af7Smrg# ...rest of your script... 1415eca46af7Smrg# 1416eca46af7Smrg# In order for the '--version' option to work, you will need to have a 1417eca46af7Smrg# suitably formatted comment like the one at the top of this file 1418eca46af7Smrg# starting with '# Written by ' and ending with '# warranty; '. 1419eca46af7Smrg# 1420eca46af7Smrg# For '-h' and '--help' to work, you will also need a one line 1421eca46af7Smrg# description of your script's purpose in a comment directly above the 1422eca46af7Smrg# '# Written by ' line, like the one at the top of this file. 1423eca46af7Smrg# 1424eca46af7Smrg# The default options also support '--debug', which will turn on shell 1425eca46af7Smrg# execution tracing (see the comment above debug_cmd below for another 1426eca46af7Smrg# use), and '--verbose' and the func_verbose function to allow your script 1427eca46af7Smrg# to display verbose messages only when your user has specified 1428eca46af7Smrg# '--verbose'. 1429eca46af7Smrg# 1430eca46af7Smrg# After sourcing this file, you can plug processing for additional 1431eca46af7Smrg# options by amending the variables from the 'Configuration' section 1432eca46af7Smrg# below, and following the instructions in the 'Option parsing' 1433eca46af7Smrg# section further down. 1434eca46af7Smrg 1435eca46af7Smrg## -------------- ## 1436eca46af7Smrg## Configuration. ## 1437eca46af7Smrg## -------------- ## 1438eca46af7Smrg 1439eca46af7Smrg# You should override these variables in your script after sourcing this 1440eca46af7Smrg# file so that they reflect the customisations you have added to the 1441eca46af7Smrg# option parser. 1442eca46af7Smrg 1443eca46af7Smrg# The usage line for option parsing errors and the start of '-h' and 1444eca46af7Smrg# '--help' output messages. You can embed shell variables for delayed 1445eca46af7Smrg# expansion at the time the message is displayed, but you will need to 1446eca46af7Smrg# quote other shell meta-characters carefully to prevent them being 1447eca46af7Smrg# expanded when the contents are evaled. 1448eca46af7Smrgusage='$progpath [OPTION]...' 1449eca46af7Smrg 1450eca46af7Smrg# Short help message in response to '-h' and '--help'. Add to this or 1451eca46af7Smrg# override it after sourcing this library to reflect the full set of 1452eca46af7Smrg# options your script accepts. 1453eca46af7Smrgusage_message="\ 1454eca46af7Smrg --debug enable verbose shell tracing 1455eca46af7Smrg -W, --warnings=CATEGORY 1456eca46af7Smrg report the warnings falling in CATEGORY [all] 1457eca46af7Smrg -v, --verbose verbosely report processing 1458eca46af7Smrg --version print version information and exit 1459eca46af7Smrg -h, --help print short or long help message and exit 1460eca46af7Smrg" 1461eca46af7Smrg 1462eca46af7Smrg# Additional text appended to 'usage_message' in response to '--help'. 1463eca46af7Smrglong_help_message=" 1464eca46af7SmrgWarning categories include: 1465eca46af7Smrg 'all' show all warnings 1466eca46af7Smrg 'none' turn off all the warnings 1467eca46af7Smrg 'error' warnings are treated as fatal errors" 1468eca46af7Smrg 1469eca46af7Smrg# Help message printed before fatal option parsing errors. 1470eca46af7Smrgfatal_help="Try '\$progname --help' for more information." 1471eca46af7Smrg 1472eca46af7Smrg 1473eca46af7Smrg 1474eca46af7Smrg## ------------------------- ## 1475eca46af7Smrg## Hook function management. ## 1476eca46af7Smrg## ------------------------- ## 1477eca46af7Smrg 1478eca46af7Smrg# This section contains functions for adding, removing, and running hooks 1479eca46af7Smrg# to the main code. A hook is just a named list of of function, that can 1480eca46af7Smrg# be run in order later on. 1481eca46af7Smrg 1482eca46af7Smrg# func_hookable FUNC_NAME 1483eca46af7Smrg# ----------------------- 1484eca46af7Smrg# Declare that FUNC_NAME will run hooks added with 1485eca46af7Smrg# 'func_add_hook FUNC_NAME ...'. 1486eca46af7Smrgfunc_hookable () 1487eca46af7Smrg{ 1488eca46af7Smrg $debug_cmd 1489eca46af7Smrg 1490eca46af7Smrg func_append hookable_fns " $1" 1491eca46af7Smrg} 1492eca46af7Smrg 1493eca46af7Smrg 1494eca46af7Smrg# func_add_hook FUNC_NAME HOOK_FUNC 1495eca46af7Smrg# --------------------------------- 1496eca46af7Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1497eca46af7Smrg# first have been declared "hookable" by a call to 'func_hookable'. 1498eca46af7Smrgfunc_add_hook () 1499eca46af7Smrg{ 1500eca46af7Smrg $debug_cmd 1501eca46af7Smrg 1502eca46af7Smrg case " $hookable_fns " in 1503eca46af7Smrg *" $1 "*) ;; 1504eca46af7Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1505eca46af7Smrg esac 1506eca46af7Smrg 1507eca46af7Smrg eval func_append ${1}_hooks '" $2"' 1508eca46af7Smrg} 1509eca46af7Smrg 1510eca46af7Smrg 1511eca46af7Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 1512eca46af7Smrg# ------------------------------------ 1513eca46af7Smrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 1514eca46af7Smrgfunc_remove_hook () 1515eca46af7Smrg{ 1516eca46af7Smrg $debug_cmd 1517eca46af7Smrg 1518eca46af7Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1519eca46af7Smrg} 1520eca46af7Smrg 1521eca46af7Smrg 1522eca46af7Smrg# func_run_hooks FUNC_NAME [ARG]... 1523eca46af7Smrg# --------------------------------- 1524eca46af7Smrg# Run all hook functions registered to FUNC_NAME. 1525eca46af7Smrg# It is assumed that the list of hook functions contains nothing more 1526eca46af7Smrg# than a whitespace-delimited list of legal shell function names, and 1527eca46af7Smrg# no effort is wasted trying to catch shell meta-characters or preserve 1528eca46af7Smrg# whitespace. 1529eca46af7Smrgfunc_run_hooks () 1530eca46af7Smrg{ 1531eca46af7Smrg $debug_cmd 1532eca46af7Smrg 1533eca46af7Smrg case " $hookable_fns " in 1534eca46af7Smrg *" $1 "*) ;; 1535eca46af7Smrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 1536eca46af7Smrg esac 1537eca46af7Smrg 1538eca46af7Smrg eval _G_hook_fns=\$$1_hooks; shift 1539eca46af7Smrg 1540eca46af7Smrg for _G_hook in $_G_hook_fns; do 1541eca46af7Smrg eval $_G_hook '"$@"' 1542eca46af7Smrg 1543eca46af7Smrg # store returned options list back into positional 1544eca46af7Smrg # parameters for next 'cmd' execution. 1545eca46af7Smrg eval _G_hook_result=\$${_G_hook}_result 1546eca46af7Smrg eval set dummy "$_G_hook_result"; shift 1547eca46af7Smrg done 1548eca46af7Smrg 1549eca46af7Smrg func_quote_for_eval ${1+"$@"} 1550eca46af7Smrg func_run_hooks_result=$func_quote_for_eval_result 1551eca46af7Smrg} 1552eca46af7Smrg 1553eca46af7Smrg 1554eca46af7Smrg 1555eca46af7Smrg## --------------- ## 1556eca46af7Smrg## Option parsing. ## 1557eca46af7Smrg## --------------- ## 1558eca46af7Smrg 1559eca46af7Smrg# In order to add your own option parsing hooks, you must accept the 1560eca46af7Smrg# full positional parameter list in your hook function, remove any 1561eca46af7Smrg# options that you action, and then pass back the remaining unprocessed 1562eca46af7Smrg# options in '<hooked_function_name>_result', escaped suitably for 1563eca46af7Smrg# 'eval'. Like this: 1564eca46af7Smrg# 1565eca46af7Smrg# my_options_prep () 1566eca46af7Smrg# { 1567eca46af7Smrg# $debug_cmd 1568eca46af7Smrg# 1569eca46af7Smrg# # Extend the existing usage message. 1570eca46af7Smrg# usage_message=$usage_message' 1571eca46af7Smrg# -s, --silent don'\''t print informational messages 1572eca46af7Smrg# ' 1573eca46af7Smrg# 1574eca46af7Smrg# func_quote_for_eval ${1+"$@"} 1575eca46af7Smrg# my_options_prep_result=$func_quote_for_eval_result 1576eca46af7Smrg# } 1577eca46af7Smrg# func_add_hook func_options_prep my_options_prep 1578eca46af7Smrg# 1579eca46af7Smrg# 1580eca46af7Smrg# my_silent_option () 1581eca46af7Smrg# { 1582eca46af7Smrg# $debug_cmd 1583eca46af7Smrg# 1584eca46af7Smrg# # Note that for efficiency, we parse as many options as we can 1585eca46af7Smrg# # recognise in a loop before passing the remainder back to the 1586eca46af7Smrg# # caller on the first unrecognised argument we encounter. 1587eca46af7Smrg# while test $# -gt 0; do 1588eca46af7Smrg# opt=$1; shift 1589eca46af7Smrg# case $opt in 1590eca46af7Smrg# --silent|-s) opt_silent=: ;; 1591eca46af7Smrg# # Separate non-argument short options: 1592eca46af7Smrg# -s*) func_split_short_opt "$_G_opt" 1593eca46af7Smrg# set dummy "$func_split_short_opt_name" \ 1594eca46af7Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 1595eca46af7Smrg# shift 1596eca46af7Smrg# ;; 1597eca46af7Smrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 1598eca46af7Smrg# esac 1599eca46af7Smrg# done 1600eca46af7Smrg# 1601eca46af7Smrg# func_quote_for_eval ${1+"$@"} 1602eca46af7Smrg# my_silent_option_result=$func_quote_for_eval_result 1603eca46af7Smrg# } 1604eca46af7Smrg# func_add_hook func_parse_options my_silent_option 1605eca46af7Smrg# 1606eca46af7Smrg# 1607eca46af7Smrg# my_option_validation () 1608eca46af7Smrg# { 1609eca46af7Smrg# $debug_cmd 1610eca46af7Smrg# 1611eca46af7Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 1612eca46af7Smrg# '--silent' and '--verbose' options are mutually exclusive." 1613eca46af7Smrg# 1614eca46af7Smrg# func_quote_for_eval ${1+"$@"} 1615eca46af7Smrg# my_option_validation_result=$func_quote_for_eval_result 1616eca46af7Smrg# } 1617eca46af7Smrg# func_add_hook func_validate_options my_option_validation 1618eca46af7Smrg# 1619eca46af7Smrg# You'll alse need to manually amend $usage_message to reflect the extra 1620eca46af7Smrg# options you parse. It's preferable to append if you can, so that 1621eca46af7Smrg# multiple option parsing hooks can be added safely. 1622eca46af7Smrg 1623eca46af7Smrg 1624eca46af7Smrg# func_options [ARG]... 1625eca46af7Smrg# --------------------- 1626eca46af7Smrg# All the functions called inside func_options are hookable. See the 1627eca46af7Smrg# individual implementations for details. 1628eca46af7Smrgfunc_hookable func_options 1629eca46af7Smrgfunc_options () 1630eca46af7Smrg{ 1631eca46af7Smrg $debug_cmd 1632eca46af7Smrg 1633eca46af7Smrg func_options_prep ${1+"$@"} 1634eca46af7Smrg eval func_parse_options \ 1635eca46af7Smrg ${func_options_prep_result+"$func_options_prep_result"} 1636eca46af7Smrg eval func_validate_options \ 1637eca46af7Smrg ${func_parse_options_result+"$func_parse_options_result"} 1638eca46af7Smrg 1639eca46af7Smrg eval func_run_hooks func_options \ 1640eca46af7Smrg ${func_validate_options_result+"$func_validate_options_result"} 1641eca46af7Smrg 1642eca46af7Smrg # save modified positional parameters for caller 1643eca46af7Smrg func_options_result=$func_run_hooks_result 164495b296d0Smrg} 164595b296d0Smrg 164695b296d0Smrg 1647eca46af7Smrg# func_options_prep [ARG]... 1648eca46af7Smrg# -------------------------- 1649eca46af7Smrg# All initialisations required before starting the option parse loop. 1650eca46af7Smrg# Note that when calling hook functions, we pass through the list of 1651eca46af7Smrg# positional parameters. If a hook function modifies that list, and 1652eca46af7Smrg# needs to propogate that back to rest of this script, then the complete 1653eca46af7Smrg# modified list must be put in 'func_run_hooks_result' before 1654eca46af7Smrg# returning. 1655eca46af7Smrgfunc_hookable func_options_prep 1656eca46af7Smrgfunc_options_prep () 165795b296d0Smrg{ 1658eca46af7Smrg $debug_cmd 16592378475aSmrg 1660eca46af7Smrg # Option defaults: 1661eca46af7Smrg opt_verbose=false 1662eca46af7Smrg opt_warning_types= 1663eca46af7Smrg 1664eca46af7Smrg func_run_hooks func_options_prep ${1+"$@"} 1665eca46af7Smrg 1666eca46af7Smrg # save modified positional parameters for caller 1667eca46af7Smrg func_options_prep_result=$func_run_hooks_result 166895b296d0Smrg} 166995b296d0Smrg 167095b296d0Smrg 1671eca46af7Smrg# func_parse_options [ARG]... 1672eca46af7Smrg# --------------------------- 1673eca46af7Smrg# The main option parsing loop. 1674eca46af7Smrgfunc_hookable func_parse_options 1675eca46af7Smrgfunc_parse_options () 167695b296d0Smrg{ 1677eca46af7Smrg $debug_cmd 16782378475aSmrg 1679eca46af7Smrg func_parse_options_result= 16802378475aSmrg 1681eca46af7Smrg # this just eases exit handling 1682eca46af7Smrg while test $# -gt 0; do 1683eca46af7Smrg # Defer to hook functions for initial option parsing, so they 1684eca46af7Smrg # get priority in the event of reusing an option name. 1685eca46af7Smrg func_run_hooks func_parse_options ${1+"$@"} 168695b296d0Smrg 1687eca46af7Smrg # Adjust func_parse_options positional parameters to match 1688eca46af7Smrg eval set dummy "$func_run_hooks_result"; shift 168995b296d0Smrg 1690eca46af7Smrg # Break out of the loop if we already parsed every option. 1691eca46af7Smrg test $# -gt 0 || break 169239713583Smrg 1693eca46af7Smrg _G_opt=$1 1694eca46af7Smrg shift 1695eca46af7Smrg case $_G_opt in 1696eca46af7Smrg --debug|-x) debug_cmd='set -x' 1697eca46af7Smrg func_echo "enabling shell trace mode" 1698eca46af7Smrg $debug_cmd 1699eca46af7Smrg ;; 1700eca46af7Smrg 1701eca46af7Smrg --no-warnings|--no-warning|--no-warn) 1702eca46af7Smrg set dummy --warnings none ${1+"$@"} 1703eca46af7Smrg shift 1704eca46af7Smrg ;; 17052378475aSmrg 1706eca46af7Smrg --warnings|--warning|-W) 1707eca46af7Smrg test $# = 0 && func_missing_arg $_G_opt && break 1708eca46af7Smrg case " $warning_categories $1" in 1709eca46af7Smrg *" $1 "*) 1710eca46af7Smrg # trailing space prevents matching last $1 above 1711eca46af7Smrg func_append_uniq opt_warning_types " $1" 1712eca46af7Smrg ;; 1713eca46af7Smrg *all) 1714eca46af7Smrg opt_warning_types=$warning_categories 1715eca46af7Smrg ;; 1716eca46af7Smrg *none) 1717eca46af7Smrg opt_warning_types=none 1718eca46af7Smrg warning_func=: 1719eca46af7Smrg ;; 1720eca46af7Smrg *error) 1721eca46af7Smrg opt_warning_types=$warning_categories 1722eca46af7Smrg warning_func=func_fatal_error 1723eca46af7Smrg ;; 1724eca46af7Smrg *) 1725eca46af7Smrg func_fatal_error \ 1726eca46af7Smrg "unsupported warning category: '$1'" 1727eca46af7Smrg ;; 1728eca46af7Smrg esac 1729eca46af7Smrg shift 1730eca46af7Smrg ;; 1731eca46af7Smrg 1732eca46af7Smrg --verbose|-v) opt_verbose=: ;; 1733eca46af7Smrg --version) func_version ;; 1734eca46af7Smrg -\?|-h) func_usage ;; 1735eca46af7Smrg --help) func_help ;; 1736eca46af7Smrg 1737eca46af7Smrg # Separate optargs to long options (plugins may need this): 1738eca46af7Smrg --*=*) func_split_equals "$_G_opt" 1739eca46af7Smrg set dummy "$func_split_equals_lhs" \ 1740eca46af7Smrg "$func_split_equals_rhs" ${1+"$@"} 1741eca46af7Smrg shift 1742eca46af7Smrg ;; 1743eca46af7Smrg 1744eca46af7Smrg # Separate optargs to short options: 1745eca46af7Smrg -W*) 1746eca46af7Smrg func_split_short_opt "$_G_opt" 1747eca46af7Smrg set dummy "$func_split_short_opt_name" \ 1748eca46af7Smrg "$func_split_short_opt_arg" ${1+"$@"} 1749eca46af7Smrg shift 1750eca46af7Smrg ;; 1751eca46af7Smrg 1752eca46af7Smrg # Separate non-argument short options: 1753eca46af7Smrg -\?*|-h*|-v*|-x*) 1754eca46af7Smrg func_split_short_opt "$_G_opt" 1755eca46af7Smrg set dummy "$func_split_short_opt_name" \ 1756eca46af7Smrg "-$func_split_short_opt_arg" ${1+"$@"} 1757eca46af7Smrg shift 1758eca46af7Smrg ;; 1759eca46af7Smrg 1760eca46af7Smrg --) break ;; 1761eca46af7Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1762eca46af7Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1763eca46af7Smrg esac 1764eca46af7Smrg done 1765eca46af7Smrg 1766eca46af7Smrg # save modified positional parameters for caller 1767eca46af7Smrg func_quote_for_eval ${1+"$@"} 1768eca46af7Smrg func_parse_options_result=$func_quote_for_eval_result 176995b296d0Smrg} 177095b296d0Smrg 17712378475aSmrg 1772eca46af7Smrg# func_validate_options [ARG]... 1773eca46af7Smrg# ------------------------------ 1774eca46af7Smrg# Perform any sanity checks on option settings and/or unconsumed 1775eca46af7Smrg# arguments. 1776eca46af7Smrgfunc_hookable func_validate_options 1777eca46af7Smrgfunc_validate_options () 177895b296d0Smrg{ 1779eca46af7Smrg $debug_cmd 17802378475aSmrg 1781eca46af7Smrg # Display all warnings if -W was not given. 1782eca46af7Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 17832378475aSmrg 1784eca46af7Smrg func_run_hooks func_validate_options ${1+"$@"} 178595b296d0Smrg 1786eca46af7Smrg # Bail if the options were screwed! 1787eca46af7Smrg $exit_cmd $EXIT_FAILURE 1788eca46af7Smrg 1789eca46af7Smrg # save modified positional parameters for caller 1790eca46af7Smrg func_validate_options_result=$func_run_hooks_result 179114330f12Smrg} 17922378475aSmrg 17932378475aSmrg 179414330f12Smrg 1795eca46af7Smrg## ----------------- ## 1796eca46af7Smrg## Helper functions. ## 1797eca46af7Smrg## ----------------- ## 17982378475aSmrg 1799eca46af7Smrg# This section contains the helper functions used by the rest of the 1800eca46af7Smrg# hookable option parser framework in ascii-betical order. 1801eca46af7Smrg 1802eca46af7Smrg 1803eca46af7Smrg# func_fatal_help ARG... 1804eca46af7Smrg# ---------------------- 1805eca46af7Smrg# Echo program name prefixed message to standard error, followed by 1806eca46af7Smrg# a help hint, and exit. 1807eca46af7Smrgfunc_fatal_help () 18082378475aSmrg{ 1809eca46af7Smrg $debug_cmd 181014330f12Smrg 1811eca46af7Smrg eval \$ECHO \""Usage: $usage"\" 1812eca46af7Smrg eval \$ECHO \""$fatal_help"\" 1813eca46af7Smrg func_error ${1+"$@"} 1814eca46af7Smrg exit $EXIT_FAILURE 18152378475aSmrg} 18162378475aSmrg 1817eca46af7Smrg 1818eca46af7Smrg# func_help 1819eca46af7Smrg# --------- 1820eca46af7Smrg# Echo long help message to standard output and exit. 18212378475aSmrgfunc_help () 18222378475aSmrg{ 1823eca46af7Smrg $debug_cmd 1824eca46af7Smrg 1825eca46af7Smrg func_usage_message 1826eca46af7Smrg $ECHO "$long_help_message" 1827eca46af7Smrg exit 0 18282378475aSmrg} 18292378475aSmrg 1830eca46af7Smrg 1831eca46af7Smrg# func_missing_arg ARGNAME 1832eca46af7Smrg# ------------------------ 18332378475aSmrg# Echo program name prefixed message to standard error and set global 18342378475aSmrg# exit_cmd. 18352378475aSmrgfunc_missing_arg () 18362378475aSmrg{ 1837eca46af7Smrg $debug_cmd 183814330f12Smrg 1839eca46af7Smrg func_error "Missing argument for '$1'." 18402378475aSmrg exit_cmd=exit 184195b296d0Smrg} 184295b296d0Smrg 184339713583Smrg 1844eca46af7Smrg# func_split_equals STRING 1845eca46af7Smrg# ------------------------ 1846eca46af7Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 1847eca46af7Smrg# splitting STRING at the '=' sign. 1848eca46af7Smrgtest -z "$_G_HAVE_XSI_OPS" \ 1849eca46af7Smrg && (eval 'x=a/b/c; 1850eca46af7Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 1851eca46af7Smrg && _G_HAVE_XSI_OPS=yes 1852eca46af7Smrg 1853eca46af7Smrgif test yes = "$_G_HAVE_XSI_OPS" 1854eca46af7Smrgthen 1855eca46af7Smrg # This is an XSI compatible shell, allowing a faster implementation... 1856eca46af7Smrg eval 'func_split_equals () 1857eca46af7Smrg { 1858eca46af7Smrg $debug_cmd 1859eca46af7Smrg 1860eca46af7Smrg func_split_equals_lhs=${1%%=*} 1861eca46af7Smrg func_split_equals_rhs=${1#*=} 1862eca46af7Smrg test "x$func_split_equals_lhs" = "x$1" \ 1863eca46af7Smrg && func_split_equals_rhs= 1864eca46af7Smrg }' 1865eca46af7Smrgelse 1866eca46af7Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 1867eca46af7Smrg func_split_equals () 1868eca46af7Smrg { 1869eca46af7Smrg $debug_cmd 1870eca46af7Smrg 1871eca46af7Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 1872eca46af7Smrg func_split_equals_rhs= 1873eca46af7Smrg test "x$func_split_equals_lhs" = "x$1" \ 1874eca46af7Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 1875eca46af7Smrg } 1876eca46af7Smrgfi #func_split_equals 1877eca46af7Smrg 1878eca46af7Smrg 1879eca46af7Smrg# func_split_short_opt SHORTOPT 1880eca46af7Smrg# ----------------------------- 188114330f12Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 188214330f12Smrg# variables after splitting SHORTOPT after the 2nd character. 1883eca46af7Smrgif test yes = "$_G_HAVE_XSI_OPS" 1884eca46af7Smrgthen 1885eca46af7Smrg # This is an XSI compatible shell, allowing a faster implementation... 1886eca46af7Smrg eval 'func_split_short_opt () 1887eca46af7Smrg { 1888eca46af7Smrg $debug_cmd 1889eca46af7Smrg 1890eca46af7Smrg func_split_short_opt_arg=${1#??} 1891eca46af7Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 1892eca46af7Smrg }' 1893eca46af7Smrgelse 1894eca46af7Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 1895eca46af7Smrg func_split_short_opt () 1896eca46af7Smrg { 1897eca46af7Smrg $debug_cmd 1898eca46af7Smrg 1899eca46af7Smrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 1900eca46af7Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 1901eca46af7Smrg } 1902eca46af7Smrgfi #func_split_short_opt 1903eca46af7Smrg 1904eca46af7Smrg 1905eca46af7Smrg# func_usage 1906eca46af7Smrg# ---------- 1907eca46af7Smrg# Echo short help message to standard output and exit. 1908eca46af7Smrgfunc_usage () 190914330f12Smrg{ 1910eca46af7Smrg $debug_cmd 191139713583Smrg 1912eca46af7Smrg func_usage_message 1913eca46af7Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 1914eca46af7Smrg exit 0 1915eca46af7Smrg} 191614330f12Smrg 191714330f12Smrg 1918eca46af7Smrg# func_usage_message 1919eca46af7Smrg# ------------------ 1920eca46af7Smrg# Echo short help message to standard output. 1921eca46af7Smrgfunc_usage_message () 192214330f12Smrg{ 1923eca46af7Smrg $debug_cmd 192414330f12Smrg 1925eca46af7Smrg eval \$ECHO \""Usage: $usage"\" 1926eca46af7Smrg echo 1927eca46af7Smrg $SED -n 's|^# || 1928eca46af7Smrg /^Written by/{ 1929eca46af7Smrg x;p;x 1930eca46af7Smrg } 1931eca46af7Smrg h 1932eca46af7Smrg /^Written by/q' < "$progpath" 1933eca46af7Smrg echo 1934eca46af7Smrg eval \$ECHO \""$usage_message"\" 1935eca46af7Smrg} 193614330f12Smrg 19372378475aSmrg 1938eca46af7Smrg# func_version 1939eca46af7Smrg# ------------ 1940eca46af7Smrg# Echo version message to standard output and exit. 1941eca46af7Smrgfunc_version () 1942eca46af7Smrg{ 1943eca46af7Smrg $debug_cmd 19442378475aSmrg 1945eca46af7Smrg printf '%s\n' "$progname $scriptversion" 1946eca46af7Smrg $SED -n ' 1947eca46af7Smrg /(C)/!b go 1948eca46af7Smrg :more 1949eca46af7Smrg /\./!{ 1950eca46af7Smrg N 1951eca46af7Smrg s|\n# | | 1952eca46af7Smrg b more 1953eca46af7Smrg } 1954eca46af7Smrg :go 1955eca46af7Smrg /^# Written by /,/# warranty; / { 1956eca46af7Smrg s|^# || 1957eca46af7Smrg s|^# *$|| 1958eca46af7Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 1959eca46af7Smrg p 1960eca46af7Smrg } 1961eca46af7Smrg /^# Written by / { 1962eca46af7Smrg s|^# || 1963eca46af7Smrg p 1964eca46af7Smrg } 1965eca46af7Smrg /^warranty; /q' < "$progpath" 19662378475aSmrg 1967eca46af7Smrg exit $? 1968eca46af7Smrg} 196995b296d0Smrg 197095b296d0Smrg 1971eca46af7Smrg# Local variables: 1972eca46af7Smrg# mode: shell-script 1973eca46af7Smrg# sh-indentation: 2 1974eca46af7Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 1975eca46af7Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1976eca46af7Smrg# time-stamp-time-zone: "UTC" 1977eca46af7Smrg# End: 197895b296d0Smrg 1979eca46af7Smrg# Set a version string. 198089b0dc75Smrgscriptversion='(GNU libtool) 2.4.6' 198139713583Smrg 19822378475aSmrg 1983eca46af7Smrg# func_echo ARG... 1984eca46af7Smrg# ---------------- 1985eca46af7Smrg# Libtool also displays the current mode in messages, so override 1986eca46af7Smrg# funclib.sh func_echo with this custom definition. 1987eca46af7Smrgfunc_echo () 198814330f12Smrg{ 1989eca46af7Smrg $debug_cmd 199014330f12Smrg 1991eca46af7Smrg _G_message=$* 1992eca46af7Smrg 1993eca46af7Smrg func_echo_IFS=$IFS 1994eca46af7Smrg IFS=$nl 1995eca46af7Smrg for _G_line in $_G_message; do 1996eca46af7Smrg IFS=$func_echo_IFS 1997eca46af7Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 1998eca46af7Smrg done 1999eca46af7Smrg IFS=$func_echo_IFS 2000eca46af7Smrg} 200114330f12Smrg 200214330f12Smrg 2003eca46af7Smrg# func_warning ARG... 2004eca46af7Smrg# ------------------- 2005eca46af7Smrg# Libtool warnings are not categorized, so override funclib.sh 2006eca46af7Smrg# func_warning with this simpler definition. 2007eca46af7Smrgfunc_warning () 200814330f12Smrg{ 2009eca46af7Smrg $debug_cmd 2010eca46af7Smrg 2011eca46af7Smrg $warning_func ${1+"$@"} 2012eca46af7Smrg} 201314330f12Smrg 201414330f12Smrg 2015eca46af7Smrg## ---------------- ## 2016eca46af7Smrg## Options parsing. ## 2017eca46af7Smrg## ---------------- ## 2018eca46af7Smrg 2019eca46af7Smrg# Hook in the functions to make sure our own options are parsed during 2020eca46af7Smrg# the option parsing loop. 2021eca46af7Smrg 2022eca46af7Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 2023eca46af7Smrg 2024eca46af7Smrg# Short help message in response to '-h'. 2025eca46af7Smrgusage_message="Options: 2026eca46af7Smrg --config show all configuration variables 2027eca46af7Smrg --debug enable verbose shell tracing 2028eca46af7Smrg -n, --dry-run display commands without modifying any files 2029eca46af7Smrg --features display basic configuration information and exit 2030eca46af7Smrg --mode=MODE use operation mode MODE 2031eca46af7Smrg --no-warnings equivalent to '-Wnone' 2032eca46af7Smrg --preserve-dup-deps don't remove duplicate dependency libraries 2033eca46af7Smrg --quiet, --silent don't print informational messages 2034eca46af7Smrg --tag=TAG use configuration variables from tag TAG 2035eca46af7Smrg -v, --verbose print more informational messages than default 2036eca46af7Smrg --version print version information 2037eca46af7Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2038eca46af7Smrg -h, --help, --help-all print short, long, or detailed help message 2039eca46af7Smrg" 204014330f12Smrg 2041eca46af7Smrg# Additional text appended to 'usage_message' in response to '--help'. 204289b0dc75Smrgfunc_help () 204389b0dc75Smrg{ 204489b0dc75Smrg $debug_cmd 204589b0dc75Smrg 204689b0dc75Smrg func_usage_message 204789b0dc75Smrg $ECHO "$long_help_message 204814330f12Smrg 2049eca46af7SmrgMODE must be one of the following: 205014330f12Smrg 2051eca46af7Smrg clean remove files from the build directory 2052eca46af7Smrg compile compile a source file into a libtool object 2053eca46af7Smrg execute automatically set library path, then run a program 2054eca46af7Smrg finish complete the installation of libtool libraries 2055eca46af7Smrg install install libraries or executables 2056eca46af7Smrg link create a library or an executable 2057eca46af7Smrg uninstall remove libraries from an installed directory 205814330f12Smrg 2059eca46af7SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2060eca46af7Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2061eca46af7SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2062eca46af7Smrg 2063eca46af7SmrgWhen reporting a bug, please describe a test case to reproduce it and 2064eca46af7Smrginclude the following information: 2065eca46af7Smrg 2066eca46af7Smrg host-triplet: $host 2067eca46af7Smrg shell: $SHELL 2068eca46af7Smrg compiler: $LTCC 2069eca46af7Smrg compiler flags: $LTCFLAGS 2070eca46af7Smrg linker: $LD (gnu? $with_gnu_ld) 207189b0dc75Smrg version: $progname (GNU libtool) 2.4.6 2072eca46af7Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2073eca46af7Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2074eca46af7Smrg 2075eca46af7SmrgReport bugs to <bug-libtool@gnu.org>. 2076eca46af7SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 2077eca46af7SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 207889b0dc75Smrg exit 0 207989b0dc75Smrg} 2080eca46af7Smrg 2081eca46af7Smrg 2082eca46af7Smrg# func_lo2o OBJECT-NAME 2083eca46af7Smrg# --------------------- 2084eca46af7Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2085eca46af7Smrg# object suffix. 2086eca46af7Smrg 2087eca46af7Smrglo2o=s/\\.lo\$/.$objext/ 2088eca46af7Smrgo2lo=s/\\.$objext\$/.lo/ 2089eca46af7Smrg 2090eca46af7Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 2091eca46af7Smrg eval 'func_lo2o () 2092eca46af7Smrg { 2093eca46af7Smrg case $1 in 2094eca46af7Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2095eca46af7Smrg * ) func_lo2o_result=$1 ;; 2096eca46af7Smrg esac 2097eca46af7Smrg }' 2098eca46af7Smrg 2099eca46af7Smrg # func_xform LIBOBJ-OR-SOURCE 2100eca46af7Smrg # --------------------------- 2101eca46af7Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2102eca46af7Smrg # suffix to a '.lo' libtool-object suffix. 2103eca46af7Smrg eval 'func_xform () 2104eca46af7Smrg { 2105eca46af7Smrg func_xform_result=${1%.*}.lo 2106eca46af7Smrg }' 2107eca46af7Smrgelse 2108eca46af7Smrg # ...otherwise fall back to using sed. 2109eca46af7Smrg func_lo2o () 2110eca46af7Smrg { 2111eca46af7Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2112eca46af7Smrg } 2113eca46af7Smrg 2114eca46af7Smrg func_xform () 2115eca46af7Smrg { 2116eca46af7Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2117eca46af7Smrg } 2118eca46af7Smrgfi 211914330f12Smrg 212014330f12Smrg 2121eca46af7Smrg# func_fatal_configuration ARG... 2122eca46af7Smrg# ------------------------------- 21232378475aSmrg# Echo program name prefixed message to standard error, followed by 21242378475aSmrg# a configuration failure hint, and exit. 21252378475aSmrgfunc_fatal_configuration () 21262378475aSmrg{ 2127eca46af7Smrg func__fatal_error ${1+"$@"} \ 2128eca46af7Smrg "See the $PACKAGE documentation for more information." \ 2129eca46af7Smrg "Fatal configuration error." 21302378475aSmrg} 2131ff89ac2bSmrg 213239713583Smrg 21332378475aSmrg# func_config 2134eca46af7Smrg# ----------- 21352378475aSmrg# Display the configuration for all the tags in this script. 21362378475aSmrgfunc_config () 21372378475aSmrg{ 21382378475aSmrg re_begincf='^# ### BEGIN LIBTOOL' 21392378475aSmrg re_endcf='^# ### END LIBTOOL' 21402378475aSmrg 21412378475aSmrg # Default configuration. 21422378475aSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 214395b296d0Smrg 214495b296d0Smrg # Now print the configurations for the tags. 214595b296d0Smrg for tagname in $taglist; do 21462378475aSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 214795b296d0Smrg done 2148e6f085baSmrg 21492378475aSmrg exit $? 21502378475aSmrg} 2151e6f085baSmrg 2152eca46af7Smrg 21532378475aSmrg# func_features 2154eca46af7Smrg# ------------- 21552378475aSmrg# Display the features supported by this script. 21562378475aSmrgfunc_features () 21572378475aSmrg{ 215814330f12Smrg echo "host: $host" 2159eca46af7Smrg if test yes = "$build_libtool_libs"; then 216014330f12Smrg echo "enable shared libraries" 216195b296d0Smrg else 216214330f12Smrg echo "disable shared libraries" 216395b296d0Smrg fi 2164eca46af7Smrg if test yes = "$build_old_libs"; then 216514330f12Smrg echo "enable static libraries" 216695b296d0Smrg else 216714330f12Smrg echo "disable static libraries" 216895b296d0Smrg fi 21692378475aSmrg 217095b296d0Smrg exit $? 21712378475aSmrg} 217295b296d0Smrg 2173eca46af7Smrg 2174eca46af7Smrg# func_enable_tag TAGNAME 2175eca46af7Smrg# ----------------------- 21762378475aSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 21772378475aSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 21782378475aSmrg# variable here. 21792378475aSmrgfunc_enable_tag () 21802378475aSmrg{ 2181eca46af7Smrg # Global variable: 2182eca46af7Smrg tagname=$1 218395b296d0Smrg 2184eca46af7Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2185eca46af7Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2186eca46af7Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 218739713583Smrg 2188eca46af7Smrg # Validate tagname. 2189eca46af7Smrg case $tagname in 2190eca46af7Smrg *[!-_A-Za-z0-9,/]*) 2191eca46af7Smrg func_fatal_error "invalid tag name: $tagname" 2192eca46af7Smrg ;; 2193eca46af7Smrg esac 219495b296d0Smrg 2195eca46af7Smrg # Don't test for the "default" C tag, as we know it's 2196eca46af7Smrg # there but not specially marked. 2197eca46af7Smrg case $tagname in 2198eca46af7Smrg CC) ;; 21992378475aSmrg *) 2200eca46af7Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2201eca46af7Smrg taglist="$taglist $tagname" 2202eca46af7Smrg 2203eca46af7Smrg # Evaluate the configuration. Be careful to quote the path 2204eca46af7Smrg # and the sed script, to avoid splitting on whitespace, but 2205eca46af7Smrg # also don't use non-portable quotes within backquotes within 2206eca46af7Smrg # quotes we have to do it in 2 steps: 2207eca46af7Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2208eca46af7Smrg eval "$extractedcf" 2209eca46af7Smrg else 2210eca46af7Smrg func_error "ignoring unknown tag $tagname" 2211eca46af7Smrg fi 2212eca46af7Smrg ;; 2213eca46af7Smrg esac 22142378475aSmrg} 22152378475aSmrg 2216eca46af7Smrg 221714330f12Smrg# func_check_version_match 2218eca46af7Smrg# ------------------------ 221914330f12Smrg# Ensure that we are using m4 macros, and libtool script from the same 222014330f12Smrg# release of libtool. 222114330f12Smrgfunc_check_version_match () 22222378475aSmrg{ 2223eca46af7Smrg if test "$package_revision" != "$macro_revision"; then 2224eca46af7Smrg if test "$VERSION" != "$macro_version"; then 2225eca46af7Smrg if test -z "$macro_version"; then 2226eca46af7Smrg cat >&2 <<_LT_EOF 222714330f12Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 222814330f12Smrg$progname: definition of this LT_INIT comes from an older release. 222914330f12Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 223014330f12Smrg$progname: and run autoconf again. 223114330f12Smrg_LT_EOF 2232eca46af7Smrg else 2233eca46af7Smrg cat >&2 <<_LT_EOF 223414330f12Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 223514330f12Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 223614330f12Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 223714330f12Smrg$progname: and run autoconf again. 223814330f12Smrg_LT_EOF 2239eca46af7Smrg fi 2240eca46af7Smrg else 2241eca46af7Smrg cat >&2 <<_LT_EOF 224214330f12Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 224314330f12Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 224414330f12Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 224514330f12Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 224614330f12Smrg_LT_EOF 2247eca46af7Smrg fi 2248e6f085baSmrg 2249eca46af7Smrg exit $EXIT_MISMATCH 2250eca46af7Smrg fi 225114330f12Smrg} 225214330f12Smrg 225314330f12Smrg 2254eca46af7Smrg# libtool_options_prep [ARG]... 2255eca46af7Smrg# ----------------------------- 2256eca46af7Smrg# Preparation for options parsed by libtool. 2257eca46af7Smrglibtool_options_prep () 2258eca46af7Smrg{ 2259eca46af7Smrg $debug_mode 226014330f12Smrg 2261eca46af7Smrg # Option defaults: 2262eca46af7Smrg opt_config=false 2263eca46af7Smrg opt_dlopen= 2264eca46af7Smrg opt_dry_run=false 2265eca46af7Smrg opt_help=false 2266eca46af7Smrg opt_mode= 2267eca46af7Smrg opt_preserve_dup_deps=false 2268eca46af7Smrg opt_quiet=false 226914330f12Smrg 2270eca46af7Smrg nonopt= 2271eca46af7Smrg preserve_args= 227214330f12Smrg 2273eca46af7Smrg # Shorthand for --mode=foo, only valid as the first argument 2274eca46af7Smrg case $1 in 2275eca46af7Smrg clean|clea|cle|cl) 2276eca46af7Smrg shift; set dummy --mode clean ${1+"$@"}; shift 2277eca46af7Smrg ;; 2278eca46af7Smrg compile|compil|compi|comp|com|co|c) 2279eca46af7Smrg shift; set dummy --mode compile ${1+"$@"}; shift 2280eca46af7Smrg ;; 2281eca46af7Smrg execute|execut|execu|exec|exe|ex|e) 2282eca46af7Smrg shift; set dummy --mode execute ${1+"$@"}; shift 2283eca46af7Smrg ;; 2284eca46af7Smrg finish|finis|fini|fin|fi|f) 2285eca46af7Smrg shift; set dummy --mode finish ${1+"$@"}; shift 2286eca46af7Smrg ;; 2287eca46af7Smrg install|instal|insta|inst|ins|in|i) 2288eca46af7Smrg shift; set dummy --mode install ${1+"$@"}; shift 2289eca46af7Smrg ;; 2290eca46af7Smrg link|lin|li|l) 2291eca46af7Smrg shift; set dummy --mode link ${1+"$@"}; shift 2292eca46af7Smrg ;; 2293eca46af7Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2294eca46af7Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2295eca46af7Smrg ;; 2296eca46af7Smrg esac 2297eca46af7Smrg 2298eca46af7Smrg # Pass back the list of options. 2299eca46af7Smrg func_quote_for_eval ${1+"$@"} 2300eca46af7Smrg libtool_options_prep_result=$func_quote_for_eval_result 2301eca46af7Smrg} 2302eca46af7Smrgfunc_add_hook func_options_prep libtool_options_prep 230395b296d0Smrg 230414330f12Smrg 2305eca46af7Smrg# libtool_parse_options [ARG]... 2306eca46af7Smrg# --------------------------------- 2307eca46af7Smrg# Provide handling for libtool specific options. 2308eca46af7Smrglibtool_parse_options () 230914330f12Smrg{ 2310eca46af7Smrg $debug_cmd 23112378475aSmrg 2312eca46af7Smrg # Perform our own loop to consume as many options as possible in 2313eca46af7Smrg # each iteration. 2314eca46af7Smrg while test $# -gt 0; do 2315eca46af7Smrg _G_opt=$1 2316eca46af7Smrg shift 2317eca46af7Smrg case $_G_opt in 2318eca46af7Smrg --dry-run|--dryrun|-n) 2319eca46af7Smrg opt_dry_run=: 2320eca46af7Smrg ;; 2321eca46af7Smrg 2322eca46af7Smrg --config) func_config ;; 2323eca46af7Smrg 2324eca46af7Smrg --dlopen|-dlopen) 2325eca46af7Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 2326eca46af7Smrg}$1" 2327eca46af7Smrg shift 2328eca46af7Smrg ;; 2329eca46af7Smrg 2330eca46af7Smrg --preserve-dup-deps) 2331eca46af7Smrg opt_preserve_dup_deps=: ;; 2332eca46af7Smrg 2333eca46af7Smrg --features) func_features ;; 2334eca46af7Smrg 2335eca46af7Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2336eca46af7Smrg 2337eca46af7Smrg --help) opt_help=: ;; 2338eca46af7Smrg 2339eca46af7Smrg --help-all) opt_help=': help-all' ;; 2340eca46af7Smrg 2341eca46af7Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2342eca46af7Smrg opt_mode=$1 2343eca46af7Smrg case $1 in 2344eca46af7Smrg # Valid mode arguments: 2345eca46af7Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2346eca46af7Smrg 2347eca46af7Smrg # Catch anything else as an error 2348eca46af7Smrg *) func_error "invalid argument for $_G_opt" 2349eca46af7Smrg exit_cmd=exit 2350eca46af7Smrg break 2351eca46af7Smrg ;; 2352eca46af7Smrg esac 2353eca46af7Smrg shift 2354eca46af7Smrg ;; 2355eca46af7Smrg 2356eca46af7Smrg --no-silent|--no-quiet) 2357eca46af7Smrg opt_quiet=false 2358eca46af7Smrg func_append preserve_args " $_G_opt" 2359eca46af7Smrg ;; 2360eca46af7Smrg 2361eca46af7Smrg --no-warnings|--no-warning|--no-warn) 2362eca46af7Smrg opt_warning=false 2363eca46af7Smrg func_append preserve_args " $_G_opt" 2364eca46af7Smrg ;; 2365eca46af7Smrg 2366eca46af7Smrg --no-verbose) 2367eca46af7Smrg opt_verbose=false 2368eca46af7Smrg func_append preserve_args " $_G_opt" 2369eca46af7Smrg ;; 2370eca46af7Smrg 2371eca46af7Smrg --silent|--quiet) 2372eca46af7Smrg opt_quiet=: 2373eca46af7Smrg opt_verbose=false 2374eca46af7Smrg func_append preserve_args " $_G_opt" 2375eca46af7Smrg ;; 2376eca46af7Smrg 2377eca46af7Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2378eca46af7Smrg opt_tag=$1 2379eca46af7Smrg func_append preserve_args " $_G_opt $1" 2380eca46af7Smrg func_enable_tag "$1" 2381eca46af7Smrg shift 2382eca46af7Smrg ;; 2383eca46af7Smrg 2384eca46af7Smrg --verbose|-v) opt_quiet=false 2385eca46af7Smrg opt_verbose=: 2386eca46af7Smrg func_append preserve_args " $_G_opt" 2387eca46af7Smrg ;; 2388eca46af7Smrg 2389eca46af7Smrg # An option not handled by this hook function: 2390eca46af7Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 2391eca46af7Smrg esac 2392eca46af7Smrg done 239314330f12Smrg 239414330f12Smrg 2395eca46af7Smrg # save modified positional parameters for caller 2396eca46af7Smrg func_quote_for_eval ${1+"$@"} 2397eca46af7Smrg libtool_parse_options_result=$func_quote_for_eval_result 2398eca46af7Smrg} 2399eca46af7Smrgfunc_add_hook func_parse_options libtool_parse_options 24002378475aSmrg 240139713583Smrg 24022378475aSmrg 2403eca46af7Smrg# libtool_validate_options [ARG]... 2404eca46af7Smrg# --------------------------------- 2405eca46af7Smrg# Perform any sanity checks on option settings and/or unconsumed 2406eca46af7Smrg# arguments. 2407eca46af7Smrglibtool_validate_options () 2408eca46af7Smrg{ 2409eca46af7Smrg # save first non-option argument 2410eca46af7Smrg if test 0 -lt $#; then 2411eca46af7Smrg nonopt=$1 2412eca46af7Smrg shift 24132378475aSmrg fi 24142378475aSmrg 2415eca46af7Smrg # preserve --debug 2416eca46af7Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 24172378475aSmrg 2418eca46af7Smrg case $host in 2419eca46af7Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2420eca46af7Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2421eca46af7Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2422eca46af7Smrg # don't eliminate duplications in $postdeps and $predeps 2423eca46af7Smrg opt_duplicate_compiler_generated_deps=: 2424eca46af7Smrg ;; 2425eca46af7Smrg *) 2426eca46af7Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2427eca46af7Smrg ;; 2428eca46af7Smrg esac 242995b296d0Smrg 2430eca46af7Smrg $opt_help || { 2431eca46af7Smrg # Sanity checks first: 2432eca46af7Smrg func_check_version_match 2433eca46af7Smrg 2434eca46af7Smrg test yes != "$build_libtool_libs" \ 2435eca46af7Smrg && test yes != "$build_old_libs" \ 2436eca46af7Smrg && func_fatal_configuration "not configured to build any kind of library" 2437eca46af7Smrg 2438eca46af7Smrg # Darwin sucks 2439eca46af7Smrg eval std_shrext=\"$shrext_cmds\" 2440eca46af7Smrg 2441eca46af7Smrg # Only execute mode is allowed to have -dlopen flags. 2442eca46af7Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2443eca46af7Smrg func_error "unrecognized option '-dlopen'" 2444eca46af7Smrg $ECHO "$help" 1>&2 2445eca46af7Smrg exit $EXIT_FAILURE 2446eca46af7Smrg fi 24472378475aSmrg 2448eca46af7Smrg # Change the help message to a mode-specific one. 2449eca46af7Smrg generic_help=$help 2450eca46af7Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 2451eca46af7Smrg } 24522378475aSmrg 2453eca46af7Smrg # Pass back the unparsed argument list 2454eca46af7Smrg func_quote_for_eval ${1+"$@"} 2455eca46af7Smrg libtool_validate_options_result=$func_quote_for_eval_result 245614330f12Smrg} 2457eca46af7Smrgfunc_add_hook func_validate_options libtool_validate_options 24582378475aSmrg 24592378475aSmrg 2460eca46af7Smrg# Process options as early as possible so that --help and --version 2461eca46af7Smrg# can return quickly. 2462eca46af7Smrgfunc_options ${1+"$@"} 2463eca46af7Smrgeval set dummy "$func_options_result"; shift 2464eca46af7Smrg 246595b296d0Smrg 246695b296d0Smrg 246714330f12Smrg## ----------- ## 246814330f12Smrg## Main. ## 246914330f12Smrg## ----------- ## 247095b296d0Smrg 2471eca46af7Smrgmagic='%%%MAGIC variable%%%' 2472eca46af7Smrgmagic_exe='%%%MAGIC EXE variable%%%' 2473eca46af7Smrg 2474eca46af7Smrg# Global variables. 2475eca46af7Smrgextracted_archives= 2476eca46af7Smrgextracted_serial=0 2477eca46af7Smrg 2478eca46af7Smrg# If this variable is set in any of the actions, the command in it 2479eca46af7Smrg# will be execed at the end. This prevents here-documents from being 2480eca46af7Smrg# left over by shells. 2481eca46af7Smrgexec_cmd= 2482eca46af7Smrg 2483eca46af7Smrg 2484eca46af7Smrg# A function that is used when there is no print builtin or printf. 2485eca46af7Smrgfunc_fallback_echo () 2486eca46af7Smrg{ 2487eca46af7Smrg eval 'cat <<_LTECHO_EOF 2488eca46af7Smrg$1 2489eca46af7Smrg_LTECHO_EOF' 2490eca46af7Smrg} 2491eca46af7Smrg 2492eca46af7Smrg# func_generated_by_libtool 2493eca46af7Smrg# True iff stdin has been generated by Libtool. This function is only 2494eca46af7Smrg# a basic sanity check; it will hardly flush out determined imposters. 2495eca46af7Smrgfunc_generated_by_libtool_p () 2496eca46af7Smrg{ 2497eca46af7Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2498eca46af7Smrg} 2499eca46af7Smrg 25002378475aSmrg# func_lalib_p file 2501eca46af7Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 25022378475aSmrg# This function is only a basic sanity check; it will hardly flush out 25032378475aSmrg# determined imposters. 25042378475aSmrgfunc_lalib_p () 25052378475aSmrg{ 25062378475aSmrg test -f "$1" && 2507eca46af7Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 25082378475aSmrg} 250995b296d0Smrg 25102378475aSmrg# func_lalib_unsafe_p file 2511eca46af7Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 25122378475aSmrg# This function implements the same check as func_lalib_p without 25132378475aSmrg# resorting to external programs. To this end, it redirects stdin and 25142378475aSmrg# closes it afterwards, without saving the original file descriptor. 25152378475aSmrg# As a safety measure, use it only where a negative result would be 2516eca46af7Smrg# fatal anyway. Works if 'file' does not exist. 25172378475aSmrgfunc_lalib_unsafe_p () 25182378475aSmrg{ 25192378475aSmrg lalib_p=no 25202378475aSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 25212378475aSmrg for lalib_p_l in 1 2 3 4 25222378475aSmrg do 25232378475aSmrg read lalib_p_line 2524eca46af7Smrg case $lalib_p_line in 25252378475aSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 25262378475aSmrg esac 25272378475aSmrg done 25282378475aSmrg exec 0<&5 5<&- 25292378475aSmrg fi 2530eca46af7Smrg test yes = "$lalib_p" 25312378475aSmrg} 253295b296d0Smrg 25332378475aSmrg# func_ltwrapper_script_p file 25342378475aSmrg# True iff FILE is a libtool wrapper script 25352378475aSmrg# This function is only a basic sanity check; it will hardly flush out 25362378475aSmrg# determined imposters. 25372378475aSmrgfunc_ltwrapper_script_p () 25382378475aSmrg{ 2539eca46af7Smrg test -f "$1" && 2540eca46af7Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 25412378475aSmrg} 254295b296d0Smrg 25432378475aSmrg# func_ltwrapper_executable_p file 25442378475aSmrg# True iff FILE is a libtool wrapper executable 25452378475aSmrg# This function is only a basic sanity check; it will hardly flush out 25462378475aSmrg# determined imposters. 25472378475aSmrgfunc_ltwrapper_executable_p () 25482378475aSmrg{ 25492378475aSmrg func_ltwrapper_exec_suffix= 25502378475aSmrg case $1 in 25512378475aSmrg *.exe) ;; 25522378475aSmrg *) func_ltwrapper_exec_suffix=.exe ;; 25532378475aSmrg esac 25542378475aSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 25552378475aSmrg} 255639713583Smrg 25572378475aSmrg# func_ltwrapper_scriptname file 25582378475aSmrg# Assumes file is an ltwrapper_executable 25592378475aSmrg# uses $file to determine the appropriate filename for a 25602378475aSmrg# temporary ltwrapper_script. 25612378475aSmrgfunc_ltwrapper_scriptname () 25622378475aSmrg{ 256314330f12Smrg func_dirname_and_basename "$1" "" "." 256414330f12Smrg func_stripname '' '.exe' "$func_basename_result" 2565eca46af7Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 25662378475aSmrg} 25672378475aSmrg 25682378475aSmrg# func_ltwrapper_p file 25692378475aSmrg# True iff FILE is a libtool wrapper script or wrapper executable 25702378475aSmrg# This function is only a basic sanity check; it will hardly flush out 25712378475aSmrg# determined imposters. 25722378475aSmrgfunc_ltwrapper_p () 25732378475aSmrg{ 25742378475aSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 25752378475aSmrg} 25762378475aSmrg 25772378475aSmrg 25782378475aSmrg# func_execute_cmds commands fail_cmd 25792378475aSmrg# Execute tilde-delimited COMMANDS. 25802378475aSmrg# If FAIL_CMD is given, eval that upon failure. 25812378475aSmrg# FAIL_CMD may read-access the current command in variable CMD! 25822378475aSmrgfunc_execute_cmds () 25832378475aSmrg{ 2584eca46af7Smrg $debug_cmd 2585eca46af7Smrg 25862378475aSmrg save_ifs=$IFS; IFS='~' 25872378475aSmrg for cmd in $1; do 2588eca46af7Smrg IFS=$sp$nl 25892378475aSmrg eval cmd=\"$cmd\" 2590eca46af7Smrg IFS=$save_ifs 25912378475aSmrg func_show_eval "$cmd" "${2-:}" 25922378475aSmrg done 25932378475aSmrg IFS=$save_ifs 25942378475aSmrg} 25952378475aSmrg 25962378475aSmrg 25972378475aSmrg# func_source file 25982378475aSmrg# Source FILE, adding directory component if necessary. 25992378475aSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 26002378475aSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 26012378475aSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2602eca46af7Smrg# 'FILE.' does not work on cygwin managed mounts. 26032378475aSmrgfunc_source () 26042378475aSmrg{ 2605eca46af7Smrg $debug_cmd 2606eca46af7Smrg 26072378475aSmrg case $1 in 26082378475aSmrg */* | *\\*) . "$1" ;; 26092378475aSmrg *) . "./$1" ;; 26102378475aSmrg esac 26112378475aSmrg} 26122378475aSmrg 26132378475aSmrg 261414330f12Smrg# func_resolve_sysroot PATH 261514330f12Smrg# Replace a leading = in PATH with a sysroot. Store the result into 261614330f12Smrg# func_resolve_sysroot_result 261714330f12Smrgfunc_resolve_sysroot () 261814330f12Smrg{ 261914330f12Smrg func_resolve_sysroot_result=$1 262014330f12Smrg case $func_resolve_sysroot_result in 262114330f12Smrg =*) 262214330f12Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 262314330f12Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 262414330f12Smrg ;; 262514330f12Smrg esac 262614330f12Smrg} 262714330f12Smrg 262814330f12Smrg# func_replace_sysroot PATH 262914330f12Smrg# If PATH begins with the sysroot, replace it with = and 263014330f12Smrg# store the result into func_replace_sysroot_result. 263114330f12Smrgfunc_replace_sysroot () 263214330f12Smrg{ 2633eca46af7Smrg case $lt_sysroot:$1 in 263414330f12Smrg ?*:"$lt_sysroot"*) 263514330f12Smrg func_stripname "$lt_sysroot" '' "$1" 2636eca46af7Smrg func_replace_sysroot_result='='$func_stripname_result 263714330f12Smrg ;; 263814330f12Smrg *) 263914330f12Smrg # Including no sysroot. 264014330f12Smrg func_replace_sysroot_result=$1 264114330f12Smrg ;; 264214330f12Smrg esac 264314330f12Smrg} 264414330f12Smrg 26452378475aSmrg# func_infer_tag arg 26462378475aSmrg# Infer tagged configuration to use if any are available and 26472378475aSmrg# if one wasn't chosen via the "--tag" command line option. 26482378475aSmrg# Only attempt this if the compiler in the base compile 26492378475aSmrg# command doesn't match the default compiler. 26502378475aSmrg# arg is usually of the form 'gcc ...' 26512378475aSmrgfunc_infer_tag () 26522378475aSmrg{ 2653eca46af7Smrg $debug_cmd 2654eca46af7Smrg 26552378475aSmrg if test -n "$available_tags" && test -z "$tagname"; then 26562378475aSmrg CC_quoted= 26572378475aSmrg for arg in $CC; do 265814330f12Smrg func_append_quoted CC_quoted "$arg" 26592378475aSmrg done 266014330f12Smrg CC_expanded=`func_echo_all $CC` 266114330f12Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 26622378475aSmrg case $@ in 26632378475aSmrg # Blanks in the command may have been stripped by the calling shell, 26642378475aSmrg # but not from the CC environment variable when configure was run. 266514330f12Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 266614330f12Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 26672378475aSmrg # Blanks at the start of $base_compile will cause this to fail 26682378475aSmrg # if we don't check for them as well. 26692378475aSmrg *) 26702378475aSmrg for z in $available_tags; do 26712378475aSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 26722378475aSmrg # Evaluate the configuration. 2673eca46af7Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 26742378475aSmrg CC_quoted= 26752378475aSmrg for arg in $CC; do 26762378475aSmrg # Double-quote args containing other shell metacharacters. 267714330f12Smrg func_append_quoted CC_quoted "$arg" 26782378475aSmrg done 267914330f12Smrg CC_expanded=`func_echo_all $CC` 268014330f12Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 26812378475aSmrg case "$@ " in 268214330f12Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 268314330f12Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 26842378475aSmrg # The compiler in the base compile command matches 26852378475aSmrg # the one in the tagged configuration. 26862378475aSmrg # Assume this is the tagged configuration we want. 26872378475aSmrg tagname=$z 26882378475aSmrg break 26892378475aSmrg ;; 26902378475aSmrg esac 26912378475aSmrg fi 26922378475aSmrg done 26932378475aSmrg # If $tagname still isn't set, then no tagged configuration 26942378475aSmrg # was found and let the user know that the "--tag" command 26952378475aSmrg # line option must be used. 26962378475aSmrg if test -z "$tagname"; then 26972378475aSmrg func_echo "unable to infer tagged configuration" 2698eca46af7Smrg func_fatal_error "specify a tag with '--tag'" 26992378475aSmrg# else 27002378475aSmrg# func_verbose "using $tagname tagged configuration" 27012378475aSmrg fi 27022378475aSmrg ;; 27032378475aSmrg esac 27042378475aSmrg fi 27052378475aSmrg} 27062378475aSmrg 27072378475aSmrg 27082378475aSmrg 27092378475aSmrg# func_write_libtool_object output_name pic_name nonpic_name 27102378475aSmrg# Create a libtool object file (analogous to a ".la" file), 27112378475aSmrg# but don't create it if we're doing a dry run. 27122378475aSmrgfunc_write_libtool_object () 27132378475aSmrg{ 2714eca46af7Smrg write_libobj=$1 2715eca46af7Smrg if test yes = "$build_libtool_libs"; then 2716eca46af7Smrg write_lobj=\'$2\' 27172378475aSmrg else 27182378475aSmrg write_lobj=none 27192378475aSmrg fi 27202378475aSmrg 2721eca46af7Smrg if test yes = "$build_old_libs"; then 2722eca46af7Smrg write_oldobj=\'$3\' 27232378475aSmrg else 27242378475aSmrg write_oldobj=none 27252378475aSmrg fi 27262378475aSmrg 27272378475aSmrg $opt_dry_run || { 27282378475aSmrg cat >${write_libobj}T <<EOF 27292378475aSmrg# $write_libobj - a libtool object file 2730eca46af7Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 27312378475aSmrg# 27322378475aSmrg# Please DO NOT delete this file! 27332378475aSmrg# It is necessary for linking the library. 27342378475aSmrg 27352378475aSmrg# Name of the PIC object. 27362378475aSmrgpic_object=$write_lobj 27372378475aSmrg 27382378475aSmrg# Name of the non-PIC object 27392378475aSmrgnon_pic_object=$write_oldobj 27402378475aSmrg 27412378475aSmrgEOF 2742eca46af7Smrg $MV "${write_libobj}T" "$write_libobj" 27432378475aSmrg } 27442378475aSmrg} 27452378475aSmrg 274614330f12Smrg 274714330f12Smrg################################################## 274814330f12Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 274914330f12Smrg################################################## 275014330f12Smrg 275114330f12Smrg# func_convert_core_file_wine_to_w32 ARG 275214330f12Smrg# Helper function used by file name conversion functions when $build is *nix, 275314330f12Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 275414330f12Smrg# correctly configured wine environment available, with the winepath program 275514330f12Smrg# in $build's $PATH. 275614330f12Smrg# 275714330f12Smrg# ARG is the $build file name to be converted to w32 format. 275814330f12Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 275914330f12Smrg# be empty on error (or when ARG is empty) 276014330f12Smrgfunc_convert_core_file_wine_to_w32 () 276114330f12Smrg{ 2762eca46af7Smrg $debug_cmd 2763eca46af7Smrg 2764eca46af7Smrg func_convert_core_file_wine_to_w32_result=$1 276514330f12Smrg if test -n "$1"; then 276614330f12Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 276714330f12Smrg # are forced to check the contents of stdout. On the other hand, if the 276814330f12Smrg # command is not found, the shell will set an exit code of 127 and print 276914330f12Smrg # *an error message* to stdout. So we must check for both error code of 277014330f12Smrg # zero AND non-empty stdout, which explains the odd construction: 277114330f12Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 2772eca46af7Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 277314330f12Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 2774eca46af7Smrg $SED -e "$sed_naive_backslashify"` 277514330f12Smrg else 277614330f12Smrg func_convert_core_file_wine_to_w32_result= 277714330f12Smrg fi 277814330f12Smrg fi 277914330f12Smrg} 278014330f12Smrg# end: func_convert_core_file_wine_to_w32 278114330f12Smrg 278214330f12Smrg 278314330f12Smrg# func_convert_core_path_wine_to_w32 ARG 278414330f12Smrg# Helper function used by path conversion functions when $build is *nix, and 278514330f12Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 278614330f12Smrg# configured wine environment available, with the winepath program in $build's 278714330f12Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 278814330f12Smrg# 278914330f12Smrg# ARG is path to be converted from $build format to win32. 279014330f12Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 279114330f12Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 279214330f12Smrg# are convertible, then the result may be empty. 279314330f12Smrgfunc_convert_core_path_wine_to_w32 () 279414330f12Smrg{ 2795eca46af7Smrg $debug_cmd 2796eca46af7Smrg 279714330f12Smrg # unfortunately, winepath doesn't convert paths, only file names 2798eca46af7Smrg func_convert_core_path_wine_to_w32_result= 279914330f12Smrg if test -n "$1"; then 280014330f12Smrg oldIFS=$IFS 280114330f12Smrg IFS=: 280214330f12Smrg for func_convert_core_path_wine_to_w32_f in $1; do 280314330f12Smrg IFS=$oldIFS 280414330f12Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 2805eca46af7Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 280614330f12Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 2807eca46af7Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 280814330f12Smrg else 280914330f12Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 281014330f12Smrg fi 281114330f12Smrg fi 281214330f12Smrg done 281314330f12Smrg IFS=$oldIFS 281414330f12Smrg fi 281514330f12Smrg} 281614330f12Smrg# end: func_convert_core_path_wine_to_w32 281714330f12Smrg 281814330f12Smrg 281914330f12Smrg# func_cygpath ARGS... 282014330f12Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 282114330f12Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 282214330f12Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 282314330f12Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 282414330f12Smrg# file name or path is assumed to be in w32 format, as previously converted 282514330f12Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 282614330f12Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 282714330f12Smrg# Cygwin format). Returns an empty string on error. 282814330f12Smrg# 282914330f12Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 283014330f12Smrg# be converted. 283114330f12Smrg# 283214330f12Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 283314330f12Smrg# environment variable; do not put it in $PATH. 283414330f12Smrgfunc_cygpath () 283514330f12Smrg{ 2836eca46af7Smrg $debug_cmd 2837eca46af7Smrg 283814330f12Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 283914330f12Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 284014330f12Smrg if test "$?" -ne 0; then 284114330f12Smrg # on failure, ensure result is empty 284214330f12Smrg func_cygpath_result= 284314330f12Smrg fi 284414330f12Smrg else 284514330f12Smrg func_cygpath_result= 2846eca46af7Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 284714330f12Smrg fi 284814330f12Smrg} 284914330f12Smrg#end: func_cygpath 285014330f12Smrg 285114330f12Smrg 285214330f12Smrg# func_convert_core_msys_to_w32 ARG 285314330f12Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 285414330f12Smrg# result in func_convert_core_msys_to_w32_result. 285514330f12Smrgfunc_convert_core_msys_to_w32 () 285614330f12Smrg{ 2857eca46af7Smrg $debug_cmd 2858eca46af7Smrg 285914330f12Smrg # awkward: cmd appends spaces to result 286014330f12Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 2861eca46af7Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 286214330f12Smrg} 286314330f12Smrg#end: func_convert_core_msys_to_w32 286414330f12Smrg 286514330f12Smrg 286614330f12Smrg# func_convert_file_check ARG1 ARG2 286714330f12Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 286814330f12Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 286914330f12Smrg# func_to_host_file_result to ARG1). 287014330f12Smrgfunc_convert_file_check () 287114330f12Smrg{ 2872eca46af7Smrg $debug_cmd 2873eca46af7Smrg 2874eca46af7Smrg if test -z "$2" && test -n "$1"; then 287514330f12Smrg func_error "Could not determine host file name corresponding to" 2876eca46af7Smrg func_error " '$1'" 287714330f12Smrg func_error "Continuing, but uninstalled executables may not work." 287814330f12Smrg # Fallback: 2879eca46af7Smrg func_to_host_file_result=$1 288014330f12Smrg fi 288114330f12Smrg} 288214330f12Smrg# end func_convert_file_check 288314330f12Smrg 288414330f12Smrg 288514330f12Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 288614330f12Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 288714330f12Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 288814330f12Smrg# func_to_host_file_result to a simplistic fallback value (see below). 288914330f12Smrgfunc_convert_path_check () 289014330f12Smrg{ 2891eca46af7Smrg $debug_cmd 2892eca46af7Smrg 289314330f12Smrg if test -z "$4" && test -n "$3"; then 289414330f12Smrg func_error "Could not determine the host path corresponding to" 2895eca46af7Smrg func_error " '$3'" 289614330f12Smrg func_error "Continuing, but uninstalled executables may not work." 289714330f12Smrg # Fallback. This is a deliberately simplistic "conversion" and 289814330f12Smrg # should not be "improved". See libtool.info. 289914330f12Smrg if test "x$1" != "x$2"; then 290014330f12Smrg lt_replace_pathsep_chars="s|$1|$2|g" 290114330f12Smrg func_to_host_path_result=`echo "$3" | 290214330f12Smrg $SED -e "$lt_replace_pathsep_chars"` 290314330f12Smrg else 2904eca46af7Smrg func_to_host_path_result=$3 290514330f12Smrg fi 290614330f12Smrg fi 290714330f12Smrg} 290814330f12Smrg# end func_convert_path_check 290914330f12Smrg 291014330f12Smrg 291114330f12Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 291214330f12Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 291314330f12Smrg# and appending REPL if ORIG matches BACKPAT. 291414330f12Smrgfunc_convert_path_front_back_pathsep () 291514330f12Smrg{ 2916eca46af7Smrg $debug_cmd 2917eca46af7Smrg 291814330f12Smrg case $4 in 2919eca46af7Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 292014330f12Smrg ;; 292114330f12Smrg esac 292214330f12Smrg case $4 in 292314330f12Smrg $2 ) func_append func_to_host_path_result "$3" 292414330f12Smrg ;; 292514330f12Smrg esac 292614330f12Smrg} 292714330f12Smrg# end func_convert_path_front_back_pathsep 292814330f12Smrg 292914330f12Smrg 293014330f12Smrg################################################## 293114330f12Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 293214330f12Smrg################################################## 2933eca46af7Smrg# invoked via '$to_host_file_cmd ARG' 293414330f12Smrg# 293514330f12Smrg# In each case, ARG is the path to be converted from $build to $host format. 293614330f12Smrg# Result will be available in $func_to_host_file_result. 293714330f12Smrg 293814330f12Smrg 293914330f12Smrg# func_to_host_file ARG 294014330f12Smrg# Converts the file name ARG from $build format to $host format. Return result 294114330f12Smrg# in func_to_host_file_result. 294214330f12Smrgfunc_to_host_file () 294314330f12Smrg{ 2944eca46af7Smrg $debug_cmd 2945eca46af7Smrg 294614330f12Smrg $to_host_file_cmd "$1" 294714330f12Smrg} 294814330f12Smrg# end func_to_host_file 294914330f12Smrg 295014330f12Smrg 295114330f12Smrg# func_to_tool_file ARG LAZY 295214330f12Smrg# converts the file name ARG from $build format to toolchain format. Return 295314330f12Smrg# result in func_to_tool_file_result. If the conversion in use is listed 295414330f12Smrg# in (the comma separated) LAZY, no conversion takes place. 295514330f12Smrgfunc_to_tool_file () 295614330f12Smrg{ 2957eca46af7Smrg $debug_cmd 2958eca46af7Smrg 295914330f12Smrg case ,$2, in 296014330f12Smrg *,"$to_tool_file_cmd",*) 296114330f12Smrg func_to_tool_file_result=$1 296214330f12Smrg ;; 296314330f12Smrg *) 296414330f12Smrg $to_tool_file_cmd "$1" 296514330f12Smrg func_to_tool_file_result=$func_to_host_file_result 296614330f12Smrg ;; 296714330f12Smrg esac 296814330f12Smrg} 296914330f12Smrg# end func_to_tool_file 297014330f12Smrg 297114330f12Smrg 297214330f12Smrg# func_convert_file_noop ARG 297314330f12Smrg# Copy ARG to func_to_host_file_result. 297414330f12Smrgfunc_convert_file_noop () 297514330f12Smrg{ 2976eca46af7Smrg func_to_host_file_result=$1 297714330f12Smrg} 297814330f12Smrg# end func_convert_file_noop 297914330f12Smrg 298014330f12Smrg 298114330f12Smrg# func_convert_file_msys_to_w32 ARG 298214330f12Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 298314330f12Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 298414330f12Smrg# func_to_host_file_result. 298514330f12Smrgfunc_convert_file_msys_to_w32 () 298614330f12Smrg{ 2987eca46af7Smrg $debug_cmd 2988eca46af7Smrg 2989eca46af7Smrg func_to_host_file_result=$1 299014330f12Smrg if test -n "$1"; then 299114330f12Smrg func_convert_core_msys_to_w32 "$1" 2992eca46af7Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 299314330f12Smrg fi 299414330f12Smrg func_convert_file_check "$1" "$func_to_host_file_result" 299514330f12Smrg} 299614330f12Smrg# end func_convert_file_msys_to_w32 299714330f12Smrg 299814330f12Smrg 299914330f12Smrg# func_convert_file_cygwin_to_w32 ARG 300014330f12Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 300114330f12Smrg# func_to_host_file_result. 300214330f12Smrgfunc_convert_file_cygwin_to_w32 () 300314330f12Smrg{ 3004eca46af7Smrg $debug_cmd 3005eca46af7Smrg 3006eca46af7Smrg func_to_host_file_result=$1 300714330f12Smrg if test -n "$1"; then 300814330f12Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 300914330f12Smrg # LT_CYGPATH in this case. 301014330f12Smrg func_to_host_file_result=`cygpath -m "$1"` 301114330f12Smrg fi 301214330f12Smrg func_convert_file_check "$1" "$func_to_host_file_result" 301314330f12Smrg} 301414330f12Smrg# end func_convert_file_cygwin_to_w32 301514330f12Smrg 301614330f12Smrg 301714330f12Smrg# func_convert_file_nix_to_w32 ARG 301814330f12Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 301914330f12Smrg# and a working winepath. Returns result in func_to_host_file_result. 302014330f12Smrgfunc_convert_file_nix_to_w32 () 302114330f12Smrg{ 3022eca46af7Smrg $debug_cmd 3023eca46af7Smrg 3024eca46af7Smrg func_to_host_file_result=$1 302514330f12Smrg if test -n "$1"; then 302614330f12Smrg func_convert_core_file_wine_to_w32 "$1" 3027eca46af7Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 302814330f12Smrg fi 302914330f12Smrg func_convert_file_check "$1" "$func_to_host_file_result" 303014330f12Smrg} 303114330f12Smrg# end func_convert_file_nix_to_w32 303214330f12Smrg 303314330f12Smrg 303414330f12Smrg# func_convert_file_msys_to_cygwin ARG 303514330f12Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 303614330f12Smrg# Returns result in func_to_host_file_result. 303714330f12Smrgfunc_convert_file_msys_to_cygwin () 303814330f12Smrg{ 3039eca46af7Smrg $debug_cmd 3040eca46af7Smrg 3041eca46af7Smrg func_to_host_file_result=$1 304214330f12Smrg if test -n "$1"; then 304314330f12Smrg func_convert_core_msys_to_w32 "$1" 304414330f12Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3045eca46af7Smrg func_to_host_file_result=$func_cygpath_result 304614330f12Smrg fi 304714330f12Smrg func_convert_file_check "$1" "$func_to_host_file_result" 304814330f12Smrg} 304914330f12Smrg# end func_convert_file_msys_to_cygwin 305014330f12Smrg 305114330f12Smrg 305214330f12Smrg# func_convert_file_nix_to_cygwin ARG 305314330f12Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 305414330f12Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 305514330f12Smrg# in func_to_host_file_result. 305614330f12Smrgfunc_convert_file_nix_to_cygwin () 305714330f12Smrg{ 3058eca46af7Smrg $debug_cmd 3059eca46af7Smrg 3060eca46af7Smrg func_to_host_file_result=$1 306114330f12Smrg if test -n "$1"; then 306214330f12Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 306314330f12Smrg func_convert_core_file_wine_to_w32 "$1" 306414330f12Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3065eca46af7Smrg func_to_host_file_result=$func_cygpath_result 306614330f12Smrg fi 306714330f12Smrg func_convert_file_check "$1" "$func_to_host_file_result" 306814330f12Smrg} 306914330f12Smrg# end func_convert_file_nix_to_cygwin 307014330f12Smrg 307114330f12Smrg 307214330f12Smrg############################################# 307314330f12Smrg# $build to $host PATH CONVERSION FUNCTIONS # 307414330f12Smrg############################################# 3075eca46af7Smrg# invoked via '$to_host_path_cmd ARG' 307614330f12Smrg# 307714330f12Smrg# In each case, ARG is the path to be converted from $build to $host format. 307814330f12Smrg# The result will be available in $func_to_host_path_result. 307914330f12Smrg# 308014330f12Smrg# Path separators are also converted from $build format to $host format. If 308114330f12Smrg# ARG begins or ends with a path separator character, it is preserved (but 308214330f12Smrg# converted to $host format) on output. 308314330f12Smrg# 308414330f12Smrg# All path conversion functions are named using the following convention: 308514330f12Smrg# file name conversion function : func_convert_file_X_to_Y () 308614330f12Smrg# path conversion function : func_convert_path_X_to_Y () 308714330f12Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 308814330f12Smrg# same. If conversion functions are added for new $build/$host combinations, 308914330f12Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 309014330f12Smrg# will break. 309114330f12Smrg 309214330f12Smrg 309314330f12Smrg# func_init_to_host_path_cmd 309414330f12Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 309514330f12Smrg# appropriate value, based on the value of $to_host_file_cmd. 309614330f12Smrgto_host_path_cmd= 309714330f12Smrgfunc_init_to_host_path_cmd () 309814330f12Smrg{ 3099eca46af7Smrg $debug_cmd 3100eca46af7Smrg 310114330f12Smrg if test -z "$to_host_path_cmd"; then 310214330f12Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3103eca46af7Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 310414330f12Smrg fi 310514330f12Smrg} 310614330f12Smrg 310714330f12Smrg 310814330f12Smrg# func_to_host_path ARG 310914330f12Smrg# Converts the path ARG from $build format to $host format. Return result 311014330f12Smrg# in func_to_host_path_result. 311114330f12Smrgfunc_to_host_path () 311214330f12Smrg{ 3113eca46af7Smrg $debug_cmd 3114eca46af7Smrg 311514330f12Smrg func_init_to_host_path_cmd 311614330f12Smrg $to_host_path_cmd "$1" 311714330f12Smrg} 311814330f12Smrg# end func_to_host_path 311914330f12Smrg 312014330f12Smrg 312114330f12Smrg# func_convert_path_noop ARG 312214330f12Smrg# Copy ARG to func_to_host_path_result. 312314330f12Smrgfunc_convert_path_noop () 312414330f12Smrg{ 3125eca46af7Smrg func_to_host_path_result=$1 312614330f12Smrg} 312714330f12Smrg# end func_convert_path_noop 312814330f12Smrg 312914330f12Smrg 313014330f12Smrg# func_convert_path_msys_to_w32 ARG 313114330f12Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 313214330f12Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 313314330f12Smrg# func_to_host_path_result. 313414330f12Smrgfunc_convert_path_msys_to_w32 () 313514330f12Smrg{ 3136eca46af7Smrg $debug_cmd 3137eca46af7Smrg 3138eca46af7Smrg func_to_host_path_result=$1 313914330f12Smrg if test -n "$1"; then 314014330f12Smrg # Remove leading and trailing path separator characters from ARG. MSYS 314114330f12Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 314214330f12Smrg # and winepath ignores them completely. 314314330f12Smrg func_stripname : : "$1" 314414330f12Smrg func_to_host_path_tmp1=$func_stripname_result 314514330f12Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3146eca46af7Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 314714330f12Smrg func_convert_path_check : ";" \ 314814330f12Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 314914330f12Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 315014330f12Smrg fi 315114330f12Smrg} 315214330f12Smrg# end func_convert_path_msys_to_w32 315314330f12Smrg 315414330f12Smrg 315514330f12Smrg# func_convert_path_cygwin_to_w32 ARG 315614330f12Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 315714330f12Smrg# func_to_host_file_result. 315814330f12Smrgfunc_convert_path_cygwin_to_w32 () 315914330f12Smrg{ 3160eca46af7Smrg $debug_cmd 3161eca46af7Smrg 3162eca46af7Smrg func_to_host_path_result=$1 316314330f12Smrg if test -n "$1"; then 316414330f12Smrg # See func_convert_path_msys_to_w32: 316514330f12Smrg func_stripname : : "$1" 316614330f12Smrg func_to_host_path_tmp1=$func_stripname_result 316714330f12Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 316814330f12Smrg func_convert_path_check : ";" \ 316914330f12Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 317014330f12Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 317114330f12Smrg fi 317214330f12Smrg} 317314330f12Smrg# end func_convert_path_cygwin_to_w32 317414330f12Smrg 317514330f12Smrg 317614330f12Smrg# func_convert_path_nix_to_w32 ARG 317714330f12Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 317814330f12Smrg# a working winepath. Returns result in func_to_host_file_result. 317914330f12Smrgfunc_convert_path_nix_to_w32 () 318014330f12Smrg{ 3181eca46af7Smrg $debug_cmd 3182eca46af7Smrg 3183eca46af7Smrg func_to_host_path_result=$1 318414330f12Smrg if test -n "$1"; then 318514330f12Smrg # See func_convert_path_msys_to_w32: 318614330f12Smrg func_stripname : : "$1" 318714330f12Smrg func_to_host_path_tmp1=$func_stripname_result 318814330f12Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3189eca46af7Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 319014330f12Smrg func_convert_path_check : ";" \ 319114330f12Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 319214330f12Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 319314330f12Smrg fi 319414330f12Smrg} 319514330f12Smrg# end func_convert_path_nix_to_w32 319614330f12Smrg 319714330f12Smrg 319814330f12Smrg# func_convert_path_msys_to_cygwin ARG 319914330f12Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 320014330f12Smrg# Returns result in func_to_host_file_result. 320114330f12Smrgfunc_convert_path_msys_to_cygwin () 320214330f12Smrg{ 3203eca46af7Smrg $debug_cmd 3204eca46af7Smrg 3205eca46af7Smrg func_to_host_path_result=$1 320614330f12Smrg if test -n "$1"; then 320714330f12Smrg # See func_convert_path_msys_to_w32: 320814330f12Smrg func_stripname : : "$1" 320914330f12Smrg func_to_host_path_tmp1=$func_stripname_result 321014330f12Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 321114330f12Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3212eca46af7Smrg func_to_host_path_result=$func_cygpath_result 321314330f12Smrg func_convert_path_check : : \ 321414330f12Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 321514330f12Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 321614330f12Smrg fi 321714330f12Smrg} 321814330f12Smrg# end func_convert_path_msys_to_cygwin 321914330f12Smrg 322014330f12Smrg 322114330f12Smrg# func_convert_path_nix_to_cygwin ARG 322214330f12Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 322314330f12Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 322414330f12Smrg# func_to_host_file_result. 322514330f12Smrgfunc_convert_path_nix_to_cygwin () 322614330f12Smrg{ 3227eca46af7Smrg $debug_cmd 3228eca46af7Smrg 3229eca46af7Smrg func_to_host_path_result=$1 323014330f12Smrg if test -n "$1"; then 323114330f12Smrg # Remove leading and trailing path separator characters from 323214330f12Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 323314330f12Smrg # into '.;' and ';.', and winepath ignores them completely. 323414330f12Smrg func_stripname : : "$1" 323514330f12Smrg func_to_host_path_tmp1=$func_stripname_result 323614330f12Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 323714330f12Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3238eca46af7Smrg func_to_host_path_result=$func_cygpath_result 323914330f12Smrg func_convert_path_check : : \ 324014330f12Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 324114330f12Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 324214330f12Smrg fi 324314330f12Smrg} 324414330f12Smrg# end func_convert_path_nix_to_cygwin 324514330f12Smrg 324614330f12Smrg 3247eca46af7Smrg# func_dll_def_p FILE 3248eca46af7Smrg# True iff FILE is a Windows DLL '.def' file. 3249eca46af7Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3250eca46af7Smrgfunc_dll_def_p () 3251eca46af7Smrg{ 3252eca46af7Smrg $debug_cmd 3253eca46af7Smrg 3254eca46af7Smrg func_dll_def_p_tmp=`$SED -n \ 3255eca46af7Smrg -e 's/^[ ]*//' \ 3256eca46af7Smrg -e '/^\(;.*\)*$/d' \ 3257eca46af7Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3258eca46af7Smrg -e q \ 3259eca46af7Smrg "$1"` 3260eca46af7Smrg test DEF = "$func_dll_def_p_tmp" 3261eca46af7Smrg} 3262eca46af7Smrg 3263eca46af7Smrg 32642378475aSmrg# func_mode_compile arg... 32652378475aSmrgfunc_mode_compile () 32662378475aSmrg{ 3267eca46af7Smrg $debug_cmd 3268eca46af7Smrg 32692378475aSmrg # Get the compilation command and the source file. 32702378475aSmrg base_compile= 3271eca46af7Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 32722378475aSmrg suppress_opt=yes 32732378475aSmrg suppress_output= 32742378475aSmrg arg_mode=normal 32752378475aSmrg libobj= 32762378475aSmrg later= 32772378475aSmrg pie_flag= 32782378475aSmrg 32792378475aSmrg for arg 32802378475aSmrg do 32812378475aSmrg case $arg_mode in 32822378475aSmrg arg ) 32832378475aSmrg # do not "continue". Instead, add this to base_compile 3284eca46af7Smrg lastarg=$arg 32852378475aSmrg arg_mode=normal 32862378475aSmrg ;; 32872378475aSmrg 32882378475aSmrg target ) 3289eca46af7Smrg libobj=$arg 32902378475aSmrg arg_mode=normal 32912378475aSmrg continue 32922378475aSmrg ;; 32932378475aSmrg 32942378475aSmrg normal ) 32952378475aSmrg # Accept any command-line options. 32962378475aSmrg case $arg in 32972378475aSmrg -o) 32982378475aSmrg test -n "$libobj" && \ 3299eca46af7Smrg func_fatal_error "you cannot specify '-o' more than once" 33002378475aSmrg arg_mode=target 33012378475aSmrg continue 33022378475aSmrg ;; 33032378475aSmrg 33042378475aSmrg -pie | -fpie | -fPIE) 330514330f12Smrg func_append pie_flag " $arg" 33062378475aSmrg continue 33072378475aSmrg ;; 33082378475aSmrg 33092378475aSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 331014330f12Smrg func_append later " $arg" 33112378475aSmrg continue 33122378475aSmrg ;; 33132378475aSmrg 33142378475aSmrg -no-suppress) 331595b296d0Smrg suppress_opt=no 331695b296d0Smrg continue 331795b296d0Smrg ;; 331895b296d0Smrg 331995b296d0Smrg -Xcompiler) 332095b296d0Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 332195b296d0Smrg continue # The current "srcfile" will either be retained or 332295b296d0Smrg ;; # replaced later. I would guess that would be a bug. 332395b296d0Smrg 332495b296d0Smrg -Wc,*) 33252378475aSmrg func_stripname '-Wc,' '' "$arg" 33262378475aSmrg args=$func_stripname_result 332795b296d0Smrg lastarg= 3328eca46af7Smrg save_ifs=$IFS; IFS=, 33292378475aSmrg for arg in $args; do 3330eca46af7Smrg IFS=$save_ifs 333114330f12Smrg func_append_quoted lastarg "$arg" 333295b296d0Smrg done 3333eca46af7Smrg IFS=$save_ifs 33342378475aSmrg func_stripname ' ' '' "$lastarg" 33352378475aSmrg lastarg=$func_stripname_result 333695b296d0Smrg 333795b296d0Smrg # Add the arguments to base_compile. 333814330f12Smrg func_append base_compile " $lastarg" 333995b296d0Smrg continue 334095b296d0Smrg ;; 334195b296d0Smrg 33422378475aSmrg *) 334395b296d0Smrg # Accept the current argument as the source file. 334495b296d0Smrg # The previous "srcfile" becomes the current argument. 334595b296d0Smrg # 3346eca46af7Smrg lastarg=$srcfile 3347eca46af7Smrg srcfile=$arg 334895b296d0Smrg ;; 334995b296d0Smrg esac # case $arg 335095b296d0Smrg ;; 335195b296d0Smrg esac # case $arg_mode 335295b296d0Smrg 335395b296d0Smrg # Aesthetically quote the previous argument. 335414330f12Smrg func_append_quoted base_compile "$lastarg" 335595b296d0Smrg done # for arg 335695b296d0Smrg 335795b296d0Smrg case $arg_mode in 335895b296d0Smrg arg) 33592378475aSmrg func_fatal_error "you must specify an argument for -Xcompile" 336095b296d0Smrg ;; 336195b296d0Smrg target) 3362eca46af7Smrg func_fatal_error "you must specify a target with '-o'" 336395b296d0Smrg ;; 336495b296d0Smrg *) 336595b296d0Smrg # Get the name of the library object. 33662378475aSmrg test -z "$libobj" && { 33672378475aSmrg func_basename "$srcfile" 3368eca46af7Smrg libobj=$func_basename_result 33692378475aSmrg } 337095b296d0Smrg ;; 337195b296d0Smrg esac 337295b296d0Smrg 337395b296d0Smrg # Recognize several different file suffixes. 337495b296d0Smrg # If the user specifies -o file.o, it is replaced with file.lo 337595b296d0Smrg case $libobj in 33762378475aSmrg *.[cCFSifmso] | \ 33772378475aSmrg *.ada | *.adb | *.ads | *.asm | \ 33782378475aSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3379eca46af7Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 33802378475aSmrg func_xform "$libobj" 33812378475aSmrg libobj=$func_xform_result 33822378475aSmrg ;; 338395b296d0Smrg esac 338495b296d0Smrg 338595b296d0Smrg case $libobj in 33862378475aSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 338795b296d0Smrg *) 3388eca46af7Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 338995b296d0Smrg ;; 339095b296d0Smrg esac 339195b296d0Smrg 339295b296d0Smrg func_infer_tag $base_compile 339395b296d0Smrg 339495b296d0Smrg for arg in $later; do 339595b296d0Smrg case $arg in 33962378475aSmrg -shared) 3397eca46af7Smrg test yes = "$build_libtool_libs" \ 3398eca46af7Smrg || func_fatal_configuration "cannot build a shared library" 33992378475aSmrg build_old_libs=no 34002378475aSmrg continue 34012378475aSmrg ;; 34022378475aSmrg 340395b296d0Smrg -static) 34042378475aSmrg build_libtool_libs=no 340595b296d0Smrg build_old_libs=yes 340695b296d0Smrg continue 340795b296d0Smrg ;; 340895b296d0Smrg 340995b296d0Smrg -prefer-pic) 341095b296d0Smrg pic_mode=yes 341195b296d0Smrg continue 341295b296d0Smrg ;; 341395b296d0Smrg 341495b296d0Smrg -prefer-non-pic) 341595b296d0Smrg pic_mode=no 341695b296d0Smrg continue 341795b296d0Smrg ;; 341895b296d0Smrg esac 341995b296d0Smrg done 342095b296d0Smrg 34212378475aSmrg func_quote_for_eval "$libobj" 34222378475aSmrg test "X$libobj" != "X$func_quote_for_eval_result" \ 34232378475aSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3424eca46af7Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 34252378475aSmrg func_dirname_and_basename "$obj" "/" "" 3426eca46af7Smrg objname=$func_basename_result 3427eca46af7Smrg xdir=$func_dirname_result 3428eca46af7Smrg lobj=$xdir$objdir/$objname 342995b296d0Smrg 34302378475aSmrg test -z "$base_compile" && \ 34312378475aSmrg func_fatal_help "you must specify a compilation command" 343295b296d0Smrg 343395b296d0Smrg # Delete any leftover library objects. 3434eca46af7Smrg if test yes = "$build_old_libs"; then 343595b296d0Smrg removelist="$obj $lobj $libobj ${libobj}T" 343695b296d0Smrg else 343795b296d0Smrg removelist="$lobj $libobj ${libobj}T" 343895b296d0Smrg fi 343995b296d0Smrg 344095b296d0Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 344195b296d0Smrg case $host_os in 34422378475aSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 344395b296d0Smrg pic_mode=default 344495b296d0Smrg ;; 344595b296d0Smrg esac 3446eca46af7Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 344795b296d0Smrg # non-PIC code in shared libraries is not supported 344895b296d0Smrg pic_mode=default 344995b296d0Smrg fi 345095b296d0Smrg 345195b296d0Smrg # Calculate the filename of the output object if compiler does 345295b296d0Smrg # not support -o with -c 3453eca46af7Smrg if test no = "$compiler_c_o"; then 3454eca46af7Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3455eca46af7Smrg lockfile=$output_obj.lock 345695b296d0Smrg else 345795b296d0Smrg output_obj= 345895b296d0Smrg need_locks=no 345995b296d0Smrg lockfile= 346095b296d0Smrg fi 346195b296d0Smrg 346295b296d0Smrg # Lock this critical section if it is needed 346395b296d0Smrg # We use this script file to make the link, it avoids creating a new file 3464eca46af7Smrg if test yes = "$need_locks"; then 34652378475aSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 34662378475aSmrg func_echo "Waiting for $lockfile to be removed" 346795b296d0Smrg sleep 2 346895b296d0Smrg done 3469eca46af7Smrg elif test warn = "$need_locks"; then 347095b296d0Smrg if test -f "$lockfile"; then 34712378475aSmrg $ECHO "\ 347295b296d0Smrg*** ERROR, $lockfile exists and contains: 347395b296d0Smrg`cat $lockfile 2>/dev/null` 347495b296d0Smrg 347595b296d0SmrgThis indicates that another process is trying to use the same 347695b296d0Smrgtemporary object file, and libtool could not work around it because 3477eca46af7Smrgyour compiler does not support '-c' and '-o' together. If you 347895b296d0Smrgrepeat this compilation, it may succeed, by chance, but you had better 347995b296d0Smrgavoid parallel builds (make -j) in this platform, or get a better 348095b296d0Smrgcompiler." 348195b296d0Smrg 34822378475aSmrg $opt_dry_run || $RM $removelist 348395b296d0Smrg exit $EXIT_FAILURE 348495b296d0Smrg fi 348514330f12Smrg func_append removelist " $output_obj" 34862378475aSmrg $ECHO "$srcfile" > "$lockfile" 348795b296d0Smrg fi 348895b296d0Smrg 34892378475aSmrg $opt_dry_run || $RM $removelist 349014330f12Smrg func_append removelist " $lockfile" 34912378475aSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 34922378475aSmrg 349314330f12Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 349414330f12Smrg srcfile=$func_to_tool_file_result 34952378475aSmrg func_quote_for_eval "$srcfile" 34962378475aSmrg qsrcfile=$func_quote_for_eval_result 349795b296d0Smrg 349895b296d0Smrg # Only build a PIC object if we are building libtool libraries. 3499eca46af7Smrg if test yes = "$build_libtool_libs"; then 350095b296d0Smrg # Without this assignment, base_compile gets emptied. 350195b296d0Smrg fbsd_hideous_sh_bug=$base_compile 350295b296d0Smrg 3503eca46af7Smrg if test no != "$pic_mode"; then 350495b296d0Smrg command="$base_compile $qsrcfile $pic_flag" 350595b296d0Smrg else 350695b296d0Smrg # Don't build PIC code 350795b296d0Smrg command="$base_compile $qsrcfile" 350895b296d0Smrg fi 350995b296d0Smrg 35102378475aSmrg func_mkdir_p "$xdir$objdir" 351195b296d0Smrg 351295b296d0Smrg if test -z "$output_obj"; then 351395b296d0Smrg # Place PIC objects in $objdir 351414330f12Smrg func_append command " -o $lobj" 351595b296d0Smrg fi 351695b296d0Smrg 35172378475aSmrg func_show_eval_locale "$command" \ 35182378475aSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 351995b296d0Smrg 3520eca46af7Smrg if test warn = "$need_locks" && 352195b296d0Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 35222378475aSmrg $ECHO "\ 352395b296d0Smrg*** ERROR, $lockfile contains: 352495b296d0Smrg`cat $lockfile 2>/dev/null` 352595b296d0Smrg 352695b296d0Smrgbut it should contain: 352795b296d0Smrg$srcfile 352895b296d0Smrg 352995b296d0SmrgThis indicates that another process is trying to use the same 353095b296d0Smrgtemporary object file, and libtool could not work around it because 3531eca46af7Smrgyour compiler does not support '-c' and '-o' together. If you 353295b296d0Smrgrepeat this compilation, it may succeed, by chance, but you had better 353395b296d0Smrgavoid parallel builds (make -j) in this platform, or get a better 353495b296d0Smrgcompiler." 353595b296d0Smrg 35362378475aSmrg $opt_dry_run || $RM $removelist 353795b296d0Smrg exit $EXIT_FAILURE 353895b296d0Smrg fi 353995b296d0Smrg 354095b296d0Smrg # Just move the object if needed, then go on to compile the next one 354195b296d0Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 35422378475aSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 35432378475aSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 354495b296d0Smrg fi 354595b296d0Smrg 354695b296d0Smrg # Allow error messages only from the first compilation. 3547eca46af7Smrg if test yes = "$suppress_opt"; then 35482378475aSmrg suppress_output=' >/dev/null 2>&1' 354995b296d0Smrg fi 355095b296d0Smrg fi 355195b296d0Smrg 355295b296d0Smrg # Only build a position-dependent object if we build old libraries. 3553eca46af7Smrg if test yes = "$build_old_libs"; then 3554eca46af7Smrg if test yes != "$pic_mode"; then 355595b296d0Smrg # Don't build PIC code 35562378475aSmrg command="$base_compile $qsrcfile$pie_flag" 355795b296d0Smrg else 355895b296d0Smrg command="$base_compile $qsrcfile $pic_flag" 355995b296d0Smrg fi 3560eca46af7Smrg if test yes = "$compiler_c_o"; then 356114330f12Smrg func_append command " -o $obj" 356295b296d0Smrg fi 356395b296d0Smrg 356495b296d0Smrg # Suppress compiler output if we already did a PIC compilation. 356514330f12Smrg func_append command "$suppress_output" 35662378475aSmrg func_show_eval_locale "$command" \ 35672378475aSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 356895b296d0Smrg 3569eca46af7Smrg if test warn = "$need_locks" && 357095b296d0Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 35712378475aSmrg $ECHO "\ 357295b296d0Smrg*** ERROR, $lockfile contains: 357395b296d0Smrg`cat $lockfile 2>/dev/null` 357495b296d0Smrg 357595b296d0Smrgbut it should contain: 357695b296d0Smrg$srcfile 357795b296d0Smrg 357895b296d0SmrgThis indicates that another process is trying to use the same 357995b296d0Smrgtemporary object file, and libtool could not work around it because 3580eca46af7Smrgyour compiler does not support '-c' and '-o' together. If you 358195b296d0Smrgrepeat this compilation, it may succeed, by chance, but you had better 358295b296d0Smrgavoid parallel builds (make -j) in this platform, or get a better 358395b296d0Smrgcompiler." 358495b296d0Smrg 35852378475aSmrg $opt_dry_run || $RM $removelist 358695b296d0Smrg exit $EXIT_FAILURE 358795b296d0Smrg fi 358895b296d0Smrg 358995b296d0Smrg # Just move the object if needed 359095b296d0Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 35912378475aSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 35922378475aSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 359395b296d0Smrg fi 359495b296d0Smrg fi 359595b296d0Smrg 35962378475aSmrg $opt_dry_run || { 35972378475aSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 359895b296d0Smrg 35992378475aSmrg # Unlock the critical section if it was locked 3600eca46af7Smrg if test no != "$need_locks"; then 36012378475aSmrg removelist=$lockfile 36022378475aSmrg $RM "$lockfile" 36032378475aSmrg fi 36042378475aSmrg } 360595b296d0Smrg 360695b296d0Smrg exit $EXIT_SUCCESS 36072378475aSmrg} 360895b296d0Smrg 36092378475aSmrg$opt_help || { 3610eca46af7Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 36112378475aSmrg} 361295b296d0Smrg 36132378475aSmrgfunc_mode_help () 36142378475aSmrg{ 36152378475aSmrg # We need to display help for each of the modes. 361614330f12Smrg case $opt_mode in 36172378475aSmrg "") 36182378475aSmrg # Generic help is extracted from the usage comments 36192378475aSmrg # at the start of this file. 36202378475aSmrg func_help 36212378475aSmrg ;; 362295b296d0Smrg 36232378475aSmrg clean) 36242378475aSmrg $ECHO \ 36252378475aSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 362695b296d0Smrg 36272378475aSmrgRemove files from the build directory. 362895b296d0Smrg 36292378475aSmrgRM is the name of the program to use to delete files associated with each FILE 3630eca46af7Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 36312378475aSmrgto RM. 363295b296d0Smrg 36332378475aSmrgIf FILE is a libtool library, object or program, all the files associated 36342378475aSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 36352378475aSmrg ;; 363695b296d0Smrg 36372378475aSmrg compile) 36382378475aSmrg $ECHO \ 36392378475aSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 364095b296d0Smrg 36412378475aSmrgCompile a source file into a libtool library object. 364295b296d0Smrg 36432378475aSmrgThis mode accepts the following additional options: 364495b296d0Smrg 36452378475aSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 36462378475aSmrg -no-suppress do not suppress compiler output for multiple passes 364714330f12Smrg -prefer-pic try to build PIC objects only 364814330f12Smrg -prefer-non-pic try to build non-PIC objects only 3649eca46af7Smrg -shared do not build a '.o' file suitable for static linking 3650eca46af7Smrg -static only build a '.o' file suitable for static linking 365114330f12Smrg -Wc,FLAG pass FLAG directly to the compiler 365295b296d0Smrg 3653eca46af7SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 36542378475aSmrgfrom the given SOURCEFILE. 365595b296d0Smrg 36562378475aSmrgThe output file name is determined by removing the directory component from 3657eca46af7SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 3658eca46af7Smrglibrary object suffix, '.lo'." 36592378475aSmrg ;; 366095b296d0Smrg 36612378475aSmrg execute) 36622378475aSmrg $ECHO \ 36632378475aSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 366495b296d0Smrg 36652378475aSmrgAutomatically set library path, then run a program. 366695b296d0Smrg 36672378475aSmrgThis mode accepts the following additional options: 366895b296d0Smrg 36692378475aSmrg -dlopen FILE add the directory containing FILE to the library path 367095b296d0Smrg 3671eca46af7SmrgThis mode sets the library path environment variable according to '-dlopen' 36722378475aSmrgflags. 367395b296d0Smrg 36742378475aSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 36752378475aSmrginto their corresponding uninstalled binary, and any of their required library 36762378475aSmrgdirectories are added to the library path. 367795b296d0Smrg 36782378475aSmrgThen, COMMAND is executed, with ARGS as arguments." 36792378475aSmrg ;; 368095b296d0Smrg 36812378475aSmrg finish) 36822378475aSmrg $ECHO \ 36832378475aSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 368495b296d0Smrg 36852378475aSmrgComplete the installation of libtool libraries. 368695b296d0Smrg 36872378475aSmrgEach LIBDIR is a directory that contains libtool libraries. 368895b296d0Smrg 36892378475aSmrgThe commands that this mode executes may require superuser privileges. Use 3690eca46af7Smrgthe '--dry-run' option if you just want to see what would be executed." 36912378475aSmrg ;; 369295b296d0Smrg 36932378475aSmrg install) 36942378475aSmrg $ECHO \ 36952378475aSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 369695b296d0Smrg 36972378475aSmrgInstall executables or libraries. 369895b296d0Smrg 36992378475aSmrgINSTALL-COMMAND is the installation command. The first component should be 3700eca46af7Smrgeither the 'install' or 'cp' program. 370195b296d0Smrg 37022378475aSmrgThe following components of INSTALL-COMMAND are treated specially: 370395b296d0Smrg 370414330f12Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 370595b296d0Smrg 37062378475aSmrgThe rest of the components are interpreted as arguments to that command (only 37072378475aSmrgBSD-compatible install options are recognized)." 37082378475aSmrg ;; 370995b296d0Smrg 37102378475aSmrg link) 37112378475aSmrg $ECHO \ 37122378475aSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 371395b296d0Smrg 37142378475aSmrgLink object files or libraries together to form another library, or to 37152378475aSmrgcreate an executable program. 371695b296d0Smrg 37172378475aSmrgLINK-COMMAND is a command using the C compiler that you would use to create 37182378475aSmrga program from several object files. 371995b296d0Smrg 37202378475aSmrgThe following components of LINK-COMMAND are treated specially: 372195b296d0Smrg 37222378475aSmrg -all-static do not do any dynamic linking at all 37232378475aSmrg -avoid-version do not add a version suffix if possible 372414330f12Smrg -bindir BINDIR specify path to binaries directory (for systems where 372514330f12Smrg libraries must be found in the PATH setting at runtime) 3726eca46af7Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 37272378475aSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 37282378475aSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 37292378475aSmrg -export-symbols SYMFILE 37302378475aSmrg try to export only the symbols listed in SYMFILE 37312378475aSmrg -export-symbols-regex REGEX 37322378475aSmrg try to export only the symbols matching REGEX 37332378475aSmrg -LLIBDIR search LIBDIR for required installed libraries 37342378475aSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 37352378475aSmrg -module build a library that can dlopened 37362378475aSmrg -no-fast-install disable the fast-install mode 37372378475aSmrg -no-install link a not-installable executable 37382378475aSmrg -no-undefined declare that a library does not refer to external symbols 37392378475aSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3740eca46af7Smrg -objectlist FILE use a list of object files found in FILE to specify objects 3741eca46af7Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 37422378475aSmrg -precious-files-regex REGEX 37432378475aSmrg don't remove output files matching REGEX 37442378475aSmrg -release RELEASE specify package release information 37452378475aSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 37462378475aSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 37472378475aSmrg -shared only do dynamic linking of libtool libraries 37482378475aSmrg -shrext SUFFIX override the standard shared library file extension 37492378475aSmrg -static do not do any dynamic linking of uninstalled libtool libraries 37502378475aSmrg -static-libtool-libs 37512378475aSmrg do not do any dynamic linking of libtool libraries 37522378475aSmrg -version-info CURRENT[:REVISION[:AGE]] 37532378475aSmrg specify library version info [each variable defaults to 0] 37542378475aSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 375514330f12Smrg -Wc,FLAG 375614330f12Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 375714330f12Smrg -Wl,FLAG 375814330f12Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 375914330f12Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 376095b296d0Smrg 3761eca46af7SmrgAll other options (arguments beginning with '-') are ignored. 376295b296d0Smrg 3763eca46af7SmrgEvery other argument is treated as a filename. Files ending in '.la' are 37642378475aSmrgtreated as uninstalled libtool libraries, other files are standard or library 37652378475aSmrgobject files. 376695b296d0Smrg 3767eca46af7SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 3768eca46af7Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 37692378475aSmrgrequired, except when creating a convenience library. 377095b296d0Smrg 3771eca46af7SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 3772eca46af7Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 377395b296d0Smrg 3774eca46af7SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 37752378475aSmrgis created, otherwise an executable program is created." 3776e6f085baSmrg ;; 377795b296d0Smrg 37782378475aSmrg uninstall) 37792378475aSmrg $ECHO \ 37802378475aSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 378195b296d0Smrg 37822378475aSmrgRemove libraries from an installation directory. 378395b296d0Smrg 37842378475aSmrgRM is the name of the program to use to delete files associated with each FILE 3785eca46af7Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 37862378475aSmrgto RM. 378739713583Smrg 37882378475aSmrgIf FILE is a libtool library, all the files associated with it are deleted. 37892378475aSmrgOtherwise, only FILE itself is deleted using RM." 37902378475aSmrg ;; 379139713583Smrg 37922378475aSmrg *) 3793eca46af7Smrg func_fatal_help "invalid operation mode '$opt_mode'" 37942378475aSmrg ;; 37952378475aSmrg esac 379639713583Smrg 379714330f12Smrg echo 3798eca46af7Smrg $ECHO "Try '$progname --help' for more information about other modes." 37992378475aSmrg} 380039713583Smrg 380114330f12Smrg# Now that we've collected a possible --mode arg, show help if necessary 380214330f12Smrgif $opt_help; then 3803eca46af7Smrg if test : = "$opt_help"; then 380414330f12Smrg func_mode_help 380514330f12Smrg else 380614330f12Smrg { 380714330f12Smrg func_help noexit 380814330f12Smrg for opt_mode in compile link execute install finish uninstall clean; do 380914330f12Smrg func_mode_help 381014330f12Smrg done 3811eca46af7Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 381214330f12Smrg { 381314330f12Smrg func_help noexit 381414330f12Smrg for opt_mode in compile link execute install finish uninstall clean; do 381514330f12Smrg echo 381614330f12Smrg func_mode_help 381714330f12Smrg done 381814330f12Smrg } | 3819eca46af7Smrg $SED '1d 382014330f12Smrg /^When reporting/,/^Report/{ 382114330f12Smrg H 382214330f12Smrg d 382314330f12Smrg } 382414330f12Smrg $x 382514330f12Smrg /information about other modes/d 382614330f12Smrg /more detailed .*MODE/d 382714330f12Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 382814330f12Smrg fi 382914330f12Smrg exit $? 383014330f12Smrgfi 383139713583Smrg 383239713583Smrg 38332378475aSmrg# func_mode_execute arg... 38342378475aSmrgfunc_mode_execute () 38352378475aSmrg{ 3836eca46af7Smrg $debug_cmd 3837eca46af7Smrg 38382378475aSmrg # The first argument is the command name. 3839eca46af7Smrg cmd=$nonopt 38402378475aSmrg test -z "$cmd" && \ 38412378475aSmrg func_fatal_help "you must specify a COMMAND" 3842e6f085baSmrg 38432378475aSmrg # Handle -dlopen flags immediately. 384414330f12Smrg for file in $opt_dlopen; do 38452378475aSmrg test -f "$file" \ 3846eca46af7Smrg || func_fatal_help "'$file' is not a file" 3847e6f085baSmrg 38482378475aSmrg dir= 38492378475aSmrg case $file in 38502378475aSmrg *.la) 385114330f12Smrg func_resolve_sysroot "$file" 385214330f12Smrg file=$func_resolve_sysroot_result 385314330f12Smrg 38542378475aSmrg # Check to see that this really is a libtool archive. 38552378475aSmrg func_lalib_unsafe_p "$file" \ 3856eca46af7Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 3857e6f085baSmrg 38582378475aSmrg # Read the libtool library. 38592378475aSmrg dlname= 38602378475aSmrg library_names= 38612378475aSmrg func_source "$file" 386295b296d0Smrg 38632378475aSmrg # Skip this library if it cannot be dlopened. 38642378475aSmrg if test -z "$dlname"; then 38652378475aSmrg # Warn if it was a shared library. 38662378475aSmrg test -n "$library_names" && \ 3867eca46af7Smrg func_warning "'$file' was not linked with '-export-dynamic'" 38682378475aSmrg continue 38692378475aSmrg fi 387095b296d0Smrg 38712378475aSmrg func_dirname "$file" "" "." 3872eca46af7Smrg dir=$func_dirname_result 387395b296d0Smrg 38742378475aSmrg if test -f "$dir/$objdir/$dlname"; then 387514330f12Smrg func_append dir "/$objdir" 38762378475aSmrg else 38772378475aSmrg if test ! -f "$dir/$dlname"; then 3878eca46af7Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 38792378475aSmrg fi 38802378475aSmrg fi 3881e6f085baSmrg ;; 388295b296d0Smrg 38832378475aSmrg *.lo) 38842378475aSmrg # Just add the directory containing the .lo file. 38852378475aSmrg func_dirname "$file" "" "." 3886eca46af7Smrg dir=$func_dirname_result 3887e6f085baSmrg ;; 388895b296d0Smrg 38892378475aSmrg *) 3890eca46af7Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3891e6f085baSmrg continue 3892e6f085baSmrg ;; 38932378475aSmrg esac 389495b296d0Smrg 38952378475aSmrg # Get the absolute pathname. 38962378475aSmrg absdir=`cd "$dir" && pwd` 3897eca46af7Smrg test -n "$absdir" && dir=$absdir 389839713583Smrg 38992378475aSmrg # Now add the directory to shlibpath_var. 39002378475aSmrg if eval "test -z \"\$$shlibpath_var\""; then 39012378475aSmrg eval "$shlibpath_var=\"\$dir\"" 39022378475aSmrg else 39032378475aSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 39042378475aSmrg fi 39052378475aSmrg done 390639713583Smrg 39072378475aSmrg # This variable tells wrapper scripts just to set shlibpath_var 39082378475aSmrg # rather than running their programs. 3909eca46af7Smrg libtool_execute_magic=$magic 391039713583Smrg 39112378475aSmrg # Check if any of the arguments is a wrapper script. 39122378475aSmrg args= 39132378475aSmrg for file 39142378475aSmrg do 39152378475aSmrg case $file in 391614330f12Smrg -* | *.la | *.lo ) ;; 39172378475aSmrg *) 39182378475aSmrg # Do a test to see if this is really a libtool program. 39192378475aSmrg if func_ltwrapper_script_p "$file"; then 39202378475aSmrg func_source "$file" 39212378475aSmrg # Transform arg to wrapped name. 3922eca46af7Smrg file=$progdir/$program 39232378475aSmrg elif func_ltwrapper_executable_p "$file"; then 39242378475aSmrg func_ltwrapper_scriptname "$file" 39252378475aSmrg func_source "$func_ltwrapper_scriptname_result" 39262378475aSmrg # Transform arg to wrapped name. 3927eca46af7Smrg file=$progdir/$program 39282378475aSmrg fi 39292378475aSmrg ;; 39302378475aSmrg esac 39312378475aSmrg # Quote arguments (to preserve shell metacharacters). 393214330f12Smrg func_append_quoted args "$file" 39332378475aSmrg done 393439713583Smrg 3935eca46af7Smrg if $opt_dry_run; then 3936eca46af7Smrg # Display what would be done. 3937eca46af7Smrg if test -n "$shlibpath_var"; then 3938eca46af7Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 3939eca46af7Smrg echo "export $shlibpath_var" 3940eca46af7Smrg fi 3941eca46af7Smrg $ECHO "$cmd$args" 3942eca46af7Smrg exit $EXIT_SUCCESS 3943eca46af7Smrg else 39442378475aSmrg if test -n "$shlibpath_var"; then 39452378475aSmrg # Export the shlibpath_var. 39462378475aSmrg eval "export $shlibpath_var" 39472378475aSmrg fi 394839713583Smrg 39492378475aSmrg # Restore saved environment variables 39502378475aSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 39512378475aSmrg do 39522378475aSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 39532378475aSmrg $lt_var=\$save_$lt_var; export $lt_var 3954e6f085baSmrg else 39552378475aSmrg $lt_unset $lt_var 39562378475aSmrg fi" 39572378475aSmrg done 395839713583Smrg 39592378475aSmrg # Now prepare to actually exec the command. 3960eca46af7Smrg exec_cmd=\$cmd$args 39612378475aSmrg fi 39622378475aSmrg} 396339713583Smrg 3964eca46af7Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 396514330f12Smrg 396614330f12Smrg 396714330f12Smrg# func_mode_finish arg... 396814330f12Smrgfunc_mode_finish () 396914330f12Smrg{ 3970eca46af7Smrg $debug_cmd 3971eca46af7Smrg 397214330f12Smrg libs= 397314330f12Smrg libdirs= 397414330f12Smrg admincmds= 397514330f12Smrg 397614330f12Smrg for opt in "$nonopt" ${1+"$@"} 397714330f12Smrg do 397814330f12Smrg if test -d "$opt"; then 397914330f12Smrg func_append libdirs " $opt" 398014330f12Smrg 398114330f12Smrg elif test -f "$opt"; then 398214330f12Smrg if func_lalib_unsafe_p "$opt"; then 398314330f12Smrg func_append libs " $opt" 398414330f12Smrg else 3985eca46af7Smrg func_warning "'$opt' is not a valid libtool archive" 398614330f12Smrg fi 398714330f12Smrg 398814330f12Smrg else 3989eca46af7Smrg func_fatal_error "invalid argument '$opt'" 399014330f12Smrg fi 399114330f12Smrg done 399239713583Smrg 399314330f12Smrg if test -n "$libs"; then 399414330f12Smrg if test -n "$lt_sysroot"; then 399514330f12Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 399614330f12Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 399714330f12Smrg else 399814330f12Smrg sysroot_cmd= 399914330f12Smrg fi 4000e6f085baSmrg 400114330f12Smrg # Remove sysroot references 400214330f12Smrg if $opt_dry_run; then 400314330f12Smrg for lib in $libs; do 4004eca46af7Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 400514330f12Smrg done 400614330f12Smrg else 400714330f12Smrg tmpdir=`func_mktempdir` 400814330f12Smrg for lib in $libs; do 4009eca46af7Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 401014330f12Smrg > $tmpdir/tmp-la 401114330f12Smrg mv -f $tmpdir/tmp-la $lib 401214330f12Smrg done 401314330f12Smrg ${RM}r "$tmpdir" 401414330f12Smrg fi 401514330f12Smrg fi 401695b296d0Smrg 40172378475aSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 40182378475aSmrg for libdir in $libdirs; do 40192378475aSmrg if test -n "$finish_cmds"; then 40202378475aSmrg # Do each command in the finish commands. 40212378475aSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 40222378475aSmrg'"$cmd"'"' 4023e6f085baSmrg fi 40242378475aSmrg if test -n "$finish_eval"; then 40252378475aSmrg # Do the single finish_eval. 40262378475aSmrg eval cmds=\"$finish_eval\" 402714330f12Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 40282378475aSmrg $cmds" 40292378475aSmrg fi 40302378475aSmrg done 40312378475aSmrg fi 403295b296d0Smrg 40332378475aSmrg # Exit here if they wanted silent mode. 4034eca46af7Smrg $opt_quiet && exit $EXIT_SUCCESS 403595b296d0Smrg 403614330f12Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 403714330f12Smrg echo "----------------------------------------------------------------------" 403814330f12Smrg echo "Libraries have been installed in:" 403914330f12Smrg for libdir in $libdirs; do 404014330f12Smrg $ECHO " $libdir" 404114330f12Smrg done 404214330f12Smrg echo 404314330f12Smrg echo "If you ever happen to want to link against installed libraries" 404414330f12Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4045eca46af7Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 404614330f12Smrg echo "flag during linking and do at least one of the following:" 404714330f12Smrg if test -n "$shlibpath_var"; then 4048eca46af7Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 404914330f12Smrg echo " during execution" 405014330f12Smrg fi 405114330f12Smrg if test -n "$runpath_var"; then 4052eca46af7Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 405314330f12Smrg echo " during linking" 405414330f12Smrg fi 405514330f12Smrg if test -n "$hardcode_libdir_flag_spec"; then 405614330f12Smrg libdir=LIBDIR 405714330f12Smrg eval flag=\"$hardcode_libdir_flag_spec\" 40582378475aSmrg 4059eca46af7Smrg $ECHO " - use the '$flag' linker flag" 406014330f12Smrg fi 406114330f12Smrg if test -n "$admincmds"; then 406214330f12Smrg $ECHO " - have your system administrator run these commands:$admincmds" 406314330f12Smrg fi 406414330f12Smrg if test -f /etc/ld.so.conf; then 4065eca46af7Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 406614330f12Smrg fi 406714330f12Smrg echo 40682378475aSmrg 406914330f12Smrg echo "See any operating system documentation about shared libraries for" 407014330f12Smrg case $host in 407114330f12Smrg solaris2.[6789]|solaris2.1[0-9]) 407214330f12Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 407314330f12Smrg echo "pages." 407414330f12Smrg ;; 407514330f12Smrg *) 407614330f12Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 407714330f12Smrg ;; 407814330f12Smrg esac 407914330f12Smrg echo "----------------------------------------------------------------------" 408014330f12Smrg fi 40812378475aSmrg exit $EXIT_SUCCESS 40822378475aSmrg} 40832378475aSmrg 4084eca46af7Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 40852378475aSmrg 40862378475aSmrg 40872378475aSmrg# func_mode_install arg... 40882378475aSmrgfunc_mode_install () 40892378475aSmrg{ 4090eca46af7Smrg $debug_cmd 4091eca46af7Smrg 40922378475aSmrg # There may be an optional sh(1) argument at the beginning of 40932378475aSmrg # install_prog (especially on Windows NT). 4094eca46af7Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 40952378475aSmrg # Allow the use of GNU shtool's install command. 4096eca46af7Smrg case $nonopt in *shtool*) :;; *) false;; esac 4097eca46af7Smrg then 40982378475aSmrg # Aesthetically quote it. 40992378475aSmrg func_quote_for_eval "$nonopt" 41002378475aSmrg install_prog="$func_quote_for_eval_result " 41012378475aSmrg arg=$1 41022378475aSmrg shift 41032378475aSmrg else 41042378475aSmrg install_prog= 41052378475aSmrg arg=$nonopt 41062378475aSmrg fi 41072378475aSmrg 41082378475aSmrg # The real first argument should be the name of the installation program. 41092378475aSmrg # Aesthetically quote it. 41102378475aSmrg func_quote_for_eval "$arg" 411114330f12Smrg func_append install_prog "$func_quote_for_eval_result" 411214330f12Smrg install_shared_prog=$install_prog 411314330f12Smrg case " $install_prog " in 411414330f12Smrg *[\\\ /]cp\ *) install_cp=: ;; 411514330f12Smrg *) install_cp=false ;; 411614330f12Smrg esac 41172378475aSmrg 41182378475aSmrg # We need to accept at least all the BSD install flags. 41192378475aSmrg dest= 41202378475aSmrg files= 41212378475aSmrg opts= 41222378475aSmrg prev= 41232378475aSmrg install_type= 4124eca46af7Smrg isdir=false 41252378475aSmrg stripme= 412614330f12Smrg no_mode=: 41272378475aSmrg for arg 41282378475aSmrg do 412914330f12Smrg arg2= 41302378475aSmrg if test -n "$dest"; then 413114330f12Smrg func_append files " $dest" 41322378475aSmrg dest=$arg 41332378475aSmrg continue 41342378475aSmrg fi 41352378475aSmrg 41362378475aSmrg case $arg in 4137eca46af7Smrg -d) isdir=: ;; 41382378475aSmrg -f) 413914330f12Smrg if $install_cp; then :; else 414014330f12Smrg prev=$arg 414114330f12Smrg fi 41422378475aSmrg ;; 41432378475aSmrg -g | -m | -o) 41442378475aSmrg prev=$arg 41452378475aSmrg ;; 41462378475aSmrg -s) 41472378475aSmrg stripme=" -s" 41482378475aSmrg continue 41492378475aSmrg ;; 41502378475aSmrg -*) 41512378475aSmrg ;; 41522378475aSmrg *) 41532378475aSmrg # If the previous option needed an argument, then skip it. 41542378475aSmrg if test -n "$prev"; then 4155eca46af7Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 415614330f12Smrg arg2=$install_override_mode 415714330f12Smrg no_mode=false 415814330f12Smrg fi 4159e6f085baSmrg prev= 416039713583Smrg else 41612378475aSmrg dest=$arg 41622378475aSmrg continue 416395b296d0Smrg fi 4164e6f085baSmrg ;; 41652378475aSmrg esac 416695b296d0Smrg 41672378475aSmrg # Aesthetically quote the argument. 41682378475aSmrg func_quote_for_eval "$arg" 416914330f12Smrg func_append install_prog " $func_quote_for_eval_result" 417014330f12Smrg if test -n "$arg2"; then 417114330f12Smrg func_quote_for_eval "$arg2" 417214330f12Smrg fi 417314330f12Smrg func_append install_shared_prog " $func_quote_for_eval_result" 41742378475aSmrg done 417595b296d0Smrg 41762378475aSmrg test -z "$install_prog" && \ 41772378475aSmrg func_fatal_help "you must specify an install program" 417895b296d0Smrg 41792378475aSmrg test -n "$prev" && \ 4180eca46af7Smrg func_fatal_help "the '$prev' option requires an argument" 418139713583Smrg 418214330f12Smrg if test -n "$install_override_mode" && $no_mode; then 418314330f12Smrg if $install_cp; then :; else 418414330f12Smrg func_quote_for_eval "$install_override_mode" 418514330f12Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 418614330f12Smrg fi 418714330f12Smrg fi 418814330f12Smrg 41892378475aSmrg if test -z "$files"; then 41902378475aSmrg if test -z "$dest"; then 41912378475aSmrg func_fatal_help "no file or destination specified" 41922378475aSmrg else 41932378475aSmrg func_fatal_help "you must specify a destination" 41942378475aSmrg fi 4195e6f085baSmrg fi 419639713583Smrg 41972378475aSmrg # Strip any trailing slash from the destination. 41982378475aSmrg func_stripname '' '/' "$dest" 41992378475aSmrg dest=$func_stripname_result 420039713583Smrg 42012378475aSmrg # Check to see that the destination is a directory. 4202eca46af7Smrg test -d "$dest" && isdir=: 4203eca46af7Smrg if $isdir; then 4204eca46af7Smrg destdir=$dest 42052378475aSmrg destname= 4206e6f085baSmrg else 42072378475aSmrg func_dirname_and_basename "$dest" "" "." 4208eca46af7Smrg destdir=$func_dirname_result 4209eca46af7Smrg destname=$func_basename_result 421039713583Smrg 42112378475aSmrg # Not a directory, so check to see that there is only one file specified. 42122378475aSmrg set dummy $files; shift 42132378475aSmrg test "$#" -gt 1 && \ 4214eca46af7Smrg func_fatal_help "'$dest' is not a directory" 421539713583Smrg fi 42162378475aSmrg case $destdir in 42172378475aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4218e6f085baSmrg *) 42192378475aSmrg for file in $files; do 42202378475aSmrg case $file in 42212378475aSmrg *.lo) ;; 42222378475aSmrg *) 4223eca46af7Smrg func_fatal_help "'$destdir' must be an absolute directory name" 42242378475aSmrg ;; 42252378475aSmrg esac 42262378475aSmrg done 4227e6f085baSmrg ;; 4228e6f085baSmrg esac 422995b296d0Smrg 42302378475aSmrg # This variable tells wrapper scripts just to set variables rather 42312378475aSmrg # than running their programs. 4232eca46af7Smrg libtool_install_magic=$magic 423395b296d0Smrg 42342378475aSmrg staticlibs= 42352378475aSmrg future_libdirs= 42362378475aSmrg current_libdirs= 42372378475aSmrg for file in $files; do 423895b296d0Smrg 42392378475aSmrg # Do each installation. 42402378475aSmrg case $file in 42412378475aSmrg *.$libext) 42422378475aSmrg # Do the static libraries later. 424314330f12Smrg func_append staticlibs " $file" 42442378475aSmrg ;; 42452378475aSmrg 42462378475aSmrg *.la) 424714330f12Smrg func_resolve_sysroot "$file" 424814330f12Smrg file=$func_resolve_sysroot_result 424914330f12Smrg 42502378475aSmrg # Check to see that this really is a libtool archive. 42512378475aSmrg func_lalib_unsafe_p "$file" \ 4252eca46af7Smrg || func_fatal_help "'$file' is not a valid libtool archive" 42532378475aSmrg 42542378475aSmrg library_names= 42552378475aSmrg old_library= 42562378475aSmrg relink_command= 42572378475aSmrg func_source "$file" 42582378475aSmrg 42592378475aSmrg # Add the libdir to current_libdirs if it is the destination. 42602378475aSmrg if test "X$destdir" = "X$libdir"; then 42612378475aSmrg case "$current_libdirs " in 42622378475aSmrg *" $libdir "*) ;; 426314330f12Smrg *) func_append current_libdirs " $libdir" ;; 426439713583Smrg esac 42652378475aSmrg else 42662378475aSmrg # Note the libdir as a future libdir. 42672378475aSmrg case "$future_libdirs " in 42682378475aSmrg *" $libdir "*) ;; 426914330f12Smrg *) func_append future_libdirs " $libdir" ;; 42702378475aSmrg esac 42712378475aSmrg fi 427239713583Smrg 42732378475aSmrg func_dirname "$file" "/" "" 4274eca46af7Smrg dir=$func_dirname_result 427514330f12Smrg func_append dir "$objdir" 42762378475aSmrg 42772378475aSmrg if test -n "$relink_command"; then 42782378475aSmrg # Determine the prefix the user has applied to our future dir. 427914330f12Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 42802378475aSmrg 42812378475aSmrg # Don't allow the user to place us outside of our expected 42822378475aSmrg # location b/c this prevents finding dependent libraries that 42832378475aSmrg # are installed to the same prefix. 42842378475aSmrg # At present, this check doesn't affect windows .dll's that 42852378475aSmrg # are installed into $libdir/../bin (currently, that works fine) 42862378475aSmrg # but it's something to keep an eye on. 42872378475aSmrg test "$inst_prefix_dir" = "$destdir" && \ 4288eca46af7Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 42892378475aSmrg 42902378475aSmrg if test -n "$inst_prefix_dir"; then 42912378475aSmrg # Stick the inst_prefix_dir data into the link command. 429214330f12Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 42932378475aSmrg else 429414330f12Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 42952378475aSmrg fi 42962378475aSmrg 4297eca46af7Smrg func_warning "relinking '$file'" 42982378475aSmrg func_show_eval "$relink_command" \ 4299eca46af7Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 43002378475aSmrg fi 43012378475aSmrg 43022378475aSmrg # See the names of the shared library. 43032378475aSmrg set dummy $library_names; shift 43042378475aSmrg if test -n "$1"; then 4305eca46af7Smrg realname=$1 43062378475aSmrg shift 43072378475aSmrg 4308eca46af7Smrg srcname=$realname 4309eca46af7Smrg test -n "$relink_command" && srcname=${realname}T 43102378475aSmrg 43112378475aSmrg # Install the shared library and build the symlinks. 431214330f12Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 43132378475aSmrg 'exit $?' 4314eca46af7Smrg tstripme=$stripme 43152378475aSmrg case $host_os in 43162378475aSmrg cygwin* | mingw* | pw32* | cegcc*) 43172378475aSmrg case $realname in 43182378475aSmrg *.dll.a) 4319eca46af7Smrg tstripme= 4320eca46af7Smrg ;; 4321eca46af7Smrg esac 4322eca46af7Smrg ;; 4323eca46af7Smrg os2*) 4324eca46af7Smrg case $realname in 4325eca46af7Smrg *_dll.a) 4326eca46af7Smrg tstripme= 43272378475aSmrg ;; 43282378475aSmrg esac 432939713583Smrg ;; 433039713583Smrg esac 43312378475aSmrg if test -n "$tstripme" && test -n "$striplib"; then 43322378475aSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333e6f085baSmrg fi 43342378475aSmrg 43352378475aSmrg if test "$#" -gt 0; then 43362378475aSmrg # Delete the old symlinks, and create new ones. 4337eca46af7Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 43382378475aSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 43392378475aSmrg # so we also need to try rm && ln -s. 43402378475aSmrg for linkname 43412378475aSmrg do 43422378475aSmrg test "$linkname" != "$realname" \ 43432378475aSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344e6f085baSmrg done 4345e6f085baSmrg fi 434695b296d0Smrg 43472378475aSmrg # Do each command in the postinstall commands. 4348eca46af7Smrg lib=$destdir/$realname 43492378475aSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4350e6f085baSmrg fi 435195b296d0Smrg 43522378475aSmrg # Install the pseudo-library for information purposes. 43532378475aSmrg func_basename "$file" 4354eca46af7Smrg name=$func_basename_result 4355eca46af7Smrg instname=$dir/${name}i 43562378475aSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 435795b296d0Smrg 43582378475aSmrg # Maybe install the static library, too. 435914330f12Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 43602378475aSmrg ;; 436195b296d0Smrg 43622378475aSmrg *.lo) 43632378475aSmrg # Install (i.e. copy) a libtool object. 436495b296d0Smrg 43652378475aSmrg # Figure out destination file name, if it wasn't already specified. 43662378475aSmrg if test -n "$destname"; then 4367eca46af7Smrg destfile=$destdir/$destname 43682378475aSmrg else 43692378475aSmrg func_basename "$file" 4370eca46af7Smrg destfile=$func_basename_result 4371eca46af7Smrg destfile=$destdir/$destfile 4372e6f085baSmrg fi 437395b296d0Smrg 43742378475aSmrg # Deduce the name of the destination old-style object file. 43752378475aSmrg case $destfile in 43762378475aSmrg *.lo) 43772378475aSmrg func_lo2o "$destfile" 43782378475aSmrg staticdest=$func_lo2o_result 43792378475aSmrg ;; 43802378475aSmrg *.$objext) 4381eca46af7Smrg staticdest=$destfile 43822378475aSmrg destfile= 43832378475aSmrg ;; 43842378475aSmrg *) 4385eca46af7Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 43862378475aSmrg ;; 43872378475aSmrg esac 438895b296d0Smrg 43892378475aSmrg # Install the libtool object if requested. 43902378475aSmrg test -n "$destfile" && \ 43912378475aSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 439295b296d0Smrg 43932378475aSmrg # Install the old object if enabled. 4394eca46af7Smrg if test yes = "$build_old_libs"; then 43952378475aSmrg # Deduce the name of the old-style object file. 43962378475aSmrg func_lo2o "$file" 43972378475aSmrg staticobj=$func_lo2o_result 43982378475aSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 439995b296d0Smrg fi 44002378475aSmrg exit $EXIT_SUCCESS 44012378475aSmrg ;; 440295b296d0Smrg 44032378475aSmrg *) 44042378475aSmrg # Figure out destination file name, if it wasn't already specified. 44052378475aSmrg if test -n "$destname"; then 4406eca46af7Smrg destfile=$destdir/$destname 44072378475aSmrg else 44082378475aSmrg func_basename "$file" 4409eca46af7Smrg destfile=$func_basename_result 4410eca46af7Smrg destfile=$destdir/$destfile 44112378475aSmrg fi 441295b296d0Smrg 44132378475aSmrg # If the file is missing, and there is a .exe on the end, strip it 44142378475aSmrg # because it is most likely a libtool script we actually want to 44152378475aSmrg # install 4416eca46af7Smrg stripped_ext= 44172378475aSmrg case $file in 44182378475aSmrg *.exe) 44192378475aSmrg if test ! -f "$file"; then 44202378475aSmrg func_stripname '' '.exe' "$file" 44212378475aSmrg file=$func_stripname_result 4422eca46af7Smrg stripped_ext=.exe 44232378475aSmrg fi 44242378475aSmrg ;; 44252378475aSmrg esac 44262378475aSmrg 44272378475aSmrg # Do a test to see if this is really a libtool program. 44282378475aSmrg case $host in 44292378475aSmrg *cygwin* | *mingw*) 44302378475aSmrg if func_ltwrapper_executable_p "$file"; then 44312378475aSmrg func_ltwrapper_scriptname "$file" 44322378475aSmrg wrapper=$func_ltwrapper_scriptname_result 44332378475aSmrg else 44342378475aSmrg func_stripname '' '.exe' "$file" 44352378475aSmrg wrapper=$func_stripname_result 44362378475aSmrg fi 44372378475aSmrg ;; 4438e6f085baSmrg *) 44392378475aSmrg wrapper=$file 44402378475aSmrg ;; 44412378475aSmrg esac 44422378475aSmrg if func_ltwrapper_script_p "$wrapper"; then 44432378475aSmrg notinst_deplibs= 44442378475aSmrg relink_command= 44452378475aSmrg 44462378475aSmrg func_source "$wrapper" 44472378475aSmrg 44482378475aSmrg # Check the variables that should have been set. 44492378475aSmrg test -z "$generated_by_libtool_version" && \ 4450eca46af7Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 44512378475aSmrg 4452eca46af7Smrg finalize=: 44532378475aSmrg for lib in $notinst_deplibs; do 44542378475aSmrg # Check to see that each library is installed. 44552378475aSmrg libdir= 44562378475aSmrg if test -f "$lib"; then 44572378475aSmrg func_source "$lib" 44582378475aSmrg fi 4459eca46af7Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 44602378475aSmrg if test -n "$libdir" && test ! -f "$libfile"; then 4461eca46af7Smrg func_warning "'$lib' has not been installed in '$libdir'" 4462eca46af7Smrg finalize=false 44632378475aSmrg fi 44642378475aSmrg done 44652378475aSmrg 44662378475aSmrg relink_command= 44672378475aSmrg func_source "$wrapper" 44682378475aSmrg 44692378475aSmrg outputname= 4470eca46af7Smrg if test no = "$fast_install" && test -n "$relink_command"; then 44712378475aSmrg $opt_dry_run || { 4472eca46af7Smrg if $finalize; then 44732378475aSmrg tmpdir=`func_mktempdir` 44742378475aSmrg func_basename "$file$stripped_ext" 4475eca46af7Smrg file=$func_basename_result 4476eca46af7Smrg outputname=$tmpdir/$file 44772378475aSmrg # Replace the output file specification. 447814330f12Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 44792378475aSmrg 4480eca46af7Smrg $opt_quiet || { 44812378475aSmrg func_quote_for_expand "$relink_command" 44822378475aSmrg eval "func_echo $func_quote_for_expand_result" 44832378475aSmrg } 44842378475aSmrg if eval "$relink_command"; then : 44852378475aSmrg else 4486eca46af7Smrg func_error "error: relink '$file' with the above command before installing it" 44872378475aSmrg $opt_dry_run || ${RM}r "$tmpdir" 44882378475aSmrg continue 44892378475aSmrg fi 4490eca46af7Smrg file=$outputname 44912378475aSmrg else 4492eca46af7Smrg func_warning "cannot relink '$file'" 44932378475aSmrg fi 44942378475aSmrg } 44952378475aSmrg else 44962378475aSmrg # Install the binary that we compiled earlier. 449714330f12Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4498e6f085baSmrg fi 44992378475aSmrg fi 45002378475aSmrg 45012378475aSmrg # remove .exe since cygwin /usr/bin/install will append another 45022378475aSmrg # one anyway 45032378475aSmrg case $install_prog,$host in 45042378475aSmrg */usr/bin/install*,*cygwin*) 45052378475aSmrg case $file:$destfile in 45062378475aSmrg *.exe:*.exe) 45072378475aSmrg # this is ok 45082378475aSmrg ;; 45092378475aSmrg *.exe:*) 45102378475aSmrg destfile=$destfile.exe 45112378475aSmrg ;; 45122378475aSmrg *:*.exe) 45132378475aSmrg func_stripname '' '.exe' "$destfile" 45142378475aSmrg destfile=$func_stripname_result 45152378475aSmrg ;; 45162378475aSmrg esac 4517e6f085baSmrg ;; 4518e6f085baSmrg esac 45192378475aSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 45202378475aSmrg $opt_dry_run || if test -n "$outputname"; then 45212378475aSmrg ${RM}r "$tmpdir" 45222378475aSmrg fi 45232378475aSmrg ;; 45242378475aSmrg esac 45252378475aSmrg done 452695b296d0Smrg 45272378475aSmrg for file in $staticlibs; do 45282378475aSmrg func_basename "$file" 4529eca46af7Smrg name=$func_basename_result 45302378475aSmrg 45312378475aSmrg # Set up the ranlib parameters. 4532eca46af7Smrg oldlib=$destdir/$name 4533eca46af7Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4534eca46af7Smrg tool_oldlib=$func_to_tool_file_result 45352378475aSmrg 45362378475aSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 45372378475aSmrg 45382378475aSmrg if test -n "$stripme" && test -n "$old_striplib"; then 4539eca46af7Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 45402378475aSmrg fi 45412378475aSmrg 45422378475aSmrg # Do each command in the postinstall commands. 45432378475aSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 45442378475aSmrg done 45452378475aSmrg 45462378475aSmrg test -n "$future_libdirs" && \ 4547eca46af7Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 45482378475aSmrg 45492378475aSmrg if test -n "$current_libdirs"; then 45502378475aSmrg # Maybe just do a dry run. 45512378475aSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4552eca46af7Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 45532378475aSmrg else 45542378475aSmrg exit $EXIT_SUCCESS 45552378475aSmrg fi 45562378475aSmrg} 45572378475aSmrg 4558eca46af7Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 45592378475aSmrg 45602378475aSmrg 45612378475aSmrg# func_generate_dlsyms outputname originator pic_p 45622378475aSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 45632378475aSmrg# a dlpreopen symbol table. 45642378475aSmrgfunc_generate_dlsyms () 45652378475aSmrg{ 4566eca46af7Smrg $debug_cmd 4567eca46af7Smrg 4568eca46af7Smrg my_outputname=$1 4569eca46af7Smrg my_originator=$2 4570eca46af7Smrg my_pic_p=${3-false} 4571eca46af7Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 45722378475aSmrg my_dlsyms= 45732378475aSmrg 4574eca46af7Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 45752378475aSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4576eca46af7Smrg my_dlsyms=${my_outputname}S.c 45772378475aSmrg else 45782378475aSmrg func_error "not configured to extract global symbols from dlpreopened files" 45792378475aSmrg fi 45802378475aSmrg fi 45812378475aSmrg 45822378475aSmrg if test -n "$my_dlsyms"; then 45832378475aSmrg case $my_dlsyms in 45842378475aSmrg "") ;; 45852378475aSmrg *.c) 45862378475aSmrg # Discover the nlist of each of the dlfiles. 4587eca46af7Smrg nlist=$output_objdir/$my_outputname.nm 45882378475aSmrg 45892378475aSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 45902378475aSmrg 45912378475aSmrg # Parse the name list into a source file. 45922378475aSmrg func_verbose "creating $output_objdir/$my_dlsyms" 45932378475aSmrg 45942378475aSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4595eca46af7Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4596eca46af7Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 45972378475aSmrg 45982378475aSmrg#ifdef __cplusplus 45992378475aSmrgextern \"C\" { 46002378475aSmrg#endif 46012378475aSmrg 4602eca46af7Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 460314330f12Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 460414330f12Smrg#endif 460514330f12Smrg 460614330f12Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4607eca46af7Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4608eca46af7Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 460914330f12Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 461014330f12Smrg# define LT_DLSYM_CONST 4611eca46af7Smrg#elif defined __osf__ 461214330f12Smrg/* This system does not cope well with relocations in const data. */ 461314330f12Smrg# define LT_DLSYM_CONST 461414330f12Smrg#else 461514330f12Smrg# define LT_DLSYM_CONST const 461614330f12Smrg#endif 461714330f12Smrg 4618eca46af7Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4619eca46af7Smrg 46202378475aSmrg/* External symbol declarations for the compiler. */\ 46212378475aSmrg" 46222378475aSmrg 4623eca46af7Smrg if test yes = "$dlself"; then 4624eca46af7Smrg func_verbose "generating symbol list for '$output'" 46252378475aSmrg 46262378475aSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 46272378475aSmrg 46282378475aSmrg # Add our own program objects to the symbol list. 462914330f12Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 46302378475aSmrg for progfile in $progfiles; do 463114330f12Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4632eca46af7Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 463314330f12Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 46342378475aSmrg done 46352378475aSmrg 46362378475aSmrg if test -n "$exclude_expsyms"; then 46372378475aSmrg $opt_dry_run || { 46382378475aSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 46392378475aSmrg eval '$MV "$nlist"T "$nlist"' 46402378475aSmrg } 4641e6f085baSmrg fi 46422378475aSmrg 46432378475aSmrg if test -n "$export_symbols_regex"; then 46442378475aSmrg $opt_dry_run || { 46452378475aSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 46462378475aSmrg eval '$MV "$nlist"T "$nlist"' 46472378475aSmrg } 46482378475aSmrg fi 46492378475aSmrg 46502378475aSmrg # Prepare the list of exported symbols 46512378475aSmrg if test -z "$export_symbols"; then 4652eca46af7Smrg export_symbols=$output_objdir/$outputname.exp 46532378475aSmrg $opt_dry_run || { 46542378475aSmrg $RM $export_symbols 4655eca46af7Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 46562378475aSmrg case $host in 46572378475aSmrg *cygwin* | *mingw* | *cegcc* ) 46582378475aSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 46592378475aSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 46602378475aSmrg ;; 46612378475aSmrg esac 46622378475aSmrg } 4663e6f085baSmrg else 46642378475aSmrg $opt_dry_run || { 4665eca46af7Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 46662378475aSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 46672378475aSmrg eval '$MV "$nlist"T "$nlist"' 46682378475aSmrg case $host in 466914330f12Smrg *cygwin* | *mingw* | *cegcc* ) 46702378475aSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 46712378475aSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 46722378475aSmrg ;; 46732378475aSmrg esac 46742378475aSmrg } 4675e6f085baSmrg fi 46762378475aSmrg fi 467795b296d0Smrg 46782378475aSmrg for dlprefile in $dlprefiles; do 4679eca46af7Smrg func_verbose "extracting global C symbols from '$dlprefile'" 46802378475aSmrg func_basename "$dlprefile" 4681eca46af7Smrg name=$func_basename_result 468214330f12Smrg case $host in 468314330f12Smrg *cygwin* | *mingw* | *cegcc* ) 468414330f12Smrg # if an import library, we need to obtain dlname 468514330f12Smrg if func_win32_import_lib_p "$dlprefile"; then 468614330f12Smrg func_tr_sh "$dlprefile" 468714330f12Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4688eca46af7Smrg dlprefile_dlbasename= 468914330f12Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 469014330f12Smrg # Use subshell, to avoid clobbering current variable values 469114330f12Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4692eca46af7Smrg if test -n "$dlprefile_dlname"; then 469314330f12Smrg func_basename "$dlprefile_dlname" 4694eca46af7Smrg dlprefile_dlbasename=$func_basename_result 469514330f12Smrg else 469614330f12Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 469714330f12Smrg $sharedlib_from_linklib_cmd "$dlprefile" 469814330f12Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 469914330f12Smrg fi 470014330f12Smrg fi 470114330f12Smrg $opt_dry_run || { 4702eca46af7Smrg if test -n "$dlprefile_dlbasename"; then 470314330f12Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 470414330f12Smrg else 470514330f12Smrg func_warning "Could not compute DLL name from $name" 470614330f12Smrg eval '$ECHO ": $name " >> "$nlist"' 470714330f12Smrg fi 470814330f12Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 470914330f12Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 471014330f12Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 471114330f12Smrg } 471214330f12Smrg else # not an import lib 471314330f12Smrg $opt_dry_run || { 471414330f12Smrg eval '$ECHO ": $name " >> "$nlist"' 471514330f12Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 471614330f12Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 471714330f12Smrg } 471814330f12Smrg fi 471914330f12Smrg ;; 472014330f12Smrg *) 472114330f12Smrg $opt_dry_run || { 472214330f12Smrg eval '$ECHO ": $name " >> "$nlist"' 472314330f12Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 472414330f12Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 472514330f12Smrg } 472614330f12Smrg ;; 472714330f12Smrg esac 47282378475aSmrg done 47292378475aSmrg 47302378475aSmrg $opt_dry_run || { 47312378475aSmrg # Make sure we have at least an empty file. 47322378475aSmrg test -f "$nlist" || : > "$nlist" 47332378475aSmrg 47342378475aSmrg if test -n "$exclude_expsyms"; then 47352378475aSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 47362378475aSmrg $MV "$nlist"T "$nlist" 4737e6f085baSmrg fi 47382378475aSmrg 47392378475aSmrg # Try sorting and uniquifying the output. 47402378475aSmrg if $GREP -v "^: " < "$nlist" | 47412378475aSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 47422378475aSmrg sort -k 3 47432378475aSmrg else 47442378475aSmrg sort +2 47452378475aSmrg fi | 47462378475aSmrg uniq > "$nlist"S; then 47472378475aSmrg : 4748e6f085baSmrg else 47492378475aSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 4750e6f085baSmrg fi 475195b296d0Smrg 47522378475aSmrg if test -f "$nlist"S; then 47532378475aSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4754e6f085baSmrg else 475514330f12Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4756e6f085baSmrg fi 475795b296d0Smrg 4758eca46af7Smrg func_show_eval '$RM "${nlist}I"' 4759eca46af7Smrg if test -n "$global_symbol_to_import"; then 4760eca46af7Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 4761eca46af7Smrg fi 4762eca46af7Smrg 476314330f12Smrg echo >> "$output_objdir/$my_dlsyms" "\ 476495b296d0Smrg 47652378475aSmrg/* The mapping between symbol names and symbols. */ 47662378475aSmrgtypedef struct { 47672378475aSmrg const char *name; 47682378475aSmrg void *address; 47692378475aSmrg} lt_dlsymlist; 477014330f12Smrgextern LT_DLSYM_CONST lt_dlsymlist 4771eca46af7Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 4772eca46af7Smrg" 4773eca46af7Smrg 4774eca46af7Smrg if test -s "$nlist"I; then 4775eca46af7Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4776eca46af7Smrgstatic void lt_syminit(void) 4777eca46af7Smrg{ 4778eca46af7Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 4779eca46af7Smrg for (; symbol->name; ++symbol) 4780eca46af7Smrg {" 4781eca46af7Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 4782eca46af7Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4783eca46af7Smrg } 4784eca46af7Smrg}" 4785eca46af7Smrg fi 4786eca46af7Smrg echo >> "$output_objdir/$my_dlsyms" "\ 478714330f12SmrgLT_DLSYM_CONST lt_dlsymlist 47882378475aSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 4789eca46af7Smrg{ {\"$my_originator\", (void *) 0}," 4790eca46af7Smrg 4791eca46af7Smrg if test -s "$nlist"I; then 4792eca46af7Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4793eca46af7Smrg {\"@INIT@\", (void *) <_syminit}," 4794eca46af7Smrg fi 479595b296d0Smrg 47962378475aSmrg case $need_lib_prefix in 47972378475aSmrg no) 47982378475aSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 47992378475aSmrg ;; 48002378475aSmrg *) 48012378475aSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 48022378475aSmrg ;; 48032378475aSmrg esac 480414330f12Smrg echo >> "$output_objdir/$my_dlsyms" "\ 48052378475aSmrg {0, (void *) 0} 48062378475aSmrg}; 480795b296d0Smrg 48082378475aSmrg/* This works around a problem in FreeBSD linker */ 48092378475aSmrg#ifdef FREEBSD_WORKAROUND 48102378475aSmrgstatic const void *lt_preloaded_setup() { 48112378475aSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 48122378475aSmrg} 48132378475aSmrg#endif 48142378475aSmrg 48152378475aSmrg#ifdef __cplusplus 48162378475aSmrg} 48172378475aSmrg#endif\ 48182378475aSmrg" 48192378475aSmrg } # !$opt_dry_run 48202378475aSmrg 48212378475aSmrg pic_flag_for_symtable= 48222378475aSmrg case "$compile_command " in 48232378475aSmrg *" -static "*) ;; 48242378475aSmrg *) 48252378475aSmrg case $host in 48262378475aSmrg # compiling the symbol table file with pic_flag works around 48272378475aSmrg # a FreeBSD bug that causes programs to crash when -lm is 48282378475aSmrg # linked before any other PIC object. But we must not use 48292378475aSmrg # pic_flag when linking with -static. The problem exists in 48302378475aSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4831eca46af7Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 48322378475aSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 48332378475aSmrg *-*-hpux*) 48342378475aSmrg pic_flag_for_symtable=" $pic_flag" ;; 48352378475aSmrg *) 4836eca46af7Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 48372378475aSmrg ;; 48382378475aSmrg esac 48392378475aSmrg ;; 48402378475aSmrg esac 48412378475aSmrg symtab_cflags= 48422378475aSmrg for arg in $LTCFLAGS; do 48432378475aSmrg case $arg in 48442378475aSmrg -pie | -fpie | -fPIE) ;; 484514330f12Smrg *) func_append symtab_cflags " $arg" ;; 48462378475aSmrg esac 48472378475aSmrg done 484895b296d0Smrg 48492378475aSmrg # Now compile the dynamic symbol file. 48502378475aSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 485139713583Smrg 48522378475aSmrg # Clean up the generated files. 4853eca46af7Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 485495b296d0Smrg 48552378475aSmrg # Transform the symbol file into the correct name. 4856eca46af7Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 48572378475aSmrg case $host in 48582378475aSmrg *cygwin* | *mingw* | *cegcc* ) 48592378475aSmrg if test -f "$output_objdir/$my_outputname.def"; then 486014330f12Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 486114330f12Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 48622378475aSmrg else 486314330f12Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486414330f12Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4865e6f085baSmrg fi 48662378475aSmrg ;; 48672378475aSmrg *) 486814330f12Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486914330f12Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48702378475aSmrg ;; 48712378475aSmrg esac 48722378475aSmrg ;; 48732378475aSmrg *) 4874eca46af7Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 48752378475aSmrg ;; 48762378475aSmrg esac 48772378475aSmrg else 48782378475aSmrg # We keep going just in case the user didn't refer to 48792378475aSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 48802378475aSmrg # really was required. 488195b296d0Smrg 48822378475aSmrg # Nullify the symbol file. 488314330f12Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 488414330f12Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 48852378475aSmrg fi 48862378475aSmrg} 488739713583Smrg 4888eca46af7Smrg# func_cygming_gnu_implib_p ARG 4889eca46af7Smrg# This predicate returns with zero status (TRUE) if 4890eca46af7Smrg# ARG is a GNU/binutils-style import library. Returns 4891eca46af7Smrg# with nonzero status (FALSE) otherwise. 4892eca46af7Smrgfunc_cygming_gnu_implib_p () 4893eca46af7Smrg{ 4894eca46af7Smrg $debug_cmd 4895eca46af7Smrg 4896eca46af7Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4897eca46af7Smrg 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)$'` 4898eca46af7Smrg test -n "$func_cygming_gnu_implib_tmp" 4899eca46af7Smrg} 4900eca46af7Smrg 4901eca46af7Smrg# func_cygming_ms_implib_p ARG 4902eca46af7Smrg# This predicate returns with zero status (TRUE) if 4903eca46af7Smrg# ARG is an MS-style import library. Returns 4904eca46af7Smrg# with nonzero status (FALSE) otherwise. 4905eca46af7Smrgfunc_cygming_ms_implib_p () 4906eca46af7Smrg{ 4907eca46af7Smrg $debug_cmd 4908eca46af7Smrg 4909eca46af7Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4910eca46af7Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 4911eca46af7Smrg test -n "$func_cygming_ms_implib_tmp" 4912eca46af7Smrg} 4913eca46af7Smrg 49142378475aSmrg# func_win32_libid arg 49152378475aSmrg# return the library type of file 'arg' 49162378475aSmrg# 49172378475aSmrg# Need a lot of goo to handle *both* DLLs and import libs 49182378475aSmrg# Has to be a shell function in order to 'eat' the argument 49192378475aSmrg# that is supplied when $file_magic_command is called. 492014330f12Smrg# Despite the name, also deal with 64 bit binaries. 49212378475aSmrgfunc_win32_libid () 49222378475aSmrg{ 4923eca46af7Smrg $debug_cmd 4924eca46af7Smrg 4925eca46af7Smrg win32_libid_type=unknown 49262378475aSmrg win32_fileres=`file -L $1 2>/dev/null` 49272378475aSmrg case $win32_fileres in 49282378475aSmrg *ar\ archive\ import\ library*) # definitely import 49292378475aSmrg win32_libid_type="x86 archive import" 49302378475aSmrg ;; 49312378475aSmrg *ar\ archive*) # could be an import, or static 493214330f12Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 49332378475aSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 493414330f12Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 4935eca46af7Smrg case $nm_interface in 4936eca46af7Smrg "MS dumpbin") 4937eca46af7Smrg if func_cygming_ms_implib_p "$1" || 4938eca46af7Smrg func_cygming_gnu_implib_p "$1" 4939eca46af7Smrg then 4940eca46af7Smrg win32_nmres=import 4941eca46af7Smrg else 4942eca46af7Smrg win32_nmres= 4943eca46af7Smrg fi 4944eca46af7Smrg ;; 4945eca46af7Smrg *) 4946eca46af7Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4947eca46af7Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 4948eca46af7Smrg $SED -n -e ' 49492378475aSmrg 1,100{ 49502378475aSmrg / I /{ 4951eca46af7Smrg s|.*|import| 49522378475aSmrg p 49532378475aSmrg q 49542378475aSmrg } 49552378475aSmrg }'` 4956eca46af7Smrg ;; 4957eca46af7Smrg esac 49582378475aSmrg case $win32_nmres in 49592378475aSmrg import*) win32_libid_type="x86 archive import";; 49602378475aSmrg *) win32_libid_type="x86 archive static";; 49612378475aSmrg esac 49622378475aSmrg fi 49632378475aSmrg ;; 49642378475aSmrg *DLL*) 49652378475aSmrg win32_libid_type="x86 DLL" 49662378475aSmrg ;; 49672378475aSmrg *executable*) # but shell scripts are "executable" too... 49682378475aSmrg case $win32_fileres in 49692378475aSmrg *MS\ Windows\ PE\ Intel*) 49702378475aSmrg win32_libid_type="x86 DLL" 49712378475aSmrg ;; 49722378475aSmrg esac 49732378475aSmrg ;; 49742378475aSmrg esac 49752378475aSmrg $ECHO "$win32_libid_type" 49762378475aSmrg} 497739713583Smrg 497814330f12Smrg# func_cygming_dll_for_implib ARG 497914330f12Smrg# 498014330f12Smrg# Platform-specific function to extract the 498114330f12Smrg# name of the DLL associated with the specified 498214330f12Smrg# import library ARG. 498314330f12Smrg# Invoked by eval'ing the libtool variable 498414330f12Smrg# $sharedlib_from_linklib_cmd 498514330f12Smrg# Result is available in the variable 498614330f12Smrg# $sharedlib_from_linklib_result 498714330f12Smrgfunc_cygming_dll_for_implib () 498814330f12Smrg{ 4989eca46af7Smrg $debug_cmd 4990eca46af7Smrg 499114330f12Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 499214330f12Smrg} 499314330f12Smrg 499414330f12Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 499514330f12Smrg# 499614330f12Smrg# The is the core of a fallback implementation of a 499714330f12Smrg# platform-specific function to extract the name of the 499814330f12Smrg# DLL associated with the specified import library LIBNAME. 499914330f12Smrg# 500014330f12Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 500114330f12Smrg# on the platform and compiler that created the implib. 500214330f12Smrg# 500314330f12Smrg# Echos the name of the DLL associated with the 500414330f12Smrg# specified import library. 500514330f12Smrgfunc_cygming_dll_for_implib_fallback_core () 500614330f12Smrg{ 5007eca46af7Smrg $debug_cmd 5008eca46af7Smrg 500914330f12Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 501014330f12Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 501114330f12Smrg $SED '/^Contents of section '"$match_literal"':/{ 501214330f12Smrg # Place marker at beginning of archive member dllname section 501314330f12Smrg s/.*/====MARK====/ 501414330f12Smrg p 501514330f12Smrg d 501614330f12Smrg } 501714330f12Smrg # These lines can sometimes be longer than 43 characters, but 501814330f12Smrg # are always uninteresting 501914330f12Smrg /:[ ]*file format pe[i]\{,1\}-/d 502014330f12Smrg /^In archive [^:]*:/d 502114330f12Smrg # Ensure marker is printed 502214330f12Smrg /^====MARK====/p 502314330f12Smrg # Remove all lines with less than 43 characters 502414330f12Smrg /^.\{43\}/!d 502514330f12Smrg # From remaining lines, remove first 43 characters 502614330f12Smrg s/^.\{43\}//' | 502714330f12Smrg $SED -n ' 502814330f12Smrg # Join marker and all lines until next marker into a single line 502914330f12Smrg /^====MARK====/ b para 503014330f12Smrg H 503114330f12Smrg $ b para 503214330f12Smrg b 503314330f12Smrg :para 503414330f12Smrg x 503514330f12Smrg s/\n//g 503614330f12Smrg # Remove the marker 503714330f12Smrg s/^====MARK====// 503814330f12Smrg # Remove trailing dots and whitespace 503914330f12Smrg s/[\. \t]*$// 504014330f12Smrg # Print 504114330f12Smrg /./p' | 504214330f12Smrg # we now have a list, one entry per line, of the stringified 504314330f12Smrg # contents of the appropriate section of all members of the 5044eca46af7Smrg # archive that possess that section. Heuristic: eliminate 5045eca46af7Smrg # all those that have a first or second character that is 504614330f12Smrg # a '.' (that is, objdump's representation of an unprintable 504714330f12Smrg # character.) This should work for all archives with less than 504814330f12Smrg # 0x302f exports -- but will fail for DLLs whose name actually 504914330f12Smrg # begins with a literal '.' or a single character followed by 505014330f12Smrg # a '.'. 505114330f12Smrg # 505214330f12Smrg # Of those that remain, print the first one. 505314330f12Smrg $SED -e '/^\./d;/^.\./d;q' 505414330f12Smrg} 505514330f12Smrg 505614330f12Smrg# func_cygming_dll_for_implib_fallback ARG 505714330f12Smrg# Platform-specific function to extract the 505814330f12Smrg# name of the DLL associated with the specified 505914330f12Smrg# import library ARG. 506014330f12Smrg# 506114330f12Smrg# This fallback implementation is for use when $DLLTOOL 506214330f12Smrg# does not support the --identify-strict option. 506314330f12Smrg# Invoked by eval'ing the libtool variable 506414330f12Smrg# $sharedlib_from_linklib_cmd 506514330f12Smrg# Result is available in the variable 506614330f12Smrg# $sharedlib_from_linklib_result 506714330f12Smrgfunc_cygming_dll_for_implib_fallback () 506814330f12Smrg{ 5069eca46af7Smrg $debug_cmd 5070eca46af7Smrg 5071eca46af7Smrg if func_cygming_gnu_implib_p "$1"; then 507214330f12Smrg # binutils import library 507314330f12Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5074eca46af7Smrg elif func_cygming_ms_implib_p "$1"; then 507514330f12Smrg # ms-generated import library 507614330f12Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 507714330f12Smrg else 507814330f12Smrg # unknown 5079eca46af7Smrg sharedlib_from_linklib_result= 508014330f12Smrg fi 508114330f12Smrg} 508239713583Smrg 508339713583Smrg 50842378475aSmrg# func_extract_an_archive dir oldlib 50852378475aSmrgfunc_extract_an_archive () 50862378475aSmrg{ 5087eca46af7Smrg $debug_cmd 5088eca46af7Smrg 5089eca46af7Smrg f_ex_an_ar_dir=$1; shift 5090eca46af7Smrg f_ex_an_ar_oldlib=$1 5091eca46af7Smrg if test yes = "$lock_old_archive_extraction"; then 509214330f12Smrg lockfile=$f_ex_an_ar_oldlib.lock 509314330f12Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 509414330f12Smrg func_echo "Waiting for $lockfile to be removed" 509514330f12Smrg sleep 2 509614330f12Smrg done 509714330f12Smrg fi 509814330f12Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 509914330f12Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5100eca46af7Smrg if test yes = "$lock_old_archive_extraction"; then 510114330f12Smrg $opt_dry_run || rm -f "$lockfile" 510214330f12Smrg fi 51032378475aSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 51042378475aSmrg : 51052378475aSmrg else 51062378475aSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 51072378475aSmrg fi 51082378475aSmrg} 510995b296d0Smrg 511095b296d0Smrg 51112378475aSmrg# func_extract_archives gentop oldlib ... 51122378475aSmrgfunc_extract_archives () 51132378475aSmrg{ 5114eca46af7Smrg $debug_cmd 5115eca46af7Smrg 5116eca46af7Smrg my_gentop=$1; shift 51172378475aSmrg my_oldlibs=${1+"$@"} 5118eca46af7Smrg my_oldobjs= 5119eca46af7Smrg my_xlib= 5120eca46af7Smrg my_xabs= 5121eca46af7Smrg my_xdir= 512295b296d0Smrg 51232378475aSmrg for my_xlib in $my_oldlibs; do 51242378475aSmrg # Extract the objects. 51252378475aSmrg case $my_xlib in 5126eca46af7Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 51272378475aSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 51282378475aSmrg esac 51292378475aSmrg func_basename "$my_xlib" 5130eca46af7Smrg my_xlib=$func_basename_result 51312378475aSmrg my_xlib_u=$my_xlib 51322378475aSmrg while :; do 51332378475aSmrg case " $extracted_archives " in 51342378475aSmrg *" $my_xlib_u "*) 51352378475aSmrg func_arith $extracted_serial + 1 51362378475aSmrg extracted_serial=$func_arith_result 51372378475aSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 51382378475aSmrg *) break ;; 51392378475aSmrg esac 51402378475aSmrg done 51412378475aSmrg extracted_archives="$extracted_archives $my_xlib_u" 5142eca46af7Smrg my_xdir=$my_gentop/$my_xlib_u 514395b296d0Smrg 51442378475aSmrg func_mkdir_p "$my_xdir" 514539713583Smrg 51462378475aSmrg case $host in 51472378475aSmrg *-darwin*) 51482378475aSmrg func_verbose "Extracting $my_xabs" 51492378475aSmrg # Do not bother doing anything if just a dry run 51502378475aSmrg $opt_dry_run || { 51512378475aSmrg darwin_orig_dir=`pwd` 51522378475aSmrg cd $my_xdir || exit $? 51532378475aSmrg darwin_archive=$my_xabs 51542378475aSmrg darwin_curdir=`pwd` 5155eca46af7Smrg func_basename "$darwin_archive" 5156eca46af7Smrg darwin_base_archive=$func_basename_result 51572378475aSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 51582378475aSmrg if test -n "$darwin_arches"; then 51592378475aSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 51602378475aSmrg darwin_arch= 51612378475aSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5162eca46af7Smrg for darwin_arch in $darwin_arches; do 5163eca46af7Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5164eca46af7Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5165eca46af7Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5166eca46af7Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 51672378475aSmrg cd "$darwin_curdir" 5168eca46af7Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 51692378475aSmrg done # $darwin_arches 51702378475aSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5171eca46af7Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 51722378475aSmrg darwin_file= 51732378475aSmrg darwin_files= 51742378475aSmrg for darwin_file in $darwin_filelist; do 517514330f12Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 51762378475aSmrg $LIPO -create -output "$darwin_file" $darwin_files 51772378475aSmrg done # $darwin_filelist 51782378475aSmrg $RM -rf unfat-$$ 51792378475aSmrg cd "$darwin_orig_dir" 5180e6f085baSmrg else 51812378475aSmrg cd $darwin_orig_dir 51822378475aSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 51832378475aSmrg fi # $darwin_arches 51842378475aSmrg } # !$opt_dry_run 51852378475aSmrg ;; 51862378475aSmrg *) 51872378475aSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 51882378475aSmrg ;; 51892378475aSmrg esac 519014330f12Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 51912378475aSmrg done 519295b296d0Smrg 5193eca46af7Smrg func_extract_archives_result=$my_oldobjs 51942378475aSmrg} 519595b296d0Smrg 519695b296d0Smrg 519714330f12Smrg# func_emit_wrapper [arg=no] 519814330f12Smrg# 519914330f12Smrg# Emit a libtool wrapper script on stdout. 520014330f12Smrg# Don't directly open a file because we may want to 520114330f12Smrg# incorporate the script contents within a cygwin/mingw 520214330f12Smrg# wrapper executable. Must ONLY be called from within 520314330f12Smrg# func_mode_link because it depends on a number of variables 520414330f12Smrg# set therein. 52052378475aSmrg# 520614330f12Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 520714330f12Smrg# variable will take. If 'yes', then the emitted script 5208eca46af7Smrg# will assume that the directory where it is stored is 520914330f12Smrg# the $objdir directory. This is a cygwin/mingw-specific 521014330f12Smrg# behavior. 521114330f12Smrgfunc_emit_wrapper () 52122378475aSmrg{ 521314330f12Smrg func_emit_wrapper_arg1=${1-no} 5214e6f085baSmrg 52152378475aSmrg $ECHO "\ 52162378475aSmrg#! $SHELL 521795b296d0Smrg 52182378475aSmrg# $output - temporary wrapper script for $objdir/$outputname 5219eca46af7Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 52202378475aSmrg# 52212378475aSmrg# The $output program cannot be directly executed until all the libtool 52222378475aSmrg# libraries that it depends on are installed. 52232378475aSmrg# 52242378475aSmrg# This wrapper script should never be moved out of the build directory. 52252378475aSmrg# If it is, it will not operate correctly. 522695b296d0Smrg 52272378475aSmrg# Sed substitution that helps us do robust quoting. It backslashifies 52282378475aSmrg# metacharacters that are still active within double-quoted strings. 52292378475aSmrgsed_quote_subst='$sed_quote_subst' 523095b296d0Smrg 52312378475aSmrg# Be Bourne compatible 52322378475aSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 52332378475aSmrg emulate sh 52342378475aSmrg NULLCMD=: 52352378475aSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 52362378475aSmrg # is contrary to our usage. Disable this feature. 52372378475aSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 52382378475aSmrg setopt NO_GLOB_SUBST 52392378475aSmrgelse 52402378475aSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 52412378475aSmrgfi 52422378475aSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 52432378475aSmrgDUALCASE=1; export DUALCASE # for MKS sh 524495b296d0Smrg 52452378475aSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 52462378475aSmrg# if CDPATH is set. 52472378475aSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 524895b296d0Smrg 52492378475aSmrgrelink_command=\"$relink_command\" 525095b296d0Smrg 52512378475aSmrg# This environment variable determines our operation mode. 52522378475aSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 52532378475aSmrg # install mode needs the following variables: 52542378475aSmrg generated_by_libtool_version='$macro_version' 52552378475aSmrg notinst_deplibs='$notinst_deplibs' 52562378475aSmrgelse 52572378475aSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 52582378475aSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 525914330f12Smrg file=\"\$0\"" 526014330f12Smrg 526114330f12Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 526214330f12Smrg $ECHO "\ 526314330f12Smrg 526414330f12Smrg# A function that is used when there is no print builtin or printf. 526514330f12Smrgfunc_fallback_echo () 526614330f12Smrg{ 526714330f12Smrg eval 'cat <<_LTECHO_EOF 526814330f12Smrg\$1 526914330f12Smrg_LTECHO_EOF' 527014330f12Smrg} 527114330f12Smrg ECHO=\"$qECHO\" 527214330f12Smrg fi 527314330f12Smrg 527414330f12Smrg# Very basic option parsing. These options are (a) specific to 527514330f12Smrg# the libtool wrapper, (b) are identical between the wrapper 5276eca46af7Smrg# /script/ and the wrapper /executable/ that is used only on 527714330f12Smrg# windows platforms, and (c) all begin with the string "--lt-" 5278eca46af7Smrg# (application programs are unlikely to have options that match 527914330f12Smrg# this pattern). 528014330f12Smrg# 528114330f12Smrg# There are only two supported options: --lt-debug and 528214330f12Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 528314330f12Smrg# 528414330f12Smrg# The first argument to this parsing function should be the 528514330f12Smrg# script's $0 value, followed by "$@". 528614330f12Smrglt_option_debug= 528714330f12Smrgfunc_parse_lt_options () 528814330f12Smrg{ 528914330f12Smrg lt_script_arg0=\$0 529014330f12Smrg shift 529114330f12Smrg for lt_opt 529214330f12Smrg do 529314330f12Smrg case \"\$lt_opt\" in 529414330f12Smrg --lt-debug) lt_option_debug=1 ;; 529514330f12Smrg --lt-dump-script) 529614330f12Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 529714330f12Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 529814330f12Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 529914330f12Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 530014330f12Smrg exit 0 530114330f12Smrg ;; 530214330f12Smrg --lt-*) 530314330f12Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 530414330f12Smrg exit 1 530514330f12Smrg ;; 530614330f12Smrg esac 530714330f12Smrg done 530814330f12Smrg 530914330f12Smrg # Print the debug banner immediately: 531014330f12Smrg if test -n \"\$lt_option_debug\"; then 5311eca46af7Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 531214330f12Smrg fi 531314330f12Smrg} 531414330f12Smrg 531514330f12Smrg# Used when --lt-debug. Prints its arguments to stdout 531614330f12Smrg# (redirection is the responsibility of the caller) 531714330f12Smrgfunc_lt_dump_args () 531814330f12Smrg{ 531914330f12Smrg lt_dump_args_N=1; 532014330f12Smrg for lt_arg 532114330f12Smrg do 5322eca46af7Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 532314330f12Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 532414330f12Smrg done 532514330f12Smrg} 532614330f12Smrg 532714330f12Smrg# Core function for launching the target application 532814330f12Smrgfunc_exec_program_core () 532914330f12Smrg{ 53302378475aSmrg" 533114330f12Smrg case $host in 533214330f12Smrg # Backslashes separate directories on plain windows 533314330f12Smrg *-*-mingw | *-*-os2* | *-cegcc*) 533414330f12Smrg $ECHO "\ 533514330f12Smrg if test -n \"\$lt_option_debug\"; then 5336eca46af7Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 533714330f12Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 533814330f12Smrg fi 533914330f12Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 534014330f12Smrg" 534114330f12Smrg ;; 534214330f12Smrg 534314330f12Smrg *) 534414330f12Smrg $ECHO "\ 534514330f12Smrg if test -n \"\$lt_option_debug\"; then 5346eca46af7Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 534714330f12Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 534814330f12Smrg fi 534914330f12Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 535014330f12Smrg" 535114330f12Smrg ;; 535214330f12Smrg esac 535314330f12Smrg $ECHO "\ 535414330f12Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 535514330f12Smrg exit 1 535614330f12Smrg} 535714330f12Smrg 535814330f12Smrg# A function to encapsulate launching the target application 535914330f12Smrg# Strips options in the --lt-* namespace from \$@ and 536014330f12Smrg# launches target application with the remaining arguments. 536114330f12Smrgfunc_exec_program () 536214330f12Smrg{ 5363eca46af7Smrg case \" \$* \" in 5364eca46af7Smrg *\\ --lt-*) 5365eca46af7Smrg for lt_wr_arg 5366eca46af7Smrg do 5367eca46af7Smrg case \$lt_wr_arg in 5368eca46af7Smrg --lt-*) ;; 5369eca46af7Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5370eca46af7Smrg esac 5371eca46af7Smrg shift 5372eca46af7Smrg done ;; 5373eca46af7Smrg esac 537414330f12Smrg func_exec_program_core \${1+\"\$@\"} 537514330f12Smrg} 537614330f12Smrg 537714330f12Smrg # Parse options 537814330f12Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 537995b296d0Smrg 53802378475aSmrg # Find the directory that this script lives in. 538114330f12Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 53822378475aSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 538395b296d0Smrg 53842378475aSmrg # Follow symbolic links until we get to the real thisdir. 538514330f12Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 53862378475aSmrg while test -n \"\$file\"; do 538714330f12Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 538895b296d0Smrg 53892378475aSmrg # If there was a directory component, then change thisdir. 53902378475aSmrg if test \"x\$destdir\" != \"x\$file\"; then 53912378475aSmrg case \"\$destdir\" in 53922378475aSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 53932378475aSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5394e6f085baSmrg esac 53952378475aSmrg fi 539695b296d0Smrg 539714330f12Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 539814330f12Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 53992378475aSmrg done 540095b296d0Smrg 54012378475aSmrg # Usually 'no', except on cygwin/mingw when embedded into 54022378475aSmrg # the cwrapper. 540314330f12Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 54042378475aSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 54052378475aSmrg # special case for '.' 54062378475aSmrg if test \"\$thisdir\" = \".\"; then 54072378475aSmrg thisdir=\`pwd\` 54082378475aSmrg fi 54092378475aSmrg # remove .libs from thisdir 54102378475aSmrg case \"\$thisdir\" in 541114330f12Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 54122378475aSmrg $objdir ) thisdir=. ;; 54132378475aSmrg esac 54142378475aSmrg fi 54152378475aSmrg 54162378475aSmrg # Try to get the absolute directory name. 54172378475aSmrg absdir=\`cd \"\$thisdir\" && pwd\` 54182378475aSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 54192378475aSmrg" 54202378475aSmrg 5421eca46af7Smrg if test yes = "$fast_install"; then 54222378475aSmrg $ECHO "\ 54232378475aSmrg program=lt-'$outputname'$exeext 54242378475aSmrg progdir=\"\$thisdir/$objdir\" 54252378475aSmrg 54262378475aSmrg if test ! -f \"\$progdir/\$program\" || 5427eca46af7Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 54282378475aSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 54292378475aSmrg 54302378475aSmrg file=\"\$\$-\$program\" 54312378475aSmrg 54322378475aSmrg if test ! -d \"\$progdir\"; then 54332378475aSmrg $MKDIR \"\$progdir\" 54342378475aSmrg else 54352378475aSmrg $RM \"\$progdir/\$file\" 54362378475aSmrg fi" 54372378475aSmrg 54382378475aSmrg $ECHO "\ 54392378475aSmrg 54402378475aSmrg # relink executable if necessary 54412378475aSmrg if test -n \"\$relink_command\"; then 54422378475aSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 54432378475aSmrg else 5444eca46af7Smrg \$ECHO \"\$relink_command_output\" >&2 54452378475aSmrg $RM \"\$progdir/\$file\" 54462378475aSmrg exit 1 5447e6f085baSmrg fi 54482378475aSmrg fi 544995b296d0Smrg 54502378475aSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 54512378475aSmrg { $RM \"\$progdir/\$program\"; 54522378475aSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 54532378475aSmrg $RM \"\$progdir/\$file\" 54542378475aSmrg fi" 54552378475aSmrg else 54562378475aSmrg $ECHO "\ 54572378475aSmrg program='$outputname' 54582378475aSmrg progdir=\"\$thisdir/$objdir\" 54592378475aSmrg" 5460e6f085baSmrg fi 546195b296d0Smrg 54622378475aSmrg $ECHO "\ 546395b296d0Smrg 54642378475aSmrg if test -f \"\$progdir/\$program\"; then" 546595b296d0Smrg 546614330f12Smrg # fixup the dll searchpath if we need to. 546714330f12Smrg # 546814330f12Smrg # Fix the DLL searchpath if we need to. Do this before prepending 546914330f12Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 547014330f12Smrg # libraries must come first. 547114330f12Smrg if test -n "$dllsearchpath"; then 547214330f12Smrg $ECHO "\ 547314330f12Smrg # Add the dll search path components to the executable PATH 547414330f12Smrg PATH=$dllsearchpath:\$PATH 547514330f12Smrg" 547614330f12Smrg fi 547714330f12Smrg 54782378475aSmrg # Export our shlibpath_var if we have one. 5479eca46af7Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 54802378475aSmrg $ECHO "\ 54812378475aSmrg # Add our own library path to $shlibpath_var 54822378475aSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 54832378475aSmrg 54842378475aSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 54852378475aSmrg # The second colon is a workaround for a bug in BeOS R4 sed 548614330f12Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 548795b296d0Smrg 54882378475aSmrg export $shlibpath_var 54892378475aSmrg" 5490e6f085baSmrg fi 549195b296d0Smrg 54922378475aSmrg $ECHO "\ 54932378475aSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 54942378475aSmrg # Run the actual program with our arguments. 549514330f12Smrg func_exec_program \${1+\"\$@\"} 54962378475aSmrg fi 54972378475aSmrg else 54982378475aSmrg # The program doesn't exist. 5499eca46af7Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 55002378475aSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 550114330f12Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 55022378475aSmrg exit 1 55032378475aSmrg fi 55042378475aSmrgfi\ 55052378475aSmrg" 55062378475aSmrg} 550795b296d0Smrg 550839713583Smrg 55092378475aSmrg# func_emit_cwrapperexe_src 55102378475aSmrg# emit the source code for a wrapper executable on stdout 55112378475aSmrg# Must ONLY be called from within func_mode_link because 55122378475aSmrg# it depends on a number of variable set therein. 55132378475aSmrgfunc_emit_cwrapperexe_src () 55142378475aSmrg{ 55152378475aSmrg cat <<EOF 551695b296d0Smrg 55172378475aSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5518eca46af7Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 551995b296d0Smrg 55202378475aSmrg The $output program cannot be directly executed until all the libtool 55212378475aSmrg libraries that it depends on are installed. 552295b296d0Smrg 55232378475aSmrg This wrapper executable should never be moved out of the build directory. 55242378475aSmrg If it is, it will not operate correctly. 55252378475aSmrg*/ 55262378475aSmrgEOF 55272378475aSmrg cat <<"EOF" 552814330f12Smrg#ifdef _MSC_VER 552914330f12Smrg# define _CRT_SECURE_NO_DEPRECATE 1 553014330f12Smrg#endif 55312378475aSmrg#include <stdio.h> 55322378475aSmrg#include <stdlib.h> 55332378475aSmrg#ifdef _MSC_VER 55342378475aSmrg# include <direct.h> 55352378475aSmrg# include <process.h> 55362378475aSmrg# include <io.h> 55372378475aSmrg#else 55382378475aSmrg# include <unistd.h> 55392378475aSmrg# include <stdint.h> 55402378475aSmrg# ifdef __CYGWIN__ 55412378475aSmrg# include <io.h> 55422378475aSmrg# endif 55432378475aSmrg#endif 55442378475aSmrg#include <malloc.h> 55452378475aSmrg#include <stdarg.h> 55462378475aSmrg#include <assert.h> 55472378475aSmrg#include <string.h> 55482378475aSmrg#include <ctype.h> 55492378475aSmrg#include <errno.h> 55502378475aSmrg#include <fcntl.h> 55512378475aSmrg#include <sys/stat.h> 555295b296d0Smrg 5553eca46af7Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5554eca46af7Smrg 555514330f12Smrg/* declarations of non-ANSI functions */ 5556eca46af7Smrg#if defined __MINGW32__ 555714330f12Smrg# ifdef __STRICT_ANSI__ 555814330f12Smrgint _putenv (const char *); 555914330f12Smrg# endif 5560eca46af7Smrg#elif defined __CYGWIN__ 556114330f12Smrg# ifdef __STRICT_ANSI__ 556214330f12Smrgchar *realpath (const char *, char *); 556314330f12Smrgint putenv (char *); 556414330f12Smrgint setenv (const char *, const char *, int); 556514330f12Smrg# endif 5566eca46af7Smrg/* #elif defined other_platform || defined ... */ 556714330f12Smrg#endif 556814330f12Smrg 556914330f12Smrg/* portability defines, excluding path handling macros */ 5570eca46af7Smrg#if defined _MSC_VER 557114330f12Smrg# define setmode _setmode 557214330f12Smrg# define stat _stat 557314330f12Smrg# define chmod _chmod 557414330f12Smrg# define getcwd _getcwd 557514330f12Smrg# define putenv _putenv 557614330f12Smrg# define S_IXUSR _S_IEXEC 5577eca46af7Smrg#elif defined __MINGW32__ 557814330f12Smrg# define setmode _setmode 557914330f12Smrg# define stat _stat 558014330f12Smrg# define chmod _chmod 558114330f12Smrg# define getcwd _getcwd 558214330f12Smrg# define putenv _putenv 5583eca46af7Smrg#elif defined __CYGWIN__ 558414330f12Smrg# define HAVE_SETENV 558514330f12Smrg# define FOPEN_WB "wb" 5586eca46af7Smrg/* #elif defined other platforms ... */ 558714330f12Smrg#endif 558814330f12Smrg 5589eca46af7Smrg#if defined PATH_MAX 55902378475aSmrg# define LT_PATHMAX PATH_MAX 5591eca46af7Smrg#elif defined MAXPATHLEN 55922378475aSmrg# define LT_PATHMAX MAXPATHLEN 55932378475aSmrg#else 55942378475aSmrg# define LT_PATHMAX 1024 55952378475aSmrg#endif 559695b296d0Smrg 55972378475aSmrg#ifndef S_IXOTH 55982378475aSmrg# define S_IXOTH 0 55992378475aSmrg#endif 56002378475aSmrg#ifndef S_IXGRP 56012378475aSmrg# define S_IXGRP 0 56022378475aSmrg#endif 560395b296d0Smrg 560414330f12Smrg/* path handling portability macros */ 56052378475aSmrg#ifndef DIR_SEPARATOR 56062378475aSmrg# define DIR_SEPARATOR '/' 56072378475aSmrg# define PATH_SEPARATOR ':' 56082378475aSmrg#endif 560995b296d0Smrg 5610eca46af7Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5611eca46af7Smrg defined __OS2__ 56122378475aSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 56132378475aSmrg# define FOPEN_WB "wb" 56142378475aSmrg# ifndef DIR_SEPARATOR_2 56152378475aSmrg# define DIR_SEPARATOR_2 '\\' 56162378475aSmrg# endif 56172378475aSmrg# ifndef PATH_SEPARATOR_2 56182378475aSmrg# define PATH_SEPARATOR_2 ';' 56192378475aSmrg# endif 56202378475aSmrg#endif 562195b296d0Smrg 56222378475aSmrg#ifndef DIR_SEPARATOR_2 56232378475aSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 56242378475aSmrg#else /* DIR_SEPARATOR_2 */ 56252378475aSmrg# define IS_DIR_SEPARATOR(ch) \ 56262378475aSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 56272378475aSmrg#endif /* DIR_SEPARATOR_2 */ 562895b296d0Smrg 56292378475aSmrg#ifndef PATH_SEPARATOR_2 56302378475aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 56312378475aSmrg#else /* PATH_SEPARATOR_2 */ 56322378475aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 56332378475aSmrg#endif /* PATH_SEPARATOR_2 */ 563495b296d0Smrg 56352378475aSmrg#ifndef FOPEN_WB 56362378475aSmrg# define FOPEN_WB "w" 56372378475aSmrg#endif 56382378475aSmrg#ifndef _O_BINARY 56392378475aSmrg# define _O_BINARY 0 56402378475aSmrg#endif 564195b296d0Smrg 56422378475aSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 56432378475aSmrg#define XFREE(stale) do { \ 5644eca46af7Smrg if (stale) { free (stale); stale = 0; } \ 56452378475aSmrg} while (0) 564695b296d0Smrg 5647eca46af7Smrg#if defined LT_DEBUGWRAPPER 564814330f12Smrgstatic int lt_debug = 1; 56492378475aSmrg#else 565014330f12Smrgstatic int lt_debug = 0; 56512378475aSmrg#endif 565295b296d0Smrg 565314330f12Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 565495b296d0Smrg 56552378475aSmrgvoid *xmalloc (size_t num); 56562378475aSmrgchar *xstrdup (const char *string); 56572378475aSmrgconst char *base_name (const char *name); 56582378475aSmrgchar *find_executable (const char *wrapper); 56592378475aSmrgchar *chase_symlinks (const char *pathspec); 56602378475aSmrgint make_executable (const char *path); 56612378475aSmrgint check_executable (const char *path); 56622378475aSmrgchar *strendzap (char *str, const char *pat); 566314330f12Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 566414330f12Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 566514330f12Smrgstatic const char *nonnull (const char *s); 566614330f12Smrgstatic const char *nonempty (const char *s); 56672378475aSmrgvoid lt_setenv (const char *name, const char *value); 56682378475aSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 56692378475aSmrgvoid lt_update_exe_path (const char *name, const char *value); 56702378475aSmrgvoid lt_update_lib_path (const char *name, const char *value); 567114330f12Smrgchar **prepare_spawn (char **argv); 567214330f12Smrgvoid lt_dump_script (FILE *f); 56732378475aSmrgEOF 56742378475aSmrg 56752378475aSmrg cat <<EOF 5676eca46af7Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5677eca46af7Smrg# define externally_visible volatile 5678eca46af7Smrg#else 5679eca46af7Smrg# define externally_visible __attribute__((externally_visible)) volatile 5680eca46af7Smrg#endif 5681eca46af7Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 56822378475aSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 56832378475aSmrgEOF 568495b296d0Smrg 5685eca46af7Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 568614330f12Smrg func_to_host_path "$temp_rpath" 56872378475aSmrg cat <<EOF 568814330f12Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 56892378475aSmrgEOF 56902378475aSmrg else 56912378475aSmrg cat <<"EOF" 56922378475aSmrgconst char * LIB_PATH_VALUE = ""; 56932378475aSmrgEOF 5694e6f085baSmrg fi 569595b296d0Smrg 56962378475aSmrg if test -n "$dllsearchpath"; then 569714330f12Smrg func_to_host_path "$dllsearchpath:" 56982378475aSmrg cat <<EOF 56992378475aSmrgconst char * EXE_PATH_VARNAME = "PATH"; 570014330f12Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5701e6f085baSmrgEOF 5702e6f085baSmrg else 57032378475aSmrg cat <<"EOF" 57042378475aSmrgconst char * EXE_PATH_VARNAME = ""; 57052378475aSmrgconst char * EXE_PATH_VALUE = ""; 57062378475aSmrgEOF 5707e6f085baSmrg fi 57082378475aSmrg 5709eca46af7Smrg if test yes = "$fast_install"; then 57102378475aSmrg cat <<EOF 57112378475aSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 57122378475aSmrgEOF 5713e6f085baSmrg else 57142378475aSmrg cat <<EOF 57152378475aSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 57162378475aSmrgEOF 5717e6f085baSmrg fi 571895b296d0Smrg 571995b296d0Smrg 57202378475aSmrg cat <<"EOF" 572195b296d0Smrg 57222378475aSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 572395b296d0Smrg 57242378475aSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 57252378475aSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 572614330f12Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 572795b296d0Smrg 57282378475aSmrgint 57292378475aSmrgmain (int argc, char *argv[]) 57302378475aSmrg{ 57312378475aSmrg char **newargz; 57322378475aSmrg int newargc; 57332378475aSmrg char *tmp_pathspec; 57342378475aSmrg char *actual_cwrapper_path; 57352378475aSmrg char *actual_cwrapper_name; 57362378475aSmrg char *target_name; 57372378475aSmrg char *lt_argv_zero; 5738eca46af7Smrg int rval = 127; 573995b296d0Smrg 57402378475aSmrg int i; 574195b296d0Smrg 57422378475aSmrg program_name = (char *) xstrdup (base_name (argv[0])); 5743eca46af7Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 574495b296d0Smrg 574514330f12Smrg /* very simple arg parsing; don't want to rely on getopt 574614330f12Smrg * also, copy all non cwrapper options to newargz, except 574714330f12Smrg * argz[0], which is handled differently 574814330f12Smrg */ 574914330f12Smrg newargc=0; 57502378475aSmrg for (i = 1; i < argc; i++) 57512378475aSmrg { 5752eca46af7Smrg if (STREQ (argv[i], dumpscript_opt)) 57532378475aSmrg { 57542378475aSmrgEOF 5755eca46af7Smrg case $host in 57562378475aSmrg *mingw* | *cygwin* ) 57572378475aSmrg # make stdout use "unix" line endings 57582378475aSmrg echo " setmode(1,_O_BINARY);" 57592378475aSmrg ;; 57602378475aSmrg esac 576195b296d0Smrg 57622378475aSmrg cat <<"EOF" 576314330f12Smrg lt_dump_script (stdout); 57642378475aSmrg return 0; 57652378475aSmrg } 5766eca46af7Smrg if (STREQ (argv[i], debug_opt)) 576714330f12Smrg { 576814330f12Smrg lt_debug = 1; 576914330f12Smrg continue; 577014330f12Smrg } 5771eca46af7Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 577214330f12Smrg { 577314330f12Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 577414330f12Smrg namespace, but it is not one of the ones we know about and 577514330f12Smrg have already dealt with, above (inluding dump-script), then 577614330f12Smrg report an error. Otherwise, targets might begin to believe 577714330f12Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 577814330f12Smrg namespace. The first time any user complains about this, we'll 577914330f12Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 578014330f12Smrg or a configure.ac-settable value. 578114330f12Smrg */ 578214330f12Smrg lt_fatal (__FILE__, __LINE__, 578314330f12Smrg "unrecognized %s option: '%s'", 578414330f12Smrg ltwrapper_option_prefix, argv[i]); 578514330f12Smrg } 578614330f12Smrg /* otherwise ... */ 578714330f12Smrg newargz[++newargc] = xstrdup (argv[i]); 57882378475aSmrg } 578914330f12Smrg newargz[++newargc] = NULL; 579014330f12Smrg 579114330f12SmrgEOF 579214330f12Smrg cat <<EOF 579314330f12Smrg /* The GNU banner must be the first non-error debug message */ 5794eca46af7Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 579514330f12SmrgEOF 579614330f12Smrg cat <<"EOF" 579714330f12Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 579814330f12Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 579995b296d0Smrg 58002378475aSmrg tmp_pathspec = find_executable (argv[0]); 58012378475aSmrg if (tmp_pathspec == NULL) 580214330f12Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 580314330f12Smrg lt_debugprintf (__FILE__, __LINE__, 580414330f12Smrg "(main) found exe (before symlink chase) at: %s\n", 580514330f12Smrg tmp_pathspec); 58062378475aSmrg 58072378475aSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 580814330f12Smrg lt_debugprintf (__FILE__, __LINE__, 580914330f12Smrg "(main) found exe (after symlink chase) at: %s\n", 581014330f12Smrg actual_cwrapper_path); 58112378475aSmrg XFREE (tmp_pathspec); 58122378475aSmrg 581314330f12Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 58142378475aSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 58152378475aSmrg 58162378475aSmrg /* wrapper name transforms */ 58172378475aSmrg strendzap (actual_cwrapper_name, ".exe"); 58182378475aSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 58192378475aSmrg XFREE (actual_cwrapper_name); 58202378475aSmrg actual_cwrapper_name = tmp_pathspec; 58212378475aSmrg tmp_pathspec = 0; 58222378475aSmrg 58232378475aSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 58242378475aSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 58252378475aSmrg strendzap (target_name, ".exe"); 58262378475aSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 58272378475aSmrg XFREE (target_name); 58282378475aSmrg target_name = tmp_pathspec; 58292378475aSmrg tmp_pathspec = 0; 58302378475aSmrg 583114330f12Smrg lt_debugprintf (__FILE__, __LINE__, 583214330f12Smrg "(main) libtool target name: %s\n", 583314330f12Smrg target_name); 58342378475aSmrgEOF 583595b296d0Smrg 58362378475aSmrg cat <<EOF 58372378475aSmrg newargz[0] = 58382378475aSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 58392378475aSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 58402378475aSmrg strcpy (newargz[0], actual_cwrapper_path); 58412378475aSmrg strcat (newargz[0], "$objdir"); 58422378475aSmrg strcat (newargz[0], "/"); 58432378475aSmrgEOF 584495b296d0Smrg 58452378475aSmrg cat <<"EOF" 58462378475aSmrg /* stop here, and copy so we don't have to do this twice */ 58472378475aSmrg tmp_pathspec = xstrdup (newargz[0]); 584895b296d0Smrg 58492378475aSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 58502378475aSmrg strcat (newargz[0], actual_cwrapper_name); 585195b296d0Smrg 58522378475aSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 58532378475aSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 58542378475aSmrg XFREE (tmp_pathspec); 58552378475aSmrg tmp_pathspec = NULL; 58562378475aSmrgEOF 585795b296d0Smrg 58582378475aSmrg case $host_os in 58592378475aSmrg mingw*) 58602378475aSmrg cat <<"EOF" 58612378475aSmrg { 58622378475aSmrg char* p; 58632378475aSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 58642378475aSmrg { 58652378475aSmrg *p = '/'; 58662378475aSmrg } 58672378475aSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 58682378475aSmrg { 58692378475aSmrg *p = '/'; 58702378475aSmrg } 58712378475aSmrg } 58722378475aSmrgEOF 58732378475aSmrg ;; 58742378475aSmrg esac 587595b296d0Smrg 58762378475aSmrg cat <<"EOF" 58772378475aSmrg XFREE (target_name); 58782378475aSmrg XFREE (actual_cwrapper_path); 58792378475aSmrg XFREE (actual_cwrapper_name); 588095b296d0Smrg 58812378475aSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 58822378475aSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 588314330f12Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 588414330f12Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 588514330f12Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 588614330f12Smrg libraries must come first. */ 58872378475aSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 588814330f12Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 588995b296d0Smrg 589014330f12Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 589114330f12Smrg nonnull (lt_argv_zero)); 58922378475aSmrg for (i = 0; i < newargc; i++) 58932378475aSmrg { 589414330f12Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 589514330f12Smrg i, nonnull (newargz[i])); 58962378475aSmrg } 589795b296d0Smrg 58982378475aSmrgEOF 589995b296d0Smrg 59002378475aSmrg case $host_os in 59012378475aSmrg mingw*) 59022378475aSmrg cat <<"EOF" 59032378475aSmrg /* execv doesn't actually work on mingw as expected on unix */ 590414330f12Smrg newargz = prepare_spawn (newargz); 5905eca46af7Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 59062378475aSmrg if (rval == -1) 59072378475aSmrg { 59082378475aSmrg /* failed to start process */ 590914330f12Smrg lt_debugprintf (__FILE__, __LINE__, 591014330f12Smrg "(main) failed to launch target \"%s\": %s\n", 591114330f12Smrg lt_argv_zero, nonnull (strerror (errno))); 59122378475aSmrg return 127; 59132378475aSmrg } 59142378475aSmrg return rval; 59152378475aSmrgEOF 59162378475aSmrg ;; 59172378475aSmrg *) 59182378475aSmrg cat <<"EOF" 59192378475aSmrg execv (lt_argv_zero, newargz); 59202378475aSmrg return rval; /* =127, but avoids unused variable warning */ 59212378475aSmrgEOF 59222378475aSmrg ;; 59232378475aSmrg esac 592495b296d0Smrg 59252378475aSmrg cat <<"EOF" 59262378475aSmrg} 592795b296d0Smrg 59282378475aSmrgvoid * 59292378475aSmrgxmalloc (size_t num) 59302378475aSmrg{ 59312378475aSmrg void *p = (void *) malloc (num); 59322378475aSmrg if (!p) 593314330f12Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 593495b296d0Smrg 59352378475aSmrg return p; 59362378475aSmrg} 593795b296d0Smrg 59382378475aSmrgchar * 59392378475aSmrgxstrdup (const char *string) 59402378475aSmrg{ 59412378475aSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 59422378475aSmrg string) : NULL; 59432378475aSmrg} 594495b296d0Smrg 59452378475aSmrgconst char * 59462378475aSmrgbase_name (const char *name) 59472378475aSmrg{ 59482378475aSmrg const char *base; 5949e6f085baSmrg 5950eca46af7Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 59512378475aSmrg /* Skip over the disk name in MSDOS pathnames. */ 59522378475aSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 59532378475aSmrg name += 2; 59542378475aSmrg#endif 5955e6f085baSmrg 59562378475aSmrg for (base = name; *name; name++) 59572378475aSmrg if (IS_DIR_SEPARATOR (*name)) 59582378475aSmrg base = name + 1; 59592378475aSmrg return base; 59602378475aSmrg} 5961e6f085baSmrg 59622378475aSmrgint 59632378475aSmrgcheck_executable (const char *path) 59642378475aSmrg{ 59652378475aSmrg struct stat st; 5966e6f085baSmrg 596714330f12Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 596814330f12Smrg nonempty (path)); 59692378475aSmrg if ((!path) || (!*path)) 59702378475aSmrg return 0; 5971e6f085baSmrg 59722378475aSmrg if ((stat (path, &st) >= 0) 59732378475aSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 59742378475aSmrg return 1; 59752378475aSmrg else 59762378475aSmrg return 0; 59772378475aSmrg} 597895b296d0Smrg 59792378475aSmrgint 59802378475aSmrgmake_executable (const char *path) 59812378475aSmrg{ 59822378475aSmrg int rval = 0; 59832378475aSmrg struct stat st; 598495b296d0Smrg 598514330f12Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 598614330f12Smrg nonempty (path)); 59872378475aSmrg if ((!path) || (!*path)) 59882378475aSmrg return 0; 598939713583Smrg 59902378475aSmrg if (stat (path, &st) >= 0) 59912378475aSmrg { 59922378475aSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 59932378475aSmrg } 59942378475aSmrg return rval; 59952378475aSmrg} 5996e6f085baSmrg 59972378475aSmrg/* Searches for the full path of the wrapper. Returns 59982378475aSmrg newly allocated full path name if found, NULL otherwise 59992378475aSmrg Does not chase symlinks, even on platforms that support them. 60002378475aSmrg*/ 60012378475aSmrgchar * 60022378475aSmrgfind_executable (const char *wrapper) 60032378475aSmrg{ 60042378475aSmrg int has_slash = 0; 60052378475aSmrg const char *p; 60062378475aSmrg const char *p_next; 60072378475aSmrg /* static buffer for getcwd */ 60082378475aSmrg char tmp[LT_PATHMAX + 1]; 6009eca46af7Smrg size_t tmp_len; 60102378475aSmrg char *concat_name; 6011e6f085baSmrg 601214330f12Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 601314330f12Smrg nonempty (wrapper)); 6014e6f085baSmrg 60152378475aSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 60162378475aSmrg return NULL; 6017e6f085baSmrg 60182378475aSmrg /* Absolute path? */ 6019eca46af7Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 60202378475aSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 60212378475aSmrg { 60222378475aSmrg concat_name = xstrdup (wrapper); 60232378475aSmrg if (check_executable (concat_name)) 60242378475aSmrg return concat_name; 60252378475aSmrg XFREE (concat_name); 60262378475aSmrg } 60272378475aSmrg else 60282378475aSmrg { 60292378475aSmrg#endif 60302378475aSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 60312378475aSmrg { 60322378475aSmrg concat_name = xstrdup (wrapper); 60332378475aSmrg if (check_executable (concat_name)) 60342378475aSmrg return concat_name; 60352378475aSmrg XFREE (concat_name); 60362378475aSmrg } 6037eca46af7Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 60382378475aSmrg } 60392378475aSmrg#endif 604095b296d0Smrg 60412378475aSmrg for (p = wrapper; *p; p++) 60422378475aSmrg if (*p == '/') 60432378475aSmrg { 60442378475aSmrg has_slash = 1; 60452378475aSmrg break; 60462378475aSmrg } 60472378475aSmrg if (!has_slash) 60482378475aSmrg { 60492378475aSmrg /* no slashes; search PATH */ 60502378475aSmrg const char *path = getenv ("PATH"); 60512378475aSmrg if (path != NULL) 60522378475aSmrg { 60532378475aSmrg for (p = path; *p; p = p_next) 60542378475aSmrg { 60552378475aSmrg const char *q; 60562378475aSmrg size_t p_len; 60572378475aSmrg for (q = p; *q; q++) 60582378475aSmrg if (IS_PATH_SEPARATOR (*q)) 60592378475aSmrg break; 6060eca46af7Smrg p_len = (size_t) (q - p); 60612378475aSmrg p_next = (*q == '\0' ? q : q + 1); 60622378475aSmrg if (p_len == 0) 60632378475aSmrg { 60642378475aSmrg /* empty path: current directory */ 60652378475aSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 606614330f12Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 606714330f12Smrg nonnull (strerror (errno))); 60682378475aSmrg tmp_len = strlen (tmp); 60692378475aSmrg concat_name = 60702378475aSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 60712378475aSmrg memcpy (concat_name, tmp, tmp_len); 60722378475aSmrg concat_name[tmp_len] = '/'; 60732378475aSmrg strcpy (concat_name + tmp_len + 1, wrapper); 60742378475aSmrg } 60752378475aSmrg else 60762378475aSmrg { 60772378475aSmrg concat_name = 60782378475aSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 60792378475aSmrg memcpy (concat_name, p, p_len); 60802378475aSmrg concat_name[p_len] = '/'; 60812378475aSmrg strcpy (concat_name + p_len + 1, wrapper); 60822378475aSmrg } 60832378475aSmrg if (check_executable (concat_name)) 60842378475aSmrg return concat_name; 60852378475aSmrg XFREE (concat_name); 60862378475aSmrg } 60872378475aSmrg } 60882378475aSmrg /* not found in PATH; assume curdir */ 60892378475aSmrg } 60902378475aSmrg /* Relative path | not found in path: prepend cwd */ 60912378475aSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 609214330f12Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 609314330f12Smrg nonnull (strerror (errno))); 60942378475aSmrg tmp_len = strlen (tmp); 60952378475aSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 60962378475aSmrg memcpy (concat_name, tmp, tmp_len); 60972378475aSmrg concat_name[tmp_len] = '/'; 60982378475aSmrg strcpy (concat_name + tmp_len + 1, wrapper); 609995b296d0Smrg 61002378475aSmrg if (check_executable (concat_name)) 61012378475aSmrg return concat_name; 61022378475aSmrg XFREE (concat_name); 61032378475aSmrg return NULL; 61042378475aSmrg} 610595b296d0Smrg 61062378475aSmrgchar * 61072378475aSmrgchase_symlinks (const char *pathspec) 61082378475aSmrg{ 61092378475aSmrg#ifndef S_ISLNK 61102378475aSmrg return xstrdup (pathspec); 61112378475aSmrg#else 61122378475aSmrg char buf[LT_PATHMAX]; 61132378475aSmrg struct stat s; 61142378475aSmrg char *tmp_pathspec = xstrdup (pathspec); 61152378475aSmrg char *p; 61162378475aSmrg int has_symlinks = 0; 61172378475aSmrg while (strlen (tmp_pathspec) && !has_symlinks) 61182378475aSmrg { 611914330f12Smrg lt_debugprintf (__FILE__, __LINE__, 612014330f12Smrg "checking path component for symlinks: %s\n", 612114330f12Smrg tmp_pathspec); 61222378475aSmrg if (lstat (tmp_pathspec, &s) == 0) 61232378475aSmrg { 61242378475aSmrg if (S_ISLNK (s.st_mode) != 0) 61252378475aSmrg { 61262378475aSmrg has_symlinks = 1; 61272378475aSmrg break; 61282378475aSmrg } 612995b296d0Smrg 61302378475aSmrg /* search backwards for last DIR_SEPARATOR */ 61312378475aSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 61322378475aSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 61332378475aSmrg p--; 61342378475aSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 61352378475aSmrg { 61362378475aSmrg /* no more DIR_SEPARATORS left */ 61372378475aSmrg break; 61382378475aSmrg } 61392378475aSmrg *p = '\0'; 61402378475aSmrg } 61412378475aSmrg else 61422378475aSmrg { 614314330f12Smrg lt_fatal (__FILE__, __LINE__, 614414330f12Smrg "error accessing file \"%s\": %s", 614514330f12Smrg tmp_pathspec, nonnull (strerror (errno))); 61462378475aSmrg } 61472378475aSmrg } 61482378475aSmrg XFREE (tmp_pathspec); 614995b296d0Smrg 61502378475aSmrg if (!has_symlinks) 61512378475aSmrg { 61522378475aSmrg return xstrdup (pathspec); 61532378475aSmrg } 615495b296d0Smrg 61552378475aSmrg tmp_pathspec = realpath (pathspec, buf); 61562378475aSmrg if (tmp_pathspec == 0) 61572378475aSmrg { 615814330f12Smrg lt_fatal (__FILE__, __LINE__, 615914330f12Smrg "could not follow symlinks for %s", pathspec); 61602378475aSmrg } 61612378475aSmrg return xstrdup (tmp_pathspec); 61622378475aSmrg#endif 61632378475aSmrg} 616495b296d0Smrg 61652378475aSmrgchar * 61662378475aSmrgstrendzap (char *str, const char *pat) 61672378475aSmrg{ 61682378475aSmrg size_t len, patlen; 616995b296d0Smrg 61702378475aSmrg assert (str != NULL); 61712378475aSmrg assert (pat != NULL); 617295b296d0Smrg 61732378475aSmrg len = strlen (str); 61742378475aSmrg patlen = strlen (pat); 617595b296d0Smrg 61762378475aSmrg if (patlen <= len) 61772378475aSmrg { 61782378475aSmrg str += len - patlen; 6179eca46af7Smrg if (STREQ (str, pat)) 61802378475aSmrg *str = '\0'; 61812378475aSmrg } 61822378475aSmrg return str; 61832378475aSmrg} 618495b296d0Smrg 618514330f12Smrgvoid 618614330f12Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 618714330f12Smrg{ 618814330f12Smrg va_list args; 618914330f12Smrg if (lt_debug) 619014330f12Smrg { 619114330f12Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 619214330f12Smrg va_start (args, fmt); 619314330f12Smrg (void) vfprintf (stderr, fmt, args); 619414330f12Smrg va_end (args); 619514330f12Smrg } 619614330f12Smrg} 619714330f12Smrg 61982378475aSmrgstatic void 619914330f12Smrglt_error_core (int exit_status, const char *file, 620014330f12Smrg int line, const char *mode, 62012378475aSmrg const char *message, va_list ap) 62022378475aSmrg{ 620314330f12Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 62042378475aSmrg vfprintf (stderr, message, ap); 62052378475aSmrg fprintf (stderr, ".\n"); 620695b296d0Smrg 62072378475aSmrg if (exit_status >= 0) 62082378475aSmrg exit (exit_status); 62092378475aSmrg} 621095b296d0Smrg 62112378475aSmrgvoid 621214330f12Smrglt_fatal (const char *file, int line, const char *message, ...) 62132378475aSmrg{ 62142378475aSmrg va_list ap; 62152378475aSmrg va_start (ap, message); 621614330f12Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 62172378475aSmrg va_end (ap); 62182378475aSmrg} 621995b296d0Smrg 622014330f12Smrgstatic const char * 622114330f12Smrgnonnull (const char *s) 622214330f12Smrg{ 622314330f12Smrg return s ? s : "(null)"; 622414330f12Smrg} 622514330f12Smrg 622614330f12Smrgstatic const char * 622714330f12Smrgnonempty (const char *s) 622814330f12Smrg{ 622914330f12Smrg return (s && !*s) ? "(empty)" : nonnull (s); 623014330f12Smrg} 623114330f12Smrg 62322378475aSmrgvoid 62332378475aSmrglt_setenv (const char *name, const char *value) 62342378475aSmrg{ 623514330f12Smrg lt_debugprintf (__FILE__, __LINE__, 623614330f12Smrg "(lt_setenv) setting '%s' to '%s'\n", 623714330f12Smrg nonnull (name), nonnull (value)); 62382378475aSmrg { 62392378475aSmrg#ifdef HAVE_SETENV 62402378475aSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 62412378475aSmrg char *str = xstrdup (value); 62422378475aSmrg setenv (name, str, 1); 62432378475aSmrg#else 6244eca46af7Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 62452378475aSmrg char *str = XMALLOC (char, len); 62462378475aSmrg sprintf (str, "%s=%s", name, value); 62472378475aSmrg if (putenv (str) != EXIT_SUCCESS) 62482378475aSmrg { 62492378475aSmrg XFREE (str); 62502378475aSmrg } 62512378475aSmrg#endif 62522378475aSmrg } 62532378475aSmrg} 625495b296d0Smrg 62552378475aSmrgchar * 62562378475aSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 62572378475aSmrg{ 62582378475aSmrg char *new_value; 62592378475aSmrg if (orig_value && *orig_value) 62602378475aSmrg { 6261eca46af7Smrg size_t orig_value_len = strlen (orig_value); 6262eca46af7Smrg size_t add_len = strlen (add); 62632378475aSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 62642378475aSmrg if (to_end) 62652378475aSmrg { 62662378475aSmrg strcpy (new_value, orig_value); 62672378475aSmrg strcpy (new_value + orig_value_len, add); 62682378475aSmrg } 62692378475aSmrg else 62702378475aSmrg { 62712378475aSmrg strcpy (new_value, add); 62722378475aSmrg strcpy (new_value + add_len, orig_value); 62732378475aSmrg } 62742378475aSmrg } 62752378475aSmrg else 62762378475aSmrg { 62772378475aSmrg new_value = xstrdup (add); 62782378475aSmrg } 62792378475aSmrg return new_value; 62802378475aSmrg} 628195b296d0Smrg 62822378475aSmrgvoid 62832378475aSmrglt_update_exe_path (const char *name, const char *value) 62842378475aSmrg{ 628514330f12Smrg lt_debugprintf (__FILE__, __LINE__, 628614330f12Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 628714330f12Smrg nonnull (name), nonnull (value)); 628895b296d0Smrg 62892378475aSmrg if (name && *name && value && *value) 62902378475aSmrg { 62912378475aSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 62922378475aSmrg /* some systems can't cope with a ':'-terminated path #' */ 6293eca46af7Smrg size_t len = strlen (new_value); 6294eca46af7Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 62952378475aSmrg { 6296eca46af7Smrg new_value[--len] = '\0'; 62972378475aSmrg } 62982378475aSmrg lt_setenv (name, new_value); 62992378475aSmrg XFREE (new_value); 63002378475aSmrg } 63012378475aSmrg} 630295b296d0Smrg 63032378475aSmrgvoid 63042378475aSmrglt_update_lib_path (const char *name, const char *value) 63052378475aSmrg{ 630614330f12Smrg lt_debugprintf (__FILE__, __LINE__, 630714330f12Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 630814330f12Smrg nonnull (name), nonnull (value)); 630995b296d0Smrg 63102378475aSmrg if (name && *name && value && *value) 63112378475aSmrg { 63122378475aSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 63132378475aSmrg lt_setenv (name, new_value); 63142378475aSmrg XFREE (new_value); 63152378475aSmrg } 63162378475aSmrg} 631795b296d0Smrg 631814330f12SmrgEOF 631914330f12Smrg case $host_os in 632014330f12Smrg mingw*) 632114330f12Smrg cat <<"EOF" 632214330f12Smrg 632314330f12Smrg/* Prepares an argument vector before calling spawn(). 632414330f12Smrg Note that spawn() does not by itself call the command interpreter 632514330f12Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 632614330f12Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 632714330f12Smrg GetVersionEx(&v); 632814330f12Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 632914330f12Smrg }) ? "cmd.exe" : "command.com"). 633014330f12Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 633114330f12Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 633214330f12Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 633314330f12Smrg special way: 633414330f12Smrg - Space and tab are interpreted as delimiters. They are not treated as 633514330f12Smrg delimiters if they are surrounded by double quotes: "...". 633614330f12Smrg - Unescaped double quotes are removed from the input. Their only effect is 633714330f12Smrg that within double quotes, space and tab are treated like normal 633814330f12Smrg characters. 633914330f12Smrg - Backslashes not followed by double quotes are not special. 634014330f12Smrg - But 2*n+1 backslashes followed by a double quote become 634114330f12Smrg n backslashes followed by a double quote (n >= 0): 634214330f12Smrg \" -> " 634314330f12Smrg \\\" -> \" 634414330f12Smrg \\\\\" -> \\" 634514330f12Smrg */ 634614330f12Smrg#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" 634714330f12Smrg#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" 634814330f12Smrgchar ** 634914330f12Smrgprepare_spawn (char **argv) 635014330f12Smrg{ 635114330f12Smrg size_t argc; 635214330f12Smrg char **new_argv; 635314330f12Smrg size_t i; 635414330f12Smrg 635514330f12Smrg /* Count number of arguments. */ 635614330f12Smrg for (argc = 0; argv[argc] != NULL; argc++) 635714330f12Smrg ; 635814330f12Smrg 635914330f12Smrg /* Allocate new argument vector. */ 636014330f12Smrg new_argv = XMALLOC (char *, argc + 1); 636114330f12Smrg 636214330f12Smrg /* Put quoted arguments into the new argument vector. */ 636314330f12Smrg for (i = 0; i < argc; i++) 636414330f12Smrg { 636514330f12Smrg const char *string = argv[i]; 636614330f12Smrg 636714330f12Smrg if (string[0] == '\0') 636814330f12Smrg new_argv[i] = xstrdup ("\"\""); 636914330f12Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 637014330f12Smrg { 637114330f12Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 637214330f12Smrg size_t length; 637314330f12Smrg unsigned int backslashes; 637414330f12Smrg const char *s; 637514330f12Smrg char *quoted_string; 637614330f12Smrg char *p; 637714330f12Smrg 637814330f12Smrg length = 0; 637914330f12Smrg backslashes = 0; 638014330f12Smrg if (quote_around) 638114330f12Smrg length++; 638214330f12Smrg for (s = string; *s != '\0'; s++) 638314330f12Smrg { 638414330f12Smrg char c = *s; 638514330f12Smrg if (c == '"') 638614330f12Smrg length += backslashes + 1; 638714330f12Smrg length++; 638814330f12Smrg if (c == '\\') 638914330f12Smrg backslashes++; 639014330f12Smrg else 639114330f12Smrg backslashes = 0; 639214330f12Smrg } 639314330f12Smrg if (quote_around) 639414330f12Smrg length += backslashes + 1; 639514330f12Smrg 639614330f12Smrg quoted_string = XMALLOC (char, length + 1); 639714330f12Smrg 639814330f12Smrg p = quoted_string; 639914330f12Smrg backslashes = 0; 640014330f12Smrg if (quote_around) 640114330f12Smrg *p++ = '"'; 640214330f12Smrg for (s = string; *s != '\0'; s++) 640314330f12Smrg { 640414330f12Smrg char c = *s; 640514330f12Smrg if (c == '"') 640614330f12Smrg { 640714330f12Smrg unsigned int j; 640814330f12Smrg for (j = backslashes + 1; j > 0; j--) 640914330f12Smrg *p++ = '\\'; 641014330f12Smrg } 641114330f12Smrg *p++ = c; 641214330f12Smrg if (c == '\\') 641314330f12Smrg backslashes++; 641414330f12Smrg else 641514330f12Smrg backslashes = 0; 641614330f12Smrg } 641714330f12Smrg if (quote_around) 641814330f12Smrg { 641914330f12Smrg unsigned int j; 642014330f12Smrg for (j = backslashes; j > 0; j--) 642114330f12Smrg *p++ = '\\'; 642214330f12Smrg *p++ = '"'; 642314330f12Smrg } 642414330f12Smrg *p = '\0'; 642514330f12Smrg 642614330f12Smrg new_argv[i] = quoted_string; 642714330f12Smrg } 642814330f12Smrg else 642914330f12Smrg new_argv[i] = (char *) string; 643014330f12Smrg } 643114330f12Smrg new_argv[argc] = NULL; 643214330f12Smrg 643314330f12Smrg return new_argv; 643414330f12Smrg} 643514330f12SmrgEOF 643614330f12Smrg ;; 643714330f12Smrg esac 643814330f12Smrg 643914330f12Smrg cat <<"EOF" 644014330f12Smrgvoid lt_dump_script (FILE* f) 644114330f12Smrg{ 644214330f12SmrgEOF 644314330f12Smrg func_emit_wrapper yes | 6444eca46af7Smrg $SED -n -e ' 6445eca46af7Smrgs/^\(.\{79\}\)\(..*\)/\1\ 6446eca46af7Smrg\2/ 6447eca46af7Smrgh 6448eca46af7Smrgs/\([\\"]\)/\\\1/g 6449eca46af7Smrgs/$/\\n/ 6450eca46af7Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6451eca46af7Smrgg 6452eca46af7SmrgD' 645314330f12Smrg cat <<"EOF" 645414330f12Smrg} 64552378475aSmrgEOF 64562378475aSmrg} 64572378475aSmrg# end: func_emit_cwrapperexe_src 645895b296d0Smrg 645914330f12Smrg# func_win32_import_lib_p ARG 646014330f12Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 646114330f12Smrgfunc_win32_import_lib_p () 646214330f12Smrg{ 6463eca46af7Smrg $debug_cmd 6464eca46af7Smrg 646514330f12Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 646614330f12Smrg *import*) : ;; 646714330f12Smrg *) false ;; 646814330f12Smrg esac 646914330f12Smrg} 647014330f12Smrg 647189b0dc75Smrg# func_suncc_cstd_abi 647289b0dc75Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 647389b0dc75Smrg# Several compiler flags select an ABI that is incompatible with the 647489b0dc75Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 647589b0dc75Smrgfunc_suncc_cstd_abi () 647689b0dc75Smrg{ 647789b0dc75Smrg $debug_cmd 647889b0dc75Smrg 647989b0dc75Smrg case " $compile_command " in 648089b0dc75Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 648189b0dc75Smrg suncc_use_cstd_abi=no 648289b0dc75Smrg ;; 648389b0dc75Smrg *) 648489b0dc75Smrg suncc_use_cstd_abi=yes 648589b0dc75Smrg ;; 648689b0dc75Smrg esac 648789b0dc75Smrg} 648889b0dc75Smrg 64892378475aSmrg# func_mode_link arg... 64902378475aSmrgfunc_mode_link () 64912378475aSmrg{ 6492eca46af7Smrg $debug_cmd 6493eca46af7Smrg 64942378475aSmrg case $host in 64952378475aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 64962378475aSmrg # It is impossible to link a dll without this setting, and 64972378475aSmrg # we shouldn't force the makefile maintainer to figure out 6498eca46af7Smrg # what system we are compiling for in order to pass an extra 64992378475aSmrg # flag for every libtool invocation. 65002378475aSmrg # allow_undefined=no 650195b296d0Smrg 65022378475aSmrg # FIXME: Unfortunately, there are problems with the above when trying 6503eca46af7Smrg # to make a dll that has undefined symbols, in which case not 65042378475aSmrg # even a static library is built. For now, we need to specify 65052378475aSmrg # -no-undefined on the libtool link line when we can be certain 65062378475aSmrg # that all symbols are satisfied, otherwise we get a static library. 65072378475aSmrg allow_undefined=yes 65082378475aSmrg ;; 65092378475aSmrg *) 65102378475aSmrg allow_undefined=yes 65112378475aSmrg ;; 65122378475aSmrg esac 65132378475aSmrg libtool_args=$nonopt 65142378475aSmrg base_compile="$nonopt $@" 65152378475aSmrg compile_command=$nonopt 65162378475aSmrg finalize_command=$nonopt 651795b296d0Smrg 65182378475aSmrg compile_rpath= 65192378475aSmrg finalize_rpath= 65202378475aSmrg compile_shlibpath= 65212378475aSmrg finalize_shlibpath= 65222378475aSmrg convenience= 65232378475aSmrg old_convenience= 65242378475aSmrg deplibs= 65252378475aSmrg old_deplibs= 65262378475aSmrg compiler_flags= 65272378475aSmrg linker_flags= 65282378475aSmrg dllsearchpath= 65292378475aSmrg lib_search_path=`pwd` 65302378475aSmrg inst_prefix_dir= 65312378475aSmrg new_inherited_linker_flags= 653295b296d0Smrg 65332378475aSmrg avoid_version=no 653414330f12Smrg bindir= 65352378475aSmrg dlfiles= 65362378475aSmrg dlprefiles= 65372378475aSmrg dlself=no 65382378475aSmrg export_dynamic=no 65392378475aSmrg export_symbols= 65402378475aSmrg export_symbols_regex= 65412378475aSmrg generated= 65422378475aSmrg libobjs= 65432378475aSmrg ltlibs= 65442378475aSmrg module=no 65452378475aSmrg no_install=no 65462378475aSmrg objs= 6547eca46af7Smrg os2dllname= 65482378475aSmrg non_pic_objects= 65492378475aSmrg precious_files_regex= 65502378475aSmrg prefer_static_libs=no 6551eca46af7Smrg preload=false 65522378475aSmrg prev= 65532378475aSmrg prevarg= 65542378475aSmrg release= 65552378475aSmrg rpath= 65562378475aSmrg xrpath= 65572378475aSmrg perm_rpath= 65582378475aSmrg temp_rpath= 65592378475aSmrg thread_safe=no 65602378475aSmrg vinfo= 65612378475aSmrg vinfo_number=no 65622378475aSmrg weak_libs= 6563eca46af7Smrg single_module=$wl-single_module 65642378475aSmrg func_infer_tag $base_compile 65652378475aSmrg 65662378475aSmrg # We need to know -static, to get the right output filenames. 65672378475aSmrg for arg 65682378475aSmrg do 65692378475aSmrg case $arg in 65702378475aSmrg -shared) 6571eca46af7Smrg test yes != "$build_libtool_libs" \ 6572eca46af7Smrg && func_fatal_configuration "cannot build a shared library" 65732378475aSmrg build_old_libs=no 65742378475aSmrg break 65752378475aSmrg ;; 65762378475aSmrg -all-static | -static | -static-libtool-libs) 65772378475aSmrg case $arg in 65782378475aSmrg -all-static) 6579eca46af7Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 65802378475aSmrg func_warning "complete static linking is impossible in this configuration" 65812378475aSmrg fi 65822378475aSmrg if test -n "$link_static_flag"; then 65832378475aSmrg dlopen_self=$dlopen_self_static 65842378475aSmrg fi 65852378475aSmrg prefer_static_libs=yes 65862378475aSmrg ;; 65872378475aSmrg -static) 65882378475aSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 65892378475aSmrg dlopen_self=$dlopen_self_static 65902378475aSmrg fi 65912378475aSmrg prefer_static_libs=built 65922378475aSmrg ;; 65932378475aSmrg -static-libtool-libs) 65942378475aSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 65952378475aSmrg dlopen_self=$dlopen_self_static 6596e6f085baSmrg fi 65972378475aSmrg prefer_static_libs=yes 65982378475aSmrg ;; 65992378475aSmrg esac 66002378475aSmrg build_libtool_libs=no 66012378475aSmrg build_old_libs=yes 66022378475aSmrg break 66032378475aSmrg ;; 66042378475aSmrg esac 66052378475aSmrg done 660695b296d0Smrg 66072378475aSmrg # See if our shared archives depend on static archives. 66082378475aSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 660995b296d0Smrg 66102378475aSmrg # Go through the arguments, transforming them on the way. 66112378475aSmrg while test "$#" -gt 0; do 6612eca46af7Smrg arg=$1 66132378475aSmrg shift 66142378475aSmrg func_quote_for_eval "$arg" 66152378475aSmrg qarg=$func_quote_for_eval_unquoted_result 66162378475aSmrg func_append libtool_args " $func_quote_for_eval_result" 661795b296d0Smrg 66182378475aSmrg # If the previous option needs an argument, assign it. 66192378475aSmrg if test -n "$prev"; then 66202378475aSmrg case $prev in 66212378475aSmrg output) 66222378475aSmrg func_append compile_command " @OUTPUT@" 66232378475aSmrg func_append finalize_command " @OUTPUT@" 66242378475aSmrg ;; 66252378475aSmrg esac 662695b296d0Smrg 66272378475aSmrg case $prev in 662814330f12Smrg bindir) 6629eca46af7Smrg bindir=$arg 663014330f12Smrg prev= 663114330f12Smrg continue 663214330f12Smrg ;; 66332378475aSmrg dlfiles|dlprefiles) 6634eca46af7Smrg $preload || { 66352378475aSmrg # Add the symbol object into the linking commands. 66362378475aSmrg func_append compile_command " @SYMFILE@" 66372378475aSmrg func_append finalize_command " @SYMFILE@" 6638eca46af7Smrg preload=: 6639eca46af7Smrg } 66402378475aSmrg case $arg in 66412378475aSmrg *.la | *.lo) ;; # We handle these cases below. 66422378475aSmrg force) 6643eca46af7Smrg if test no = "$dlself"; then 66442378475aSmrg dlself=needless 66452378475aSmrg export_dynamic=yes 66462378475aSmrg fi 66472378475aSmrg prev= 66482378475aSmrg continue 66492378475aSmrg ;; 66502378475aSmrg self) 6651eca46af7Smrg if test dlprefiles = "$prev"; then 66522378475aSmrg dlself=yes 6653eca46af7Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 66542378475aSmrg dlself=yes 6655e6f085baSmrg else 66562378475aSmrg dlself=needless 66572378475aSmrg export_dynamic=yes 6658e6f085baSmrg fi 66592378475aSmrg prev= 66602378475aSmrg continue 66612378475aSmrg ;; 66622378475aSmrg *) 6663eca46af7Smrg if test dlfiles = "$prev"; then 666414330f12Smrg func_append dlfiles " $arg" 6665e6f085baSmrg else 666614330f12Smrg func_append dlprefiles " $arg" 6667e6f085baSmrg fi 66682378475aSmrg prev= 66692378475aSmrg continue 66702378475aSmrg ;; 66712378475aSmrg esac 66722378475aSmrg ;; 66732378475aSmrg expsyms) 6674eca46af7Smrg export_symbols=$arg 66752378475aSmrg test -f "$arg" \ 6676eca46af7Smrg || func_fatal_error "symbol file '$arg' does not exist" 66772378475aSmrg prev= 66782378475aSmrg continue 66792378475aSmrg ;; 66802378475aSmrg expsyms_regex) 6681eca46af7Smrg export_symbols_regex=$arg 66822378475aSmrg prev= 66832378475aSmrg continue 66842378475aSmrg ;; 66852378475aSmrg framework) 6686e6f085baSmrg case $host in 66872378475aSmrg *-*-darwin*) 66882378475aSmrg case "$deplibs " in 66892378475aSmrg *" $qarg.ltframework "*) ;; 669014330f12Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 66912378475aSmrg ;; 66922378475aSmrg esac 66932378475aSmrg ;; 6694e6f085baSmrg esac 66952378475aSmrg prev= 66962378475aSmrg continue 6697e6f085baSmrg ;; 66982378475aSmrg inst_prefix) 6699eca46af7Smrg inst_prefix_dir=$arg 6700eca46af7Smrg prev= 6701eca46af7Smrg continue 6702eca46af7Smrg ;; 6703eca46af7Smrg mllvm) 6704eca46af7Smrg # Clang does not use LLVM to link, so we can simply discard any 6705eca46af7Smrg # '-mllvm $arg' options when doing the link step. 67062378475aSmrg prev= 67072378475aSmrg continue 6708e6f085baSmrg ;; 67092378475aSmrg objectlist) 67102378475aSmrg if test -f "$arg"; then 67112378475aSmrg save_arg=$arg 67122378475aSmrg moreargs= 67132378475aSmrg for fil in `cat "$save_arg"` 67142378475aSmrg do 671514330f12Smrg# func_append moreargs " $fil" 67162378475aSmrg arg=$fil 67172378475aSmrg # A libtool-controlled object. 671895b296d0Smrg 67192378475aSmrg # Check to see that this really is a libtool object. 67202378475aSmrg if func_lalib_unsafe_p "$arg"; then 67212378475aSmrg pic_object= 67222378475aSmrg non_pic_object= 672339713583Smrg 67242378475aSmrg # Read the .lo file 67252378475aSmrg func_source "$arg" 672639713583Smrg 67272378475aSmrg if test -z "$pic_object" || 67282378475aSmrg test -z "$non_pic_object" || 6729eca46af7Smrg test none = "$pic_object" && 6730eca46af7Smrg test none = "$non_pic_object"; then 6731eca46af7Smrg func_fatal_error "cannot find name of object for '$arg'" 67322378475aSmrg fi 673339713583Smrg 67342378475aSmrg # Extract subdirectory from the argument. 67352378475aSmrg func_dirname "$arg" "/" "" 6736eca46af7Smrg xdir=$func_dirname_result 673739713583Smrg 6738eca46af7Smrg if test none != "$pic_object"; then 67392378475aSmrg # Prepend the subdirectory the object is found in. 6740eca46af7Smrg pic_object=$xdir$pic_object 674139713583Smrg 6742eca46af7Smrg if test dlfiles = "$prev"; then 6743eca46af7Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 674414330f12Smrg func_append dlfiles " $pic_object" 67452378475aSmrg prev= 67462378475aSmrg continue 67472378475aSmrg else 67482378475aSmrg # If libtool objects are unsupported, then we need to preload. 67492378475aSmrg prev=dlprefiles 67502378475aSmrg fi 67512378475aSmrg fi 675239713583Smrg 67532378475aSmrg # CHECK ME: I think I busted this. -Ossama 6754eca46af7Smrg if test dlprefiles = "$prev"; then 67552378475aSmrg # Preload the old-style object. 675614330f12Smrg func_append dlprefiles " $pic_object" 67572378475aSmrg prev= 67582378475aSmrg fi 675939713583Smrg 67602378475aSmrg # A PIC object. 67612378475aSmrg func_append libobjs " $pic_object" 6762eca46af7Smrg arg=$pic_object 67632378475aSmrg fi 676439713583Smrg 67652378475aSmrg # Non-PIC object. 6766eca46af7Smrg if test none != "$non_pic_object"; then 67672378475aSmrg # Prepend the subdirectory the object is found in. 6768eca46af7Smrg non_pic_object=$xdir$non_pic_object 676939713583Smrg 67702378475aSmrg # A standard non-PIC object 67712378475aSmrg func_append non_pic_objects " $non_pic_object" 6772eca46af7Smrg if test -z "$pic_object" || test none = "$pic_object"; then 6773eca46af7Smrg arg=$non_pic_object 67742378475aSmrg fi 67752378475aSmrg else 67762378475aSmrg # If the PIC object exists, use it instead. 67772378475aSmrg # $xdir was prepended to $pic_object above. 6778eca46af7Smrg non_pic_object=$pic_object 67792378475aSmrg func_append non_pic_objects " $non_pic_object" 67802378475aSmrg fi 67812378475aSmrg else 67822378475aSmrg # Only an error if not doing a dry-run. 67832378475aSmrg if $opt_dry_run; then 67842378475aSmrg # Extract subdirectory from the argument. 67852378475aSmrg func_dirname "$arg" "/" "" 6786eca46af7Smrg xdir=$func_dirname_result 67872378475aSmrg 67882378475aSmrg func_lo2o "$arg" 67892378475aSmrg pic_object=$xdir$objdir/$func_lo2o_result 67902378475aSmrg non_pic_object=$xdir$func_lo2o_result 67912378475aSmrg func_append libobjs " $pic_object" 67922378475aSmrg func_append non_pic_objects " $non_pic_object" 67932378475aSmrg else 6794eca46af7Smrg func_fatal_error "'$arg' is not a valid libtool object" 67952378475aSmrg fi 67962378475aSmrg fi 67972378475aSmrg done 6798e6f085baSmrg else 6799eca46af7Smrg func_fatal_error "link input file '$arg' does not exist" 6800e6f085baSmrg fi 68012378475aSmrg arg=$save_arg 68022378475aSmrg prev= 68032378475aSmrg continue 68042378475aSmrg ;; 6805eca46af7Smrg os2dllname) 6806eca46af7Smrg os2dllname=$arg 6807eca46af7Smrg prev= 6808eca46af7Smrg continue 6809eca46af7Smrg ;; 68102378475aSmrg precious_regex) 6811eca46af7Smrg precious_files_regex=$arg 68122378475aSmrg prev= 68132378475aSmrg continue 68142378475aSmrg ;; 68152378475aSmrg release) 6816eca46af7Smrg release=-$arg 68172378475aSmrg prev= 68182378475aSmrg continue 68192378475aSmrg ;; 68202378475aSmrg rpath | xrpath) 68212378475aSmrg # We need an absolute path. 68222378475aSmrg case $arg in 68232378475aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 68242378475aSmrg *) 68252378475aSmrg func_fatal_error "only absolute run-paths are allowed" 68262378475aSmrg ;; 68272378475aSmrg esac 6828eca46af7Smrg if test rpath = "$prev"; then 68292378475aSmrg case "$rpath " in 68302378475aSmrg *" $arg "*) ;; 683114330f12Smrg *) func_append rpath " $arg" ;; 68322378475aSmrg esac 6833e6f085baSmrg else 68342378475aSmrg case "$xrpath " in 68352378475aSmrg *" $arg "*) ;; 683614330f12Smrg *) func_append xrpath " $arg" ;; 68372378475aSmrg esac 6838e6f085baSmrg fi 68392378475aSmrg prev= 68402378475aSmrg continue 68412378475aSmrg ;; 68422378475aSmrg shrext) 6843eca46af7Smrg shrext_cmds=$arg 68442378475aSmrg prev= 68452378475aSmrg continue 68462378475aSmrg ;; 68472378475aSmrg weak) 684814330f12Smrg func_append weak_libs " $arg" 68492378475aSmrg prev= 68502378475aSmrg continue 68512378475aSmrg ;; 68522378475aSmrg xcclinker) 685314330f12Smrg func_append linker_flags " $qarg" 685414330f12Smrg func_append compiler_flags " $qarg" 68552378475aSmrg prev= 68562378475aSmrg func_append compile_command " $qarg" 68572378475aSmrg func_append finalize_command " $qarg" 68582378475aSmrg continue 68592378475aSmrg ;; 68602378475aSmrg xcompiler) 686114330f12Smrg func_append compiler_flags " $qarg" 68622378475aSmrg prev= 68632378475aSmrg func_append compile_command " $qarg" 68642378475aSmrg func_append finalize_command " $qarg" 68652378475aSmrg continue 68662378475aSmrg ;; 68672378475aSmrg xlinker) 686814330f12Smrg func_append linker_flags " $qarg" 686914330f12Smrg func_append compiler_flags " $wl$qarg" 68702378475aSmrg prev= 68712378475aSmrg func_append compile_command " $wl$qarg" 68722378475aSmrg func_append finalize_command " $wl$qarg" 68732378475aSmrg continue 68742378475aSmrg ;; 68752378475aSmrg *) 68762378475aSmrg eval "$prev=\"\$arg\"" 68772378475aSmrg prev= 68782378475aSmrg continue 68792378475aSmrg ;; 688039713583Smrg esac 68812378475aSmrg fi # test -n "$prev" 688239713583Smrg 6883eca46af7Smrg prevarg=$arg 688439713583Smrg 68852378475aSmrg case $arg in 68862378475aSmrg -all-static) 68872378475aSmrg if test -n "$link_static_flag"; then 68882378475aSmrg # See comment for -static flag below, for more details. 68892378475aSmrg func_append compile_command " $link_static_flag" 68902378475aSmrg func_append finalize_command " $link_static_flag" 68912378475aSmrg fi 68922378475aSmrg continue 68932378475aSmrg ;; 689439713583Smrg 68952378475aSmrg -allow-undefined) 68962378475aSmrg # FIXME: remove this flag sometime in the future. 6897eca46af7Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 68982378475aSmrg ;; 689939713583Smrg 69002378475aSmrg -avoid-version) 69012378475aSmrg avoid_version=yes 69022378475aSmrg continue 69032378475aSmrg ;; 690439713583Smrg 690514330f12Smrg -bindir) 690614330f12Smrg prev=bindir 690714330f12Smrg continue 690814330f12Smrg ;; 690914330f12Smrg 69102378475aSmrg -dlopen) 69112378475aSmrg prev=dlfiles 69122378475aSmrg continue 69132378475aSmrg ;; 691439713583Smrg 69152378475aSmrg -dlpreopen) 69162378475aSmrg prev=dlprefiles 69172378475aSmrg continue 69182378475aSmrg ;; 691939713583Smrg 69202378475aSmrg -export-dynamic) 69212378475aSmrg export_dynamic=yes 69222378475aSmrg continue 69232378475aSmrg ;; 692439713583Smrg 69252378475aSmrg -export-symbols | -export-symbols-regex) 69262378475aSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 69272378475aSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 69282378475aSmrg fi 6929eca46af7Smrg if test X-export-symbols = "X$arg"; then 69302378475aSmrg prev=expsyms 69312378475aSmrg else 69322378475aSmrg prev=expsyms_regex 69332378475aSmrg fi 69342378475aSmrg continue 69352378475aSmrg ;; 693639713583Smrg 69372378475aSmrg -framework) 69382378475aSmrg prev=framework 69392378475aSmrg continue 69402378475aSmrg ;; 694139713583Smrg 69422378475aSmrg -inst-prefix-dir) 69432378475aSmrg prev=inst_prefix 69442378475aSmrg continue 69452378475aSmrg ;; 694639713583Smrg 69472378475aSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 69482378475aSmrg # so, if we see these flags be careful not to treat them like -L 69492378475aSmrg -L[A-Z][A-Z]*:*) 69502378475aSmrg case $with_gcc/$host in 69512378475aSmrg no/*-*-irix* | /*-*-irix*) 69522378475aSmrg func_append compile_command " $arg" 69532378475aSmrg func_append finalize_command " $arg" 69542378475aSmrg ;; 69552378475aSmrg esac 69562378475aSmrg continue 69572378475aSmrg ;; 695839713583Smrg 69592378475aSmrg -L*) 696014330f12Smrg func_stripname "-L" '' "$arg" 696114330f12Smrg if test -z "$func_stripname_result"; then 69622378475aSmrg if test "$#" -gt 0; then 6963eca46af7Smrg func_fatal_error "require no space between '-L' and '$1'" 69642378475aSmrg else 6965eca46af7Smrg func_fatal_error "need path for '-L' option" 69662378475aSmrg fi 69672378475aSmrg fi 696814330f12Smrg func_resolve_sysroot "$func_stripname_result" 696914330f12Smrg dir=$func_resolve_sysroot_result 69702378475aSmrg # We need an absolute path. 69712378475aSmrg case $dir in 69722378475aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 69732378475aSmrg *) 69742378475aSmrg absdir=`cd "$dir" && pwd` 69752378475aSmrg test -z "$absdir" && \ 6976eca46af7Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 6977eca46af7Smrg dir=$absdir 69782378475aSmrg ;; 69792378475aSmrg esac 69802378475aSmrg case "$deplibs " in 698114330f12Smrg *" -L$dir "* | *" $arg "*) 698214330f12Smrg # Will only happen for absolute or sysroot arguments 698314330f12Smrg ;; 69842378475aSmrg *) 698514330f12Smrg # Preserve sysroot, but never include relative directories 698614330f12Smrg case $dir in 698714330f12Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 698814330f12Smrg *) func_append deplibs " -L$dir" ;; 698914330f12Smrg esac 699014330f12Smrg func_append lib_search_path " $dir" 69912378475aSmrg ;; 69922378475aSmrg esac 69932378475aSmrg case $host in 69942378475aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 699514330f12Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 69962378475aSmrg case :$dllsearchpath: in 69972378475aSmrg *":$dir:"*) ;; 69982378475aSmrg ::) dllsearchpath=$dir;; 699914330f12Smrg *) func_append dllsearchpath ":$dir";; 70002378475aSmrg esac 70012378475aSmrg case :$dllsearchpath: in 70022378475aSmrg *":$testbindir:"*) ;; 70032378475aSmrg ::) dllsearchpath=$testbindir;; 700414330f12Smrg *) func_append dllsearchpath ":$testbindir";; 70052378475aSmrg esac 70062378475aSmrg ;; 70072378475aSmrg esac 70082378475aSmrg continue 70092378475aSmrg ;; 701039713583Smrg 70112378475aSmrg -l*) 7012eca46af7Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 70132378475aSmrg case $host in 701414330f12Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 70152378475aSmrg # These systems don't actually have a C or math library (as such) 70162378475aSmrg continue 70172378475aSmrg ;; 70182378475aSmrg *-*-os2*) 70192378475aSmrg # These systems don't actually have a C library (as such) 7020eca46af7Smrg test X-lc = "X$arg" && continue 70212378475aSmrg ;; 7022eca46af7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 70232378475aSmrg # Do not include libc due to us having libc/libc_r. 7024eca46af7Smrg test X-lc = "X$arg" && continue 70252378475aSmrg ;; 70262378475aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 70272378475aSmrg # Rhapsody C and math libraries are in the System framework 702814330f12Smrg func_append deplibs " System.ltframework" 70292378475aSmrg continue 70302378475aSmrg ;; 70312378475aSmrg *-*-sco3.2v5* | *-*-sco5v6*) 70322378475aSmrg # Causes problems with __ctype 7033eca46af7Smrg test X-lc = "X$arg" && continue 70342378475aSmrg ;; 70352378475aSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 70362378475aSmrg # Compiler inserts libc in the correct place for threads to work 7037eca46af7Smrg test X-lc = "X$arg" && continue 70382378475aSmrg ;; 70392378475aSmrg esac 7040eca46af7Smrg elif test X-lc_r = "X$arg"; then 70412378475aSmrg case $host in 7042eca46af7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 70432378475aSmrg # Do not include libc_r directly, use -pthread flag. 70442378475aSmrg continue 70452378475aSmrg ;; 70462378475aSmrg esac 70472378475aSmrg fi 704814330f12Smrg func_append deplibs " $arg" 70492378475aSmrg continue 70502378475aSmrg ;; 705139713583Smrg 7052eca46af7Smrg -mllvm) 7053eca46af7Smrg prev=mllvm 7054eca46af7Smrg continue 7055eca46af7Smrg ;; 7056eca46af7Smrg 70572378475aSmrg -module) 70582378475aSmrg module=yes 70592378475aSmrg continue 70602378475aSmrg ;; 706139713583Smrg 70622378475aSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 70632378475aSmrg # classes, name mangling, and exception handling. 70642378475aSmrg # Darwin uses the -arch flag to determine output architecture. 706514330f12Smrg -model|-arch|-isysroot|--sysroot) 706614330f12Smrg func_append compiler_flags " $arg" 70672378475aSmrg func_append compile_command " $arg" 70682378475aSmrg func_append finalize_command " $arg" 70692378475aSmrg prev=xcompiler 70702378475aSmrg continue 70712378475aSmrg ;; 707239713583Smrg 7073eca46af7Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7074eca46af7Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 707514330f12Smrg func_append compiler_flags " $arg" 70762378475aSmrg func_append compile_command " $arg" 70772378475aSmrg func_append finalize_command " $arg" 70782378475aSmrg case "$new_inherited_linker_flags " in 70792378475aSmrg *" $arg "*) ;; 708014330f12Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 70812378475aSmrg esac 70822378475aSmrg continue 70832378475aSmrg ;; 708439713583Smrg 70852378475aSmrg -multi_module) 7086eca46af7Smrg single_module=$wl-multi_module 70872378475aSmrg continue 70882378475aSmrg ;; 708939713583Smrg 70902378475aSmrg -no-fast-install) 70912378475aSmrg fast_install=no 70922378475aSmrg continue 70932378475aSmrg ;; 709439713583Smrg 70952378475aSmrg -no-install) 70962378475aSmrg case $host in 70972378475aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 70982378475aSmrg # The PATH hackery in wrapper scripts is required on Windows 70992378475aSmrg # and Darwin in order for the loader to find any dlls it needs. 7100eca46af7Smrg func_warning "'-no-install' is ignored for $host" 7101eca46af7Smrg func_warning "assuming '-no-fast-install' instead" 71022378475aSmrg fast_install=no 71032378475aSmrg ;; 71042378475aSmrg *) no_install=yes ;; 71052378475aSmrg esac 71062378475aSmrg continue 71072378475aSmrg ;; 710839713583Smrg 71092378475aSmrg -no-undefined) 71102378475aSmrg allow_undefined=no 71112378475aSmrg continue 71122378475aSmrg ;; 711339713583Smrg 71142378475aSmrg -objectlist) 71152378475aSmrg prev=objectlist 71162378475aSmrg continue 71172378475aSmrg ;; 711839713583Smrg 7119eca46af7Smrg -os2dllname) 7120eca46af7Smrg prev=os2dllname 7121eca46af7Smrg continue 7122eca46af7Smrg ;; 7123eca46af7Smrg 71242378475aSmrg -o) prev=output ;; 712539713583Smrg 71262378475aSmrg -precious-files-regex) 71272378475aSmrg prev=precious_regex 71282378475aSmrg continue 71292378475aSmrg ;; 713039713583Smrg 71312378475aSmrg -release) 71322378475aSmrg prev=release 71332378475aSmrg continue 71342378475aSmrg ;; 713539713583Smrg 71362378475aSmrg -rpath) 71372378475aSmrg prev=rpath 71382378475aSmrg continue 71392378475aSmrg ;; 714039713583Smrg 71412378475aSmrg -R) 71422378475aSmrg prev=xrpath 71432378475aSmrg continue 71442378475aSmrg ;; 714539713583Smrg 71462378475aSmrg -R*) 71472378475aSmrg func_stripname '-R' '' "$arg" 71482378475aSmrg dir=$func_stripname_result 71492378475aSmrg # We need an absolute path. 71502378475aSmrg case $dir in 71512378475aSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 715214330f12Smrg =*) 715314330f12Smrg func_stripname '=' '' "$dir" 715414330f12Smrg dir=$lt_sysroot$func_stripname_result 715514330f12Smrg ;; 71562378475aSmrg *) 71572378475aSmrg func_fatal_error "only absolute run-paths are allowed" 71582378475aSmrg ;; 71592378475aSmrg esac 71602378475aSmrg case "$xrpath " in 71612378475aSmrg *" $dir "*) ;; 716214330f12Smrg *) func_append xrpath " $dir" ;; 71632378475aSmrg esac 71642378475aSmrg continue 71652378475aSmrg ;; 716639713583Smrg 71672378475aSmrg -shared) 71682378475aSmrg # The effects of -shared are defined in a previous loop. 71692378475aSmrg continue 71702378475aSmrg ;; 717139713583Smrg 71722378475aSmrg -shrext) 71732378475aSmrg prev=shrext 71742378475aSmrg continue 71752378475aSmrg ;; 717639713583Smrg 71772378475aSmrg -static | -static-libtool-libs) 71782378475aSmrg # The effects of -static are defined in a previous loop. 71792378475aSmrg # We used to do the same as -all-static on platforms that 71802378475aSmrg # didn't have a PIC flag, but the assumption that the effects 71812378475aSmrg # would be equivalent was wrong. It would break on at least 71822378475aSmrg # Digital Unix and AIX. 71832378475aSmrg continue 71842378475aSmrg ;; 718539713583Smrg 71862378475aSmrg -thread-safe) 71872378475aSmrg thread_safe=yes 71882378475aSmrg continue 71892378475aSmrg ;; 719039713583Smrg 71912378475aSmrg -version-info) 71922378475aSmrg prev=vinfo 71932378475aSmrg continue 71942378475aSmrg ;; 719539713583Smrg 71962378475aSmrg -version-number) 71972378475aSmrg prev=vinfo 71982378475aSmrg vinfo_number=yes 71992378475aSmrg continue 72002378475aSmrg ;; 720139713583Smrg 72022378475aSmrg -weak) 72032378475aSmrg prev=weak 72042378475aSmrg continue 72052378475aSmrg ;; 720695b296d0Smrg 72072378475aSmrg -Wc,*) 72082378475aSmrg func_stripname '-Wc,' '' "$arg" 72092378475aSmrg args=$func_stripname_result 72102378475aSmrg arg= 7211eca46af7Smrg save_ifs=$IFS; IFS=, 72122378475aSmrg for flag in $args; do 7213eca46af7Smrg IFS=$save_ifs 72142378475aSmrg func_quote_for_eval "$flag" 721514330f12Smrg func_append arg " $func_quote_for_eval_result" 721614330f12Smrg func_append compiler_flags " $func_quote_for_eval_result" 72172378475aSmrg done 7218eca46af7Smrg IFS=$save_ifs 72192378475aSmrg func_stripname ' ' '' "$arg" 72202378475aSmrg arg=$func_stripname_result 72212378475aSmrg ;; 7222e6f085baSmrg 72232378475aSmrg -Wl,*) 72242378475aSmrg func_stripname '-Wl,' '' "$arg" 72252378475aSmrg args=$func_stripname_result 72262378475aSmrg arg= 7227eca46af7Smrg save_ifs=$IFS; IFS=, 72282378475aSmrg for flag in $args; do 7229eca46af7Smrg IFS=$save_ifs 72302378475aSmrg func_quote_for_eval "$flag" 723114330f12Smrg func_append arg " $wl$func_quote_for_eval_result" 723214330f12Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 723314330f12Smrg func_append linker_flags " $func_quote_for_eval_result" 72342378475aSmrg done 7235eca46af7Smrg IFS=$save_ifs 72362378475aSmrg func_stripname ' ' '' "$arg" 72372378475aSmrg arg=$func_stripname_result 72382378475aSmrg ;; 7239e6f085baSmrg 72402378475aSmrg -Xcompiler) 72412378475aSmrg prev=xcompiler 72422378475aSmrg continue 72432378475aSmrg ;; 7244e6f085baSmrg 72452378475aSmrg -Xlinker) 72462378475aSmrg prev=xlinker 72472378475aSmrg continue 72482378475aSmrg ;; 7249e6f085baSmrg 72502378475aSmrg -XCClinker) 72512378475aSmrg prev=xcclinker 72522378475aSmrg continue 72532378475aSmrg ;; 7254e6f085baSmrg 72552378475aSmrg # -msg_* for osf cc 72562378475aSmrg -msg_*) 72572378475aSmrg func_quote_for_eval "$arg" 7258eca46af7Smrg arg=$func_quote_for_eval_result 72592378475aSmrg ;; 7260e6f085baSmrg 726114330f12Smrg # Flags to be passed through unchanged, with rationale: 726214330f12Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 726314330f12Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 726414330f12Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 726514330f12Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 726614330f12Smrg # -q* compiler args for the IBM compiler 726714330f12Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 726814330f12Smrg # -F/path path to uninstalled frameworks, gcc on darwin 726914330f12Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7270eca46af7Smrg # -fstack-protector* stack protector flags for GCC 727114330f12Smrg # @file GCC response files 727214330f12Smrg # -tp=* Portland pgcc target processor selection 727314330f12Smrg # --sysroot=* for sysroot support 7274eca46af7Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7275eca46af7Smrg # -stdlib=* select c++ std lib with clang 72762378475aSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 727714330f12Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7278eca46af7Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 72792378475aSmrg func_quote_for_eval "$arg" 7280eca46af7Smrg arg=$func_quote_for_eval_result 72812378475aSmrg func_append compile_command " $arg" 72822378475aSmrg func_append finalize_command " $arg" 728314330f12Smrg func_append compiler_flags " $arg" 72842378475aSmrg continue 72852378475aSmrg ;; 7286e6f085baSmrg 7287eca46af7Smrg -Z*) 7288eca46af7Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7289eca46af7Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 7290eca46af7Smrg compiler_flags="$compiler_flags $arg" 7291eca46af7Smrg func_append compile_command " $arg" 7292eca46af7Smrg func_append finalize_command " $arg" 7293eca46af7Smrg case $arg in 7294eca46af7Smrg -Zlinker | -Zstack) 7295eca46af7Smrg prev=xcompiler 7296eca46af7Smrg ;; 7297eca46af7Smrg esac 7298eca46af7Smrg continue 7299eca46af7Smrg else 7300eca46af7Smrg # Otherwise treat like 'Some other compiler flag' below 7301eca46af7Smrg func_quote_for_eval "$arg" 7302eca46af7Smrg arg=$func_quote_for_eval_result 7303eca46af7Smrg fi 7304eca46af7Smrg ;; 7305eca46af7Smrg 73062378475aSmrg # Some other compiler flag. 73072378475aSmrg -* | +*) 73082378475aSmrg func_quote_for_eval "$arg" 7309eca46af7Smrg arg=$func_quote_for_eval_result 73102378475aSmrg ;; 7311e6f085baSmrg 73122378475aSmrg *.$objext) 73132378475aSmrg # A standard object. 731414330f12Smrg func_append objs " $arg" 73152378475aSmrg ;; 7316e6f085baSmrg 73172378475aSmrg *.lo) 73182378475aSmrg # A libtool-controlled object. 7319e6f085baSmrg 73202378475aSmrg # Check to see that this really is a libtool object. 73212378475aSmrg if func_lalib_unsafe_p "$arg"; then 73222378475aSmrg pic_object= 73232378475aSmrg non_pic_object= 7324e6f085baSmrg 73252378475aSmrg # Read the .lo file 73262378475aSmrg func_source "$arg" 7327e6f085baSmrg 73282378475aSmrg if test -z "$pic_object" || 73292378475aSmrg test -z "$non_pic_object" || 7330eca46af7Smrg test none = "$pic_object" && 7331eca46af7Smrg test none = "$non_pic_object"; then 7332eca46af7Smrg func_fatal_error "cannot find name of object for '$arg'" 73332378475aSmrg fi 7334e6f085baSmrg 73352378475aSmrg # Extract subdirectory from the argument. 73362378475aSmrg func_dirname "$arg" "/" "" 7337eca46af7Smrg xdir=$func_dirname_result 7338e6f085baSmrg 7339eca46af7Smrg test none = "$pic_object" || { 73402378475aSmrg # Prepend the subdirectory the object is found in. 7341eca46af7Smrg pic_object=$xdir$pic_object 7342e6f085baSmrg 7343eca46af7Smrg if test dlfiles = "$prev"; then 7344eca46af7Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 734514330f12Smrg func_append dlfiles " $pic_object" 73462378475aSmrg prev= 73472378475aSmrg continue 73482378475aSmrg else 73492378475aSmrg # If libtool objects are unsupported, then we need to preload. 73502378475aSmrg prev=dlprefiles 73512378475aSmrg fi 73522378475aSmrg fi 7353e6f085baSmrg 73542378475aSmrg # CHECK ME: I think I busted this. -Ossama 7355eca46af7Smrg if test dlprefiles = "$prev"; then 73562378475aSmrg # Preload the old-style object. 735714330f12Smrg func_append dlprefiles " $pic_object" 73582378475aSmrg prev= 73592378475aSmrg fi 736095b296d0Smrg 73612378475aSmrg # A PIC object. 73622378475aSmrg func_append libobjs " $pic_object" 7363eca46af7Smrg arg=$pic_object 7364eca46af7Smrg } 736595b296d0Smrg 73662378475aSmrg # Non-PIC object. 7367eca46af7Smrg if test none != "$non_pic_object"; then 73682378475aSmrg # Prepend the subdirectory the object is found in. 7369eca46af7Smrg non_pic_object=$xdir$non_pic_object 737095b296d0Smrg 73712378475aSmrg # A standard non-PIC object 73722378475aSmrg func_append non_pic_objects " $non_pic_object" 7373eca46af7Smrg if test -z "$pic_object" || test none = "$pic_object"; then 7374eca46af7Smrg arg=$non_pic_object 73752378475aSmrg fi 73762378475aSmrg else 73772378475aSmrg # If the PIC object exists, use it instead. 73782378475aSmrg # $xdir was prepended to $pic_object above. 7379eca46af7Smrg non_pic_object=$pic_object 73802378475aSmrg func_append non_pic_objects " $non_pic_object" 73812378475aSmrg fi 73822378475aSmrg else 73832378475aSmrg # Only an error if not doing a dry-run. 73842378475aSmrg if $opt_dry_run; then 73852378475aSmrg # Extract subdirectory from the argument. 73862378475aSmrg func_dirname "$arg" "/" "" 7387eca46af7Smrg xdir=$func_dirname_result 73882378475aSmrg 73892378475aSmrg func_lo2o "$arg" 73902378475aSmrg pic_object=$xdir$objdir/$func_lo2o_result 73912378475aSmrg non_pic_object=$xdir$func_lo2o_result 73922378475aSmrg func_append libobjs " $pic_object" 73932378475aSmrg func_append non_pic_objects " $non_pic_object" 73942378475aSmrg else 7395eca46af7Smrg func_fatal_error "'$arg' is not a valid libtool object" 73962378475aSmrg fi 73972378475aSmrg fi 73982378475aSmrg ;; 739995b296d0Smrg 74002378475aSmrg *.$libext) 74012378475aSmrg # An archive. 740214330f12Smrg func_append deplibs " $arg" 740314330f12Smrg func_append old_deplibs " $arg" 74042378475aSmrg continue 74052378475aSmrg ;; 74062378475aSmrg 74072378475aSmrg *.la) 74082378475aSmrg # A libtool-controlled library. 74092378475aSmrg 741014330f12Smrg func_resolve_sysroot "$arg" 7411eca46af7Smrg if test dlfiles = "$prev"; then 74122378475aSmrg # This library was specified with -dlopen. 741314330f12Smrg func_append dlfiles " $func_resolve_sysroot_result" 74142378475aSmrg prev= 7415eca46af7Smrg elif test dlprefiles = "$prev"; then 74162378475aSmrg # The library was specified with -dlpreopen. 741714330f12Smrg func_append dlprefiles " $func_resolve_sysroot_result" 74182378475aSmrg prev= 74192378475aSmrg else 742014330f12Smrg func_append deplibs " $func_resolve_sysroot_result" 74212378475aSmrg fi 74222378475aSmrg continue 74232378475aSmrg ;; 74242378475aSmrg 74252378475aSmrg # Some other compiler argument. 74262378475aSmrg *) 74272378475aSmrg # Unknown arguments in both finalize_command and compile_command need 74282378475aSmrg # to be aesthetically quoted because they are evaled later. 74292378475aSmrg func_quote_for_eval "$arg" 7430eca46af7Smrg arg=$func_quote_for_eval_result 74312378475aSmrg ;; 74322378475aSmrg esac # arg 74332378475aSmrg 74342378475aSmrg # Now actually substitute the argument into the commands. 74352378475aSmrg if test -n "$arg"; then 74362378475aSmrg func_append compile_command " $arg" 74372378475aSmrg func_append finalize_command " $arg" 74382378475aSmrg fi 74392378475aSmrg done # argument parsing loop 74402378475aSmrg 74412378475aSmrg test -n "$prev" && \ 7442eca46af7Smrg func_fatal_help "the '$prevarg' option requires an argument" 74432378475aSmrg 7444eca46af7Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 74452378475aSmrg eval arg=\"$export_dynamic_flag_spec\" 74462378475aSmrg func_append compile_command " $arg" 74472378475aSmrg func_append finalize_command " $arg" 74482378475aSmrg fi 74492378475aSmrg 74502378475aSmrg oldlibs= 74512378475aSmrg # calculate the name of the file, without its directory 74522378475aSmrg func_basename "$output" 7453eca46af7Smrg outputname=$func_basename_result 7454eca46af7Smrg libobjs_save=$libobjs 74552378475aSmrg 74562378475aSmrg if test -n "$shlibpath_var"; then 74572378475aSmrg # get the directories listed in $shlibpath_var 7458eca46af7Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 74592378475aSmrg else 74602378475aSmrg shlib_search_path= 74612378475aSmrg fi 74622378475aSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 74632378475aSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 74642378475aSmrg 746589b0dc75Smrg # Definition is injected by LT_CONFIG during libtool generation. 746689b0dc75Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 746789b0dc75Smrg 74682378475aSmrg func_dirname "$output" "/" "" 7469eca46af7Smrg output_objdir=$func_dirname_result$objdir 747014330f12Smrg func_to_tool_file "$output_objdir/" 747114330f12Smrg tool_output_objdir=$func_to_tool_file_result 74722378475aSmrg # Create the object directory. 74732378475aSmrg func_mkdir_p "$output_objdir" 74742378475aSmrg 74752378475aSmrg # Determine the type of output 74762378475aSmrg case $output in 74772378475aSmrg "") 74782378475aSmrg func_fatal_help "you must specify an output file" 74792378475aSmrg ;; 74802378475aSmrg *.$libext) linkmode=oldlib ;; 74812378475aSmrg *.lo | *.$objext) linkmode=obj ;; 74822378475aSmrg *.la) linkmode=lib ;; 74832378475aSmrg *) linkmode=prog ;; # Anything else should be a program. 74842378475aSmrg esac 74852378475aSmrg 74862378475aSmrg specialdeplibs= 74872378475aSmrg 74882378475aSmrg libs= 74892378475aSmrg # Find all interdependent deplibs by searching for libraries 74902378475aSmrg # that are linked more than once (e.g. -la -lb -la) 74912378475aSmrg for deplib in $deplibs; do 7492eca46af7Smrg if $opt_preserve_dup_deps; then 74932378475aSmrg case "$libs " in 749414330f12Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 74952378475aSmrg esac 74962378475aSmrg fi 749714330f12Smrg func_append libs " $deplib" 74982378475aSmrg done 74992378475aSmrg 7500eca46af7Smrg if test lib = "$linkmode"; then 75012378475aSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 75022378475aSmrg 75032378475aSmrg # Compute libraries that are listed more than once in $predeps 75042378475aSmrg # $postdeps and mark them as special (i.e., whose duplicates are 75052378475aSmrg # not to be eliminated). 75062378475aSmrg pre_post_deps= 75072378475aSmrg if $opt_duplicate_compiler_generated_deps; then 75082378475aSmrg for pre_post_dep in $predeps $postdeps; do 75092378475aSmrg case "$pre_post_deps " in 751014330f12Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 75112378475aSmrg esac 751214330f12Smrg func_append pre_post_deps " $pre_post_dep" 75132378475aSmrg done 75142378475aSmrg fi 75152378475aSmrg pre_post_deps= 75162378475aSmrg fi 75172378475aSmrg 75182378475aSmrg deplibs= 75192378475aSmrg newdependency_libs= 75202378475aSmrg newlib_search_path= 75212378475aSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 75222378475aSmrg notinst_deplibs= # not-installed libtool libraries 75232378475aSmrg notinst_path= # paths that contain not-installed libtool libraries 75242378475aSmrg 75252378475aSmrg case $linkmode in 75262378475aSmrg lib) 75272378475aSmrg passes="conv dlpreopen link" 75282378475aSmrg for file in $dlfiles $dlprefiles; do 75292378475aSmrg case $file in 75302378475aSmrg *.la) ;; 75312378475aSmrg *) 7532eca46af7Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 75332378475aSmrg ;; 75342378475aSmrg esac 75352378475aSmrg done 75362378475aSmrg ;; 75372378475aSmrg prog) 75382378475aSmrg compile_deplibs= 75392378475aSmrg finalize_deplibs= 7540eca46af7Smrg alldeplibs=false 75412378475aSmrg newdlfiles= 75422378475aSmrg newdlprefiles= 75432378475aSmrg passes="conv scan dlopen dlpreopen link" 75442378475aSmrg ;; 75452378475aSmrg *) passes="conv" 75462378475aSmrg ;; 75472378475aSmrg esac 75482378475aSmrg 75492378475aSmrg for pass in $passes; do 75502378475aSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 75512378475aSmrg # so that -L comes before libs that need it for instance... 7552eca46af7Smrg if test lib,link = "$linkmode,$pass"; then 75532378475aSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 75542378475aSmrg ## order, and fix it there properly 75552378475aSmrg tmp_deplibs= 75562378475aSmrg for deplib in $deplibs; do 75572378475aSmrg tmp_deplibs="$deplib $tmp_deplibs" 75582378475aSmrg done 7559eca46af7Smrg deplibs=$tmp_deplibs 75602378475aSmrg fi 75612378475aSmrg 7562eca46af7Smrg if test lib,link = "$linkmode,$pass" || 7563eca46af7Smrg test prog,scan = "$linkmode,$pass"; then 7564eca46af7Smrg libs=$deplibs 75652378475aSmrg deplibs= 75662378475aSmrg fi 7567eca46af7Smrg if test prog = "$linkmode"; then 75682378475aSmrg case $pass in 7569eca46af7Smrg dlopen) libs=$dlfiles ;; 7570eca46af7Smrg dlpreopen) libs=$dlprefiles ;; 75712378475aSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 75722378475aSmrg esac 75732378475aSmrg fi 7574eca46af7Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 75752378475aSmrg # Collect and forward deplibs of preopened libtool libs 75762378475aSmrg for lib in $dlprefiles; do 75772378475aSmrg # Ignore non-libtool-libs 75782378475aSmrg dependency_libs= 757914330f12Smrg func_resolve_sysroot "$lib" 75802378475aSmrg case $lib in 758114330f12Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 75822378475aSmrg esac 75832378475aSmrg 75842378475aSmrg # Collect preopened libtool deplibs, except any this library 75852378475aSmrg # has declared as weak libs 75862378475aSmrg for deplib in $dependency_libs; do 758714330f12Smrg func_basename "$deplib" 758814330f12Smrg deplib_base=$func_basename_result 75892378475aSmrg case " $weak_libs " in 75902378475aSmrg *" $deplib_base "*) ;; 759114330f12Smrg *) func_append deplibs " $deplib" ;; 75922378475aSmrg esac 75932378475aSmrg done 75942378475aSmrg done 7595eca46af7Smrg libs=$dlprefiles 75962378475aSmrg fi 7597eca46af7Smrg if test dlopen = "$pass"; then 75982378475aSmrg # Collect dlpreopened libraries 7599eca46af7Smrg save_deplibs=$deplibs 76002378475aSmrg deplibs= 76012378475aSmrg fi 76022378475aSmrg 76032378475aSmrg for deplib in $libs; do 76042378475aSmrg lib= 7605eca46af7Smrg found=false 76062378475aSmrg case $deplib in 7607eca46af7Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7608eca46af7Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7609eca46af7Smrg if test prog,link = "$linkmode,$pass"; then 76102378475aSmrg compile_deplibs="$deplib $compile_deplibs" 76112378475aSmrg finalize_deplibs="$deplib $finalize_deplibs" 76122378475aSmrg else 761314330f12Smrg func_append compiler_flags " $deplib" 7614eca46af7Smrg if test lib = "$linkmode"; then 76152378475aSmrg case "$new_inherited_linker_flags " in 76162378475aSmrg *" $deplib "*) ;; 761714330f12Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 76182378475aSmrg esac 76192378475aSmrg fi 76202378475aSmrg fi 76212378475aSmrg continue 76222378475aSmrg ;; 76232378475aSmrg -l*) 7624eca46af7Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7625eca46af7Smrg func_warning "'-l' is ignored for archives/objects" 76262378475aSmrg continue 76272378475aSmrg fi 76282378475aSmrg func_stripname '-l' '' "$deplib" 76292378475aSmrg name=$func_stripname_result 7630eca46af7Smrg if test lib = "$linkmode"; then 76312378475aSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 76322378475aSmrg else 76332378475aSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 76342378475aSmrg fi 76352378475aSmrg for searchdir in $searchdirs; do 76362378475aSmrg for search_ext in .la $std_shrext .so .a; do 76372378475aSmrg # Search the libtool library 7638eca46af7Smrg lib=$searchdir/lib$name$search_ext 76392378475aSmrg if test -f "$lib"; then 7640eca46af7Smrg if test .la = "$search_ext"; then 7641eca46af7Smrg found=: 76422378475aSmrg else 7643eca46af7Smrg found=false 76442378475aSmrg fi 76452378475aSmrg break 2 76462378475aSmrg fi 76472378475aSmrg done 76482378475aSmrg done 7649eca46af7Smrg if $found; then 7650eca46af7Smrg # deplib is a libtool library 76512378475aSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 76522378475aSmrg # We need to do some special things here, and not later. 7653eca46af7Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 76542378475aSmrg case " $predeps $postdeps " in 76552378475aSmrg *" $deplib "*) 76562378475aSmrg if func_lalib_p "$lib"; then 76572378475aSmrg library_names= 76582378475aSmrg old_library= 76592378475aSmrg func_source "$lib" 76602378475aSmrg for l in $old_library $library_names; do 7661eca46af7Smrg ll=$l 76622378475aSmrg done 7663eca46af7Smrg if test "X$ll" = "X$old_library"; then # only static version available 7664eca46af7Smrg found=false 76652378475aSmrg func_dirname "$lib" "" "." 7666eca46af7Smrg ladir=$func_dirname_result 76672378475aSmrg lib=$ladir/$old_library 7668eca46af7Smrg if test prog,link = "$linkmode,$pass"; then 76692378475aSmrg compile_deplibs="$deplib $compile_deplibs" 76702378475aSmrg finalize_deplibs="$deplib $finalize_deplibs" 76712378475aSmrg else 76722378475aSmrg deplibs="$deplib $deplibs" 7673eca46af7Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 76742378475aSmrg fi 76752378475aSmrg continue 76762378475aSmrg fi 76772378475aSmrg fi 76782378475aSmrg ;; 76792378475aSmrg *) ;; 76802378475aSmrg esac 76812378475aSmrg fi 7682eca46af7Smrg else 7683eca46af7Smrg # deplib doesn't seem to be a libtool library 7684eca46af7Smrg if test prog,link = "$linkmode,$pass"; then 7685eca46af7Smrg compile_deplibs="$deplib $compile_deplibs" 7686eca46af7Smrg finalize_deplibs="$deplib $finalize_deplibs" 7687eca46af7Smrg else 7688eca46af7Smrg deplibs="$deplib $deplibs" 7689eca46af7Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7690eca46af7Smrg fi 7691eca46af7Smrg continue 76922378475aSmrg fi 76932378475aSmrg ;; # -l 76942378475aSmrg *.ltframework) 7695eca46af7Smrg if test prog,link = "$linkmode,$pass"; then 76962378475aSmrg compile_deplibs="$deplib $compile_deplibs" 76972378475aSmrg finalize_deplibs="$deplib $finalize_deplibs" 76982378475aSmrg else 76992378475aSmrg deplibs="$deplib $deplibs" 7700eca46af7Smrg if test lib = "$linkmode"; then 77012378475aSmrg case "$new_inherited_linker_flags " in 77022378475aSmrg *" $deplib "*) ;; 770314330f12Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 77042378475aSmrg esac 77052378475aSmrg fi 77062378475aSmrg fi 77072378475aSmrg continue 77082378475aSmrg ;; 77092378475aSmrg -L*) 77102378475aSmrg case $linkmode in 77112378475aSmrg lib) 77122378475aSmrg deplibs="$deplib $deplibs" 7713eca46af7Smrg test conv = "$pass" && continue 77142378475aSmrg newdependency_libs="$deplib $newdependency_libs" 77152378475aSmrg func_stripname '-L' '' "$deplib" 771614330f12Smrg func_resolve_sysroot "$func_stripname_result" 771714330f12Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 77182378475aSmrg ;; 77192378475aSmrg prog) 7720eca46af7Smrg if test conv = "$pass"; then 77212378475aSmrg deplibs="$deplib $deplibs" 77222378475aSmrg continue 77232378475aSmrg fi 7724eca46af7Smrg if test scan = "$pass"; then 77252378475aSmrg deplibs="$deplib $deplibs" 77262378475aSmrg else 77272378475aSmrg compile_deplibs="$deplib $compile_deplibs" 77282378475aSmrg finalize_deplibs="$deplib $finalize_deplibs" 77292378475aSmrg fi 77302378475aSmrg func_stripname '-L' '' "$deplib" 773114330f12Smrg func_resolve_sysroot "$func_stripname_result" 773214330f12Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 77332378475aSmrg ;; 77342378475aSmrg *) 7735eca46af7Smrg func_warning "'-L' is ignored for archives/objects" 77362378475aSmrg ;; 77372378475aSmrg esac # linkmode 77382378475aSmrg continue 77392378475aSmrg ;; # -L 77402378475aSmrg -R*) 7741eca46af7Smrg if test link = "$pass"; then 77422378475aSmrg func_stripname '-R' '' "$deplib" 774314330f12Smrg func_resolve_sysroot "$func_stripname_result" 774414330f12Smrg dir=$func_resolve_sysroot_result 77452378475aSmrg # Make sure the xrpath contains only unique directories. 77462378475aSmrg case "$xrpath " in 77472378475aSmrg *" $dir "*) ;; 774814330f12Smrg *) func_append xrpath " $dir" ;; 77492378475aSmrg esac 77502378475aSmrg fi 77512378475aSmrg deplibs="$deplib $deplibs" 77522378475aSmrg continue 77532378475aSmrg ;; 775414330f12Smrg *.la) 775514330f12Smrg func_resolve_sysroot "$deplib" 775614330f12Smrg lib=$func_resolve_sysroot_result 775714330f12Smrg ;; 77582378475aSmrg *.$libext) 7759eca46af7Smrg if test conv = "$pass"; then 77602378475aSmrg deplibs="$deplib $deplibs" 77612378475aSmrg continue 77622378475aSmrg fi 77632378475aSmrg case $linkmode in 77642378475aSmrg lib) 77652378475aSmrg # Linking convenience modules into shared libraries is allowed, 77662378475aSmrg # but linking other static libraries is non-portable. 77672378475aSmrg case " $dlpreconveniencelibs " in 77682378475aSmrg *" $deplib "*) ;; 77692378475aSmrg *) 7770eca46af7Smrg valid_a_lib=false 77712378475aSmrg case $deplibs_check_method in 77722378475aSmrg match_pattern*) 77732378475aSmrg set dummy $deplibs_check_method; shift 77742378475aSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 777514330f12Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 77762378475aSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 7777eca46af7Smrg valid_a_lib=: 77782378475aSmrg fi 77792378475aSmrg ;; 77802378475aSmrg pass_all) 7781eca46af7Smrg valid_a_lib=: 77822378475aSmrg ;; 77832378475aSmrg esac 7784eca46af7Smrg if $valid_a_lib; then 7785eca46af7Smrg echo 7786eca46af7Smrg $ECHO "*** Warning: Linking the shared library $output against the" 7787eca46af7Smrg $ECHO "*** static library $deplib is not portable!" 7788eca46af7Smrg deplibs="$deplib $deplibs" 7789eca46af7Smrg else 779014330f12Smrg echo 77912378475aSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 779214330f12Smrg echo "*** I have the capability to make that library automatically link in when" 779314330f12Smrg echo "*** you link to this library. But I can only do this if you have a" 779414330f12Smrg echo "*** shared version of the library, which you do not appear to have" 779514330f12Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 779614330f12Smrg echo "*** that it is just a static archive that I should not use here." 77972378475aSmrg fi 77982378475aSmrg ;; 77992378475aSmrg esac 78002378475aSmrg continue 78012378475aSmrg ;; 78022378475aSmrg prog) 7803eca46af7Smrg if test link != "$pass"; then 78042378475aSmrg deplibs="$deplib $deplibs" 78052378475aSmrg else 78062378475aSmrg compile_deplibs="$deplib $compile_deplibs" 78072378475aSmrg finalize_deplibs="$deplib $finalize_deplibs" 78082378475aSmrg fi 78092378475aSmrg continue 78102378475aSmrg ;; 78112378475aSmrg esac # linkmode 78122378475aSmrg ;; # *.$libext 78132378475aSmrg *.lo | *.$objext) 7814eca46af7Smrg if test conv = "$pass"; then 78152378475aSmrg deplibs="$deplib $deplibs" 7816eca46af7Smrg elif test prog = "$linkmode"; then 7817eca46af7Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 78182378475aSmrg # If there is no dlopen support or we're linking statically, 78192378475aSmrg # we need to preload. 782014330f12Smrg func_append newdlprefiles " $deplib" 78212378475aSmrg compile_deplibs="$deplib $compile_deplibs" 78222378475aSmrg finalize_deplibs="$deplib $finalize_deplibs" 78232378475aSmrg else 782414330f12Smrg func_append newdlfiles " $deplib" 78252378475aSmrg fi 78262378475aSmrg fi 78272378475aSmrg continue 78282378475aSmrg ;; 78292378475aSmrg %DEPLIBS%) 7830eca46af7Smrg alldeplibs=: 78312378475aSmrg continue 78322378475aSmrg ;; 78332378475aSmrg esac # case $deplib 78342378475aSmrg 7835eca46af7Smrg $found || test -f "$lib" \ 7836eca46af7Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 78372378475aSmrg 78382378475aSmrg # Check to see that this really is a libtool archive. 78392378475aSmrg func_lalib_unsafe_p "$lib" \ 7840eca46af7Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 78412378475aSmrg 78422378475aSmrg func_dirname "$lib" "" "." 7843eca46af7Smrg ladir=$func_dirname_result 78442378475aSmrg 78452378475aSmrg dlname= 78462378475aSmrg dlopen= 78472378475aSmrg dlpreopen= 78482378475aSmrg libdir= 78492378475aSmrg library_names= 78502378475aSmrg old_library= 78512378475aSmrg inherited_linker_flags= 78522378475aSmrg # If the library was installed with an old release of libtool, 78532378475aSmrg # it will not redefine variables installed, or shouldnotlink 78542378475aSmrg installed=yes 78552378475aSmrg shouldnotlink=no 78562378475aSmrg avoidtemprpath= 78572378475aSmrg 78582378475aSmrg 78592378475aSmrg # Read the .la file 78602378475aSmrg func_source "$lib" 78612378475aSmrg 78622378475aSmrg # Convert "-framework foo" to "foo.ltframework" 78632378475aSmrg if test -n "$inherited_linker_flags"; then 786414330f12Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 78652378475aSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 78662378475aSmrg case " $new_inherited_linker_flags " in 78672378475aSmrg *" $tmp_inherited_linker_flag "*) ;; 786814330f12Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 78692378475aSmrg esac 78702378475aSmrg done 78712378475aSmrg fi 787214330f12Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7873eca46af7Smrg if test lib,link = "$linkmode,$pass" || 7874eca46af7Smrg test prog,scan = "$linkmode,$pass" || 7875eca46af7Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 787614330f12Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 787714330f12Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 78782378475aSmrg fi 78792378475aSmrg 7880eca46af7Smrg if test conv = "$pass"; then 78812378475aSmrg # Only check for convenience libraries 78822378475aSmrg deplibs="$lib $deplibs" 78832378475aSmrg if test -z "$libdir"; then 78842378475aSmrg if test -z "$old_library"; then 7885eca46af7Smrg func_fatal_error "cannot find name of link library for '$lib'" 78862378475aSmrg fi 78872378475aSmrg # It is a libtool convenience library, so add in its objects. 788814330f12Smrg func_append convenience " $ladir/$objdir/$old_library" 788914330f12Smrg func_append old_convenience " $ladir/$objdir/$old_library" 7890eca46af7Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 7891eca46af7Smrg func_fatal_error "'$lib' is not a convenience library" 78922378475aSmrg fi 78932378475aSmrg tmp_libs= 78942378475aSmrg for deplib in $dependency_libs; do 78952378475aSmrg deplibs="$deplib $deplibs" 7896eca46af7Smrg if $opt_preserve_dup_deps; then 78972378475aSmrg case "$tmp_libs " in 789814330f12Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 78992378475aSmrg esac 79002378475aSmrg fi 790114330f12Smrg func_append tmp_libs " $deplib" 79022378475aSmrg done 79032378475aSmrg continue 79042378475aSmrg fi # $pass = conv 79052378475aSmrg 79062378475aSmrg 79072378475aSmrg # Get the name of the library we link against. 79082378475aSmrg linklib= 790914330f12Smrg if test -n "$old_library" && 7910eca46af7Smrg { test yes = "$prefer_static_libs" || 7911eca46af7Smrg test built,no = "$prefer_static_libs,$installed"; }; then 791214330f12Smrg linklib=$old_library 791314330f12Smrg else 791414330f12Smrg for l in $old_library $library_names; do 7915eca46af7Smrg linklib=$l 791614330f12Smrg done 791714330f12Smrg fi 79182378475aSmrg if test -z "$linklib"; then 7919eca46af7Smrg func_fatal_error "cannot find name of link library for '$lib'" 79202378475aSmrg fi 79212378475aSmrg 79222378475aSmrg # This library was specified with -dlopen. 7923eca46af7Smrg if test dlopen = "$pass"; then 7924eca46af7Smrg test -z "$libdir" \ 7925eca46af7Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 79262378475aSmrg if test -z "$dlname" || 7927eca46af7Smrg test yes != "$dlopen_support" || 7928eca46af7Smrg test no = "$build_libtool_libs" 7929eca46af7Smrg then 79302378475aSmrg # If there is no dlname, no dlopen support or we're linking 79312378475aSmrg # statically, we need to preload. We also need to preload any 79322378475aSmrg # dependent libraries so libltdl's deplib preloader doesn't 79332378475aSmrg # bomb out in the load deplibs phase. 793414330f12Smrg func_append dlprefiles " $lib $dependency_libs" 79352378475aSmrg else 793614330f12Smrg func_append newdlfiles " $lib" 79372378475aSmrg fi 79382378475aSmrg continue 79392378475aSmrg fi # $pass = dlopen 79402378475aSmrg 79412378475aSmrg # We need an absolute path. 79422378475aSmrg case $ladir in 7943eca46af7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 79442378475aSmrg *) 79452378475aSmrg abs_ladir=`cd "$ladir" && pwd` 79462378475aSmrg if test -z "$abs_ladir"; then 7947eca46af7Smrg func_warning "cannot determine absolute directory name of '$ladir'" 79482378475aSmrg func_warning "passing it literally to the linker, although it might fail" 7949eca46af7Smrg abs_ladir=$ladir 79502378475aSmrg fi 79512378475aSmrg ;; 79522378475aSmrg esac 79532378475aSmrg func_basename "$lib" 7954eca46af7Smrg laname=$func_basename_result 79552378475aSmrg 79562378475aSmrg # Find the relevant object directory and library name. 7957eca46af7Smrg if test yes = "$installed"; then 795814330f12Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7959eca46af7Smrg func_warning "library '$lib' was moved." 7960eca46af7Smrg dir=$ladir 7961eca46af7Smrg absdir=$abs_ladir 7962eca46af7Smrg libdir=$abs_ladir 79632378475aSmrg else 7964eca46af7Smrg dir=$lt_sysroot$libdir 7965eca46af7Smrg absdir=$lt_sysroot$libdir 79662378475aSmrg fi 7967eca46af7Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 79682378475aSmrg else 79692378475aSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7970eca46af7Smrg dir=$ladir 7971eca46af7Smrg absdir=$abs_ladir 79722378475aSmrg # Remove this search path later 797314330f12Smrg func_append notinst_path " $abs_ladir" 79742378475aSmrg else 7975eca46af7Smrg dir=$ladir/$objdir 7976eca46af7Smrg absdir=$abs_ladir/$objdir 79772378475aSmrg # Remove this search path later 797814330f12Smrg func_append notinst_path " $abs_ladir" 79792378475aSmrg fi 79802378475aSmrg fi # $installed = yes 79812378475aSmrg func_stripname 'lib' '.la' "$laname" 79822378475aSmrg name=$func_stripname_result 79832378475aSmrg 79842378475aSmrg # This library was specified with -dlpreopen. 7985eca46af7Smrg if test dlpreopen = "$pass"; then 7986eca46af7Smrg if test -z "$libdir" && test prog = "$linkmode"; then 7987eca46af7Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 79882378475aSmrg fi 7989eca46af7Smrg case $host in 799014330f12Smrg # special handling for platforms with PE-DLLs. 799114330f12Smrg *cygwin* | *mingw* | *cegcc* ) 799214330f12Smrg # Linker will automatically link against shared library if both 799314330f12Smrg # static and shared are present. Therefore, ensure we extract 799414330f12Smrg # symbols from the import library if a shared library is present 799514330f12Smrg # (otherwise, the dlopen module name will be incorrect). We do 799614330f12Smrg # this by putting the import library name into $newdlprefiles. 799714330f12Smrg # We recover the dlopen module name by 'saving' the la file 799814330f12Smrg # name in a special purpose variable, and (later) extracting the 799914330f12Smrg # dlname from the la file. 800014330f12Smrg if test -n "$dlname"; then 800114330f12Smrg func_tr_sh "$dir/$linklib" 800214330f12Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 800314330f12Smrg func_append newdlprefiles " $dir/$linklib" 800414330f12Smrg else 800514330f12Smrg func_append newdlprefiles " $dir/$old_library" 800614330f12Smrg # Keep a list of preopened convenience libraries to check 800714330f12Smrg # that they are being used correctly in the link pass. 800814330f12Smrg test -z "$libdir" && \ 800914330f12Smrg func_append dlpreconveniencelibs " $dir/$old_library" 801014330f12Smrg fi 801114330f12Smrg ;; 801214330f12Smrg * ) 801314330f12Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 801414330f12Smrg # are required to link). 801514330f12Smrg if test -n "$old_library"; then 801614330f12Smrg func_append newdlprefiles " $dir/$old_library" 801714330f12Smrg # Keep a list of preopened convenience libraries to check 801814330f12Smrg # that they are being used correctly in the link pass. 801914330f12Smrg test -z "$libdir" && \ 802014330f12Smrg func_append dlpreconveniencelibs " $dir/$old_library" 802114330f12Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 802214330f12Smrg elif test -n "$dlname"; then 802314330f12Smrg func_append newdlprefiles " $dir/$dlname" 802414330f12Smrg else 802514330f12Smrg func_append newdlprefiles " $dir/$linklib" 802614330f12Smrg fi 802714330f12Smrg ;; 802814330f12Smrg esac 80292378475aSmrg fi # $pass = dlpreopen 80302378475aSmrg 80312378475aSmrg if test -z "$libdir"; then 80322378475aSmrg # Link the convenience library 8033eca46af7Smrg if test lib = "$linkmode"; then 80342378475aSmrg deplibs="$dir/$old_library $deplibs" 8035eca46af7Smrg elif test prog,link = "$linkmode,$pass"; then 80362378475aSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 80372378475aSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 80382378475aSmrg else 80392378475aSmrg deplibs="$lib $deplibs" # used for prog,scan pass 80402378475aSmrg fi 80412378475aSmrg continue 80422378475aSmrg fi 80432378475aSmrg 80442378475aSmrg 8045eca46af7Smrg if test prog = "$linkmode" && test link != "$pass"; then 804614330f12Smrg func_append newlib_search_path " $ladir" 80472378475aSmrg deplibs="$lib $deplibs" 80482378475aSmrg 8049eca46af7Smrg linkalldeplibs=false 8050eca46af7Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8051eca46af7Smrg test no = "$build_libtool_libs"; then 8052eca46af7Smrg linkalldeplibs=: 80532378475aSmrg fi 80542378475aSmrg 80552378475aSmrg tmp_libs= 80562378475aSmrg for deplib in $dependency_libs; do 80572378475aSmrg case $deplib in 80582378475aSmrg -L*) func_stripname '-L' '' "$deplib" 805914330f12Smrg func_resolve_sysroot "$func_stripname_result" 806014330f12Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 80612378475aSmrg ;; 80622378475aSmrg esac 80632378475aSmrg # Need to link against all dependency_libs? 8064eca46af7Smrg if $linkalldeplibs; then 80652378475aSmrg deplibs="$deplib $deplibs" 80662378475aSmrg else 80672378475aSmrg # Need to hardcode shared library paths 80682378475aSmrg # or/and link against static libraries 80692378475aSmrg newdependency_libs="$deplib $newdependency_libs" 80702378475aSmrg fi 8071eca46af7Smrg if $opt_preserve_dup_deps; then 80722378475aSmrg case "$tmp_libs " in 807314330f12Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 80742378475aSmrg esac 80752378475aSmrg fi 807614330f12Smrg func_append tmp_libs " $deplib" 80772378475aSmrg done # for deplib 80782378475aSmrg continue 80792378475aSmrg fi # $linkmode = prog... 80802378475aSmrg 8081eca46af7Smrg if test prog,link = "$linkmode,$pass"; then 80822378475aSmrg if test -n "$library_names" && 8083eca46af7Smrg { { test no = "$prefer_static_libs" || 8084eca46af7Smrg test built,yes = "$prefer_static_libs,$installed"; } || 80852378475aSmrg test -z "$old_library"; }; then 80862378475aSmrg # We need to hardcode the library path 8087eca46af7Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 80882378475aSmrg # Make sure the rpath contains only unique directories. 8089eca46af7Smrg case $temp_rpath: in 80902378475aSmrg *"$absdir:"*) ;; 809114330f12Smrg *) func_append temp_rpath "$absdir:" ;; 80922378475aSmrg esac 80932378475aSmrg fi 80942378475aSmrg 80952378475aSmrg # Hardcode the library path. 80962378475aSmrg # Skip directories that are in the system default run-time 80972378475aSmrg # search path. 80982378475aSmrg case " $sys_lib_dlsearch_path " in 80992378475aSmrg *" $absdir "*) ;; 81002378475aSmrg *) 81012378475aSmrg case "$compile_rpath " in 81022378475aSmrg *" $absdir "*) ;; 810314330f12Smrg *) func_append compile_rpath " $absdir" ;; 81042378475aSmrg esac 81052378475aSmrg ;; 81062378475aSmrg esac 81072378475aSmrg case " $sys_lib_dlsearch_path " in 81082378475aSmrg *" $libdir "*) ;; 81092378475aSmrg *) 81102378475aSmrg case "$finalize_rpath " in 81112378475aSmrg *" $libdir "*) ;; 811214330f12Smrg *) func_append finalize_rpath " $libdir" ;; 81132378475aSmrg esac 81142378475aSmrg ;; 81152378475aSmrg esac 81162378475aSmrg fi # $linkmode,$pass = prog,link... 81172378475aSmrg 8118eca46af7Smrg if $alldeplibs && 8119eca46af7Smrg { test pass_all = "$deplibs_check_method" || 8120eca46af7Smrg { test yes = "$build_libtool_libs" && 81212378475aSmrg test -n "$library_names"; }; }; then 81222378475aSmrg # We only need to search for static libraries 81232378475aSmrg continue 81242378475aSmrg fi 81252378475aSmrg fi 81262378475aSmrg 81272378475aSmrg link_static=no # Whether the deplib will be linked statically 81282378475aSmrg use_static_libs=$prefer_static_libs 8129eca46af7Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 81302378475aSmrg use_static_libs=no 81312378475aSmrg fi 81322378475aSmrg if test -n "$library_names" && 8133eca46af7Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 81342378475aSmrg case $host in 8135eca46af7Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 81362378475aSmrg # No point in relinking DLLs because paths are not encoded 813714330f12Smrg func_append notinst_deplibs " $lib" 81382378475aSmrg need_relink=no 81392378475aSmrg ;; 81402378475aSmrg *) 8141eca46af7Smrg if test no = "$installed"; then 814214330f12Smrg func_append notinst_deplibs " $lib" 81432378475aSmrg need_relink=yes 81442378475aSmrg fi 81452378475aSmrg ;; 81462378475aSmrg esac 81472378475aSmrg # This is a shared library 81482378475aSmrg 81492378475aSmrg # Warn about portability, can't link against -module's on some 81502378475aSmrg # systems (darwin). Don't bleat about dlopened modules though! 8151eca46af7Smrg dlopenmodule= 81522378475aSmrg for dlpremoduletest in $dlprefiles; do 81532378475aSmrg if test "X$dlpremoduletest" = "X$lib"; then 8154eca46af7Smrg dlopenmodule=$dlpremoduletest 81552378475aSmrg break 81562378475aSmrg fi 81572378475aSmrg done 8158eca46af7Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 815914330f12Smrg echo 8160eca46af7Smrg if test prog = "$linkmode"; then 81612378475aSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 81622378475aSmrg else 81632378475aSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 81642378475aSmrg fi 81652378475aSmrg $ECHO "*** $linklib is not portable!" 81662378475aSmrg fi 8167eca46af7Smrg if test lib = "$linkmode" && 8168eca46af7Smrg test yes = "$hardcode_into_libs"; then 81692378475aSmrg # Hardcode the library path. 81702378475aSmrg # Skip directories that are in the system default run-time 81712378475aSmrg # search path. 81722378475aSmrg case " $sys_lib_dlsearch_path " in 81732378475aSmrg *" $absdir "*) ;; 81742378475aSmrg *) 81752378475aSmrg case "$compile_rpath " in 81762378475aSmrg *" $absdir "*) ;; 817714330f12Smrg *) func_append compile_rpath " $absdir" ;; 81782378475aSmrg esac 81792378475aSmrg ;; 81802378475aSmrg esac 81812378475aSmrg case " $sys_lib_dlsearch_path " in 81822378475aSmrg *" $libdir "*) ;; 81832378475aSmrg *) 81842378475aSmrg case "$finalize_rpath " in 81852378475aSmrg *" $libdir "*) ;; 818614330f12Smrg *) func_append finalize_rpath " $libdir" ;; 81872378475aSmrg esac 81882378475aSmrg ;; 81892378475aSmrg esac 81902378475aSmrg fi 81912378475aSmrg 81922378475aSmrg if test -n "$old_archive_from_expsyms_cmds"; then 81932378475aSmrg # figure out the soname 81942378475aSmrg set dummy $library_names 81952378475aSmrg shift 8196eca46af7Smrg realname=$1 81972378475aSmrg shift 81982378475aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 81992378475aSmrg # use dlname if we got it. it's perfectly good, no? 82002378475aSmrg if test -n "$dlname"; then 8201eca46af7Smrg soname=$dlname 82022378475aSmrg elif test -n "$soname_spec"; then 82032378475aSmrg # bleh windows 82042378475aSmrg case $host in 8205eca46af7Smrg *cygwin* | mingw* | *cegcc* | *os2*) 82062378475aSmrg func_arith $current - $age 82072378475aSmrg major=$func_arith_result 8208eca46af7Smrg versuffix=-$major 82092378475aSmrg ;; 82102378475aSmrg esac 82112378475aSmrg eval soname=\"$soname_spec\" 82122378475aSmrg else 8213eca46af7Smrg soname=$realname 82142378475aSmrg fi 82152378475aSmrg 82162378475aSmrg # Make a new name for the extract_expsyms_cmds to use 8217eca46af7Smrg soroot=$soname 82182378475aSmrg func_basename "$soroot" 8219eca46af7Smrg soname=$func_basename_result 82202378475aSmrg func_stripname 'lib' '.dll' "$soname" 82212378475aSmrg newlib=libimp-$func_stripname_result.a 82222378475aSmrg 82232378475aSmrg # If the library has no export list, then create one now 82242378475aSmrg if test -f "$output_objdir/$soname-def"; then : 82252378475aSmrg else 8226eca46af7Smrg func_verbose "extracting exported symbol list from '$soname'" 82272378475aSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 82282378475aSmrg fi 82292378475aSmrg 82302378475aSmrg # Create $newlib 82312378475aSmrg if test -f "$output_objdir/$newlib"; then :; else 8232eca46af7Smrg func_verbose "generating import library for '$soname'" 82332378475aSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 82342378475aSmrg fi 82352378475aSmrg # make sure the library variables are pointing to the new library 82362378475aSmrg dir=$output_objdir 82372378475aSmrg linklib=$newlib 82382378475aSmrg fi # test -n "$old_archive_from_expsyms_cmds" 82392378475aSmrg 8240eca46af7Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 82412378475aSmrg add_shlibpath= 82422378475aSmrg add_dir= 82432378475aSmrg add= 82442378475aSmrg lib_linked=yes 82452378475aSmrg case $hardcode_action in 82462378475aSmrg immediate | unsupported) 8247eca46af7Smrg if test no = "$hardcode_direct"; then 8248eca46af7Smrg add=$dir/$linklib 82492378475aSmrg case $host in 8250eca46af7Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8251eca46af7Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 82522378475aSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8253eca46af7Smrg *-*-unixware7*) add_dir=-L$dir ;; 82542378475aSmrg *-*-darwin* ) 8255eca46af7Smrg # if the lib is a (non-dlopened) module then we cannot 82562378475aSmrg # link against it, someone is ignoring the earlier warnings 82572378475aSmrg if /usr/bin/file -L $add 2> /dev/null | 8258eca46af7Smrg $GREP ": [^:]* bundle" >/dev/null; then 82592378475aSmrg if test "X$dlopenmodule" != "X$lib"; then 82602378475aSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8261eca46af7Smrg if test -z "$old_library"; then 826214330f12Smrg echo 826314330f12Smrg echo "*** And there doesn't seem to be a static archive available" 826414330f12Smrg echo "*** The link will probably fail, sorry" 82652378475aSmrg else 8266eca46af7Smrg add=$dir/$old_library 82672378475aSmrg fi 82682378475aSmrg elif test -n "$old_library"; then 8269eca46af7Smrg add=$dir/$old_library 82702378475aSmrg fi 82712378475aSmrg fi 82722378475aSmrg esac 8273eca46af7Smrg elif test no = "$hardcode_minus_L"; then 82742378475aSmrg case $host in 8275eca46af7Smrg *-*-sunos*) add_shlibpath=$dir ;; 82762378475aSmrg esac 8277eca46af7Smrg add_dir=-L$dir 8278eca46af7Smrg add=-l$name 8279eca46af7Smrg elif test no = "$hardcode_shlibpath_var"; then 8280eca46af7Smrg add_shlibpath=$dir 8281eca46af7Smrg add=-l$name 82822378475aSmrg else 82832378475aSmrg lib_linked=no 82842378475aSmrg fi 82852378475aSmrg ;; 82862378475aSmrg relink) 8287eca46af7Smrg if test yes = "$hardcode_direct" && 8288eca46af7Smrg test no = "$hardcode_direct_absolute"; then 8289eca46af7Smrg add=$dir/$linklib 8290eca46af7Smrg elif test yes = "$hardcode_minus_L"; then 8291eca46af7Smrg add_dir=-L$absdir 82922378475aSmrg # Try looking first in the location we're being installed to. 82932378475aSmrg if test -n "$inst_prefix_dir"; then 82942378475aSmrg case $libdir in 82952378475aSmrg [\\/]*) 829614330f12Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 82972378475aSmrg ;; 82982378475aSmrg esac 82992378475aSmrg fi 8300eca46af7Smrg add=-l$name 8301eca46af7Smrg elif test yes = "$hardcode_shlibpath_var"; then 8302eca46af7Smrg add_shlibpath=$dir 8303eca46af7Smrg add=-l$name 83042378475aSmrg else 83052378475aSmrg lib_linked=no 83062378475aSmrg fi 83072378475aSmrg ;; 83082378475aSmrg *) lib_linked=no ;; 83092378475aSmrg esac 83102378475aSmrg 8311eca46af7Smrg if test yes != "$lib_linked"; then 83122378475aSmrg func_fatal_configuration "unsupported hardcode properties" 83132378475aSmrg fi 83142378475aSmrg 83152378475aSmrg if test -n "$add_shlibpath"; then 83162378475aSmrg case :$compile_shlibpath: in 83172378475aSmrg *":$add_shlibpath:"*) ;; 831814330f12Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 83192378475aSmrg esac 83202378475aSmrg fi 8321eca46af7Smrg if test prog = "$linkmode"; then 83222378475aSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 83232378475aSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 83242378475aSmrg else 83252378475aSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 83262378475aSmrg test -n "$add" && deplibs="$add $deplibs" 8327eca46af7Smrg if test yes != "$hardcode_direct" && 8328eca46af7Smrg test yes != "$hardcode_minus_L" && 8329eca46af7Smrg test yes = "$hardcode_shlibpath_var"; then 83302378475aSmrg case :$finalize_shlibpath: in 83312378475aSmrg *":$libdir:"*) ;; 833214330f12Smrg *) func_append finalize_shlibpath "$libdir:" ;; 83332378475aSmrg esac 83342378475aSmrg fi 83352378475aSmrg fi 83362378475aSmrg fi 83372378475aSmrg 8338eca46af7Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 83392378475aSmrg add_shlibpath= 83402378475aSmrg add_dir= 83412378475aSmrg add= 83422378475aSmrg # Finalize command for both is simple: just hardcode it. 8343eca46af7Smrg if test yes = "$hardcode_direct" && 8344eca46af7Smrg test no = "$hardcode_direct_absolute"; then 8345eca46af7Smrg add=$libdir/$linklib 8346eca46af7Smrg elif test yes = "$hardcode_minus_L"; then 8347eca46af7Smrg add_dir=-L$libdir 8348eca46af7Smrg add=-l$name 8349eca46af7Smrg elif test yes = "$hardcode_shlibpath_var"; then 83502378475aSmrg case :$finalize_shlibpath: in 83512378475aSmrg *":$libdir:"*) ;; 835214330f12Smrg *) func_append finalize_shlibpath "$libdir:" ;; 83532378475aSmrg esac 8354eca46af7Smrg add=-l$name 8355eca46af7Smrg elif test yes = "$hardcode_automatic"; then 83562378475aSmrg if test -n "$inst_prefix_dir" && 8357eca46af7Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8358eca46af7Smrg add=$inst_prefix_dir$libdir/$linklib 83592378475aSmrg else 8360eca46af7Smrg add=$libdir/$linklib 83612378475aSmrg fi 83622378475aSmrg else 83632378475aSmrg # We cannot seem to hardcode it, guess we'll fake it. 8364eca46af7Smrg add_dir=-L$libdir 83652378475aSmrg # Try looking first in the location we're being installed to. 83662378475aSmrg if test -n "$inst_prefix_dir"; then 83672378475aSmrg case $libdir in 83682378475aSmrg [\\/]*) 836914330f12Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 83702378475aSmrg ;; 83712378475aSmrg esac 83722378475aSmrg fi 8373eca46af7Smrg add=-l$name 83742378475aSmrg fi 83752378475aSmrg 8376eca46af7Smrg if test prog = "$linkmode"; then 83772378475aSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 83782378475aSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 83792378475aSmrg else 83802378475aSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 83812378475aSmrg test -n "$add" && deplibs="$add $deplibs" 83822378475aSmrg fi 83832378475aSmrg fi 8384eca46af7Smrg elif test prog = "$linkmode"; then 83852378475aSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 83862378475aSmrg # is not unsupported. This is valid on all known static and 83872378475aSmrg # shared platforms. 8388eca46af7Smrg if test unsupported != "$hardcode_direct"; then 8389eca46af7Smrg test -n "$old_library" && linklib=$old_library 83902378475aSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 83912378475aSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 83922378475aSmrg else 83932378475aSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 83942378475aSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 83952378475aSmrg fi 8396eca46af7Smrg elif test yes = "$build_libtool_libs"; then 83972378475aSmrg # Not a shared library 8398eca46af7Smrg if test pass_all != "$deplibs_check_method"; then 83992378475aSmrg # We're trying link a shared library against a static one 84002378475aSmrg # but the system doesn't support it. 84012378475aSmrg 84022378475aSmrg # Just print a warning and add the library to dependency_libs so 84032378475aSmrg # that the program can be linked against the static library. 840414330f12Smrg echo 8405eca46af7Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 840614330f12Smrg echo "*** I have the capability to make that library automatically link in when" 840714330f12Smrg echo "*** you link to this library. But I can only do this if you have a" 840814330f12Smrg echo "*** shared version of the library, which you do not appear to have." 8409eca46af7Smrg if test yes = "$module"; then 841014330f12Smrg echo "*** But as you try to build a module library, libtool will still create " 841114330f12Smrg echo "*** a static module, that should work as long as the dlopening application" 841214330f12Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 84132378475aSmrg if test -z "$global_symbol_pipe"; then 841414330f12Smrg echo 841514330f12Smrg echo "*** However, this would only work if libtool was able to extract symbol" 8416eca46af7Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 841714330f12Smrg echo "*** not find such a program. So, this module is probably useless." 8418eca46af7Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 84192378475aSmrg fi 8420eca46af7Smrg if test no = "$build_old_libs"; then 84212378475aSmrg build_libtool_libs=module 84222378475aSmrg build_old_libs=yes 84232378475aSmrg else 84242378475aSmrg build_libtool_libs=no 84252378475aSmrg fi 84262378475aSmrg fi 84272378475aSmrg else 84282378475aSmrg deplibs="$dir/$old_library $deplibs" 84292378475aSmrg link_static=yes 84302378475aSmrg fi 84312378475aSmrg fi # link shared/static library? 84322378475aSmrg 8433eca46af7Smrg if test lib = "$linkmode"; then 84342378475aSmrg if test -n "$dependency_libs" && 8435eca46af7Smrg { test yes != "$hardcode_into_libs" || 8436eca46af7Smrg test yes = "$build_old_libs" || 8437eca46af7Smrg test yes = "$link_static"; }; then 84382378475aSmrg # Extract -R from dependency_libs 84392378475aSmrg temp_deplibs= 84402378475aSmrg for libdir in $dependency_libs; do 84412378475aSmrg case $libdir in 84422378475aSmrg -R*) func_stripname '-R' '' "$libdir" 84432378475aSmrg temp_xrpath=$func_stripname_result 84442378475aSmrg case " $xrpath " in 84452378475aSmrg *" $temp_xrpath "*) ;; 844614330f12Smrg *) func_append xrpath " $temp_xrpath";; 84472378475aSmrg esac;; 844814330f12Smrg *) func_append temp_deplibs " $libdir";; 84492378475aSmrg esac 84502378475aSmrg done 8451eca46af7Smrg dependency_libs=$temp_deplibs 84522378475aSmrg fi 84532378475aSmrg 845414330f12Smrg func_append newlib_search_path " $absdir" 84552378475aSmrg # Link against this library 8456eca46af7Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 84572378475aSmrg # ... and its dependency_libs 84582378475aSmrg tmp_libs= 84592378475aSmrg for deplib in $dependency_libs; do 84602378475aSmrg newdependency_libs="$deplib $newdependency_libs" 846114330f12Smrg case $deplib in 846214330f12Smrg -L*) func_stripname '-L' '' "$deplib" 846314330f12Smrg func_resolve_sysroot "$func_stripname_result";; 846414330f12Smrg *) func_resolve_sysroot "$deplib" ;; 846514330f12Smrg esac 8466eca46af7Smrg if $opt_preserve_dup_deps; then 84672378475aSmrg case "$tmp_libs " in 846814330f12Smrg *" $func_resolve_sysroot_result "*) 846914330f12Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 84702378475aSmrg esac 84712378475aSmrg fi 847214330f12Smrg func_append tmp_libs " $func_resolve_sysroot_result" 84732378475aSmrg done 84742378475aSmrg 8475eca46af7Smrg if test no != "$link_all_deplibs"; then 84762378475aSmrg # Add the search paths of all dependency libraries 84772378475aSmrg for deplib in $dependency_libs; do 847814330f12Smrg path= 84792378475aSmrg case $deplib in 8480eca46af7Smrg -L*) path=$deplib ;; 84812378475aSmrg *.la) 848214330f12Smrg func_resolve_sysroot "$deplib" 848314330f12Smrg deplib=$func_resolve_sysroot_result 84842378475aSmrg func_dirname "$deplib" "" "." 848514330f12Smrg dir=$func_dirname_result 84862378475aSmrg # We need an absolute path. 84872378475aSmrg case $dir in 8488eca46af7Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 84892378475aSmrg *) 84902378475aSmrg absdir=`cd "$dir" && pwd` 84912378475aSmrg if test -z "$absdir"; then 8492eca46af7Smrg func_warning "cannot determine absolute directory name of '$dir'" 8493eca46af7Smrg absdir=$dir 84942378475aSmrg fi 84952378475aSmrg ;; 84962378475aSmrg esac 84972378475aSmrg if $GREP "^installed=no" $deplib > /dev/null; then 84982378475aSmrg case $host in 84992378475aSmrg *-*-darwin*) 85002378475aSmrg depdepl= 8501eca46af7Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8502eca46af7Smrg if test -n "$deplibrary_names"; then 8503eca46af7Smrg for tmp in $deplibrary_names; do 85042378475aSmrg depdepl=$tmp 85052378475aSmrg done 8506eca46af7Smrg if test -f "$absdir/$objdir/$depdepl"; then 8507eca46af7Smrg depdepl=$absdir/$objdir/$depdepl 8508eca46af7Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 85092378475aSmrg if test -z "$darwin_install_name"; then 8510eca46af7Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 85112378475aSmrg fi 8512eca46af7Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8513eca46af7Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 85142378475aSmrg path= 85152378475aSmrg fi 85162378475aSmrg fi 85172378475aSmrg ;; 85182378475aSmrg *) 8519eca46af7Smrg path=-L$absdir/$objdir 85202378475aSmrg ;; 85212378475aSmrg esac 85222378475aSmrg else 8523eca46af7Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 85242378475aSmrg test -z "$libdir" && \ 8525eca46af7Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 85262378475aSmrg test "$absdir" != "$libdir" && \ 8527eca46af7Smrg func_warning "'$deplib' seems to be moved" 85282378475aSmrg 8529eca46af7Smrg path=-L$absdir 85302378475aSmrg fi 85312378475aSmrg ;; 85322378475aSmrg esac 85332378475aSmrg case " $deplibs " in 85342378475aSmrg *" $path "*) ;; 85352378475aSmrg *) deplibs="$path $deplibs" ;; 85362378475aSmrg esac 85372378475aSmrg done 85382378475aSmrg fi # link_all_deplibs != no 85392378475aSmrg fi # linkmode = lib 85402378475aSmrg done # for deplib in $libs 8541eca46af7Smrg if test link = "$pass"; then 8542eca46af7Smrg if test prog = "$linkmode"; then 85432378475aSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 85442378475aSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 85452378475aSmrg else 854614330f12Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 85472378475aSmrg fi 85482378475aSmrg fi 8549eca46af7Smrg dependency_libs=$newdependency_libs 8550eca46af7Smrg if test dlpreopen = "$pass"; then 85512378475aSmrg # Link the dlpreopened libraries before other libraries 85522378475aSmrg for deplib in $save_deplibs; do 85532378475aSmrg deplibs="$deplib $deplibs" 85542378475aSmrg done 85552378475aSmrg fi 8556eca46af7Smrg if test dlopen != "$pass"; then 8557eca46af7Smrg test conv = "$pass" || { 85582378475aSmrg # Make sure lib_search_path contains only unique directories. 85592378475aSmrg lib_search_path= 85602378475aSmrg for dir in $newlib_search_path; do 85612378475aSmrg case "$lib_search_path " in 85622378475aSmrg *" $dir "*) ;; 856314330f12Smrg *) func_append lib_search_path " $dir" ;; 85642378475aSmrg esac 85652378475aSmrg done 85662378475aSmrg newlib_search_path= 8567eca46af7Smrg } 85682378475aSmrg 8569eca46af7Smrg if test prog,link = "$linkmode,$pass"; then 85702378475aSmrg vars="compile_deplibs finalize_deplibs" 8571eca46af7Smrg else 8572eca46af7Smrg vars=deplibs 85732378475aSmrg fi 85742378475aSmrg for var in $vars dependency_libs; do 85752378475aSmrg # Add libraries to $var in reverse order 85762378475aSmrg eval tmp_libs=\"\$$var\" 85772378475aSmrg new_libs= 85782378475aSmrg for deplib in $tmp_libs; do 85792378475aSmrg # FIXME: Pedantically, this is the right thing to do, so 85802378475aSmrg # that some nasty dependency loop isn't accidentally 85812378475aSmrg # broken: 85822378475aSmrg #new_libs="$deplib $new_libs" 85832378475aSmrg # Pragmatically, this seems to cause very few problems in 85842378475aSmrg # practice: 85852378475aSmrg case $deplib in 85862378475aSmrg -L*) new_libs="$deplib $new_libs" ;; 85872378475aSmrg -R*) ;; 85882378475aSmrg *) 85892378475aSmrg # And here is the reason: when a library appears more 85902378475aSmrg # than once as an explicit dependence of a library, or 85912378475aSmrg # is implicitly linked in more than once by the 85922378475aSmrg # compiler, it is considered special, and multiple 85932378475aSmrg # occurrences thereof are not removed. Compare this 85942378475aSmrg # with having the same library being listed as a 85952378475aSmrg # dependency of multiple other libraries: in this case, 85962378475aSmrg # we know (pedantically, we assume) the library does not 85972378475aSmrg # need to be listed more than once, so we keep only the 85982378475aSmrg # last copy. This is not always right, but it is rare 85992378475aSmrg # enough that we require users that really mean to play 86002378475aSmrg # such unportable linking tricks to link the library 86012378475aSmrg # using -Wl,-lname, so that libtool does not consider it 86022378475aSmrg # for duplicate removal. 86032378475aSmrg case " $specialdeplibs " in 86042378475aSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 86052378475aSmrg *) 86062378475aSmrg case " $new_libs " in 86072378475aSmrg *" $deplib "*) ;; 86082378475aSmrg *) new_libs="$deplib $new_libs" ;; 86092378475aSmrg esac 86102378475aSmrg ;; 86112378475aSmrg esac 86122378475aSmrg ;; 86132378475aSmrg esac 86142378475aSmrg done 86152378475aSmrg tmp_libs= 86162378475aSmrg for deplib in $new_libs; do 86172378475aSmrg case $deplib in 86182378475aSmrg -L*) 86192378475aSmrg case " $tmp_libs " in 86202378475aSmrg *" $deplib "*) ;; 862114330f12Smrg *) func_append tmp_libs " $deplib" ;; 86222378475aSmrg esac 86232378475aSmrg ;; 862414330f12Smrg *) func_append tmp_libs " $deplib" ;; 86252378475aSmrg esac 86262378475aSmrg done 86272378475aSmrg eval $var=\"$tmp_libs\" 86282378475aSmrg done # for var 86292378475aSmrg fi 863089b0dc75Smrg 863189b0dc75Smrg # Add Sun CC postdeps if required: 863289b0dc75Smrg test CXX = "$tagname" && { 863389b0dc75Smrg case $host_os in 863489b0dc75Smrg linux*) 863589b0dc75Smrg case `$CC -V 2>&1 | sed 5q` in 863689b0dc75Smrg *Sun\ C*) # Sun C++ 5.9 863789b0dc75Smrg func_suncc_cstd_abi 863889b0dc75Smrg 863989b0dc75Smrg if test no != "$suncc_use_cstd_abi"; then 864089b0dc75Smrg func_append postdeps ' -library=Cstd -library=Crun' 864189b0dc75Smrg fi 864289b0dc75Smrg ;; 864389b0dc75Smrg esac 864489b0dc75Smrg ;; 864589b0dc75Smrg 864689b0dc75Smrg solaris*) 864789b0dc75Smrg func_cc_basename "$CC" 864889b0dc75Smrg case $func_cc_basename_result in 864989b0dc75Smrg CC* | sunCC*) 865089b0dc75Smrg func_suncc_cstd_abi 865189b0dc75Smrg 865289b0dc75Smrg if test no != "$suncc_use_cstd_abi"; then 865389b0dc75Smrg func_append postdeps ' -library=Cstd -library=Crun' 865489b0dc75Smrg fi 865589b0dc75Smrg ;; 865689b0dc75Smrg esac 865789b0dc75Smrg ;; 865889b0dc75Smrg esac 865989b0dc75Smrg } 866089b0dc75Smrg 86612378475aSmrg # Last step: remove runtime libs from dependency_libs 86622378475aSmrg # (they stay in deplibs) 86632378475aSmrg tmp_libs= 8664eca46af7Smrg for i in $dependency_libs; do 86652378475aSmrg case " $predeps $postdeps $compiler_lib_search_path " in 86662378475aSmrg *" $i "*) 8667eca46af7Smrg i= 86682378475aSmrg ;; 86692378475aSmrg esac 8670eca46af7Smrg if test -n "$i"; then 867114330f12Smrg func_append tmp_libs " $i" 86722378475aSmrg fi 86732378475aSmrg done 86742378475aSmrg dependency_libs=$tmp_libs 86752378475aSmrg done # for pass 8676eca46af7Smrg if test prog = "$linkmode"; then 8677eca46af7Smrg dlfiles=$newdlfiles 86782378475aSmrg fi 8679eca46af7Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8680eca46af7Smrg dlprefiles=$newdlprefiles 86812378475aSmrg fi 86822378475aSmrg 86832378475aSmrg case $linkmode in 86842378475aSmrg oldlib) 8685eca46af7Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8686eca46af7Smrg func_warning "'-dlopen' is ignored for archives" 86872378475aSmrg fi 86882378475aSmrg 86892378475aSmrg case " $deplibs" in 86902378475aSmrg *\ -l* | *\ -L*) 8691eca46af7Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 86922378475aSmrg esac 86932378475aSmrg 86942378475aSmrg test -n "$rpath" && \ 8695eca46af7Smrg func_warning "'-rpath' is ignored for archives" 86962378475aSmrg 86972378475aSmrg test -n "$xrpath" && \ 8698eca46af7Smrg func_warning "'-R' is ignored for archives" 86992378475aSmrg 87002378475aSmrg test -n "$vinfo" && \ 8701eca46af7Smrg func_warning "'-version-info/-version-number' is ignored for archives" 87022378475aSmrg 87032378475aSmrg test -n "$release" && \ 8704eca46af7Smrg func_warning "'-release' is ignored for archives" 87052378475aSmrg 87062378475aSmrg test -n "$export_symbols$export_symbols_regex" && \ 8707eca46af7Smrg func_warning "'-export-symbols' is ignored for archives" 87082378475aSmrg 87092378475aSmrg # Now set the variables for building old libraries. 87102378475aSmrg build_libtool_libs=no 8711eca46af7Smrg oldlibs=$output 871214330f12Smrg func_append objs "$old_deplibs" 87132378475aSmrg ;; 87142378475aSmrg 87152378475aSmrg lib) 8716eca46af7Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 87172378475aSmrg case $outputname in 87182378475aSmrg lib*) 87192378475aSmrg func_stripname 'lib' '.la' "$outputname" 87202378475aSmrg name=$func_stripname_result 87212378475aSmrg eval shared_ext=\"$shrext_cmds\" 87222378475aSmrg eval libname=\"$libname_spec\" 87232378475aSmrg ;; 87242378475aSmrg *) 8725eca46af7Smrg test no = "$module" \ 8726eca46af7Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 87272378475aSmrg 8728eca46af7Smrg if test no != "$need_lib_prefix"; then 87292378475aSmrg # Add the "lib" prefix for modules if required 87302378475aSmrg func_stripname '' '.la' "$outputname" 87312378475aSmrg name=$func_stripname_result 87322378475aSmrg eval shared_ext=\"$shrext_cmds\" 87332378475aSmrg eval libname=\"$libname_spec\" 87342378475aSmrg else 87352378475aSmrg func_stripname '' '.la' "$outputname" 87362378475aSmrg libname=$func_stripname_result 87372378475aSmrg fi 87382378475aSmrg ;; 87392378475aSmrg esac 87402378475aSmrg 87412378475aSmrg if test -n "$objs"; then 8742eca46af7Smrg if test pass_all != "$deplibs_check_method"; then 8743eca46af7Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 87442378475aSmrg else 874514330f12Smrg echo 87462378475aSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 87472378475aSmrg $ECHO "*** objects $objs is not portable!" 874814330f12Smrg func_append libobjs " $objs" 87492378475aSmrg fi 87502378475aSmrg fi 87512378475aSmrg 8752eca46af7Smrg test no = "$dlself" \ 8753eca46af7Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 87542378475aSmrg 87552378475aSmrg set dummy $rpath 87562378475aSmrg shift 8757eca46af7Smrg test 1 -lt "$#" \ 8758eca46af7Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 87592378475aSmrg 8760eca46af7Smrg install_libdir=$1 87612378475aSmrg 87622378475aSmrg oldlibs= 87632378475aSmrg if test -z "$rpath"; then 8764eca46af7Smrg if test yes = "$build_libtool_libs"; then 87652378475aSmrg # Building a libtool convenience library. 8766eca46af7Smrg # Some compilers have problems with a '.al' extension so 87672378475aSmrg # convenience libraries should have the same extension an 87682378475aSmrg # archive normally would. 87692378475aSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 87702378475aSmrg build_libtool_libs=convenience 87712378475aSmrg build_old_libs=yes 87722378475aSmrg fi 87732378475aSmrg 87742378475aSmrg test -n "$vinfo" && \ 8775eca46af7Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 87762378475aSmrg 87772378475aSmrg test -n "$release" && \ 8778eca46af7Smrg func_warning "'-release' is ignored for convenience libraries" 87792378475aSmrg else 87802378475aSmrg 87812378475aSmrg # Parse the version information argument. 8782eca46af7Smrg save_ifs=$IFS; IFS=: 87832378475aSmrg set dummy $vinfo 0 0 0 87842378475aSmrg shift 8785eca46af7Smrg IFS=$save_ifs 87862378475aSmrg 87872378475aSmrg test -n "$7" && \ 8788eca46af7Smrg func_fatal_help "too many parameters to '-version-info'" 87892378475aSmrg 87902378475aSmrg # convert absolute version numbers to libtool ages 87912378475aSmrg # this retains compatibility with .la files and attempts 87922378475aSmrg # to make the code below a bit more comprehensible 87932378475aSmrg 87942378475aSmrg case $vinfo_number in 87952378475aSmrg yes) 8796eca46af7Smrg number_major=$1 8797eca46af7Smrg number_minor=$2 8798eca46af7Smrg number_revision=$3 87992378475aSmrg # 88002378475aSmrg # There are really only two kinds -- those that 88012378475aSmrg # use the current revision as the major version 88022378475aSmrg # and those that subtract age and use age as 88032378475aSmrg # a minor version. But, then there is irix 8804eca46af7Smrg # that has an extra 1 added just for fun 88052378475aSmrg # 88062378475aSmrg case $version_type in 8807eca46af7Smrg # correct linux to gnu/linux during the next big refactor 8808eca46af7Smrg darwin|freebsd-elf|linux|osf|windows|none) 88092378475aSmrg func_arith $number_major + $number_minor 88102378475aSmrg current=$func_arith_result 8811eca46af7Smrg age=$number_minor 8812eca46af7Smrg revision=$number_revision 88132378475aSmrg ;; 8814eca46af7Smrg freebsd-aout|qnx|sunos) 8815eca46af7Smrg current=$number_major 8816eca46af7Smrg revision=$number_minor 8817eca46af7Smrg age=0 88182378475aSmrg ;; 88192378475aSmrg irix|nonstopux) 88202378475aSmrg func_arith $number_major + $number_minor 88212378475aSmrg current=$func_arith_result 8822eca46af7Smrg age=$number_minor 8823eca46af7Smrg revision=$number_minor 88242378475aSmrg lt_irix_increment=no 88252378475aSmrg ;; 88262378475aSmrg esac 88272378475aSmrg ;; 88282378475aSmrg no) 8829eca46af7Smrg current=$1 8830eca46af7Smrg revision=$2 8831eca46af7Smrg age=$3 88322378475aSmrg ;; 88332378475aSmrg esac 88342378475aSmrg 88352378475aSmrg # Check that each of the things are valid numbers. 88362378475aSmrg case $current in 88372378475aSmrg 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]) ;; 88382378475aSmrg *) 8839eca46af7Smrg func_error "CURRENT '$current' must be a nonnegative integer" 8840eca46af7Smrg func_fatal_error "'$vinfo' is not valid version information" 88412378475aSmrg ;; 88422378475aSmrg esac 88432378475aSmrg 88442378475aSmrg case $revision in 88452378475aSmrg 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]) ;; 88462378475aSmrg *) 8847eca46af7Smrg func_error "REVISION '$revision' must be a nonnegative integer" 8848eca46af7Smrg func_fatal_error "'$vinfo' is not valid version information" 88492378475aSmrg ;; 88502378475aSmrg esac 88512378475aSmrg 88522378475aSmrg case $age in 88532378475aSmrg 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]) ;; 88542378475aSmrg *) 8855eca46af7Smrg func_error "AGE '$age' must be a nonnegative integer" 8856eca46af7Smrg func_fatal_error "'$vinfo' is not valid version information" 88572378475aSmrg ;; 88582378475aSmrg esac 88592378475aSmrg 88602378475aSmrg if test "$age" -gt "$current"; then 8861eca46af7Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 8862eca46af7Smrg func_fatal_error "'$vinfo' is not valid version information" 88632378475aSmrg fi 88642378475aSmrg 88652378475aSmrg # Calculate the version variables. 88662378475aSmrg major= 88672378475aSmrg versuffix= 88682378475aSmrg verstring= 88692378475aSmrg case $version_type in 88702378475aSmrg none) ;; 88712378475aSmrg 88722378475aSmrg darwin) 88732378475aSmrg # Like Linux, but with the current version available in 88742378475aSmrg # verstring for coding it into the library header 88752378475aSmrg func_arith $current - $age 88762378475aSmrg major=.$func_arith_result 8877eca46af7Smrg versuffix=$major.$age.$revision 88782378475aSmrg # Darwin ld doesn't like 0 for these options... 88792378475aSmrg func_arith $current + 1 88802378475aSmrg minor_current=$func_arith_result 8881eca46af7Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 88822378475aSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8883eca46af7Smrg # On Darwin other compilers 8884eca46af7Smrg case $CC in 8885eca46af7Smrg nagfor*) 8886eca46af7Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8887eca46af7Smrg ;; 8888eca46af7Smrg *) 8889eca46af7Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8890eca46af7Smrg ;; 8891eca46af7Smrg esac 88922378475aSmrg ;; 88932378475aSmrg 88942378475aSmrg freebsd-aout) 8895eca46af7Smrg major=.$current 8896eca46af7Smrg versuffix=.$current.$revision 88972378475aSmrg ;; 88982378475aSmrg 88992378475aSmrg freebsd-elf) 8900eca46af7Smrg func_arith $current - $age 8901eca46af7Smrg major=.$func_arith_result 8902eca46af7Smrg versuffix=$major.$age.$revision 89032378475aSmrg ;; 89042378475aSmrg 89052378475aSmrg irix | nonstopux) 8906eca46af7Smrg if test no = "$lt_irix_increment"; then 89072378475aSmrg func_arith $current - $age 89082378475aSmrg else 89092378475aSmrg func_arith $current - $age + 1 89102378475aSmrg fi 89112378475aSmrg major=$func_arith_result 89122378475aSmrg 89132378475aSmrg case $version_type in 89142378475aSmrg nonstopux) verstring_prefix=nonstopux ;; 89152378475aSmrg *) verstring_prefix=sgi ;; 89162378475aSmrg esac 8917eca46af7Smrg verstring=$verstring_prefix$major.$revision 89182378475aSmrg 89192378475aSmrg # Add in all the interfaces that we are compatible with. 89202378475aSmrg loop=$revision 8921eca46af7Smrg while test 0 -ne "$loop"; do 89222378475aSmrg func_arith $revision - $loop 89232378475aSmrg iface=$func_arith_result 89242378475aSmrg func_arith $loop - 1 89252378475aSmrg loop=$func_arith_result 8926eca46af7Smrg verstring=$verstring_prefix$major.$iface:$verstring 89272378475aSmrg done 89282378475aSmrg 8929eca46af7Smrg # Before this point, $major must not contain '.'. 89302378475aSmrg major=.$major 8931eca46af7Smrg versuffix=$major.$revision 89322378475aSmrg ;; 89332378475aSmrg 8934eca46af7Smrg linux) # correct to gnu/linux during the next big refactor 89352378475aSmrg func_arith $current - $age 89362378475aSmrg major=.$func_arith_result 8937eca46af7Smrg versuffix=$major.$age.$revision 89382378475aSmrg ;; 89392378475aSmrg 89402378475aSmrg osf) 89412378475aSmrg func_arith $current - $age 89422378475aSmrg major=.$func_arith_result 8943eca46af7Smrg versuffix=.$current.$age.$revision 8944eca46af7Smrg verstring=$current.$age.$revision 89452378475aSmrg 89462378475aSmrg # Add in all the interfaces that we are compatible with. 89472378475aSmrg loop=$age 8948eca46af7Smrg while test 0 -ne "$loop"; do 89492378475aSmrg func_arith $current - $loop 89502378475aSmrg iface=$func_arith_result 89512378475aSmrg func_arith $loop - 1 89522378475aSmrg loop=$func_arith_result 8953eca46af7Smrg verstring=$verstring:$iface.0 89542378475aSmrg done 89552378475aSmrg 89562378475aSmrg # Make executables depend on our current version. 8957eca46af7Smrg func_append verstring ":$current.0" 89582378475aSmrg ;; 89592378475aSmrg 89602378475aSmrg qnx) 8961eca46af7Smrg major=.$current 8962eca46af7Smrg versuffix=.$current 8963eca46af7Smrg ;; 8964eca46af7Smrg 8965eca46af7Smrg sco) 8966eca46af7Smrg major=.$current 8967eca46af7Smrg versuffix=.$current 89682378475aSmrg ;; 89692378475aSmrg 89702378475aSmrg sunos) 8971eca46af7Smrg major=.$current 8972eca46af7Smrg versuffix=.$current.$revision 89732378475aSmrg ;; 89742378475aSmrg 89752378475aSmrg windows) 89762378475aSmrg # Use '-' rather than '.', since we only want one 8977eca46af7Smrg # extension on DOS 8.3 file systems. 89782378475aSmrg func_arith $current - $age 89792378475aSmrg major=$func_arith_result 8980eca46af7Smrg versuffix=-$major 89812378475aSmrg ;; 89822378475aSmrg 89832378475aSmrg *) 8984eca46af7Smrg func_fatal_configuration "unknown library version type '$version_type'" 89852378475aSmrg ;; 89862378475aSmrg esac 89872378475aSmrg 89882378475aSmrg # Clear the version info if we defaulted, and they specified a release. 89892378475aSmrg if test -z "$vinfo" && test -n "$release"; then 89902378475aSmrg major= 89912378475aSmrg case $version_type in 89922378475aSmrg darwin) 89932378475aSmrg # we can't check for "0.0" in archive_cmds due to quoting 89942378475aSmrg # problems, so we reset it completely 89952378475aSmrg verstring= 89962378475aSmrg ;; 89972378475aSmrg *) 8998eca46af7Smrg verstring=0.0 89992378475aSmrg ;; 90002378475aSmrg esac 9001eca46af7Smrg if test no = "$need_version"; then 90022378475aSmrg versuffix= 90032378475aSmrg else 9004eca46af7Smrg versuffix=.0.0 90052378475aSmrg fi 90062378475aSmrg fi 90072378475aSmrg 90082378475aSmrg # Remove version info from name if versioning should be avoided 9009eca46af7Smrg if test yes,no = "$avoid_version,$need_version"; then 90102378475aSmrg major= 90112378475aSmrg versuffix= 9012eca46af7Smrg verstring= 90132378475aSmrg fi 90142378475aSmrg 90152378475aSmrg # Check to see if the archive will have undefined symbols. 9016eca46af7Smrg if test yes = "$allow_undefined"; then 9017eca46af7Smrg if test unsupported = "$allow_undefined_flag"; then 9018eca46af7Smrg if test yes = "$build_old_libs"; then 9019eca46af7Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9020eca46af7Smrg build_libtool_libs=no 9021eca46af7Smrg else 9022eca46af7Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9023eca46af7Smrg fi 90242378475aSmrg fi 90252378475aSmrg else 90262378475aSmrg # Don't allow undefined symbols. 9027eca46af7Smrg allow_undefined_flag=$no_undefined_flag 90282378475aSmrg fi 90292378475aSmrg 90302378475aSmrg fi 90312378475aSmrg 9032eca46af7Smrg func_generate_dlsyms "$libname" "$libname" : 903314330f12Smrg func_append libobjs " $symfileobj" 9034eca46af7Smrg test " " = "$libobjs" && libobjs= 90352378475aSmrg 9036eca46af7Smrg if test relink != "$opt_mode"; then 90372378475aSmrg # Remove our outputs, but don't remove object files since they 90382378475aSmrg # may have been created when compiling PIC objects. 90392378475aSmrg removelist= 90402378475aSmrg tempremovelist=`$ECHO "$output_objdir/*"` 90412378475aSmrg for p in $tempremovelist; do 90422378475aSmrg case $p in 90432378475aSmrg *.$objext | *.gcno) 90442378475aSmrg ;; 9045eca46af7Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9046eca46af7Smrg if test -n "$precious_files_regex"; then 90472378475aSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 90482378475aSmrg then 90492378475aSmrg continue 90502378475aSmrg fi 90512378475aSmrg fi 905214330f12Smrg func_append removelist " $p" 90532378475aSmrg ;; 90542378475aSmrg *) ;; 90552378475aSmrg esac 90562378475aSmrg done 90572378475aSmrg test -n "$removelist" && \ 90582378475aSmrg func_show_eval "${RM}r \$removelist" 90592378475aSmrg fi 90602378475aSmrg 90612378475aSmrg # Now set the variables for building old libraries. 9062eca46af7Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 906314330f12Smrg func_append oldlibs " $output_objdir/$libname.$libext" 90642378475aSmrg 90652378475aSmrg # Transform .lo files to .o files. 9066eca46af7Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 90672378475aSmrg fi 90682378475aSmrg 90692378475aSmrg # Eliminate all temporary directories. 90702378475aSmrg #for path in $notinst_path; do 907114330f12Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 907214330f12Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 907314330f12Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 90742378475aSmrg #done 90752378475aSmrg 90762378475aSmrg if test -n "$xrpath"; then 90772378475aSmrg # If the user specified any rpath flags, then add them. 90782378475aSmrg temp_xrpath= 90792378475aSmrg for libdir in $xrpath; do 908014330f12Smrg func_replace_sysroot "$libdir" 908114330f12Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 90822378475aSmrg case "$finalize_rpath " in 90832378475aSmrg *" $libdir "*) ;; 908414330f12Smrg *) func_append finalize_rpath " $libdir" ;; 90852378475aSmrg esac 90862378475aSmrg done 9087eca46af7Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 90882378475aSmrg dependency_libs="$temp_xrpath $dependency_libs" 90892378475aSmrg fi 90902378475aSmrg fi 90912378475aSmrg 90922378475aSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9093eca46af7Smrg old_dlfiles=$dlfiles 90942378475aSmrg dlfiles= 90952378475aSmrg for lib in $old_dlfiles; do 90962378475aSmrg case " $dlprefiles $dlfiles " in 90972378475aSmrg *" $lib "*) ;; 909814330f12Smrg *) func_append dlfiles " $lib" ;; 90992378475aSmrg esac 91002378475aSmrg done 91012378475aSmrg 91022378475aSmrg # Make sure dlprefiles contains only unique files 9103eca46af7Smrg old_dlprefiles=$dlprefiles 91042378475aSmrg dlprefiles= 91052378475aSmrg for lib in $old_dlprefiles; do 91062378475aSmrg case "$dlprefiles " in 91072378475aSmrg *" $lib "*) ;; 910814330f12Smrg *) func_append dlprefiles " $lib" ;; 91092378475aSmrg esac 91102378475aSmrg done 91112378475aSmrg 9112eca46af7Smrg if test yes = "$build_libtool_libs"; then 91132378475aSmrg if test -n "$rpath"; then 91142378475aSmrg case $host in 911514330f12Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 91162378475aSmrg # these systems don't actually have a c library (as such)! 91172378475aSmrg ;; 91182378475aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 91192378475aSmrg # Rhapsody C library is in the System framework 912014330f12Smrg func_append deplibs " System.ltframework" 91212378475aSmrg ;; 91222378475aSmrg *-*-netbsd*) 91232378475aSmrg # Don't link with libc until the a.out ld.so is fixed. 91242378475aSmrg ;; 91252378475aSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 91262378475aSmrg # Do not include libc due to us having libc/libc_r. 91272378475aSmrg ;; 91282378475aSmrg *-*-sco3.2v5* | *-*-sco5v6*) 91292378475aSmrg # Causes problems with __ctype 91302378475aSmrg ;; 91312378475aSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 91322378475aSmrg # Compiler inserts libc in the correct place for threads to work 91332378475aSmrg ;; 91342378475aSmrg *) 91352378475aSmrg # Add libc to deplibs on all other systems if necessary. 9136eca46af7Smrg if test yes = "$build_libtool_need_lc"; then 913714330f12Smrg func_append deplibs " -lc" 91382378475aSmrg fi 91392378475aSmrg ;; 91402378475aSmrg esac 91412378475aSmrg fi 91422378475aSmrg 91432378475aSmrg # Transform deplibs into only deplibs that can be linked in shared. 91442378475aSmrg name_save=$name 91452378475aSmrg libname_save=$libname 91462378475aSmrg release_save=$release 91472378475aSmrg versuffix_save=$versuffix 91482378475aSmrg major_save=$major 91492378475aSmrg # I'm not sure if I'm treating the release correctly. I think 91502378475aSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 91512378475aSmrg # add it in twice. Is that correct? 9152eca46af7Smrg release= 9153eca46af7Smrg versuffix= 9154eca46af7Smrg major= 91552378475aSmrg newdeplibs= 91562378475aSmrg droppeddeps=no 91572378475aSmrg case $deplibs_check_method in 91582378475aSmrg pass_all) 91592378475aSmrg # Don't check for shared/static. Everything works. 91602378475aSmrg # This might be a little naive. We might want to check 91612378475aSmrg # whether the library exists or not. But this is on 91622378475aSmrg # osf3 & osf4 and I'm not really sure... Just 91632378475aSmrg # implementing what was already the behavior. 91642378475aSmrg newdeplibs=$deplibs 91652378475aSmrg ;; 91662378475aSmrg test_compile) 91672378475aSmrg # This code stresses the "libraries are programs" paradigm to its 91682378475aSmrg # limits. Maybe even breaks it. We compile a program, linking it 91692378475aSmrg # against the deplibs as a proxy for the library. Then we can check 91702378475aSmrg # whether they linked in statically or dynamically with ldd. 91712378475aSmrg $opt_dry_run || $RM conftest.c 91722378475aSmrg cat > conftest.c <<EOF 91732378475aSmrg int main() { return 0; } 91742378475aSmrgEOF 91752378475aSmrg $opt_dry_run || $RM conftest 91762378475aSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 91772378475aSmrg ldd_output=`ldd conftest` 91782378475aSmrg for i in $deplibs; do 91792378475aSmrg case $i in 91802378475aSmrg -l*) 91812378475aSmrg func_stripname -l '' "$i" 91822378475aSmrg name=$func_stripname_result 9183eca46af7Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 91842378475aSmrg case " $predeps $postdeps " in 91852378475aSmrg *" $i "*) 918614330f12Smrg func_append newdeplibs " $i" 9187eca46af7Smrg i= 91882378475aSmrg ;; 91892378475aSmrg esac 91902378475aSmrg fi 9191eca46af7Smrg if test -n "$i"; then 91922378475aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 91932378475aSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 91942378475aSmrg set dummy $deplib_matches; shift 91952378475aSmrg deplib_match=$1 9196eca46af7Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 919714330f12Smrg func_append newdeplibs " $i" 91982378475aSmrg else 91992378475aSmrg droppeddeps=yes 920014330f12Smrg echo 92012378475aSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 920214330f12Smrg echo "*** I have the capability to make that library automatically link in when" 920314330f12Smrg echo "*** you link to this library. But I can only do this if you have a" 920414330f12Smrg echo "*** shared version of the library, which I believe you do not have" 920514330f12Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 920614330f12Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 92072378475aSmrg fi 92082378475aSmrg fi 92092378475aSmrg ;; 92102378475aSmrg *) 921114330f12Smrg func_append newdeplibs " $i" 92122378475aSmrg ;; 92132378475aSmrg esac 92142378475aSmrg done 92152378475aSmrg else 92162378475aSmrg # Error occurred in the first compile. Let's try to salvage 92172378475aSmrg # the situation: Compile a separate program for each library. 92182378475aSmrg for i in $deplibs; do 92192378475aSmrg case $i in 92202378475aSmrg -l*) 92212378475aSmrg func_stripname -l '' "$i" 92222378475aSmrg name=$func_stripname_result 92232378475aSmrg $opt_dry_run || $RM conftest 92242378475aSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 92252378475aSmrg ldd_output=`ldd conftest` 9226eca46af7Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 92272378475aSmrg case " $predeps $postdeps " in 92282378475aSmrg *" $i "*) 922914330f12Smrg func_append newdeplibs " $i" 9230eca46af7Smrg i= 92312378475aSmrg ;; 92322378475aSmrg esac 92332378475aSmrg fi 9234eca46af7Smrg if test -n "$i"; then 92352378475aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 92362378475aSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 92372378475aSmrg set dummy $deplib_matches; shift 92382378475aSmrg deplib_match=$1 9239eca46af7Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 924014330f12Smrg func_append newdeplibs " $i" 92412378475aSmrg else 92422378475aSmrg droppeddeps=yes 924314330f12Smrg echo 92442378475aSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 924514330f12Smrg echo "*** I have the capability to make that library automatically link in when" 924614330f12Smrg echo "*** you link to this library. But I can only do this if you have a" 924714330f12Smrg echo "*** shared version of the library, which you do not appear to have" 924814330f12Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 924914330f12Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 92502378475aSmrg fi 92512378475aSmrg fi 92522378475aSmrg else 92532378475aSmrg droppeddeps=yes 925414330f12Smrg echo 92552378475aSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 925614330f12Smrg echo "*** make it link in! You will probably need to install it or some" 925714330f12Smrg echo "*** library that it depends on before this library will be fully" 925814330f12Smrg echo "*** functional. Installing it before continuing would be even better." 92592378475aSmrg fi 92602378475aSmrg ;; 92612378475aSmrg *) 926214330f12Smrg func_append newdeplibs " $i" 92632378475aSmrg ;; 92642378475aSmrg esac 92652378475aSmrg done 92662378475aSmrg fi 92672378475aSmrg ;; 92682378475aSmrg file_magic*) 92692378475aSmrg set dummy $deplibs_check_method; shift 92702378475aSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 92712378475aSmrg for a_deplib in $deplibs; do 92722378475aSmrg case $a_deplib in 92732378475aSmrg -l*) 92742378475aSmrg func_stripname -l '' "$a_deplib" 92752378475aSmrg name=$func_stripname_result 9276eca46af7Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 92772378475aSmrg case " $predeps $postdeps " in 92782378475aSmrg *" $a_deplib "*) 927914330f12Smrg func_append newdeplibs " $a_deplib" 9280eca46af7Smrg a_deplib= 92812378475aSmrg ;; 92822378475aSmrg esac 92832378475aSmrg fi 9284eca46af7Smrg if test -n "$a_deplib"; then 92852378475aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 928614330f12Smrg if test -n "$file_magic_glob"; then 928714330f12Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 928814330f12Smrg else 928914330f12Smrg libnameglob=$libname 929014330f12Smrg fi 9291eca46af7Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 92922378475aSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9293eca46af7Smrg if test yes = "$want_nocaseglob"; then 929414330f12Smrg shopt -s nocaseglob 929514330f12Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 929614330f12Smrg $nocaseglob 929714330f12Smrg else 929814330f12Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 929914330f12Smrg fi 93002378475aSmrg for potent_lib in $potential_libs; do 93012378475aSmrg # Follow soft links. 93022378475aSmrg if ls -lLd "$potent_lib" 2>/dev/null | 93032378475aSmrg $GREP " -> " >/dev/null; then 93042378475aSmrg continue 93052378475aSmrg fi 93062378475aSmrg # The statement above tries to avoid entering an 93072378475aSmrg # endless loop below, in case of cyclic links. 93082378475aSmrg # We might still enter an endless loop, since a link 93092378475aSmrg # loop can be closed while we follow links, 93102378475aSmrg # but so what? 9311eca46af7Smrg potlib=$potent_lib 93122378475aSmrg while test -h "$potlib" 2>/dev/null; do 9313eca46af7Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 93142378475aSmrg case $potliblink in 9315eca46af7Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9316eca46af7Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 93172378475aSmrg esac 93182378475aSmrg done 93192378475aSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 93202378475aSmrg $SED -e 10q | 93212378475aSmrg $EGREP "$file_magic_regex" > /dev/null; then 932214330f12Smrg func_append newdeplibs " $a_deplib" 9323eca46af7Smrg a_deplib= 93242378475aSmrg break 2 93252378475aSmrg fi 93262378475aSmrg done 93272378475aSmrg done 93282378475aSmrg fi 9329eca46af7Smrg if test -n "$a_deplib"; then 93302378475aSmrg droppeddeps=yes 933114330f12Smrg echo 93322378475aSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 933314330f12Smrg echo "*** I have the capability to make that library automatically link in when" 933414330f12Smrg echo "*** you link to this library. But I can only do this if you have a" 933514330f12Smrg echo "*** shared version of the library, which you do not appear to have" 933614330f12Smrg echo "*** because I did check the linker path looking for a file starting" 9337eca46af7Smrg if test -z "$potlib"; then 93382378475aSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 93392378475aSmrg else 93402378475aSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 93412378475aSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 93422378475aSmrg fi 93432378475aSmrg fi 93442378475aSmrg ;; 93452378475aSmrg *) 93462378475aSmrg # Add a -L argument. 934714330f12Smrg func_append newdeplibs " $a_deplib" 93482378475aSmrg ;; 93492378475aSmrg esac 93502378475aSmrg done # Gone through all deplibs. 93512378475aSmrg ;; 93522378475aSmrg match_pattern*) 93532378475aSmrg set dummy $deplibs_check_method; shift 93542378475aSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 93552378475aSmrg for a_deplib in $deplibs; do 93562378475aSmrg case $a_deplib in 93572378475aSmrg -l*) 93582378475aSmrg func_stripname -l '' "$a_deplib" 93592378475aSmrg name=$func_stripname_result 9360eca46af7Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 93612378475aSmrg case " $predeps $postdeps " in 93622378475aSmrg *" $a_deplib "*) 936314330f12Smrg func_append newdeplibs " $a_deplib" 9364eca46af7Smrg a_deplib= 93652378475aSmrg ;; 93662378475aSmrg esac 93672378475aSmrg fi 9368eca46af7Smrg if test -n "$a_deplib"; then 93692378475aSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 93702378475aSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 93712378475aSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 93722378475aSmrg for potent_lib in $potential_libs; do 9373eca46af7Smrg potlib=$potent_lib # see symlink-check above in file_magic test 937414330f12Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 93752378475aSmrg $EGREP "$match_pattern_regex" > /dev/null; then 937614330f12Smrg func_append newdeplibs " $a_deplib" 9377eca46af7Smrg a_deplib= 93782378475aSmrg break 2 93792378475aSmrg fi 93802378475aSmrg done 93812378475aSmrg done 93822378475aSmrg fi 9383eca46af7Smrg if test -n "$a_deplib"; then 93842378475aSmrg droppeddeps=yes 938514330f12Smrg echo 93862378475aSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 938714330f12Smrg echo "*** I have the capability to make that library automatically link in when" 938814330f12Smrg echo "*** you link to this library. But I can only do this if you have a" 938914330f12Smrg echo "*** shared version of the library, which you do not appear to have" 939014330f12Smrg echo "*** because I did check the linker path looking for a file starting" 9391eca46af7Smrg if test -z "$potlib"; then 93922378475aSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 93932378475aSmrg else 93942378475aSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 93952378475aSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 93962378475aSmrg fi 93972378475aSmrg fi 93982378475aSmrg ;; 93992378475aSmrg *) 94002378475aSmrg # Add a -L argument. 940114330f12Smrg func_append newdeplibs " $a_deplib" 94022378475aSmrg ;; 94032378475aSmrg esac 94042378475aSmrg done # Gone through all deplibs. 94052378475aSmrg ;; 94062378475aSmrg none | unknown | *) 9407eca46af7Smrg newdeplibs= 940814330f12Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9409eca46af7Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9410eca46af7Smrg for i in $predeps $postdeps; do 94112378475aSmrg # can't use Xsed below, because $i might contain '/' 9412eca46af7Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 94132378475aSmrg done 94142378475aSmrg fi 941514330f12Smrg case $tmp_deplibs in 941614330f12Smrg *[!\ \ ]*) 941714330f12Smrg echo 9418eca46af7Smrg if test none = "$deplibs_check_method"; then 941914330f12Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 94202378475aSmrg else 942114330f12Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 94222378475aSmrg fi 942314330f12Smrg echo "*** All declared inter-library dependencies are being dropped." 94242378475aSmrg droppeddeps=yes 942514330f12Smrg ;; 942614330f12Smrg esac 94272378475aSmrg ;; 94282378475aSmrg esac 94292378475aSmrg versuffix=$versuffix_save 94302378475aSmrg major=$major_save 94312378475aSmrg release=$release_save 94322378475aSmrg libname=$libname_save 94332378475aSmrg name=$name_save 94342378475aSmrg 94352378475aSmrg case $host in 94362378475aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 94372378475aSmrg # On Rhapsody replace the C library with the System framework 943814330f12Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 94392378475aSmrg ;; 94402378475aSmrg esac 94412378475aSmrg 9442eca46af7Smrg if test yes = "$droppeddeps"; then 9443eca46af7Smrg if test yes = "$module"; then 944414330f12Smrg echo 944514330f12Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 94462378475aSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 944714330f12Smrg echo "*** a static module, that should work as long as the dlopening" 944814330f12Smrg echo "*** application is linked with the -dlopen flag." 94492378475aSmrg if test -z "$global_symbol_pipe"; then 945014330f12Smrg echo 945114330f12Smrg echo "*** However, this would only work if libtool was able to extract symbol" 9452eca46af7Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 945314330f12Smrg echo "*** not find such a program. So, this module is probably useless." 9454eca46af7Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 94552378475aSmrg fi 9456eca46af7Smrg if test no = "$build_old_libs"; then 9457eca46af7Smrg oldlibs=$output_objdir/$libname.$libext 94582378475aSmrg build_libtool_libs=module 94592378475aSmrg build_old_libs=yes 94602378475aSmrg else 94612378475aSmrg build_libtool_libs=no 94622378475aSmrg fi 94632378475aSmrg else 946414330f12Smrg echo "*** The inter-library dependencies that have been dropped here will be" 946514330f12Smrg echo "*** automatically added whenever a program is linked with this library" 946614330f12Smrg echo "*** or is declared to -dlopen it." 94672378475aSmrg 9468eca46af7Smrg if test no = "$allow_undefined"; then 946914330f12Smrg echo 947014330f12Smrg echo "*** Since this library must not contain undefined symbols," 947114330f12Smrg echo "*** because either the platform does not support them or" 947214330f12Smrg echo "*** it was explicitly requested with -no-undefined," 947314330f12Smrg echo "*** libtool will only create a static version of it." 9474eca46af7Smrg if test no = "$build_old_libs"; then 9475eca46af7Smrg oldlibs=$output_objdir/$libname.$libext 94762378475aSmrg build_libtool_libs=module 94772378475aSmrg build_old_libs=yes 94782378475aSmrg else 94792378475aSmrg build_libtool_libs=no 94802378475aSmrg fi 94812378475aSmrg fi 94822378475aSmrg fi 94832378475aSmrg fi 94842378475aSmrg # Done checking deplibs! 94852378475aSmrg deplibs=$newdeplibs 94862378475aSmrg fi 94872378475aSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 94882378475aSmrg case $host in 94892378475aSmrg *-*-darwin*) 949014330f12Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949114330f12Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949214330f12Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 94932378475aSmrg ;; 94942378475aSmrg esac 94952378475aSmrg 94962378475aSmrg # move library search paths that coincide with paths to not yet 94972378475aSmrg # installed libraries to the beginning of the library search list 94982378475aSmrg new_libs= 94992378475aSmrg for path in $notinst_path; do 95002378475aSmrg case " $new_libs " in 95012378475aSmrg *" -L$path/$objdir "*) ;; 95022378475aSmrg *) 95032378475aSmrg case " $deplibs " in 95042378475aSmrg *" -L$path/$objdir "*) 950514330f12Smrg func_append new_libs " -L$path/$objdir" ;; 95062378475aSmrg esac 95072378475aSmrg ;; 95082378475aSmrg esac 95092378475aSmrg done 95102378475aSmrg for deplib in $deplibs; do 95112378475aSmrg case $deplib in 95122378475aSmrg -L*) 95132378475aSmrg case " $new_libs " in 95142378475aSmrg *" $deplib "*) ;; 951514330f12Smrg *) func_append new_libs " $deplib" ;; 95162378475aSmrg esac 95172378475aSmrg ;; 951814330f12Smrg *) func_append new_libs " $deplib" ;; 95192378475aSmrg esac 95202378475aSmrg done 9521eca46af7Smrg deplibs=$new_libs 95222378475aSmrg 95232378475aSmrg # All the library-specific variables (install_libdir is set above). 95242378475aSmrg library_names= 95252378475aSmrg old_library= 95262378475aSmrg dlname= 95272378475aSmrg 95282378475aSmrg # Test again, we may have decided not to build it any more 9529eca46af7Smrg if test yes = "$build_libtool_libs"; then 9530eca46af7Smrg # Remove $wl instances when linking with ld. 9531eca46af7Smrg # FIXME: should test the right _cmds variable. 9532eca46af7Smrg case $archive_cmds in 9533eca46af7Smrg *\$LD\ *) wl= ;; 9534eca46af7Smrg esac 9535eca46af7Smrg if test yes = "$hardcode_into_libs"; then 95362378475aSmrg # Hardcode the library paths 95372378475aSmrg hardcode_libdirs= 95382378475aSmrg dep_rpath= 9539eca46af7Smrg rpath=$finalize_rpath 9540eca46af7Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 95412378475aSmrg for libdir in $rpath; do 95422378475aSmrg if test -n "$hardcode_libdir_flag_spec"; then 95432378475aSmrg if test -n "$hardcode_libdir_separator"; then 954414330f12Smrg func_replace_sysroot "$libdir" 954514330f12Smrg libdir=$func_replace_sysroot_result 95462378475aSmrg if test -z "$hardcode_libdirs"; then 9547eca46af7Smrg hardcode_libdirs=$libdir 95482378475aSmrg else 95492378475aSmrg # Just accumulate the unique libdirs. 95502378475aSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 95512378475aSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 95522378475aSmrg ;; 95532378475aSmrg *) 955414330f12Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 95552378475aSmrg ;; 95562378475aSmrg esac 95572378475aSmrg fi 95582378475aSmrg else 95592378475aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 956014330f12Smrg func_append dep_rpath " $flag" 95612378475aSmrg fi 95622378475aSmrg elif test -n "$runpath_var"; then 95632378475aSmrg case "$perm_rpath " in 95642378475aSmrg *" $libdir "*) ;; 9565eca46af7Smrg *) func_append perm_rpath " $libdir" ;; 95662378475aSmrg esac 95672378475aSmrg fi 95682378475aSmrg done 95692378475aSmrg # Substitute the hardcoded libdirs into the rpath. 95702378475aSmrg if test -n "$hardcode_libdir_separator" && 95712378475aSmrg test -n "$hardcode_libdirs"; then 9572eca46af7Smrg libdir=$hardcode_libdirs 9573eca46af7Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 95742378475aSmrg fi 95752378475aSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 95762378475aSmrg # We should set the runpath_var. 95772378475aSmrg rpath= 95782378475aSmrg for dir in $perm_rpath; do 957914330f12Smrg func_append rpath "$dir:" 95802378475aSmrg done 95812378475aSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 95822378475aSmrg fi 95832378475aSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 95842378475aSmrg fi 958595b296d0Smrg 9586eca46af7Smrg shlibpath=$finalize_shlibpath 9587eca46af7Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 95882378475aSmrg if test -n "$shlibpath"; then 95892378475aSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 95902378475aSmrg fi 959195b296d0Smrg 95922378475aSmrg # Get the real and link names of the library. 95932378475aSmrg eval shared_ext=\"$shrext_cmds\" 95942378475aSmrg eval library_names=\"$library_names_spec\" 95952378475aSmrg set dummy $library_names 95962378475aSmrg shift 9597eca46af7Smrg realname=$1 95982378475aSmrg shift 959995b296d0Smrg 96002378475aSmrg if test -n "$soname_spec"; then 96012378475aSmrg eval soname=\"$soname_spec\" 96022378475aSmrg else 9603eca46af7Smrg soname=$realname 96042378475aSmrg fi 96052378475aSmrg if test -z "$dlname"; then 96062378475aSmrg dlname=$soname 96072378475aSmrg fi 960895b296d0Smrg 9609eca46af7Smrg lib=$output_objdir/$realname 96102378475aSmrg linknames= 96112378475aSmrg for link 96122378475aSmrg do 961314330f12Smrg func_append linknames " $link" 96142378475aSmrg done 961595b296d0Smrg 96162378475aSmrg # Use standard objects if they are pic 961714330f12Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 96182378475aSmrg test "X$libobjs" = "X " && libobjs= 961995b296d0Smrg 96202378475aSmrg delfiles= 96212378475aSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 96222378475aSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9623eca46af7Smrg export_symbols=$output_objdir/$libname.uexp 962414330f12Smrg func_append delfiles " $export_symbols" 96252378475aSmrg fi 962695b296d0Smrg 96272378475aSmrg orig_export_symbols= 96282378475aSmrg case $host_os in 96292378475aSmrg cygwin* | mingw* | cegcc*) 96302378475aSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 96312378475aSmrg # exporting using user supplied symfile 9632eca46af7Smrg func_dll_def_p "$export_symbols" || { 96332378475aSmrg # and it's NOT already a .def file. Must figure out 96342378475aSmrg # which of the given symbols are data symbols and tag 96352378475aSmrg # them as such. So, trigger use of export_symbols_cmds. 96362378475aSmrg # export_symbols gets reassigned inside the "prepare 96372378475aSmrg # the list of exported symbols" if statement, so the 96382378475aSmrg # include_expsyms logic still works. 9639eca46af7Smrg orig_export_symbols=$export_symbols 96402378475aSmrg export_symbols= 96412378475aSmrg always_export_symbols=yes 9642eca46af7Smrg } 96432378475aSmrg fi 96442378475aSmrg ;; 96452378475aSmrg esac 964695b296d0Smrg 96472378475aSmrg # Prepare the list of exported symbols 96482378475aSmrg if test -z "$export_symbols"; then 9649eca46af7Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9650eca46af7Smrg func_verbose "generating symbol list for '$libname.la'" 9651eca46af7Smrg export_symbols=$output_objdir/$libname.exp 96522378475aSmrg $opt_dry_run || $RM $export_symbols 96532378475aSmrg cmds=$export_symbols_cmds 9654eca46af7Smrg save_ifs=$IFS; IFS='~' 965514330f12Smrg for cmd1 in $cmds; do 9656eca46af7Smrg IFS=$save_ifs 965714330f12Smrg # Take the normal branch if the nm_file_list_spec branch 965814330f12Smrg # doesn't work or if tool conversion is not needed. 965914330f12Smrg case $nm_file_list_spec~$to_tool_file_cmd in 966014330f12Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 966114330f12Smrg try_normal_branch=yes 966214330f12Smrg eval cmd=\"$cmd1\" 966314330f12Smrg func_len " $cmd" 966414330f12Smrg len=$func_len_result 966514330f12Smrg ;; 966614330f12Smrg *) 966714330f12Smrg try_normal_branch=no 966814330f12Smrg ;; 966914330f12Smrg esac 9670eca46af7Smrg if test yes = "$try_normal_branch" \ 967114330f12Smrg && { test "$len" -lt "$max_cmd_len" \ 967214330f12Smrg || test "$max_cmd_len" -le -1; } 967314330f12Smrg then 967414330f12Smrg func_show_eval "$cmd" 'exit $?' 967514330f12Smrg skipped_export=false 967614330f12Smrg elif test -n "$nm_file_list_spec"; then 967714330f12Smrg func_basename "$output" 967814330f12Smrg output_la=$func_basename_result 967914330f12Smrg save_libobjs=$libobjs 968014330f12Smrg save_output=$output 9681eca46af7Smrg output=$output_objdir/$output_la.nm 968214330f12Smrg func_to_tool_file "$output" 968314330f12Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 968414330f12Smrg func_append delfiles " $output" 968514330f12Smrg func_verbose "creating $NM input file list: $output" 968614330f12Smrg for obj in $save_libobjs; do 968714330f12Smrg func_to_tool_file "$obj" 968814330f12Smrg $ECHO "$func_to_tool_file_result" 968914330f12Smrg done > "$output" 969014330f12Smrg eval cmd=\"$cmd1\" 96912378475aSmrg func_show_eval "$cmd" 'exit $?' 969214330f12Smrg output=$save_output 969314330f12Smrg libobjs=$save_libobjs 96942378475aSmrg skipped_export=false 96952378475aSmrg else 96962378475aSmrg # The command line is too long to execute in one step. 96972378475aSmrg func_verbose "using reloadable object file for export list..." 96982378475aSmrg skipped_export=: 96992378475aSmrg # Break out early, otherwise skipped_export may be 97002378475aSmrg # set to false by a later but shorter cmd. 97012378475aSmrg break 97022378475aSmrg fi 97032378475aSmrg done 9704eca46af7Smrg IFS=$save_ifs 9705eca46af7Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 97062378475aSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 97072378475aSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 97082378475aSmrg fi 97092378475aSmrg fi 971095b296d0Smrg fi 971195b296d0Smrg 97122378475aSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9713eca46af7Smrg tmp_export_symbols=$export_symbols 9714eca46af7Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 971514330f12Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 97162378475aSmrg fi 971795b296d0Smrg 9718eca46af7Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 97192378475aSmrg # The given exports_symbols file has to be filtered, so filter it. 9720eca46af7Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 97212378475aSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9722eca46af7Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 97232378475aSmrg # though. Also, the filter scales superlinearly with the number of 97242378475aSmrg # global variables. join(1) would be nice here, but unfortunately 97252378475aSmrg # isn't a blessed tool. 97262378475aSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 972714330f12Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 97282378475aSmrg export_symbols=$output_objdir/$libname.def 97292378475aSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 97302378475aSmrg fi 973195b296d0Smrg 97322378475aSmrg tmp_deplibs= 97332378475aSmrg for test_deplib in $deplibs; do 97342378475aSmrg case " $convenience " in 97352378475aSmrg *" $test_deplib "*) ;; 97362378475aSmrg *) 973714330f12Smrg func_append tmp_deplibs " $test_deplib" 97382378475aSmrg ;; 97392378475aSmrg esac 97402378475aSmrg done 9741eca46af7Smrg deplibs=$tmp_deplibs 974295b296d0Smrg 97432378475aSmrg if test -n "$convenience"; then 97442378475aSmrg if test -n "$whole_archive_flag_spec" && 9745eca46af7Smrg test yes = "$compiler_needs_object" && 97462378475aSmrg test -z "$libobjs"; then 97472378475aSmrg # extract the archives, so we have objects to list. 97482378475aSmrg # TODO: could optimize this to just extract one archive. 97492378475aSmrg whole_archive_flag_spec= 97502378475aSmrg fi 97512378475aSmrg if test -n "$whole_archive_flag_spec"; then 97522378475aSmrg save_libobjs=$libobjs 97532378475aSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 97542378475aSmrg test "X$libobjs" = "X " && libobjs= 97552378475aSmrg else 9756eca46af7Smrg gentop=$output_objdir/${outputname}x 975714330f12Smrg func_append generated " $gentop" 975895b296d0Smrg 97592378475aSmrg func_extract_archives $gentop $convenience 976014330f12Smrg func_append libobjs " $func_extract_archives_result" 97612378475aSmrg test "X$libobjs" = "X " && libobjs= 97622378475aSmrg fi 9763e6f085baSmrg fi 976495b296d0Smrg 9765eca46af7Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 97662378475aSmrg eval flag=\"$thread_safe_flag_spec\" 976714330f12Smrg func_append linker_flags " $flag" 9768e6f085baSmrg fi 976939713583Smrg 97702378475aSmrg # Make a backup of the uninstalled library when relinking 9771eca46af7Smrg if test relink = "$opt_mode"; then 97722378475aSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 97732378475aSmrg fi 977495b296d0Smrg 97752378475aSmrg # Do each of the archive commands. 9776eca46af7Smrg if test yes = "$module" && test -n "$module_cmds"; then 97772378475aSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 97782378475aSmrg eval test_cmds=\"$module_expsym_cmds\" 97792378475aSmrg cmds=$module_expsym_cmds 97802378475aSmrg else 97812378475aSmrg eval test_cmds=\"$module_cmds\" 97822378475aSmrg cmds=$module_cmds 97832378475aSmrg fi 9784e6f085baSmrg else 97852378475aSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 97862378475aSmrg eval test_cmds=\"$archive_expsym_cmds\" 97872378475aSmrg cmds=$archive_expsym_cmds 97882378475aSmrg else 97892378475aSmrg eval test_cmds=\"$archive_cmds\" 97902378475aSmrg cmds=$archive_cmds 97912378475aSmrg fi 9792e6f085baSmrg fi 979395b296d0Smrg 9794eca46af7Smrg if test : != "$skipped_export" && 97952378475aSmrg func_len " $test_cmds" && 97962378475aSmrg len=$func_len_result && 97972378475aSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 97982378475aSmrg : 97992378475aSmrg else 98002378475aSmrg # The command line is too long to link in one step, link piecewise 98012378475aSmrg # or, if using GNU ld and skipped_export is not :, use a linker 98022378475aSmrg # script. 980395b296d0Smrg 98042378475aSmrg # Save the value of $output and $libobjs because we want to 98052378475aSmrg # use them later. If we have whole_archive_flag_spec, we 98062378475aSmrg # want to use save_libobjs as it was before 98072378475aSmrg # whole_archive_flag_spec was expanded, because we can't 98082378475aSmrg # assume the linker understands whole_archive_flag_spec. 98092378475aSmrg # This may have to be revisited, in case too many 98102378475aSmrg # convenience libraries get linked in and end up exceeding 98112378475aSmrg # the spec. 98122378475aSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 98132378475aSmrg save_libobjs=$libobjs 98142378475aSmrg fi 98152378475aSmrg save_output=$output 981614330f12Smrg func_basename "$output" 981714330f12Smrg output_la=$func_basename_result 981895b296d0Smrg 98192378475aSmrg # Clear the reloadable object creation command queue and 98202378475aSmrg # initialize k to one. 98212378475aSmrg test_cmds= 98222378475aSmrg concat_cmds= 98232378475aSmrg objlist= 98242378475aSmrg last_robj= 98252378475aSmrg k=1 98262378475aSmrg 9827eca46af7Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 9828eca46af7Smrg output=$output_objdir/$output_la.lnkscript 98292378475aSmrg func_verbose "creating GNU ld script: $output" 983014330f12Smrg echo 'INPUT (' > $output 98312378475aSmrg for obj in $save_libobjs 9832e6f085baSmrg do 983314330f12Smrg func_to_tool_file "$obj" 983414330f12Smrg $ECHO "$func_to_tool_file_result" >> $output 98352378475aSmrg done 983614330f12Smrg echo ')' >> $output 983714330f12Smrg func_append delfiles " $output" 983814330f12Smrg func_to_tool_file "$output" 983914330f12Smrg output=$func_to_tool_file_result 9840eca46af7Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 9841eca46af7Smrg output=$output_objdir/$output_la.lnk 98422378475aSmrg func_verbose "creating linker input file list: $output" 98432378475aSmrg : > $output 98442378475aSmrg set x $save_libobjs 98452378475aSmrg shift 98462378475aSmrg firstobj= 9847eca46af7Smrg if test yes = "$compiler_needs_object"; then 98482378475aSmrg firstobj="$1 " 98492378475aSmrg shift 98502378475aSmrg fi 98512378475aSmrg for obj 98522378475aSmrg do 985314330f12Smrg func_to_tool_file "$obj" 985414330f12Smrg $ECHO "$func_to_tool_file_result" >> $output 98552378475aSmrg done 985614330f12Smrg func_append delfiles " $output" 985714330f12Smrg func_to_tool_file "$output" 985814330f12Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 98592378475aSmrg else 98602378475aSmrg if test -n "$save_libobjs"; then 98612378475aSmrg func_verbose "creating reloadable object files..." 9862eca46af7Smrg output=$output_objdir/$output_la-$k.$objext 98632378475aSmrg eval test_cmds=\"$reload_cmds\" 98642378475aSmrg func_len " $test_cmds" 98652378475aSmrg len0=$func_len_result 98662378475aSmrg len=$len0 98672378475aSmrg 98682378475aSmrg # Loop over the list of objects to be linked. 98692378475aSmrg for obj in $save_libobjs 98702378475aSmrg do 98712378475aSmrg func_len " $obj" 98722378475aSmrg func_arith $len + $func_len_result 98732378475aSmrg len=$func_arith_result 9874eca46af7Smrg if test -z "$objlist" || 98752378475aSmrg test "$len" -lt "$max_cmd_len"; then 98762378475aSmrg func_append objlist " $obj" 98772378475aSmrg else 98782378475aSmrg # The command $test_cmds is almost too long, add a 98792378475aSmrg # command to the queue. 9880eca46af7Smrg if test 1 -eq "$k"; then 98812378475aSmrg # The first file doesn't have a previous command to add. 988214330f12Smrg reload_objs=$objlist 988314330f12Smrg eval concat_cmds=\"$reload_cmds\" 98842378475aSmrg else 98852378475aSmrg # All subsequent reloadable object files will link in 98862378475aSmrg # the last one created. 988714330f12Smrg reload_objs="$objlist $last_robj" 988814330f12Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 98892378475aSmrg fi 9890eca46af7Smrg last_robj=$output_objdir/$output_la-$k.$objext 98912378475aSmrg func_arith $k + 1 98922378475aSmrg k=$func_arith_result 9893eca46af7Smrg output=$output_objdir/$output_la-$k.$objext 989414330f12Smrg objlist=" $obj" 98952378475aSmrg func_len " $last_robj" 98962378475aSmrg func_arith $len0 + $func_len_result 98972378475aSmrg len=$func_arith_result 98982378475aSmrg fi 98992378475aSmrg done 99002378475aSmrg # Handle the remaining objects by creating one last 99012378475aSmrg # reloadable object file. All subsequent reloadable object 99022378475aSmrg # files will link in the last one created. 99032378475aSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 990414330f12Smrg reload_objs="$objlist $last_robj" 9905eca46af7Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 99062378475aSmrg if test -n "$last_robj"; then 9907eca46af7Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 99082378475aSmrg fi 990914330f12Smrg func_append delfiles " $output" 991095b296d0Smrg 99112378475aSmrg else 99122378475aSmrg output= 99132378475aSmrg fi 991495b296d0Smrg 9915eca46af7Smrg ${skipped_export-false} && { 9916eca46af7Smrg func_verbose "generating symbol list for '$libname.la'" 9917eca46af7Smrg export_symbols=$output_objdir/$libname.exp 99182378475aSmrg $opt_dry_run || $RM $export_symbols 99192378475aSmrg libobjs=$output 99202378475aSmrg # Append the command to create the export file. 99212378475aSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 99222378475aSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 99232378475aSmrg if test -n "$last_robj"; then 99242378475aSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 99252378475aSmrg fi 9926eca46af7Smrg } 992795b296d0Smrg 99282378475aSmrg test -n "$save_libobjs" && 99292378475aSmrg func_verbose "creating a temporary reloadable object file: $output" 993095b296d0Smrg 99312378475aSmrg # Loop through the commands generated above and execute them. 9932eca46af7Smrg save_ifs=$IFS; IFS='~' 99332378475aSmrg for cmd in $concat_cmds; do 9934eca46af7Smrg IFS=$save_ifs 9935eca46af7Smrg $opt_quiet || { 99362378475aSmrg func_quote_for_expand "$cmd" 99372378475aSmrg eval "func_echo $func_quote_for_expand_result" 99382378475aSmrg } 99392378475aSmrg $opt_dry_run || eval "$cmd" || { 99402378475aSmrg lt_exit=$? 99412378475aSmrg 99422378475aSmrg # Restore the uninstalled library and exit 9943eca46af7Smrg if test relink = "$opt_mode"; then 99442378475aSmrg ( cd "$output_objdir" && \ 99452378475aSmrg $RM "${realname}T" && \ 99462378475aSmrg $MV "${realname}U" "$realname" ) 99472378475aSmrg fi 994895b296d0Smrg 99492378475aSmrg exit $lt_exit 99502378475aSmrg } 99512378475aSmrg done 9952eca46af7Smrg IFS=$save_ifs 9953e6f085baSmrg 99542378475aSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 99552378475aSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 99562378475aSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 995795b296d0Smrg fi 995895b296d0Smrg fi 995995b296d0Smrg 9960eca46af7Smrg ${skipped_export-false} && { 99612378475aSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9962eca46af7Smrg tmp_export_symbols=$export_symbols 9963eca46af7Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 996414330f12Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 99652378475aSmrg fi 996639713583Smrg 99672378475aSmrg if test -n "$orig_export_symbols"; then 99682378475aSmrg # The given exports_symbols file has to be filtered, so filter it. 9969eca46af7Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 99702378475aSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9971eca46af7Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 99722378475aSmrg # though. Also, the filter scales superlinearly with the number of 99732378475aSmrg # global variables. join(1) would be nice here, but unfortunately 99742378475aSmrg # isn't a blessed tool. 99752378475aSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 997614330f12Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 99772378475aSmrg export_symbols=$output_objdir/$libname.def 99782378475aSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 99792378475aSmrg fi 9980eca46af7Smrg } 998195b296d0Smrg 99822378475aSmrg libobjs=$output 99832378475aSmrg # Restore the value of output. 99842378475aSmrg output=$save_output 998595b296d0Smrg 99862378475aSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 99872378475aSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 99882378475aSmrg test "X$libobjs" = "X " && libobjs= 99892378475aSmrg fi 99902378475aSmrg # Expand the library linking commands again to reset the 99912378475aSmrg # value of $libobjs for piecewise linking. 999295b296d0Smrg 99932378475aSmrg # Do each of the archive commands. 9994eca46af7Smrg if test yes = "$module" && test -n "$module_cmds"; then 99952378475aSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 99962378475aSmrg cmds=$module_expsym_cmds 99972378475aSmrg else 99982378475aSmrg cmds=$module_cmds 9999e6f085baSmrg fi 10000e6f085baSmrg else 100012378475aSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 100022378475aSmrg cmds=$archive_expsym_cmds 100032378475aSmrg else 100042378475aSmrg cmds=$archive_cmds 100052378475aSmrg fi 10006e6f085baSmrg fi 100072378475aSmrg fi 1000895b296d0Smrg 100092378475aSmrg if test -n "$delfiles"; then 100102378475aSmrg # Append the command to remove temporary files to $cmds. 100112378475aSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 100122378475aSmrg fi 1001395b296d0Smrg 100142378475aSmrg # Add any objects from preloaded convenience libraries 100152378475aSmrg if test -n "$dlprefiles"; then 10016eca46af7Smrg gentop=$output_objdir/${outputname}x 1001714330f12Smrg func_append generated " $gentop" 1001895b296d0Smrg 100192378475aSmrg func_extract_archives $gentop $dlprefiles 1002014330f12Smrg func_append libobjs " $func_extract_archives_result" 100212378475aSmrg test "X$libobjs" = "X " && libobjs= 100222378475aSmrg fi 1002395b296d0Smrg 10024eca46af7Smrg save_ifs=$IFS; IFS='~' 100252378475aSmrg for cmd in $cmds; do 10026eca46af7Smrg IFS=$sp$nl 100272378475aSmrg eval cmd=\"$cmd\" 10028eca46af7Smrg IFS=$save_ifs 10029eca46af7Smrg $opt_quiet || { 100302378475aSmrg func_quote_for_expand "$cmd" 100312378475aSmrg eval "func_echo $func_quote_for_expand_result" 100322378475aSmrg } 100332378475aSmrg $opt_dry_run || eval "$cmd" || { 100342378475aSmrg lt_exit=$? 1003539713583Smrg 100362378475aSmrg # Restore the uninstalled library and exit 10037eca46af7Smrg if test relink = "$opt_mode"; then 100382378475aSmrg ( cd "$output_objdir" && \ 100392378475aSmrg $RM "${realname}T" && \ 100402378475aSmrg $MV "${realname}U" "$realname" ) 100412378475aSmrg fi 1004239713583Smrg 100432378475aSmrg exit $lt_exit 100442378475aSmrg } 100452378475aSmrg done 10046eca46af7Smrg IFS=$save_ifs 1004739713583Smrg 100482378475aSmrg # Restore the uninstalled library and exit 10049eca46af7Smrg if test relink = "$opt_mode"; then 100502378475aSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 1005139713583Smrg 100522378475aSmrg if test -n "$convenience"; then 100532378475aSmrg if test -z "$whole_archive_flag_spec"; then 100542378475aSmrg func_show_eval '${RM}r "$gentop"' 100552378475aSmrg fi 100562378475aSmrg fi 1005739713583Smrg 100582378475aSmrg exit $EXIT_SUCCESS 100592378475aSmrg fi 100602378475aSmrg 100612378475aSmrg # Create links to the real library. 100622378475aSmrg for linkname in $linknames; do 100632378475aSmrg if test "$realname" != "$linkname"; then 100642378475aSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10065e6f085baSmrg fi 10066e6f085baSmrg done 1006739713583Smrg 100682378475aSmrg # If -module or -export-dynamic was specified, set the dlname. 10069eca46af7Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 100702378475aSmrg # On all known operating systems, these are identical. 10071eca46af7Smrg dlname=$soname 100722378475aSmrg fi 100732378475aSmrg fi 1007495b296d0Smrg ;; 1007595b296d0Smrg 100762378475aSmrg obj) 10077eca46af7Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10078eca46af7Smrg func_warning "'-dlopen' is ignored for objects" 100792378475aSmrg fi 10080e6f085baSmrg 100812378475aSmrg case " $deplibs" in 100822378475aSmrg *\ -l* | *\ -L*) 10083eca46af7Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 1008439713583Smrg esac 1008595b296d0Smrg 100862378475aSmrg test -n "$rpath" && \ 10087eca46af7Smrg func_warning "'-rpath' is ignored for objects" 100882378475aSmrg 100892378475aSmrg test -n "$xrpath" && \ 10090eca46af7Smrg func_warning "'-R' is ignored for objects" 1009195b296d0Smrg 100922378475aSmrg test -n "$vinfo" && \ 10093eca46af7Smrg func_warning "'-version-info' is ignored for objects" 1009439713583Smrg 100952378475aSmrg test -n "$release" && \ 10096eca46af7Smrg func_warning "'-release' is ignored for objects" 100972378475aSmrg 100982378475aSmrg case $output in 100992378475aSmrg *.lo) 101002378475aSmrg test -n "$objs$old_deplibs" && \ 10101eca46af7Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 101022378475aSmrg 101032378475aSmrg libobj=$output 101042378475aSmrg func_lo2o "$libobj" 101052378475aSmrg obj=$func_lo2o_result 10106e6f085baSmrg ;; 10107e6f085baSmrg *) 101082378475aSmrg libobj= 10109eca46af7Smrg obj=$output 1011095b296d0Smrg ;; 1011139713583Smrg esac 1011295b296d0Smrg 101132378475aSmrg # Delete the old objects. 101142378475aSmrg $opt_dry_run || $RM $obj $libobj 1011595b296d0Smrg 101162378475aSmrg # Objects from convenience libraries. This assumes 101172378475aSmrg # single-version convenience libraries. Whenever we create 101182378475aSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 101192378475aSmrg # the extraction. 101202378475aSmrg reload_conv_objs= 101212378475aSmrg gentop= 10122eca46af7Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 10123eca46af7Smrg # whole_archive_flag_spec and hope we can get by with turning comma 10124eca46af7Smrg # into space. 10125eca46af7Smrg case $reload_cmds in 10126eca46af7Smrg *\$LD[\ \$]*) wl= ;; 10127eca46af7Smrg esac 101282378475aSmrg if test -n "$convenience"; then 101292378475aSmrg if test -n "$whole_archive_flag_spec"; then 101302378475aSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10131eca46af7Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10132eca46af7Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 101332378475aSmrg else 10134eca46af7Smrg gentop=$output_objdir/${obj}x 1013514330f12Smrg func_append generated " $gentop" 10136e6f085baSmrg 101372378475aSmrg func_extract_archives $gentop $convenience 101382378475aSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 101392378475aSmrg fi 10140e6f085baSmrg fi 10141e6f085baSmrg 1014214330f12Smrg # If we're not building shared, we need to use non_pic_objs 10143eca46af7Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 1014414330f12Smrg 101452378475aSmrg # Create the old-style object. 10146eca46af7Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10147e6f085baSmrg 10148eca46af7Smrg output=$obj 101492378475aSmrg func_execute_cmds "$reload_cmds" 'exit $?' 10150e6f085baSmrg 101512378475aSmrg # Exit if we aren't doing a library object file. 101522378475aSmrg if test -z "$libobj"; then 101532378475aSmrg if test -n "$gentop"; then 101542378475aSmrg func_show_eval '${RM}r "$gentop"' 101552378475aSmrg fi 101562378475aSmrg 101572378475aSmrg exit $EXIT_SUCCESS 10158e6f085baSmrg fi 101592378475aSmrg 10160eca46af7Smrg test yes = "$build_libtool_libs" || { 101612378475aSmrg if test -n "$gentop"; then 101622378475aSmrg func_show_eval '${RM}r "$gentop"' 101632378475aSmrg fi 101642378475aSmrg 101652378475aSmrg # Create an invalid libtool object if no PIC, so that we don't 101662378475aSmrg # accidentally link it into a program. 101672378475aSmrg # $show "echo timestamp > $libobj" 101682378475aSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 101692378475aSmrg exit $EXIT_SUCCESS 10170eca46af7Smrg } 101712378475aSmrg 10172eca46af7Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 101732378475aSmrg # Only do commands if we really have different PIC objects. 101742378475aSmrg reload_objs="$libobjs $reload_conv_objs" 10175eca46af7Smrg output=$libobj 101762378475aSmrg func_execute_cmds "$reload_cmds" 'exit $?' 101772378475aSmrg fi 101782378475aSmrg 101792378475aSmrg if test -n "$gentop"; then 101802378475aSmrg func_show_eval '${RM}r "$gentop"' 101812378475aSmrg fi 101822378475aSmrg 101832378475aSmrg exit $EXIT_SUCCESS 10184e6f085baSmrg ;; 1018595b296d0Smrg 101862378475aSmrg prog) 101872378475aSmrg case $host in 101882378475aSmrg *cygwin*) func_stripname '' '.exe' "$output" 101892378475aSmrg output=$func_stripname_result.exe;; 101902378475aSmrg esac 101912378475aSmrg test -n "$vinfo" && \ 10192eca46af7Smrg func_warning "'-version-info' is ignored for programs" 1019395b296d0Smrg 101942378475aSmrg test -n "$release" && \ 10195eca46af7Smrg func_warning "'-release' is ignored for programs" 1019695b296d0Smrg 10197eca46af7Smrg $preload \ 10198eca46af7Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10199eca46af7Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 102002378475aSmrg 102012378475aSmrg case $host in 102022378475aSmrg *-*-rhapsody* | *-*-darwin1.[012]) 102032378475aSmrg # On Rhapsody replace the C library is the System framework 1020414330f12Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 1020514330f12Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10206e6f085baSmrg ;; 102072378475aSmrg esac 10208e6f085baSmrg 102092378475aSmrg case $host in 102102378475aSmrg *-*-darwin*) 102112378475aSmrg # Don't allow lazy linking, it breaks C++ global constructors 102122378475aSmrg # But is supposedly fixed on 10.4 or later (yay!). 10213eca46af7Smrg if test CXX = "$tagname"; then 102142378475aSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 102152378475aSmrg 10.[0123]) 10216eca46af7Smrg func_append compile_command " $wl-bind_at_load" 10217eca46af7Smrg func_append finalize_command " $wl-bind_at_load" 102182378475aSmrg ;; 102192378475aSmrg esac 10220e6f085baSmrg fi 102212378475aSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 1022214330f12Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1022314330f12Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 102242378475aSmrg ;; 102252378475aSmrg esac 10226e6f085baSmrg 10227e6f085baSmrg 102282378475aSmrg # move library search paths that coincide with paths to not yet 102292378475aSmrg # installed libraries to the beginning of the library search list 102302378475aSmrg new_libs= 102312378475aSmrg for path in $notinst_path; do 102322378475aSmrg case " $new_libs " in 102332378475aSmrg *" -L$path/$objdir "*) ;; 102342378475aSmrg *) 102352378475aSmrg case " $compile_deplibs " in 102362378475aSmrg *" -L$path/$objdir "*) 1023714330f12Smrg func_append new_libs " -L$path/$objdir" ;; 1023839713583Smrg esac 102392378475aSmrg ;; 102402378475aSmrg esac 102412378475aSmrg done 102422378475aSmrg for deplib in $compile_deplibs; do 102432378475aSmrg case $deplib in 102442378475aSmrg -L*) 102452378475aSmrg case " $new_libs " in 102462378475aSmrg *" $deplib "*) ;; 1024714330f12Smrg *) func_append new_libs " $deplib" ;; 1024839713583Smrg esac 102492378475aSmrg ;; 1025014330f12Smrg *) func_append new_libs " $deplib" ;; 102512378475aSmrg esac 102522378475aSmrg done 10253eca46af7Smrg compile_deplibs=$new_libs 1025495b296d0Smrg 10255e6f085baSmrg 1025614330f12Smrg func_append compile_command " $compile_deplibs" 1025714330f12Smrg func_append finalize_command " $finalize_deplibs" 10258e6f085baSmrg 102592378475aSmrg if test -n "$rpath$xrpath"; then 102602378475aSmrg # If the user specified any rpath flags, then add them. 102612378475aSmrg for libdir in $rpath $xrpath; do 102622378475aSmrg # This is the magic to use -rpath. 102632378475aSmrg case "$finalize_rpath " in 102642378475aSmrg *" $libdir "*) ;; 1026514330f12Smrg *) func_append finalize_rpath " $libdir" ;; 102662378475aSmrg esac 102672378475aSmrg done 102682378475aSmrg fi 10269e6f085baSmrg 102702378475aSmrg # Now hardcode the library paths 102712378475aSmrg rpath= 102722378475aSmrg hardcode_libdirs= 102732378475aSmrg for libdir in $compile_rpath $finalize_rpath; do 102742378475aSmrg if test -n "$hardcode_libdir_flag_spec"; then 102752378475aSmrg if test -n "$hardcode_libdir_separator"; then 102762378475aSmrg if test -z "$hardcode_libdirs"; then 10277eca46af7Smrg hardcode_libdirs=$libdir 102782378475aSmrg else 102792378475aSmrg # Just accumulate the unique libdirs. 102802378475aSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 102812378475aSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 102822378475aSmrg ;; 102832378475aSmrg *) 1028414330f12Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 102852378475aSmrg ;; 102862378475aSmrg esac 102872378475aSmrg fi 10288e6f085baSmrg else 102892378475aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 1029014330f12Smrg func_append rpath " $flag" 10291e6f085baSmrg fi 102922378475aSmrg elif test -n "$runpath_var"; then 102932378475aSmrg case "$perm_rpath " in 102942378475aSmrg *" $libdir "*) ;; 1029514330f12Smrg *) func_append perm_rpath " $libdir" ;; 102962378475aSmrg esac 102972378475aSmrg fi 102982378475aSmrg case $host in 102992378475aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10300eca46af7Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 103012378475aSmrg case :$dllsearchpath: in 103022378475aSmrg *":$libdir:"*) ;; 103032378475aSmrg ::) dllsearchpath=$libdir;; 1030414330f12Smrg *) func_append dllsearchpath ":$libdir";; 103052378475aSmrg esac 103062378475aSmrg case :$dllsearchpath: in 103072378475aSmrg *":$testbindir:"*) ;; 103082378475aSmrg ::) dllsearchpath=$testbindir;; 1030914330f12Smrg *) func_append dllsearchpath ":$testbindir";; 103102378475aSmrg esac 103112378475aSmrg ;; 103122378475aSmrg esac 103132378475aSmrg done 103142378475aSmrg # Substitute the hardcoded libdirs into the rpath. 103152378475aSmrg if test -n "$hardcode_libdir_separator" && 103162378475aSmrg test -n "$hardcode_libdirs"; then 10317eca46af7Smrg libdir=$hardcode_libdirs 103182378475aSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 103192378475aSmrg fi 10320eca46af7Smrg compile_rpath=$rpath 10321e6f085baSmrg 103222378475aSmrg rpath= 103232378475aSmrg hardcode_libdirs= 103242378475aSmrg for libdir in $finalize_rpath; do 103252378475aSmrg if test -n "$hardcode_libdir_flag_spec"; then 103262378475aSmrg if test -n "$hardcode_libdir_separator"; then 103272378475aSmrg if test -z "$hardcode_libdirs"; then 10328eca46af7Smrg hardcode_libdirs=$libdir 103292378475aSmrg else 103302378475aSmrg # Just accumulate the unique libdirs. 103312378475aSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 103322378475aSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 103332378475aSmrg ;; 103342378475aSmrg *) 1033514330f12Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 103362378475aSmrg ;; 103372378475aSmrg esac 103382378475aSmrg fi 1033995b296d0Smrg else 103402378475aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 1034114330f12Smrg func_append rpath " $flag" 1034295b296d0Smrg fi 103432378475aSmrg elif test -n "$runpath_var"; then 103442378475aSmrg case "$finalize_perm_rpath " in 103452378475aSmrg *" $libdir "*) ;; 1034614330f12Smrg *) func_append finalize_perm_rpath " $libdir" ;; 103472378475aSmrg esac 1034895b296d0Smrg fi 103492378475aSmrg done 103502378475aSmrg # Substitute the hardcoded libdirs into the rpath. 103512378475aSmrg if test -n "$hardcode_libdir_separator" && 103522378475aSmrg test -n "$hardcode_libdirs"; then 10353eca46af7Smrg libdir=$hardcode_libdirs 103542378475aSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 103552378475aSmrg fi 10356eca46af7Smrg finalize_rpath=$rpath 1035795b296d0Smrg 10358eca46af7Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 103592378475aSmrg # Transform all the library objects into standard objects. 1036014330f12Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1036114330f12Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 103622378475aSmrg fi 1036395b296d0Smrg 10364eca46af7Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 1036595b296d0Smrg 103662378475aSmrg # template prelinking step 103672378475aSmrg if test -n "$prelink_cmds"; then 103682378475aSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 103692378475aSmrg fi 1037095b296d0Smrg 10371eca46af7Smrg wrappers_required=: 103722378475aSmrg case $host in 1037314330f12Smrg *cegcc* | *mingw32ce*) 1037414330f12Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10375eca46af7Smrg wrappers_required=false 1037614330f12Smrg ;; 103772378475aSmrg *cygwin* | *mingw* ) 10378eca46af7Smrg test yes = "$build_libtool_libs" || wrappers_required=false 103792378475aSmrg ;; 103802378475aSmrg *) 10381eca46af7Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10382eca46af7Smrg wrappers_required=false 103832378475aSmrg fi 103842378475aSmrg ;; 103852378475aSmrg esac 10386eca46af7Smrg $wrappers_required || { 103872378475aSmrg # Replace the output file specification. 1038814330f12Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10389eca46af7Smrg link_command=$compile_command$compile_rpath 1039095b296d0Smrg 103912378475aSmrg # We have no uninstalled library dependencies, so finalize right now. 103922378475aSmrg exit_status=0 103932378475aSmrg func_show_eval "$link_command" 'exit_status=$?' 1039495b296d0Smrg 1039514330f12Smrg if test -n "$postlink_cmds"; then 1039614330f12Smrg func_to_tool_file "$output" 1039714330f12Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1039814330f12Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1039914330f12Smrg fi 1040014330f12Smrg 104012378475aSmrg # Delete the generated files. 10402eca46af7Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 10403eca46af7Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 1040495b296d0Smrg fi 1040595b296d0Smrg 104062378475aSmrg exit $exit_status 10407eca46af7Smrg } 1040895b296d0Smrg 104092378475aSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 104102378475aSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 104112378475aSmrg fi 104122378475aSmrg if test -n "$finalize_shlibpath"; then 104132378475aSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 104142378475aSmrg fi 10415e6f085baSmrg 104162378475aSmrg compile_var= 104172378475aSmrg finalize_var= 104182378475aSmrg if test -n "$runpath_var"; then 104192378475aSmrg if test -n "$perm_rpath"; then 104202378475aSmrg # We should set the runpath_var. 104212378475aSmrg rpath= 104222378475aSmrg for dir in $perm_rpath; do 1042314330f12Smrg func_append rpath "$dir:" 104242378475aSmrg done 104252378475aSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 1042695b296d0Smrg fi 104272378475aSmrg if test -n "$finalize_perm_rpath"; then 104282378475aSmrg # We should set the runpath_var. 104292378475aSmrg rpath= 104302378475aSmrg for dir in $finalize_perm_rpath; do 1043114330f12Smrg func_append rpath "$dir:" 104322378475aSmrg done 104332378475aSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 1043495b296d0Smrg fi 104352378475aSmrg fi 1043695b296d0Smrg 10437eca46af7Smrg if test yes = "$no_install"; then 104382378475aSmrg # We don't need to create a wrapper script. 10439eca46af7Smrg link_command=$compile_var$compile_command$compile_rpath 104402378475aSmrg # Replace the output file specification. 1044114330f12Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 104422378475aSmrg # Delete the old output file. 104432378475aSmrg $opt_dry_run || $RM $output 104442378475aSmrg # Link the executable and exit 104452378475aSmrg func_show_eval "$link_command" 'exit $?' 1044614330f12Smrg 1044714330f12Smrg if test -n "$postlink_cmds"; then 1044814330f12Smrg func_to_tool_file "$output" 1044914330f12Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1045014330f12Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1045114330f12Smrg fi 1045214330f12Smrg 10453e6f085baSmrg exit $EXIT_SUCCESS 104542378475aSmrg fi 1045539713583Smrg 10456eca46af7Smrg case $hardcode_action,$fast_install in 10457eca46af7Smrg relink,*) 10458eca46af7Smrg # Fast installation is not supported 10459eca46af7Smrg link_command=$compile_var$compile_command$compile_rpath 10460eca46af7Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 104612378475aSmrg 10462eca46af7Smrg func_warning "this platform does not like uninstalled shared libraries" 10463eca46af7Smrg func_warning "'$output' will be relinked during installation" 10464eca46af7Smrg ;; 10465eca46af7Smrg *,yes) 10466eca46af7Smrg link_command=$finalize_var$compile_command$finalize_rpath 10467eca46af7Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10468eca46af7Smrg ;; 10469eca46af7Smrg *,no) 10470eca46af7Smrg link_command=$compile_var$compile_command$compile_rpath 10471eca46af7Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10472eca46af7Smrg ;; 10473eca46af7Smrg *,needless) 10474eca46af7Smrg link_command=$finalize_var$compile_command$finalize_rpath 10475eca46af7Smrg relink_command= 10476eca46af7Smrg ;; 10477eca46af7Smrg esac 1047895b296d0Smrg 104792378475aSmrg # Replace the output file specification. 1048014330f12Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 1048195b296d0Smrg 104822378475aSmrg # Delete the old output files. 104832378475aSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 1048495b296d0Smrg 104852378475aSmrg func_show_eval "$link_command" 'exit $?' 10486e6f085baSmrg 1048714330f12Smrg if test -n "$postlink_cmds"; then 1048814330f12Smrg func_to_tool_file "$output_objdir/$outputname" 1048914330f12Smrg 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'` 1049014330f12Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1049114330f12Smrg fi 1049214330f12Smrg 104932378475aSmrg # Now create the wrapper script. 104942378475aSmrg func_verbose "creating $output" 10495e6f085baSmrg 104962378475aSmrg # Quote the relink command for shipping. 104972378475aSmrg if test -n "$relink_command"; then 104982378475aSmrg # Preserve any variables that may affect compiler behavior 104992378475aSmrg for var in $variables_saved_for_relink; do 105002378475aSmrg if eval test -z \"\${$var+set}\"; then 105012378475aSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 105022378475aSmrg elif eval var_value=\$$var; test -z "$var_value"; then 105032378475aSmrg relink_command="$var=; export $var; $relink_command" 1050495b296d0Smrg else 105052378475aSmrg func_quote_for_eval "$var_value" 105062378475aSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 1050795b296d0Smrg fi 105082378475aSmrg done 105092378475aSmrg relink_command="(cd `pwd`; $relink_command)" 1051014330f12Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 105112378475aSmrg fi 105122378475aSmrg 105132378475aSmrg # Only actually do things if not in dry run mode. 105142378475aSmrg $opt_dry_run || { 105152378475aSmrg # win32 will think the script is a binary if it has 105162378475aSmrg # a .exe suffix, so we strip it off here. 105172378475aSmrg case $output in 105182378475aSmrg *.exe) func_stripname '' '.exe' "$output" 105192378475aSmrg output=$func_stripname_result ;; 105202378475aSmrg esac 105212378475aSmrg # test for cygwin because mv fails w/o .exe extensions 105222378475aSmrg case $host in 105232378475aSmrg *cygwin*) 105242378475aSmrg exeext=.exe 105252378475aSmrg func_stripname '' '.exe' "$outputname" 105262378475aSmrg outputname=$func_stripname_result ;; 105272378475aSmrg *) exeext= ;; 1052895b296d0Smrg esac 105292378475aSmrg case $host in 105302378475aSmrg *cygwin* | *mingw* ) 105312378475aSmrg func_dirname_and_basename "$output" "" "." 105322378475aSmrg output_name=$func_basename_result 105332378475aSmrg output_path=$func_dirname_result 10534eca46af7Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10535eca46af7Smrg cwrapper=$output_path/$output_name.exe 105362378475aSmrg $RM $cwrappersource $cwrapper 105372378475aSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 105382378475aSmrg 105392378475aSmrg func_emit_cwrapperexe_src > $cwrappersource 105402378475aSmrg 105412378475aSmrg # The wrapper executable is built using the $host compiler, 105422378475aSmrg # because it contains $host paths and files. If cross- 105432378475aSmrg # compiling, it, like the target executable, must be 105442378475aSmrg # executed on the $host or under an emulation environment. 105452378475aSmrg $opt_dry_run || { 105462378475aSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 105472378475aSmrg $STRIP $cwrapper 105482378475aSmrg } 1054995b296d0Smrg 105502378475aSmrg # Now, create the wrapper script for func_source use: 105512378475aSmrg func_ltwrapper_scriptname $cwrapper 105522378475aSmrg $RM $func_ltwrapper_scriptname_result 105532378475aSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 105542378475aSmrg $opt_dry_run || { 105552378475aSmrg # note: this script will not be executed, so do not chmod. 10556eca46af7Smrg if test "x$build" = "x$host"; then 105572378475aSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 105582378475aSmrg else 105592378475aSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 105602378475aSmrg fi 105612378475aSmrg } 105622378475aSmrg ;; 105632378475aSmrg * ) 105642378475aSmrg $RM $output 105652378475aSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 1056695b296d0Smrg 105672378475aSmrg func_emit_wrapper no > $output 105682378475aSmrg chmod +x $output 105692378475aSmrg ;; 105702378475aSmrg esac 105712378475aSmrg } 105722378475aSmrg exit $EXIT_SUCCESS 105732378475aSmrg ;; 105742378475aSmrg esac 1057595b296d0Smrg 105762378475aSmrg # See if we need to build an old-fashioned archive. 105772378475aSmrg for oldlib in $oldlibs; do 1057895b296d0Smrg 10579eca46af7Smrg case $build_libtool_libs in 10580eca46af7Smrg convenience) 10581eca46af7Smrg oldobjs="$libobjs_save $symfileobj" 10582eca46af7Smrg addlibs=$convenience 105832378475aSmrg build_libtool_libs=no 10584eca46af7Smrg ;; 10585eca46af7Smrg module) 10586eca46af7Smrg oldobjs=$libobjs_save 10587eca46af7Smrg addlibs=$old_convenience 10588eca46af7Smrg build_libtool_libs=no 10589eca46af7Smrg ;; 10590eca46af7Smrg *) 105912378475aSmrg oldobjs="$old_deplibs $non_pic_objects" 10592eca46af7Smrg $preload && test -f "$symfileobj" \ 10593eca46af7Smrg && func_append oldobjs " $symfileobj" 10594eca46af7Smrg addlibs=$old_convenience 10595eca46af7Smrg ;; 10596eca46af7Smrg esac 1059795b296d0Smrg 105982378475aSmrg if test -n "$addlibs"; then 10599eca46af7Smrg gentop=$output_objdir/${outputname}x 1060014330f12Smrg func_append generated " $gentop" 1060195b296d0Smrg 106022378475aSmrg func_extract_archives $gentop $addlibs 1060314330f12Smrg func_append oldobjs " $func_extract_archives_result" 106042378475aSmrg fi 1060595b296d0Smrg 106062378475aSmrg # Do each command in the archive commands. 10607eca46af7Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 106082378475aSmrg cmds=$old_archive_from_new_cmds 106092378475aSmrg else 1061095b296d0Smrg 106112378475aSmrg # Add any objects from preloaded convenience libraries 106122378475aSmrg if test -n "$dlprefiles"; then 10613eca46af7Smrg gentop=$output_objdir/${outputname}x 1061414330f12Smrg func_append generated " $gentop" 1061595b296d0Smrg 106162378475aSmrg func_extract_archives $gentop $dlprefiles 1061714330f12Smrg func_append oldobjs " $func_extract_archives_result" 106182378475aSmrg fi 1061995b296d0Smrg 106202378475aSmrg # POSIX demands no paths to be encoded in archives. We have 106212378475aSmrg # to avoid creating archives with duplicate basenames if we 106222378475aSmrg # might have to extract them afterwards, e.g., when creating a 106232378475aSmrg # static archive out of a convenience library, or when linking 106242378475aSmrg # the entirety of a libtool archive into another (currently 106252378475aSmrg # not supported by libtool). 106262378475aSmrg if (for obj in $oldobjs 106272378475aSmrg do 106282378475aSmrg func_basename "$obj" 106292378475aSmrg $ECHO "$func_basename_result" 106302378475aSmrg done | sort | sort -uc >/dev/null 2>&1); then 106312378475aSmrg : 106322378475aSmrg else 1063314330f12Smrg echo "copying selected object files to avoid basename conflicts..." 10634eca46af7Smrg gentop=$output_objdir/${outputname}x 1063514330f12Smrg func_append generated " $gentop" 106362378475aSmrg func_mkdir_p "$gentop" 106372378475aSmrg save_oldobjs=$oldobjs 106382378475aSmrg oldobjs= 106392378475aSmrg counter=1 106402378475aSmrg for obj in $save_oldobjs 106412378475aSmrg do 106422378475aSmrg func_basename "$obj" 10643eca46af7Smrg objbase=$func_basename_result 106442378475aSmrg case " $oldobjs " in 106452378475aSmrg " ") oldobjs=$obj ;; 106462378475aSmrg *[\ /]"$objbase "*) 106472378475aSmrg while :; do 106482378475aSmrg # Make sure we don't pick an alternate name that also 106492378475aSmrg # overlaps. 106502378475aSmrg newobj=lt$counter-$objbase 106512378475aSmrg func_arith $counter + 1 106522378475aSmrg counter=$func_arith_result 106532378475aSmrg case " $oldobjs " in 106542378475aSmrg *[\ /]"$newobj "*) ;; 106552378475aSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 106562378475aSmrg esac 106572378475aSmrg done 106582378475aSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 1065914330f12Smrg func_append oldobjs " $gentop/$newobj" 106602378475aSmrg ;; 1066114330f12Smrg *) func_append oldobjs " $obj" ;; 106622378475aSmrg esac 1066395b296d0Smrg done 1066439713583Smrg fi 10665eca46af7Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10666eca46af7Smrg tool_oldlib=$func_to_tool_file_result 106672378475aSmrg eval cmds=\"$old_archive_cmds\" 10668e6f085baSmrg 106692378475aSmrg func_len " $cmds" 106702378475aSmrg len=$func_len_result 106712378475aSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 106722378475aSmrg cmds=$old_archive_cmds 1067314330f12Smrg elif test -n "$archiver_list_spec"; then 1067414330f12Smrg func_verbose "using command file archive linking..." 1067514330f12Smrg for obj in $oldobjs 1067614330f12Smrg do 1067714330f12Smrg func_to_tool_file "$obj" 1067814330f12Smrg $ECHO "$func_to_tool_file_result" 1067914330f12Smrg done > $output_objdir/$libname.libcmd 1068014330f12Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 1068114330f12Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 1068214330f12Smrg cmds=$old_archive_cmds 106832378475aSmrg else 106842378475aSmrg # the command line is too long to link in one step, link in parts 106852378475aSmrg func_verbose "using piecewise archive linking..." 106862378475aSmrg save_RANLIB=$RANLIB 106872378475aSmrg RANLIB=: 106882378475aSmrg objlist= 106892378475aSmrg concat_cmds= 106902378475aSmrg save_oldobjs=$oldobjs 106912378475aSmrg oldobjs= 106922378475aSmrg # Is there a better way of finding the last object in the list? 106932378475aSmrg for obj in $save_oldobjs 106942378475aSmrg do 106952378475aSmrg last_oldobj=$obj 106962378475aSmrg done 106972378475aSmrg eval test_cmds=\"$old_archive_cmds\" 106982378475aSmrg func_len " $test_cmds" 106992378475aSmrg len0=$func_len_result 107002378475aSmrg len=$len0 107012378475aSmrg for obj in $save_oldobjs 107022378475aSmrg do 107032378475aSmrg func_len " $obj" 107042378475aSmrg func_arith $len + $func_len_result 107052378475aSmrg len=$func_arith_result 107062378475aSmrg func_append objlist " $obj" 107072378475aSmrg if test "$len" -lt "$max_cmd_len"; then 107082378475aSmrg : 107092378475aSmrg else 107102378475aSmrg # the above command should be used before it gets too long 107112378475aSmrg oldobjs=$objlist 10712eca46af7Smrg if test "$obj" = "$last_oldobj"; then 107132378475aSmrg RANLIB=$save_RANLIB 107142378475aSmrg fi 107152378475aSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10716eca46af7Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 107172378475aSmrg objlist= 107182378475aSmrg len=$len0 107192378475aSmrg fi 107202378475aSmrg done 107212378475aSmrg RANLIB=$save_RANLIB 107222378475aSmrg oldobjs=$objlist 10723eca46af7Smrg if test -z "$oldobjs"; then 107242378475aSmrg eval cmds=\"\$concat_cmds\" 107252378475aSmrg else 107262378475aSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 107272378475aSmrg fi 107282378475aSmrg fi 107292378475aSmrg fi 107302378475aSmrg func_execute_cmds "$cmds" 'exit $?' 1073195b296d0Smrg done 1073295b296d0Smrg 107332378475aSmrg test -n "$generated" && \ 107342378475aSmrg func_show_eval "${RM}r$generated" 1073595b296d0Smrg 107362378475aSmrg # Now create the libtool archive. 107372378475aSmrg case $output in 107382378475aSmrg *.la) 107392378475aSmrg old_library= 10740eca46af7Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 107412378475aSmrg func_verbose "creating $output" 1074239713583Smrg 107432378475aSmrg # Preserve any variables that may affect compiler behavior 107442378475aSmrg for var in $variables_saved_for_relink; do 107452378475aSmrg if eval test -z \"\${$var+set}\"; then 107462378475aSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 107472378475aSmrg elif eval var_value=\$$var; test -z "$var_value"; then 107482378475aSmrg relink_command="$var=; export $var; $relink_command" 10749e6f085baSmrg else 107502378475aSmrg func_quote_for_eval "$var_value" 107512378475aSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10752e6f085baSmrg fi 107532378475aSmrg done 107542378475aSmrg # Quote the link command for shipping. 10755eca46af7Smrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 1075614330f12Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10757eca46af7Smrg if test yes = "$hardcode_automatic"; then 107582378475aSmrg relink_command= 107592378475aSmrg fi 1076095b296d0Smrg 107612378475aSmrg # Only create the output if not a dry run. 107622378475aSmrg $opt_dry_run || { 107632378475aSmrg for installed in no yes; do 10764eca46af7Smrg if test yes = "$installed"; then 107652378475aSmrg if test -z "$install_libdir"; then 107662378475aSmrg break 107672378475aSmrg fi 10768eca46af7Smrg output=$output_objdir/${outputname}i 107692378475aSmrg # Replace all uninstalled libtool libraries with the installed ones 107702378475aSmrg newdependency_libs= 107712378475aSmrg for deplib in $dependency_libs; do 107722378475aSmrg case $deplib in 107732378475aSmrg *.la) 107742378475aSmrg func_basename "$deplib" 10775eca46af7Smrg name=$func_basename_result 10776eca46af7Smrg func_resolve_sysroot "$deplib" 10777eca46af7Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 107782378475aSmrg test -z "$libdir" && \ 10779eca46af7Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 1078014330f12Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 1078114330f12Smrg ;; 1078214330f12Smrg -L*) 1078314330f12Smrg func_stripname -L '' "$deplib" 1078414330f12Smrg func_replace_sysroot "$func_stripname_result" 1078514330f12Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 107862378475aSmrg ;; 1078714330f12Smrg -R*) 1078814330f12Smrg func_stripname -R '' "$deplib" 1078914330f12Smrg func_replace_sysroot "$func_stripname_result" 1079014330f12Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 1079114330f12Smrg ;; 1079214330f12Smrg *) func_append newdependency_libs " $deplib" ;; 107932378475aSmrg esac 107942378475aSmrg done 10795eca46af7Smrg dependency_libs=$newdependency_libs 107962378475aSmrg newdlfiles= 107972378475aSmrg 107982378475aSmrg for lib in $dlfiles; do 107992378475aSmrg case $lib in 108002378475aSmrg *.la) 108012378475aSmrg func_basename "$lib" 10802eca46af7Smrg name=$func_basename_result 10803eca46af7Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 108042378475aSmrg test -z "$libdir" && \ 10805eca46af7Smrg func_fatal_error "'$lib' is not a valid libtool archive" 1080614330f12Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 108072378475aSmrg ;; 1080814330f12Smrg *) func_append newdlfiles " $lib" ;; 108092378475aSmrg esac 108102378475aSmrg done 10811eca46af7Smrg dlfiles=$newdlfiles 108122378475aSmrg newdlprefiles= 108132378475aSmrg for lib in $dlprefiles; do 108142378475aSmrg case $lib in 108152378475aSmrg *.la) 108162378475aSmrg # Only pass preopened files to the pseudo-archive (for 108172378475aSmrg # eventual linking with the app. that links it) if we 108182378475aSmrg # didn't already link the preopened objects directly into 108192378475aSmrg # the library: 108202378475aSmrg func_basename "$lib" 10821eca46af7Smrg name=$func_basename_result 10822eca46af7Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 108232378475aSmrg test -z "$libdir" && \ 10824eca46af7Smrg func_fatal_error "'$lib' is not a valid libtool archive" 1082514330f12Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 108262378475aSmrg ;; 108272378475aSmrg esac 108282378475aSmrg done 10829eca46af7Smrg dlprefiles=$newdlprefiles 108302378475aSmrg else 108312378475aSmrg newdlfiles= 108322378475aSmrg for lib in $dlfiles; do 108332378475aSmrg case $lib in 10834eca46af7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 108352378475aSmrg *) abs=`pwd`"/$lib" ;; 108362378475aSmrg esac 1083714330f12Smrg func_append newdlfiles " $abs" 108382378475aSmrg done 10839eca46af7Smrg dlfiles=$newdlfiles 108402378475aSmrg newdlprefiles= 108412378475aSmrg for lib in $dlprefiles; do 108422378475aSmrg case $lib in 10843eca46af7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 108442378475aSmrg *) abs=`pwd`"/$lib" ;; 108452378475aSmrg esac 1084614330f12Smrg func_append newdlprefiles " $abs" 108472378475aSmrg done 10848eca46af7Smrg dlprefiles=$newdlprefiles 108492378475aSmrg fi 108502378475aSmrg $RM $output 108512378475aSmrg # place dlname in correct position for cygwin 1085214330f12Smrg # In fact, it would be nice if we could use this code for all target 1085314330f12Smrg # systems that can't hard-code library paths into their executables 1085414330f12Smrg # and that have no shared library path variable independent of PATH, 1085514330f12Smrg # but it turns out we can't easily determine that from inspecting 1085614330f12Smrg # libtool variables, so we have to hard-code the OSs to which it 1085714330f12Smrg # applies here; at the moment, that means platforms that use the PE 1085814330f12Smrg # object format with DLL files. See the long comment at the top of 1085914330f12Smrg # tests/bindir.at for full details. 108602378475aSmrg tdlname=$dlname 108612378475aSmrg case $host,$output,$installed,$module,$dlname in 1086214330f12Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 1086314330f12Smrg # If a -bindir argument was supplied, place the dll there. 10864eca46af7Smrg if test -n "$bindir"; then 1086514330f12Smrg func_relative_path "$install_libdir" "$bindir" 10866eca46af7Smrg tdlname=$func_relative_path_result/$dlname 1086714330f12Smrg else 1086814330f12Smrg # Otherwise fall back on heuristic. 1086914330f12Smrg tdlname=../bin/$dlname 1087014330f12Smrg fi 1087114330f12Smrg ;; 108722378475aSmrg esac 108732378475aSmrg $ECHO > $output "\ 108742378475aSmrg# $outputname - a libtool library file 10875eca46af7Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 108762378475aSmrg# 108772378475aSmrg# Please DO NOT delete this file! 108782378475aSmrg# It is necessary for linking the library. 1087995b296d0Smrg 108802378475aSmrg# The name that we can dlopen(3). 108812378475aSmrgdlname='$tdlname' 1088295b296d0Smrg 108832378475aSmrg# Names of this library. 108842378475aSmrglibrary_names='$library_names' 1088595b296d0Smrg 108862378475aSmrg# The name of the static archive. 108872378475aSmrgold_library='$old_library' 1088895b296d0Smrg 10889eca46af7Smrg# Linker flags that cannot go in dependency_libs. 108902378475aSmrginherited_linker_flags='$new_inherited_linker_flags' 1089195b296d0Smrg 108922378475aSmrg# Libraries that this one depends upon. 108932378475aSmrgdependency_libs='$dependency_libs' 1089495b296d0Smrg 108952378475aSmrg# Names of additional weak libraries provided by this library 108962378475aSmrgweak_library_names='$weak_libs' 1089795b296d0Smrg 108982378475aSmrg# Version information for $libname. 108992378475aSmrgcurrent=$current 109002378475aSmrgage=$age 109012378475aSmrgrevision=$revision 1090295b296d0Smrg 109032378475aSmrg# Is this an already installed library? 109042378475aSmrginstalled=$installed 1090595b296d0Smrg 109062378475aSmrg# Should we warn about portability when linking against -modules? 109072378475aSmrgshouldnotlink=$module 1090895b296d0Smrg 109092378475aSmrg# Files to dlopen/dlpreopen 109102378475aSmrgdlopen='$dlfiles' 109112378475aSmrgdlpreopen='$dlprefiles' 1091295b296d0Smrg 109132378475aSmrg# Directory that this library needs to be installed in: 109142378475aSmrglibdir='$install_libdir'" 10915eca46af7Smrg if test no,yes = "$installed,$need_relink"; then 109162378475aSmrg $ECHO >> $output "\ 109172378475aSmrgrelink_command=\"$relink_command\"" 109182378475aSmrg fi 109192378475aSmrg done 109202378475aSmrg } 1092195b296d0Smrg 109222378475aSmrg # Do a symbolic link so that the libtool archive can be found in 109232378475aSmrg # LD_LIBRARY_PATH before the program is installed. 109242378475aSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 109252378475aSmrg ;; 109262378475aSmrg esac 109272378475aSmrg exit $EXIT_SUCCESS 109282378475aSmrg} 10929e6f085baSmrg 10930eca46af7Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 10931eca46af7Smrg func_mode_link ${1+"$@"} 10932eca46af7Smrgfi 1093395b296d0Smrg 1093495b296d0Smrg 109352378475aSmrg# func_mode_uninstall arg... 109362378475aSmrgfunc_mode_uninstall () 109372378475aSmrg{ 10938eca46af7Smrg $debug_cmd 10939eca46af7Smrg 10940eca46af7Smrg RM=$nonopt 1094195b296d0Smrg files= 10942eca46af7Smrg rmforce=false 1094395b296d0Smrg exit_status=0 1094495b296d0Smrg 1094595b296d0Smrg # This variable tells wrapper scripts just to set variables rather 1094695b296d0Smrg # than running their programs. 10947eca46af7Smrg libtool_install_magic=$magic 1094895b296d0Smrg 1094995b296d0Smrg for arg 1095095b296d0Smrg do 1095195b296d0Smrg case $arg in 10952eca46af7Smrg -f) func_append RM " $arg"; rmforce=: ;; 1095314330f12Smrg -*) func_append RM " $arg" ;; 1095414330f12Smrg *) func_append files " $arg" ;; 1095595b296d0Smrg esac 1095695b296d0Smrg done 1095795b296d0Smrg 109582378475aSmrg test -z "$RM" && \ 109592378475aSmrg func_fatal_help "you must specify an RM program" 1096095b296d0Smrg 1096195b296d0Smrg rmdirs= 1096295b296d0Smrg 1096395b296d0Smrg for file in $files; do 109642378475aSmrg func_dirname "$file" "" "." 10965eca46af7Smrg dir=$func_dirname_result 10966eca46af7Smrg if test . = "$dir"; then 10967eca46af7Smrg odir=$objdir 1096895b296d0Smrg else 10969eca46af7Smrg odir=$dir/$objdir 1097095b296d0Smrg fi 109712378475aSmrg func_basename "$file" 10972eca46af7Smrg name=$func_basename_result 10973eca46af7Smrg test uninstall = "$opt_mode" && odir=$dir 1097495b296d0Smrg 1097514330f12Smrg # Remember odir for removal later, being careful to avoid duplicates 10976eca46af7Smrg if test clean = "$opt_mode"; then 1097795b296d0Smrg case " $rmdirs " in 1097814330f12Smrg *" $odir "*) ;; 1097914330f12Smrg *) func_append rmdirs " $odir" ;; 1098095b296d0Smrg esac 1098195b296d0Smrg fi 1098295b296d0Smrg 1098395b296d0Smrg # Don't error if the file doesn't exist and rm -f was used. 109842378475aSmrg if { test -L "$file"; } >/dev/null 2>&1 || 109852378475aSmrg { test -h "$file"; } >/dev/null 2>&1 || 109862378475aSmrg test -f "$file"; then 1098795b296d0Smrg : 1098895b296d0Smrg elif test -d "$file"; then 1098995b296d0Smrg exit_status=1 1099095b296d0Smrg continue 10991eca46af7Smrg elif $rmforce; then 1099295b296d0Smrg continue 1099395b296d0Smrg fi 1099495b296d0Smrg 10995eca46af7Smrg rmfiles=$file 1099695b296d0Smrg 1099795b296d0Smrg case $name in 1099895b296d0Smrg *.la) 1099995b296d0Smrg # Possibly a libtool archive, so verify it. 110002378475aSmrg if func_lalib_p "$file"; then 110012378475aSmrg func_source $dir/$name 1100295b296d0Smrg 1100395b296d0Smrg # Delete the libtool libraries and symlinks. 1100495b296d0Smrg for n in $library_names; do 1100514330f12Smrg func_append rmfiles " $odir/$n" 1100695b296d0Smrg done 1100714330f12Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 1100895b296d0Smrg 11009eca46af7Smrg case $opt_mode in 1101095b296d0Smrg clean) 1101114330f12Smrg case " $library_names " in 1101295b296d0Smrg *" $dlname "*) ;; 1101314330f12Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 1101495b296d0Smrg esac 1101514330f12Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 1101695b296d0Smrg ;; 1101795b296d0Smrg uninstall) 1101895b296d0Smrg if test -n "$library_names"; then 1101995b296d0Smrg # Do each command in the postuninstall commands. 11020eca46af7Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 1102195b296d0Smrg fi 1102295b296d0Smrg 1102395b296d0Smrg if test -n "$old_library"; then 1102495b296d0Smrg # Do each command in the old_postuninstall commands. 11025eca46af7Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 1102695b296d0Smrg fi 1102795b296d0Smrg # FIXME: should reinstall the best remaining shared library. 1102895b296d0Smrg ;; 1102995b296d0Smrg esac 1103095b296d0Smrg fi 1103195b296d0Smrg ;; 1103295b296d0Smrg 1103395b296d0Smrg *.lo) 1103495b296d0Smrg # Possibly a libtool object, so verify it. 110352378475aSmrg if func_lalib_p "$file"; then 1103695b296d0Smrg 1103795b296d0Smrg # Read the .lo file 110382378475aSmrg func_source $dir/$name 1103995b296d0Smrg 1104095b296d0Smrg # Add PIC object to the list of files to remove. 11041eca46af7Smrg if test -n "$pic_object" && test none != "$pic_object"; then 1104214330f12Smrg func_append rmfiles " $dir/$pic_object" 1104395b296d0Smrg fi 1104495b296d0Smrg 1104595b296d0Smrg # Add non-PIC object to the list of files to remove. 11046eca46af7Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 1104714330f12Smrg func_append rmfiles " $dir/$non_pic_object" 1104895b296d0Smrg fi 1104995b296d0Smrg fi 1105095b296d0Smrg ;; 1105195b296d0Smrg 1105295b296d0Smrg *) 11053eca46af7Smrg if test clean = "$opt_mode"; then 1105495b296d0Smrg noexename=$name 1105595b296d0Smrg case $file in 1105695b296d0Smrg *.exe) 110572378475aSmrg func_stripname '' '.exe' "$file" 110582378475aSmrg file=$func_stripname_result 110592378475aSmrg func_stripname '' '.exe' "$name" 110602378475aSmrg noexename=$func_stripname_result 1106195b296d0Smrg # $file with .exe has already been added to rmfiles, 1106295b296d0Smrg # add $file without .exe 1106314330f12Smrg func_append rmfiles " $file" 1106495b296d0Smrg ;; 1106595b296d0Smrg esac 1106695b296d0Smrg # Do a test to see if this is a libtool program. 110672378475aSmrg if func_ltwrapper_p "$file"; then 110682378475aSmrg if func_ltwrapper_executable_p "$file"; then 110692378475aSmrg func_ltwrapper_scriptname "$file" 110702378475aSmrg relink_command= 110712378475aSmrg func_source $func_ltwrapper_scriptname_result 1107214330f12Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 110732378475aSmrg else 110742378475aSmrg relink_command= 110752378475aSmrg func_source $dir/$noexename 110762378475aSmrg fi 1107795b296d0Smrg 1107895b296d0Smrg # note $name still contains .exe if it was in $file originally 1107995b296d0Smrg # as does the version of $file that was added into $rmfiles 11080eca46af7Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11081eca46af7Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 1108214330f12Smrg func_append rmfiles " $odir/lt-$name" 1108395b296d0Smrg fi 11084eca46af7Smrg if test "X$noexename" != "X$name"; then 11085eca46af7Smrg func_append rmfiles " $odir/lt-$noexename.c" 1108695b296d0Smrg fi 1108795b296d0Smrg fi 1108895b296d0Smrg fi 1108995b296d0Smrg ;; 1109095b296d0Smrg esac 110912378475aSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 1109295b296d0Smrg done 1109395b296d0Smrg 11094eca46af7Smrg # Try to remove the $objdir's in the directories where we deleted files 1109595b296d0Smrg for dir in $rmdirs; do 1109695b296d0Smrg if test -d "$dir"; then 110972378475aSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 1109895b296d0Smrg fi 1109995b296d0Smrg done 1110095b296d0Smrg 1110195b296d0Smrg exit $exit_status 111022378475aSmrg} 1110395b296d0Smrg 11104eca46af7Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11105eca46af7Smrg func_mode_uninstall ${1+"$@"} 11106eca46af7Smrgfi 1110739713583Smrg 1110814330f12Smrgtest -z "$opt_mode" && { 11109eca46af7Smrg help=$generic_help 111102378475aSmrg func_fatal_help "you must specify a MODE" 111112378475aSmrg} 111122378475aSmrg 111132378475aSmrgtest -z "$exec_cmd" && \ 11114eca46af7Smrg func_fatal_help "invalid operation mode '$opt_mode'" 1111595b296d0Smrg 1111695b296d0Smrgif test -n "$exec_cmd"; then 111172378475aSmrg eval exec "$exec_cmd" 1111895b296d0Smrg exit $EXIT_FAILURE 1111995b296d0Smrgfi 1112095b296d0Smrg 111212378475aSmrgexit $exit_status 1112295b296d0Smrg 1112395b296d0Smrg 1112495b296d0Smrg# The TAGs below are defined such that we never get into a situation 11125eca46af7Smrg# where we disable both kinds of libraries. Given conflicting 1112695b296d0Smrg# choices, we go for a static library, that is the most portable, 1112795b296d0Smrg# since we can't tell whether shared libraries were disabled because 1112895b296d0Smrg# the user asked for that or because the platform doesn't support 1112995b296d0Smrg# them. This is particularly important on AIX, because we don't 1113095b296d0Smrg# support having both static and shared libraries enabled at the same 1113195b296d0Smrg# time on that platform, so we default to a shared-only configuration. 1113295b296d0Smrg# If a disable-shared tag is given, we'll fallback to a static-only 1113395b296d0Smrg# configuration. But we'll never go from static-only to shared-only. 1113495b296d0Smrg 1113595b296d0Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 111362378475aSmrgbuild_libtool_libs=no 111372378475aSmrgbuild_old_libs=yes 1113895b296d0Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 1113995b296d0Smrg 1114095b296d0Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 111412378475aSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 1114295b296d0Smrg# ### END LIBTOOL TAG CONFIG: disable-static 1114395b296d0Smrg 1114495b296d0Smrg# Local Variables: 1114595b296d0Smrg# mode:shell-script 1114695b296d0Smrg# sh-indentation:2 1114795b296d0Smrg# End: 11148