ltmain.sh revision c7b4381a
1fd60135fSmrg#! /bin/sh 2fd60135fSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3fd60135fSmrg## by inline-source v2014-01-03.01 4a96d7823Smrg 5fd60135fSmrg# libtool (GNU libtool) 2.4.6 6fd60135fSmrg# Provide generalized library-building support services. 7a96d7823Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8a96d7823Smrg 9fd60135fSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 10a96d7823Smrg# This is free software; see the source for copying conditions. There is NO 11a96d7823Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12a96d7823Smrg 13a96d7823Smrg# GNU Libtool is free software; you can redistribute it and/or modify 14a96d7823Smrg# it under the terms of the GNU General Public License as published by 15a96d7823Smrg# the Free Software Foundation; either version 2 of the License, or 16a96d7823Smrg# (at your option) any later version. 17a96d7823Smrg# 18a96d7823Smrg# As a special exception to the GNU General Public License, 19a96d7823Smrg# if you distribute this file as part of a program or library that 20a96d7823Smrg# is built using GNU Libtool, you may include this file under the 21a96d7823Smrg# same distribution terms that you use for the rest of that program. 22a96d7823Smrg# 23a96d7823Smrg# GNU Libtool is distributed in the hope that it will be useful, but 24a96d7823Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25a96d7823Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26a96d7823Smrg# General Public License for more details. 27a96d7823Smrg# 28a96d7823Smrg# You should have received a copy of the GNU General Public License 29fd60135fSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30a96d7823Smrg 31a96d7823Smrg 32a96d7823SmrgPROGRAM=libtool 33a96d7823SmrgPACKAGE=libtool 34c7b4381aSmrgVERSION=2.4.6 35fd60135fSmrgpackage_revision=2.4.6 36a96d7823Smrg 37fd60135fSmrg 38fd60135fSmrg## ------ ## 39fd60135fSmrg## Usage. ## 40fd60135fSmrg## ------ ## 41fd60135fSmrg 42fd60135fSmrg# Run './libtool --help' for help with using this script from the 43fd60135fSmrg# command line. 44fd60135fSmrg 45fd60135fSmrg 46fd60135fSmrg## ------------------------------- ## 47fd60135fSmrg## User overridable command paths. ## 48fd60135fSmrg## ------------------------------- ## 49fd60135fSmrg 50fd60135fSmrg# After configure completes, it has a better idea of some of the 51fd60135fSmrg# shell tools we need than the defaults used by the functions shared 52fd60135fSmrg# with bootstrap, so set those here where they can still be over- 53fd60135fSmrg# ridden by the user, but otherwise take precedence. 54fd60135fSmrg 55fd60135fSmrg: ${AUTOCONF="autoconf"} 56fd60135fSmrg: ${AUTOMAKE="automake"} 57fd60135fSmrg 58fd60135fSmrg 59fd60135fSmrg## -------------------------- ## 60fd60135fSmrg## Source external libraries. ## 61fd60135fSmrg## -------------------------- ## 62fd60135fSmrg 63fd60135fSmrg# Much of our low-level functionality needs to be sourced from external 64fd60135fSmrg# libraries, which are installed to $pkgauxdir. 65fd60135fSmrg 66fd60135fSmrg# Set a version string for this script. 67fd60135fSmrgscriptversion=2015-01-20.17; # UTC 68fd60135fSmrg 69fd60135fSmrg# General shell script boiler plate, and helper functions. 70fd60135fSmrg# Written by Gary V. Vaughan, 2004 71fd60135fSmrg 72fd60135fSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 73fd60135fSmrg# This is free software; see the source for copying conditions. There is NO 74fd60135fSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 75fd60135fSmrg 76fd60135fSmrg# This program is free software; you can redistribute it and/or modify 77fd60135fSmrg# it under the terms of the GNU General Public License as published by 78fd60135fSmrg# the Free Software Foundation; either version 3 of the License, or 79fd60135fSmrg# (at your option) any later version. 80fd60135fSmrg 81fd60135fSmrg# As a special exception to the GNU General Public License, if you distribute 82fd60135fSmrg# this file as part of a program or library that is built using GNU Libtool, 83fd60135fSmrg# you may include this file under the same distribution terms that you use 84fd60135fSmrg# for the rest of that program. 85fd60135fSmrg 86fd60135fSmrg# This program is distributed in the hope that it will be useful, 87fd60135fSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 88fd60135fSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 89fd60135fSmrg# General Public License for more details. 90fd60135fSmrg 91fd60135fSmrg# You should have received a copy of the GNU General Public License 92fd60135fSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 93fd60135fSmrg 94fd60135fSmrg# Please report bugs or propose patches to gary@gnu.org. 95fd60135fSmrg 96fd60135fSmrg 97fd60135fSmrg## ------ ## 98fd60135fSmrg## Usage. ## 99fd60135fSmrg## ------ ## 100fd60135fSmrg 101fd60135fSmrg# Evaluate this file near the top of your script to gain access to 102fd60135fSmrg# the functions and variables defined here: 103fd60135fSmrg# 104fd60135fSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 105fd60135fSmrg# 106fd60135fSmrg# If you need to override any of the default environment variable 107fd60135fSmrg# settings, do that before evaluating this file. 108fd60135fSmrg 109fd60135fSmrg 110fd60135fSmrg## -------------------- ## 111fd60135fSmrg## Shell normalisation. ## 112fd60135fSmrg## -------------------- ## 113fd60135fSmrg 114fd60135fSmrg# Some shells need a little help to be as Bourne compatible as possible. 115fd60135fSmrg# Before doing anything else, make sure all that help has been provided! 116fd60135fSmrg 117fd60135fSmrgDUALCASE=1; export DUALCASE # for MKS sh 118fd60135fSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 119a96d7823Smrg emulate sh 120a96d7823Smrg NULLCMD=: 121fd60135fSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 122a96d7823Smrg # is contrary to our usage. Disable this feature. 123a96d7823Smrg alias -g '${1+"$@"}'='"$@"' 124a96d7823Smrg setopt NO_GLOB_SUBST 125a96d7823Smrgelse 126fd60135fSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 127a96d7823Smrgfi 128a96d7823Smrg 129fd60135fSmrg# NLS nuisances: We save the old values in case they are required later. 130fd60135fSmrg_G_user_locale= 131fd60135fSmrg_G_safe_locale= 132fd60135fSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 133a96d7823Smrgdo 134fd60135fSmrg eval "if test set = \"\${$_G_var+set}\"; then 135fd60135fSmrg save_$_G_var=\$$_G_var 136fd60135fSmrg $_G_var=C 137fd60135fSmrg export $_G_var 138fd60135fSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 139fd60135fSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 140a96d7823Smrg fi" 141a96d7823Smrgdone 142a96d7823Smrg 143fd60135fSmrg# CDPATH. 144fd60135fSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 145a96d7823Smrg 146fd60135fSmrg# Make sure IFS has a sensible default 147fd60135fSmrgsp=' ' 148fd60135fSmrgnl=' 149fd60135fSmrg' 150fd60135fSmrgIFS="$sp $nl" 151fd60135fSmrg 152fd60135fSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 153fd60135fSmrgif test "${PATH_SEPARATOR+set}" != set; then 154fd60135fSmrg PATH_SEPARATOR=: 155fd60135fSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 156fd60135fSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 157fd60135fSmrg PATH_SEPARATOR=';' 158fd60135fSmrg } 159fd60135fSmrgfi 160a96d7823Smrg 161a96d7823Smrg 162a96d7823Smrg 163fd60135fSmrg## ------------------------- ## 164fd60135fSmrg## Locate command utilities. ## 165fd60135fSmrg## ------------------------- ## 166fd60135fSmrg 167fd60135fSmrg 168fd60135fSmrg# func_executable_p FILE 169fd60135fSmrg# ---------------------- 170fd60135fSmrg# Check that FILE is an executable regular file. 171fd60135fSmrgfunc_executable_p () 172fd60135fSmrg{ 173fd60135fSmrg test -f "$1" && test -x "$1" 174fd60135fSmrg} 175fd60135fSmrg 176fd60135fSmrg 177fd60135fSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 178fd60135fSmrg# -------------------------------------------- 179fd60135fSmrg# Search for either a program that responds to --version with output 180fd60135fSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 181fd60135fSmrg# trying all the directories in PATH with each of the elements of 182fd60135fSmrg# PROGS_LIST. 183fd60135fSmrg# 184fd60135fSmrg# CHECK_FUNC should accept the path to a candidate program, and 185fd60135fSmrg# set $func_check_prog_result if it truncates its output less than 186fd60135fSmrg# $_G_path_prog_max characters. 187fd60135fSmrgfunc_path_progs () 188fd60135fSmrg{ 189fd60135fSmrg _G_progs_list=$1 190fd60135fSmrg _G_check_func=$2 191fd60135fSmrg _G_PATH=${3-"$PATH"} 192fd60135fSmrg 193fd60135fSmrg _G_path_prog_max=0 194fd60135fSmrg _G_path_prog_found=false 195fd60135fSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 196fd60135fSmrg for _G_dir in $_G_PATH; do 197fd60135fSmrg IFS=$_G_save_IFS 198fd60135fSmrg test -z "$_G_dir" && _G_dir=. 199fd60135fSmrg for _G_prog_name in $_G_progs_list; do 200fd60135fSmrg for _exeext in '' .EXE; do 201fd60135fSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 202fd60135fSmrg func_executable_p "$_G_path_prog" || continue 203fd60135fSmrg case `"$_G_path_prog" --version 2>&1` in 204fd60135fSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 205fd60135fSmrg *) $_G_check_func $_G_path_prog 206fd60135fSmrg func_path_progs_result=$func_check_prog_result 207fd60135fSmrg ;; 208fd60135fSmrg esac 209fd60135fSmrg $_G_path_prog_found && break 3 210fd60135fSmrg done 211fd60135fSmrg done 212fd60135fSmrg done 213fd60135fSmrg IFS=$_G_save_IFS 214fd60135fSmrg test -z "$func_path_progs_result" && { 215fd60135fSmrg echo "no acceptable sed could be found in \$PATH" >&2 216fd60135fSmrg exit 1 217fd60135fSmrg } 218fd60135fSmrg} 219fd60135fSmrg 220fd60135fSmrg 221fd60135fSmrg# We want to be able to use the functions in this file before configure 222fd60135fSmrg# has figured out where the best binaries are kept, which means we have 223fd60135fSmrg# to search for them ourselves - except when the results are already set 224fd60135fSmrg# where we skip the searches. 225fd60135fSmrg 226fd60135fSmrg# Unless the user overrides by setting SED, search the path for either GNU 227fd60135fSmrg# sed, or the sed that truncates its output the least. 228fd60135fSmrgtest -z "$SED" && { 229fd60135fSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 230fd60135fSmrg for _G_i in 1 2 3 4 5 6 7; do 231fd60135fSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 232fd60135fSmrg done 233fd60135fSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 234fd60135fSmrg _G_sed_script= 235fd60135fSmrg 236fd60135fSmrg func_check_prog_sed () 237fd60135fSmrg { 238fd60135fSmrg _G_path_prog=$1 239fd60135fSmrg 240fd60135fSmrg _G_count=0 241fd60135fSmrg printf 0123456789 >conftest.in 242fd60135fSmrg while : 243fd60135fSmrg do 244fd60135fSmrg cat conftest.in conftest.in >conftest.tmp 245fd60135fSmrg mv conftest.tmp conftest.in 246fd60135fSmrg cp conftest.in conftest.nl 247fd60135fSmrg echo '' >> conftest.nl 248fd60135fSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 249fd60135fSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 250fd60135fSmrg _G_count=`expr $_G_count + 1` 251fd60135fSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 252fd60135fSmrg # Best one so far, save it but keep looking for a better one 253fd60135fSmrg func_check_prog_result=$_G_path_prog 254fd60135fSmrg _G_path_prog_max=$_G_count 255fd60135fSmrg fi 256fd60135fSmrg # 10*(2^10) chars as input seems more than enough 257fd60135fSmrg test 10 -lt "$_G_count" && break 258fd60135fSmrg done 259fd60135fSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 260fd60135fSmrg } 261fd60135fSmrg 262fd60135fSmrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 263fd60135fSmrg rm -f conftest.sed 264fd60135fSmrg SED=$func_path_progs_result 265fd60135fSmrg} 266fd60135fSmrg 267fd60135fSmrg 268fd60135fSmrg# Unless the user overrides by setting GREP, search the path for either GNU 269fd60135fSmrg# grep, or the grep that truncates its output the least. 270fd60135fSmrgtest -z "$GREP" && { 271fd60135fSmrg func_check_prog_grep () 272fd60135fSmrg { 273fd60135fSmrg _G_path_prog=$1 274fd60135fSmrg 275fd60135fSmrg _G_count=0 276fd60135fSmrg _G_path_prog_max=0 277fd60135fSmrg printf 0123456789 >conftest.in 278fd60135fSmrg while : 279fd60135fSmrg do 280fd60135fSmrg cat conftest.in conftest.in >conftest.tmp 281fd60135fSmrg mv conftest.tmp conftest.in 282fd60135fSmrg cp conftest.in conftest.nl 283fd60135fSmrg echo 'GREP' >> conftest.nl 284fd60135fSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 285fd60135fSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 286fd60135fSmrg _G_count=`expr $_G_count + 1` 287fd60135fSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 288fd60135fSmrg # Best one so far, save it but keep looking for a better one 289fd60135fSmrg func_check_prog_result=$_G_path_prog 290fd60135fSmrg _G_path_prog_max=$_G_count 291fd60135fSmrg fi 292fd60135fSmrg # 10*(2^10) chars as input seems more than enough 293fd60135fSmrg test 10 -lt "$_G_count" && break 294fd60135fSmrg done 295fd60135fSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 296fd60135fSmrg } 297fd60135fSmrg 298fd60135fSmrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 299fd60135fSmrg GREP=$func_path_progs_result 300fd60135fSmrg} 301fd60135fSmrg 302fd60135fSmrg 303fd60135fSmrg## ------------------------------- ## 304fd60135fSmrg## User overridable command paths. ## 305fd60135fSmrg## ------------------------------- ## 306fd60135fSmrg 307fd60135fSmrg# All uppercase variable names are used for environment variables. These 308fd60135fSmrg# variables can be overridden by the user before calling a script that 309fd60135fSmrg# uses them if a suitable command of that name is not already available 310fd60135fSmrg# in the command search PATH. 311a96d7823Smrg 312a96d7823Smrg: ${CP="cp -f"} 313fd60135fSmrg: ${ECHO="printf %s\n"} 314fd60135fSmrg: ${EGREP="$GREP -E"} 315fd60135fSmrg: ${FGREP="$GREP -F"} 316fd60135fSmrg: ${LN_S="ln -s"} 317a96d7823Smrg: ${MAKE="make"} 318a96d7823Smrg: ${MKDIR="mkdir"} 319a96d7823Smrg: ${MV="mv -f"} 320a96d7823Smrg: ${RM="rm -f"} 321a96d7823Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 322a96d7823Smrg 323a96d7823Smrg 324fd60135fSmrg## -------------------- ## 325fd60135fSmrg## Useful sed snippets. ## 326fd60135fSmrg## -------------------- ## 327a96d7823Smrg 328fd60135fSmrgsed_dirname='s|/[^/]*$||' 329fd60135fSmrgsed_basename='s|^.*/||' 330a96d7823Smrg 331fd60135fSmrg# Sed substitution that helps us do robust quoting. It backslashifies 332fd60135fSmrg# metacharacters that are still active within double-quoted strings. 333fd60135fSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 334a96d7823Smrg 335fd60135fSmrg# Same as above, but do not quote variable references. 336fd60135fSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 337a96d7823Smrg 338fd60135fSmrg# Sed substitution that turns a string into a regex matching for the 339fd60135fSmrg# string literally. 340fd60135fSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 341a96d7823Smrg 342fd60135fSmrg# Sed substitution that converts a w32 file name or path 343fd60135fSmrg# that contains forward slashes, into one that contains 344fd60135fSmrg# (escaped) backslashes. A very naive implementation. 345fd60135fSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 346fd60135fSmrg 347fd60135fSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 348fd60135fSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 349fd60135fSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 350fd60135fSmrg# expansion. Since each input '\' is now two '\'s, look for any number 351fd60135fSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 352fd60135fSmrg_G_bs='\\' 353fd60135fSmrg_G_bs2='\\\\' 354fd60135fSmrg_G_bs4='\\\\\\\\' 355fd60135fSmrg_G_dollar='\$' 356fd60135fSmrgsed_double_backslash="\ 357fd60135fSmrg s/$_G_bs4/&\\ 358fd60135fSmrg/g 359fd60135fSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 360fd60135fSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 361fd60135fSmrg s/\n//g" 362a96d7823Smrg 363a96d7823Smrg 364fd60135fSmrg## ----------------- ## 365fd60135fSmrg## Global variables. ## 366fd60135fSmrg## ----------------- ## 367a96d7823Smrg 368fd60135fSmrg# Except for the global variables explicitly listed below, the following 369fd60135fSmrg# functions in the '^func_' namespace, and the '^require_' namespace 370fd60135fSmrg# variables initialised in the 'Resource management' section, sourcing 371fd60135fSmrg# this file will not pollute your global namespace with anything 372fd60135fSmrg# else. There's no portable way to scope variables in Bourne shell 373fd60135fSmrg# though, so actually running these functions will sometimes place 374fd60135fSmrg# results into a variable named after the function, and often use 375fd60135fSmrg# temporary variables in the '^_G_' namespace. If you are careful to 376fd60135fSmrg# avoid using those namespaces casually in your sourcing script, things 377fd60135fSmrg# should continue to work as you expect. And, of course, you can freely 378fd60135fSmrg# overwrite any of the functions or variables defined here before 379fd60135fSmrg# calling anything to customize them. 380a96d7823Smrg 381fd60135fSmrgEXIT_SUCCESS=0 382fd60135fSmrgEXIT_FAILURE=1 383fd60135fSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 384fd60135fSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 385a96d7823Smrg 386fd60135fSmrg# Allow overriding, eg assuming that you follow the convention of 387fd60135fSmrg# putting '$debug_cmd' at the start of all your functions, you can get 388fd60135fSmrg# bash to show function call trace with: 389fd60135fSmrg# 390fd60135fSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 391fd60135fSmrgdebug_cmd=${debug_cmd-":"} 392fd60135fSmrgexit_cmd=: 393a96d7823Smrg 394fd60135fSmrg# By convention, finish your script with: 395fd60135fSmrg# 396fd60135fSmrg# exit $exit_status 397fd60135fSmrg# 398fd60135fSmrg# so that you can set exit_status to non-zero if you want to indicate 399fd60135fSmrg# something went wrong during execution without actually bailing out at 400fd60135fSmrg# the point of failure. 401fd60135fSmrgexit_status=$EXIT_SUCCESS 402a96d7823Smrg 403fd60135fSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 404fd60135fSmrg# is ksh but when the shell is invoked as "sh" and the current value of 405fd60135fSmrg# the _XPG environment variable is not equal to 1 (one), the special 406fd60135fSmrg# positional parameter $0, within a function call, is the name of the 407fd60135fSmrg# function. 408fd60135fSmrgprogpath=$0 409a96d7823Smrg 410fd60135fSmrg# The name of this program. 411fd60135fSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 412a96d7823Smrg 413fd60135fSmrg# Make sure we have an absolute progpath for reexecution: 414a96d7823Smrgcase $progpath in 415a96d7823Smrg [\\/]*|[A-Za-z]:\\*) ;; 416a96d7823Smrg *[\\/]*) 417fd60135fSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 418a96d7823Smrg progdir=`cd "$progdir" && pwd` 419fd60135fSmrg progpath=$progdir/$progname 420a96d7823Smrg ;; 421a96d7823Smrg *) 422fd60135fSmrg _G_IFS=$IFS 423a96d7823Smrg IFS=${PATH_SEPARATOR-:} 424a96d7823Smrg for progdir in $PATH; do 425fd60135fSmrg IFS=$_G_IFS 426a96d7823Smrg test -x "$progdir/$progname" && break 427a96d7823Smrg done 428fd60135fSmrg IFS=$_G_IFS 429a96d7823Smrg test -n "$progdir" || progdir=`pwd` 430fd60135fSmrg progpath=$progdir/$progname 431a96d7823Smrg ;; 432a96d7823Smrgesac 433a96d7823Smrg 434a96d7823Smrg 435fd60135fSmrg## ----------------- ## 436fd60135fSmrg## Standard options. ## 437fd60135fSmrg## ----------------- ## 438a96d7823Smrg 439fd60135fSmrg# The following options affect the operation of the functions defined 440fd60135fSmrg# below, and should be set appropriately depending on run-time para- 441fd60135fSmrg# meters passed on the command line. 442a96d7823Smrg 443a96d7823Smrgopt_dry_run=false 444a96d7823Smrgopt_quiet=false 445a96d7823Smrgopt_verbose=false 446a96d7823Smrg 447fd60135fSmrg# Categories 'all' and 'none' are always available. Append any others 448fd60135fSmrg# you will pass as the first argument to func_warning from your own 449fd60135fSmrg# code. 450fd60135fSmrgwarning_categories= 451a96d7823Smrg 452fd60135fSmrg# By default, display warnings according to 'opt_warning_types'. Set 453fd60135fSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 454fd60135fSmrg# treat the next displayed warning as a fatal error. 455fd60135fSmrgwarning_func=func_warn_and_continue 456a96d7823Smrg 457fd60135fSmrg# Set to 'all' to display all warnings, 'none' to suppress all 458fd60135fSmrg# warnings, or a space delimited list of some subset of 459fd60135fSmrg# 'warning_categories' to display only the listed warnings. 460fd60135fSmrgopt_warning_types=all 461a96d7823Smrg 462a96d7823Smrg 463fd60135fSmrg## -------------------- ## 464fd60135fSmrg## Resource management. ## 465fd60135fSmrg## -------------------- ## 466a96d7823Smrg 467fd60135fSmrg# This section contains definitions for functions that each ensure a 468fd60135fSmrg# particular resource (a file, or a non-empty configuration variable for 469fd60135fSmrg# example) is available, and if appropriate to extract default values 470fd60135fSmrg# from pertinent package files. Call them using their associated 471fd60135fSmrg# 'require_*' variable to ensure that they are executed, at most, once. 472fd60135fSmrg# 473fd60135fSmrg# It's entirely deliberate that calling these functions can set 474fd60135fSmrg# variables that don't obey the namespace limitations obeyed by the rest 475fd60135fSmrg# of this file, in order that that they be as useful as possible to 476fd60135fSmrg# callers. 477a96d7823Smrg 478a96d7823Smrg 479fd60135fSmrg# require_term_colors 480fd60135fSmrg# ------------------- 481fd60135fSmrg# Allow display of bold text on terminals that support it. 482fd60135fSmrgrequire_term_colors=func_require_term_colors 483fd60135fSmrgfunc_require_term_colors () 484a96d7823Smrg{ 485fd60135fSmrg $debug_cmd 486fd60135fSmrg 487fd60135fSmrg test -t 1 && { 488fd60135fSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 489fd60135fSmrg # precedence, because most terminfo databases neglect to describe 490fd60135fSmrg # whether color sequences are supported. 491fd60135fSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 492fd60135fSmrg 493fd60135fSmrg if test 1 = "$USE_ANSI_COLORS"; then 494fd60135fSmrg # Standard ANSI escape sequences 495fd60135fSmrg tc_reset='[0m' 496fd60135fSmrg tc_bold='[1m'; tc_standout='[7m' 497fd60135fSmrg tc_red='[31m'; tc_green='[32m' 498fd60135fSmrg tc_blue='[34m'; tc_cyan='[36m' 499fd60135fSmrg else 500fd60135fSmrg # Otherwise trust the terminfo database after all. 501fd60135fSmrg test -n "`tput sgr0 2>/dev/null`" && { 502fd60135fSmrg tc_reset=`tput sgr0` 503fd60135fSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 504fd60135fSmrg tc_standout=$tc_bold 505fd60135fSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 506fd60135fSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 507fd60135fSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 508fd60135fSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 509fd60135fSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 510fd60135fSmrg } 511fd60135fSmrg fi 512fd60135fSmrg } 513a96d7823Smrg 514fd60135fSmrg require_term_colors=: 515a96d7823Smrg} 516a96d7823Smrg 517a96d7823Smrg 518fd60135fSmrg## ----------------- ## 519fd60135fSmrg## Function library. ## 520fd60135fSmrg## ----------------- ## 521fd60135fSmrg 522fd60135fSmrg# This section contains a variety of useful functions to call in your 523fd60135fSmrg# scripts. Take note of the portable wrappers for features provided by 524fd60135fSmrg# some modern shells, which will fall back to slower equivalents on 525fd60135fSmrg# less featureful shells. 526fd60135fSmrg 527fd60135fSmrg 528fd60135fSmrg# func_append VAR VALUE 529fd60135fSmrg# --------------------- 530fd60135fSmrg# Append VALUE onto the existing contents of VAR. 531fd60135fSmrg 532fd60135fSmrg # We should try to minimise forks, especially on Windows where they are 533fd60135fSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 534fd60135fSmrg # being used: 535fd60135fSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 536fd60135fSmrg : ${_G_HAVE_ARITH_OP="yes"} 537fd60135fSmrg : ${_G_HAVE_XSI_OPS="yes"} 538fd60135fSmrg # The += operator was introduced in bash 3.1 539fd60135fSmrg case $BASH_VERSION in 540fd60135fSmrg [12].* | 3.0 | 3.0*) ;; 541fd60135fSmrg *) 542fd60135fSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 543fd60135fSmrg ;; 544fd60135fSmrg esac 545fd60135fSmrg fi 546fd60135fSmrg 547fd60135fSmrg # _G_HAVE_PLUSEQ_OP 548fd60135fSmrg # Can be empty, in which case the shell is probed, "yes" if += is 549fd60135fSmrg # useable or anything else if it does not work. 550fd60135fSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 551fd60135fSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 552fd60135fSmrg && _G_HAVE_PLUSEQ_OP=yes 553fd60135fSmrg 554fd60135fSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 555fd60135fSmrgthen 556fd60135fSmrg # This is an XSI compatible shell, allowing a faster implementation... 557fd60135fSmrg eval 'func_append () 558fd60135fSmrg { 559fd60135fSmrg $debug_cmd 560fd60135fSmrg 561fd60135fSmrg eval "$1+=\$2" 562fd60135fSmrg }' 563fd60135fSmrgelse 564fd60135fSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 565fd60135fSmrg func_append () 566fd60135fSmrg { 567fd60135fSmrg $debug_cmd 568fd60135fSmrg 569fd60135fSmrg eval "$1=\$$1\$2" 570fd60135fSmrg } 571fd60135fSmrgfi 572fd60135fSmrg 573fd60135fSmrg 574fd60135fSmrg# func_append_quoted VAR VALUE 575fd60135fSmrg# ---------------------------- 576fd60135fSmrg# Quote VALUE and append to the end of shell variable VAR, separated 577fd60135fSmrg# by a space. 578fd60135fSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 579fd60135fSmrg eval 'func_append_quoted () 580fd60135fSmrg { 581fd60135fSmrg $debug_cmd 582fd60135fSmrg 583fd60135fSmrg func_quote_for_eval "$2" 584fd60135fSmrg eval "$1+=\\ \$func_quote_for_eval_result" 585fd60135fSmrg }' 586fd60135fSmrgelse 587fd60135fSmrg func_append_quoted () 588fd60135fSmrg { 589fd60135fSmrg $debug_cmd 590fd60135fSmrg 591fd60135fSmrg func_quote_for_eval "$2" 592fd60135fSmrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 593fd60135fSmrg } 594fd60135fSmrgfi 595fd60135fSmrg 596fd60135fSmrg 597fd60135fSmrg# func_append_uniq VAR VALUE 598fd60135fSmrg# -------------------------- 599fd60135fSmrg# Append unique VALUE onto the existing contents of VAR, assuming 600fd60135fSmrg# entries are delimited by the first character of VALUE. For example: 601fd60135fSmrg# 602fd60135fSmrg# func_append_uniq options " --another-option option-argument" 603fd60135fSmrg# 604fd60135fSmrg# will only append to $options if " --another-option option-argument " 605fd60135fSmrg# is not already present somewhere in $options already (note spaces at 606fd60135fSmrg# each end implied by leading space in second argument). 607fd60135fSmrgfunc_append_uniq () 608fd60135fSmrg{ 609fd60135fSmrg $debug_cmd 610fd60135fSmrg 611fd60135fSmrg eval _G_current_value='`$ECHO $'$1'`' 612fd60135fSmrg _G_delim=`expr "$2" : '\(.\)'` 613fd60135fSmrg 614fd60135fSmrg case $_G_delim$_G_current_value$_G_delim in 615fd60135fSmrg *"$2$_G_delim"*) ;; 616fd60135fSmrg *) func_append "$@" ;; 617fd60135fSmrg esac 618fd60135fSmrg} 619fd60135fSmrg 620fd60135fSmrg 621fd60135fSmrg# func_arith TERM... 622fd60135fSmrg# ------------------ 623fd60135fSmrg# Set func_arith_result to the result of evaluating TERMs. 624fd60135fSmrg test -z "$_G_HAVE_ARITH_OP" \ 625fd60135fSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 626fd60135fSmrg && _G_HAVE_ARITH_OP=yes 627fd60135fSmrg 628fd60135fSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 629fd60135fSmrg eval 'func_arith () 630fd60135fSmrg { 631fd60135fSmrg $debug_cmd 632fd60135fSmrg 633fd60135fSmrg func_arith_result=$(( $* )) 634fd60135fSmrg }' 635fd60135fSmrgelse 636fd60135fSmrg func_arith () 637fd60135fSmrg { 638fd60135fSmrg $debug_cmd 639fd60135fSmrg 640fd60135fSmrg func_arith_result=`expr "$@"` 641fd60135fSmrg } 642fd60135fSmrgfi 643fd60135fSmrg 644fd60135fSmrg 645fd60135fSmrg# func_basename FILE 646fd60135fSmrg# ------------------ 647fd60135fSmrg# Set func_basename_result to FILE with everything up to and including 648fd60135fSmrg# the last / stripped. 649fd60135fSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 650fd60135fSmrg # If this shell supports suffix pattern removal, then use it to avoid 651fd60135fSmrg # forking. Hide the definitions single quotes in case the shell chokes 652fd60135fSmrg # on unsupported syntax... 653fd60135fSmrg _b='func_basename_result=${1##*/}' 654fd60135fSmrg _d='case $1 in 655fd60135fSmrg */*) func_dirname_result=${1%/*}$2 ;; 656fd60135fSmrg * ) func_dirname_result=$3 ;; 657fd60135fSmrg esac' 658fd60135fSmrg 659fd60135fSmrgelse 660fd60135fSmrg # ...otherwise fall back to using sed. 661fd60135fSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 662fd60135fSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 663fd60135fSmrg if test "X$func_dirname_result" = "X$1"; then 664fd60135fSmrg func_dirname_result=$3 665fd60135fSmrg else 666fd60135fSmrg func_append func_dirname_result "$2" 667fd60135fSmrg fi' 668fd60135fSmrgfi 669fd60135fSmrg 670fd60135fSmrgeval 'func_basename () 671fd60135fSmrg{ 672fd60135fSmrg $debug_cmd 673fd60135fSmrg 674fd60135fSmrg '"$_b"' 675fd60135fSmrg}' 676fd60135fSmrg 677fd60135fSmrg 678fd60135fSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 679fd60135fSmrg# ------------------------------------------- 680fd60135fSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 681fd60135fSmrg# otherwise set result to NONDIR_REPLACEMENT. 682fd60135fSmrgeval 'func_dirname () 683fd60135fSmrg{ 684fd60135fSmrg $debug_cmd 685fd60135fSmrg 686fd60135fSmrg '"$_d"' 687fd60135fSmrg}' 688fd60135fSmrg 689fd60135fSmrg 690fd60135fSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 691fd60135fSmrg# -------------------------------------------------------- 692fd60135fSmrg# Perform func_basename and func_dirname in a single function 693fd60135fSmrg# call: 694fd60135fSmrg# dirname: Compute the dirname of FILE. If nonempty, 695fd60135fSmrg# add APPEND to the result, otherwise set result 696fd60135fSmrg# to NONDIR_REPLACEMENT. 697fd60135fSmrg# value returned in "$func_dirname_result" 698fd60135fSmrg# basename: Compute filename of FILE. 699fd60135fSmrg# value retuned in "$func_basename_result" 700fd60135fSmrg# For efficiency, we do not delegate to the functions above but instead 701fd60135fSmrg# duplicate the functionality here. 702fd60135fSmrgeval 'func_dirname_and_basename () 703fd60135fSmrg{ 704fd60135fSmrg $debug_cmd 705fd60135fSmrg 706fd60135fSmrg '"$_b"' 707fd60135fSmrg '"$_d"' 708fd60135fSmrg}' 709fd60135fSmrg 710fd60135fSmrg 711fd60135fSmrg# func_echo ARG... 712fd60135fSmrg# ---------------- 713fd60135fSmrg# Echo program name prefixed message. 714fd60135fSmrgfunc_echo () 715fd60135fSmrg{ 716fd60135fSmrg $debug_cmd 717fd60135fSmrg 718fd60135fSmrg _G_message=$* 719fd60135fSmrg 720fd60135fSmrg func_echo_IFS=$IFS 721fd60135fSmrg IFS=$nl 722fd60135fSmrg for _G_line in $_G_message; do 723fd60135fSmrg IFS=$func_echo_IFS 724fd60135fSmrg $ECHO "$progname: $_G_line" 725fd60135fSmrg done 726fd60135fSmrg IFS=$func_echo_IFS 727fd60135fSmrg} 728fd60135fSmrg 729fd60135fSmrg 730fd60135fSmrg# func_echo_all ARG... 731fd60135fSmrg# -------------------- 732fd60135fSmrg# Invoke $ECHO with all args, space-separated. 733fd60135fSmrgfunc_echo_all () 734fd60135fSmrg{ 735fd60135fSmrg $ECHO "$*" 736fd60135fSmrg} 737fd60135fSmrg 738fd60135fSmrg 739fd60135fSmrg# func_echo_infix_1 INFIX ARG... 740fd60135fSmrg# ------------------------------ 741fd60135fSmrg# Echo program name, followed by INFIX on the first line, with any 742fd60135fSmrg# additional lines not showing INFIX. 743fd60135fSmrgfunc_echo_infix_1 () 744fd60135fSmrg{ 745fd60135fSmrg $debug_cmd 746fd60135fSmrg 747fd60135fSmrg $require_term_colors 748fd60135fSmrg 749fd60135fSmrg _G_infix=$1; shift 750fd60135fSmrg _G_indent=$_G_infix 751fd60135fSmrg _G_prefix="$progname: $_G_infix: " 752fd60135fSmrg _G_message=$* 753fd60135fSmrg 754fd60135fSmrg # Strip color escape sequences before counting printable length 755fd60135fSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 756fd60135fSmrg do 757fd60135fSmrg test -n "$_G_tc" && { 758fd60135fSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 759fd60135fSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 760fd60135fSmrg } 761fd60135fSmrg done 762fd60135fSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 763fd60135fSmrg 764fd60135fSmrg func_echo_infix_1_IFS=$IFS 765fd60135fSmrg IFS=$nl 766fd60135fSmrg for _G_line in $_G_message; do 767fd60135fSmrg IFS=$func_echo_infix_1_IFS 768fd60135fSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 769fd60135fSmrg _G_prefix=$_G_indent 770fd60135fSmrg done 771fd60135fSmrg IFS=$func_echo_infix_1_IFS 772fd60135fSmrg} 773fd60135fSmrg 774fd60135fSmrg 775fd60135fSmrg# func_error ARG... 776fd60135fSmrg# ----------------- 777fd60135fSmrg# Echo program name prefixed message to standard error. 778fd60135fSmrgfunc_error () 779fd60135fSmrg{ 780fd60135fSmrg $debug_cmd 781fd60135fSmrg 782fd60135fSmrg $require_term_colors 783fd60135fSmrg 784fd60135fSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 785fd60135fSmrg} 786fd60135fSmrg 787fd60135fSmrg 788fd60135fSmrg# func_fatal_error ARG... 789fd60135fSmrg# ----------------------- 790fd60135fSmrg# Echo program name prefixed message to standard error, and exit. 791fd60135fSmrgfunc_fatal_error () 792fd60135fSmrg{ 793fd60135fSmrg $debug_cmd 794fd60135fSmrg 795fd60135fSmrg func_error "$*" 796fd60135fSmrg exit $EXIT_FAILURE 797fd60135fSmrg} 798fd60135fSmrg 799fd60135fSmrg 800fd60135fSmrg# func_grep EXPRESSION FILENAME 801fd60135fSmrg# ----------------------------- 802a96d7823Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 803a96d7823Smrgfunc_grep () 804a96d7823Smrg{ 805fd60135fSmrg $debug_cmd 806fd60135fSmrg 807a96d7823Smrg $GREP "$1" "$2" >/dev/null 2>&1 808a96d7823Smrg} 809a96d7823Smrg 810a96d7823Smrg 811fd60135fSmrg# func_len STRING 812fd60135fSmrg# --------------- 813fd60135fSmrg# Set func_len_result to the length of STRING. STRING may not 814fd60135fSmrg# start with a hyphen. 815fd60135fSmrg test -z "$_G_HAVE_XSI_OPS" \ 816fd60135fSmrg && (eval 'x=a/b/c; 817fd60135fSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 818fd60135fSmrg && _G_HAVE_XSI_OPS=yes 819fd60135fSmrg 820fd60135fSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 821fd60135fSmrg eval 'func_len () 822fd60135fSmrg { 823fd60135fSmrg $debug_cmd 824fd60135fSmrg 825fd60135fSmrg func_len_result=${#1} 826fd60135fSmrg }' 827fd60135fSmrgelse 828fd60135fSmrg func_len () 829fd60135fSmrg { 830fd60135fSmrg $debug_cmd 831fd60135fSmrg 832fd60135fSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 833fd60135fSmrg } 834fd60135fSmrgfi 835fd60135fSmrg 836fd60135fSmrg 837fd60135fSmrg# func_mkdir_p DIRECTORY-PATH 838fd60135fSmrg# --------------------------- 839a96d7823Smrg# Make sure the entire path to DIRECTORY-PATH is available. 840a96d7823Smrgfunc_mkdir_p () 841a96d7823Smrg{ 842fd60135fSmrg $debug_cmd 843a96d7823Smrg 844fd60135fSmrg _G_directory_path=$1 845fd60135fSmrg _G_dir_list= 846a96d7823Smrg 847fd60135fSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 848fd60135fSmrg 849fd60135fSmrg # Protect directory names starting with '-' 850fd60135fSmrg case $_G_directory_path in 851fd60135fSmrg -*) _G_directory_path=./$_G_directory_path ;; 852a96d7823Smrg esac 853a96d7823Smrg 854a96d7823Smrg # While some portion of DIR does not yet exist... 855fd60135fSmrg while test ! -d "$_G_directory_path"; do 856a96d7823Smrg # ...make a list in topmost first order. Use a colon delimited 857a96d7823Smrg # list incase some portion of path contains whitespace. 858fd60135fSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 859a96d7823Smrg 860a96d7823Smrg # If the last portion added has no slash in it, the list is done 861fd60135fSmrg case $_G_directory_path in */*) ;; *) break ;; esac 862a96d7823Smrg 863a96d7823Smrg # ...otherwise throw away the child directory and loop 864fd60135fSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 865a96d7823Smrg done 866fd60135fSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 867a96d7823Smrg 868fd60135fSmrg func_mkdir_p_IFS=$IFS; IFS=: 869fd60135fSmrg for _G_dir in $_G_dir_list; do 870fd60135fSmrg IFS=$func_mkdir_p_IFS 871fd60135fSmrg # mkdir can fail with a 'File exist' error if two processes 872a96d7823Smrg # try to create one of the directories concurrently. Don't 873a96d7823Smrg # stop in that case! 874fd60135fSmrg $MKDIR "$_G_dir" 2>/dev/null || : 875a96d7823Smrg done 876fd60135fSmrg IFS=$func_mkdir_p_IFS 877a96d7823Smrg 878a96d7823Smrg # Bail out if we (or some other process) failed to create a directory. 879fd60135fSmrg test -d "$_G_directory_path" || \ 880fd60135fSmrg func_fatal_error "Failed to create '$1'" 881a96d7823Smrg fi 882a96d7823Smrg} 883a96d7823Smrg 884a96d7823Smrg 885fd60135fSmrg# func_mktempdir [BASENAME] 886fd60135fSmrg# ------------------------- 887a96d7823Smrg# Make a temporary directory that won't clash with other running 888a96d7823Smrg# libtool processes, and avoids race conditions if possible. If 889fd60135fSmrg# given, BASENAME is the basename for that directory. 890a96d7823Smrgfunc_mktempdir () 891a96d7823Smrg{ 892fd60135fSmrg $debug_cmd 893fd60135fSmrg 894fd60135fSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 895a96d7823Smrg 896fd60135fSmrg if test : = "$opt_dry_run"; then 897a96d7823Smrg # Return a directory name, but don't create it in dry-run mode 898fd60135fSmrg _G_tmpdir=$_G_template-$$ 899a96d7823Smrg else 900a96d7823Smrg 901a96d7823Smrg # If mktemp works, use that first and foremost 902fd60135fSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 903a96d7823Smrg 904fd60135fSmrg if test ! -d "$_G_tmpdir"; then 905a96d7823Smrg # Failing that, at least try and use $RANDOM to avoid a race 906fd60135fSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 907a96d7823Smrg 908fd60135fSmrg func_mktempdir_umask=`umask` 909a96d7823Smrg umask 0077 910fd60135fSmrg $MKDIR "$_G_tmpdir" 911fd60135fSmrg umask $func_mktempdir_umask 912a96d7823Smrg fi 913a96d7823Smrg 914a96d7823Smrg # If we're not in dry-run mode, bomb out on failure 915fd60135fSmrg test -d "$_G_tmpdir" || \ 916fd60135fSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 917fd60135fSmrg fi 918fd60135fSmrg 919fd60135fSmrg $ECHO "$_G_tmpdir" 920fd60135fSmrg} 921fd60135fSmrg 922fd60135fSmrg 923fd60135fSmrg# func_normal_abspath PATH 924fd60135fSmrg# ------------------------ 925fd60135fSmrg# Remove doubled-up and trailing slashes, "." path components, 926fd60135fSmrg# and cancel out any ".." path components in PATH after making 927fd60135fSmrg# it an absolute path. 928fd60135fSmrgfunc_normal_abspath () 929fd60135fSmrg{ 930fd60135fSmrg $debug_cmd 931fd60135fSmrg 932fd60135fSmrg # These SED scripts presuppose an absolute path with a trailing slash. 933fd60135fSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 934fd60135fSmrg _G_pathcdr='s|^/[^/]*||' 935fd60135fSmrg _G_removedotparts=':dotsl 936fd60135fSmrg s|/\./|/|g 937fd60135fSmrg t dotsl 938fd60135fSmrg s|/\.$|/|' 939fd60135fSmrg _G_collapseslashes='s|/\{1,\}|/|g' 940fd60135fSmrg _G_finalslash='s|/*$|/|' 941fd60135fSmrg 942fd60135fSmrg # Start from root dir and reassemble the path. 943fd60135fSmrg func_normal_abspath_result= 944fd60135fSmrg func_normal_abspath_tpath=$1 945fd60135fSmrg func_normal_abspath_altnamespace= 946fd60135fSmrg case $func_normal_abspath_tpath in 947fd60135fSmrg "") 948fd60135fSmrg # Empty path, that just means $cwd. 949fd60135fSmrg func_stripname '' '/' "`pwd`" 950fd60135fSmrg func_normal_abspath_result=$func_stripname_result 951fd60135fSmrg return 952fd60135fSmrg ;; 953fd60135fSmrg # The next three entries are used to spot a run of precisely 954fd60135fSmrg # two leading slashes without using negated character classes; 955fd60135fSmrg # we take advantage of case's first-match behaviour. 956fd60135fSmrg ///*) 957fd60135fSmrg # Unusual form of absolute path, do nothing. 958fd60135fSmrg ;; 959fd60135fSmrg //*) 960fd60135fSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 961fd60135fSmrg # and for example Cygwin uses it to access remote file shares 962fd60135fSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 963fd60135fSmrg func_normal_abspath_altnamespace=/ 964fd60135fSmrg ;; 965fd60135fSmrg /*) 966fd60135fSmrg # Absolute path, do nothing. 967fd60135fSmrg ;; 968fd60135fSmrg *) 969fd60135fSmrg # Relative path, prepend $cwd. 970fd60135fSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 971fd60135fSmrg ;; 972fd60135fSmrg esac 973fd60135fSmrg 974fd60135fSmrg # Cancel out all the simple stuff to save iterations. We also want 975fd60135fSmrg # the path to end with a slash for ease of parsing, so make sure 976fd60135fSmrg # there is one (and only one) here. 977fd60135fSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 978fd60135fSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 979fd60135fSmrg while :; do 980fd60135fSmrg # Processed it all yet? 981fd60135fSmrg if test / = "$func_normal_abspath_tpath"; then 982fd60135fSmrg # If we ascended to the root using ".." the result may be empty now. 983fd60135fSmrg if test -z "$func_normal_abspath_result"; then 984fd60135fSmrg func_normal_abspath_result=/ 985fd60135fSmrg fi 986fd60135fSmrg break 987fd60135fSmrg fi 988fd60135fSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 989fd60135fSmrg -e "$_G_pathcar"` 990fd60135fSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 991fd60135fSmrg -e "$_G_pathcdr"` 992fd60135fSmrg # Figure out what to do with it 993fd60135fSmrg case $func_normal_abspath_tcomponent in 994fd60135fSmrg "") 995fd60135fSmrg # Trailing empty path component, ignore it. 996fd60135fSmrg ;; 997fd60135fSmrg ..) 998fd60135fSmrg # Parent dir; strip last assembled component from result. 999fd60135fSmrg func_dirname "$func_normal_abspath_result" 1000fd60135fSmrg func_normal_abspath_result=$func_dirname_result 1001fd60135fSmrg ;; 1002fd60135fSmrg *) 1003fd60135fSmrg # Actual path component, append it. 1004fd60135fSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1005fd60135fSmrg ;; 1006fd60135fSmrg esac 1007fd60135fSmrg done 1008fd60135fSmrg # Restore leading double-slash if one was found on entry. 1009fd60135fSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1010fd60135fSmrg} 1011fd60135fSmrg 1012fd60135fSmrg 1013fd60135fSmrg# func_notquiet ARG... 1014fd60135fSmrg# -------------------- 1015fd60135fSmrg# Echo program name prefixed message only when not in quiet mode. 1016fd60135fSmrgfunc_notquiet () 1017fd60135fSmrg{ 1018fd60135fSmrg $debug_cmd 1019fd60135fSmrg 1020fd60135fSmrg $opt_quiet || func_echo ${1+"$@"} 1021fd60135fSmrg 1022fd60135fSmrg # A bug in bash halts the script if the last line of a function 1023fd60135fSmrg # fails when set -e is in force, so we need another command to 1024fd60135fSmrg # work around that: 1025fd60135fSmrg : 1026fd60135fSmrg} 1027fd60135fSmrg 1028fd60135fSmrg 1029fd60135fSmrg# func_relative_path SRCDIR DSTDIR 1030fd60135fSmrg# -------------------------------- 1031fd60135fSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1032fd60135fSmrgfunc_relative_path () 1033fd60135fSmrg{ 1034fd60135fSmrg $debug_cmd 1035fd60135fSmrg 1036fd60135fSmrg func_relative_path_result= 1037fd60135fSmrg func_normal_abspath "$1" 1038fd60135fSmrg func_relative_path_tlibdir=$func_normal_abspath_result 1039fd60135fSmrg func_normal_abspath "$2" 1040fd60135fSmrg func_relative_path_tbindir=$func_normal_abspath_result 1041fd60135fSmrg 1042fd60135fSmrg # Ascend the tree starting from libdir 1043fd60135fSmrg while :; do 1044fd60135fSmrg # check if we have found a prefix of bindir 1045fd60135fSmrg case $func_relative_path_tbindir in 1046fd60135fSmrg $func_relative_path_tlibdir) 1047fd60135fSmrg # found an exact match 1048fd60135fSmrg func_relative_path_tcancelled= 1049fd60135fSmrg break 1050fd60135fSmrg ;; 1051fd60135fSmrg $func_relative_path_tlibdir*) 1052fd60135fSmrg # found a matching prefix 1053fd60135fSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1054fd60135fSmrg func_relative_path_tcancelled=$func_stripname_result 1055fd60135fSmrg if test -z "$func_relative_path_result"; then 1056fd60135fSmrg func_relative_path_result=. 1057fd60135fSmrg fi 1058fd60135fSmrg break 1059fd60135fSmrg ;; 1060fd60135fSmrg *) 1061fd60135fSmrg func_dirname $func_relative_path_tlibdir 1062fd60135fSmrg func_relative_path_tlibdir=$func_dirname_result 1063fd60135fSmrg if test -z "$func_relative_path_tlibdir"; then 1064fd60135fSmrg # Have to descend all the way to the root! 1065fd60135fSmrg func_relative_path_result=../$func_relative_path_result 1066fd60135fSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 1067fd60135fSmrg break 1068fd60135fSmrg fi 1069fd60135fSmrg func_relative_path_result=../$func_relative_path_result 1070fd60135fSmrg ;; 1071fd60135fSmrg esac 1072fd60135fSmrg done 1073fd60135fSmrg 1074fd60135fSmrg # Now calculate path; take care to avoid doubling-up slashes. 1075fd60135fSmrg func_stripname '' '/' "$func_relative_path_result" 1076fd60135fSmrg func_relative_path_result=$func_stripname_result 1077fd60135fSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1078fd60135fSmrg if test -n "$func_stripname_result"; then 1079fd60135fSmrg func_append func_relative_path_result "/$func_stripname_result" 1080fd60135fSmrg fi 1081fd60135fSmrg 1082fd60135fSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 1083fd60135fSmrg if test -n "$func_relative_path_result"; then 1084fd60135fSmrg func_stripname './' '' "$func_relative_path_result" 1085fd60135fSmrg func_relative_path_result=$func_stripname_result 1086a96d7823Smrg fi 1087a96d7823Smrg 1088fd60135fSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 1089fd60135fSmrg 1090fd60135fSmrg : 1091fd60135fSmrg} 1092fd60135fSmrg 1093fd60135fSmrg 1094fd60135fSmrg# func_quote_for_eval ARG... 1095fd60135fSmrg# -------------------------- 1096fd60135fSmrg# Aesthetically quote ARGs to be evaled later. 1097fd60135fSmrg# This function returns two values: 1098fd60135fSmrg# i) func_quote_for_eval_result 1099fd60135fSmrg# double-quoted, suitable for a subsequent eval 1100fd60135fSmrg# ii) func_quote_for_eval_unquoted_result 1101fd60135fSmrg# has all characters that are still active within double 1102fd60135fSmrg# quotes backslashified. 1103fd60135fSmrgfunc_quote_for_eval () 1104fd60135fSmrg{ 1105fd60135fSmrg $debug_cmd 1106fd60135fSmrg 1107fd60135fSmrg func_quote_for_eval_unquoted_result= 1108fd60135fSmrg func_quote_for_eval_result= 1109fd60135fSmrg while test 0 -lt $#; do 1110fd60135fSmrg case $1 in 1111fd60135fSmrg *[\\\`\"\$]*) 1112fd60135fSmrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 1113fd60135fSmrg *) 1114fd60135fSmrg _G_unquoted_arg=$1 ;; 1115fd60135fSmrg esac 1116fd60135fSmrg if test -n "$func_quote_for_eval_unquoted_result"; then 1117fd60135fSmrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 1118fd60135fSmrg else 1119fd60135fSmrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 1120fd60135fSmrg fi 1121fd60135fSmrg 1122fd60135fSmrg case $_G_unquoted_arg in 1123fd60135fSmrg # Double-quote args containing shell metacharacters to delay 1124fd60135fSmrg # word splitting, command substitution and variable expansion 1125fd60135fSmrg # for a subsequent eval. 1126fd60135fSmrg # Many Bourne shells cannot handle close brackets correctly 1127fd60135fSmrg # in scan sets, so we specify it separately. 1128fd60135fSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1129fd60135fSmrg _G_quoted_arg=\"$_G_unquoted_arg\" 1130fd60135fSmrg ;; 1131fd60135fSmrg *) 1132fd60135fSmrg _G_quoted_arg=$_G_unquoted_arg 1133fd60135fSmrg ;; 1134fd60135fSmrg esac 1135fd60135fSmrg 1136fd60135fSmrg if test -n "$func_quote_for_eval_result"; then 1137fd60135fSmrg func_append func_quote_for_eval_result " $_G_quoted_arg" 1138fd60135fSmrg else 1139fd60135fSmrg func_append func_quote_for_eval_result "$_G_quoted_arg" 1140fd60135fSmrg fi 1141fd60135fSmrg shift 1142fd60135fSmrg done 1143fd60135fSmrg} 1144fd60135fSmrg 1145fd60135fSmrg 1146fd60135fSmrg# func_quote_for_expand ARG 1147fd60135fSmrg# ------------------------- 1148fd60135fSmrg# Aesthetically quote ARG to be evaled later; same as above, 1149fd60135fSmrg# but do not quote variable references. 1150fd60135fSmrgfunc_quote_for_expand () 1151fd60135fSmrg{ 1152fd60135fSmrg $debug_cmd 1153fd60135fSmrg 1154fd60135fSmrg case $1 in 1155fd60135fSmrg *[\\\`\"]*) 1156fd60135fSmrg _G_arg=`$ECHO "$1" | $SED \ 1157fd60135fSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 1158fd60135fSmrg *) 1159fd60135fSmrg _G_arg=$1 ;; 1160fd60135fSmrg esac 1161fd60135fSmrg 1162fd60135fSmrg case $_G_arg in 1163fd60135fSmrg # Double-quote args containing shell metacharacters to delay 1164fd60135fSmrg # word splitting and command substitution for a subsequent eval. 1165fd60135fSmrg # Many Bourne shells cannot handle close brackets correctly 1166fd60135fSmrg # in scan sets, so we specify it separately. 1167fd60135fSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1168fd60135fSmrg _G_arg=\"$_G_arg\" 1169fd60135fSmrg ;; 1170fd60135fSmrg esac 1171fd60135fSmrg 1172fd60135fSmrg func_quote_for_expand_result=$_G_arg 1173fd60135fSmrg} 1174fd60135fSmrg 1175fd60135fSmrg 1176fd60135fSmrg# func_stripname PREFIX SUFFIX NAME 1177fd60135fSmrg# --------------------------------- 1178fd60135fSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1179fd60135fSmrg# PREFIX and SUFFIX must not contain globbing or regex special 1180fd60135fSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 1181fd60135fSmrg# dot (in which case that matches only a dot). 1182fd60135fSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 1183fd60135fSmrg eval 'func_stripname () 1184fd60135fSmrg { 1185fd60135fSmrg $debug_cmd 1186fd60135fSmrg 1187fd60135fSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1188fd60135fSmrg # positional parameters, so assign one to ordinary variable first. 1189fd60135fSmrg func_stripname_result=$3 1190fd60135fSmrg func_stripname_result=${func_stripname_result#"$1"} 1191fd60135fSmrg func_stripname_result=${func_stripname_result%"$2"} 1192fd60135fSmrg }' 1193fd60135fSmrgelse 1194fd60135fSmrg func_stripname () 1195fd60135fSmrg { 1196fd60135fSmrg $debug_cmd 1197fd60135fSmrg 1198fd60135fSmrg case $2 in 1199fd60135fSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1200fd60135fSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1201fd60135fSmrg esac 1202fd60135fSmrg } 1203fd60135fSmrgfi 1204fd60135fSmrg 1205fd60135fSmrg 1206fd60135fSmrg# func_show_eval CMD [FAIL_EXP] 1207fd60135fSmrg# ----------------------------- 1208fd60135fSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1209fd60135fSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1210fd60135fSmrg# is given, then evaluate it. 1211fd60135fSmrgfunc_show_eval () 1212fd60135fSmrg{ 1213fd60135fSmrg $debug_cmd 1214fd60135fSmrg 1215fd60135fSmrg _G_cmd=$1 1216fd60135fSmrg _G_fail_exp=${2-':'} 1217fd60135fSmrg 1218fd60135fSmrg func_quote_for_expand "$_G_cmd" 1219fd60135fSmrg eval "func_notquiet $func_quote_for_expand_result" 1220fd60135fSmrg 1221fd60135fSmrg $opt_dry_run || { 1222fd60135fSmrg eval "$_G_cmd" 1223fd60135fSmrg _G_status=$? 1224fd60135fSmrg if test 0 -ne "$_G_status"; then 1225fd60135fSmrg eval "(exit $_G_status); $_G_fail_exp" 1226fd60135fSmrg fi 1227fd60135fSmrg } 1228fd60135fSmrg} 1229fd60135fSmrg 1230fd60135fSmrg 1231fd60135fSmrg# func_show_eval_locale CMD [FAIL_EXP] 1232fd60135fSmrg# ------------------------------------ 1233fd60135fSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1234fd60135fSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1235fd60135fSmrg# is given, then evaluate it. Use the saved locale for evaluation. 1236fd60135fSmrgfunc_show_eval_locale () 1237fd60135fSmrg{ 1238fd60135fSmrg $debug_cmd 1239fd60135fSmrg 1240fd60135fSmrg _G_cmd=$1 1241fd60135fSmrg _G_fail_exp=${2-':'} 1242fd60135fSmrg 1243fd60135fSmrg $opt_quiet || { 1244fd60135fSmrg func_quote_for_expand "$_G_cmd" 1245fd60135fSmrg eval "func_echo $func_quote_for_expand_result" 1246fd60135fSmrg } 1247fd60135fSmrg 1248fd60135fSmrg $opt_dry_run || { 1249fd60135fSmrg eval "$_G_user_locale 1250fd60135fSmrg $_G_cmd" 1251fd60135fSmrg _G_status=$? 1252fd60135fSmrg eval "$_G_safe_locale" 1253fd60135fSmrg if test 0 -ne "$_G_status"; then 1254fd60135fSmrg eval "(exit $_G_status); $_G_fail_exp" 1255fd60135fSmrg fi 1256fd60135fSmrg } 1257fd60135fSmrg} 1258fd60135fSmrg 1259fd60135fSmrg 1260fd60135fSmrg# func_tr_sh 1261fd60135fSmrg# ---------- 1262fd60135fSmrg# Turn $1 into a string suitable for a shell variable name. 1263fd60135fSmrg# Result is stored in $func_tr_sh_result. All characters 1264fd60135fSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1265fd60135fSmrg# if $1 begins with a digit, a '_' is prepended as well. 1266fd60135fSmrgfunc_tr_sh () 1267fd60135fSmrg{ 1268fd60135fSmrg $debug_cmd 1269fd60135fSmrg 1270fd60135fSmrg case $1 in 1271fd60135fSmrg [0-9]* | *[!a-zA-Z0-9_]*) 1272fd60135fSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1273fd60135fSmrg ;; 1274fd60135fSmrg * ) 1275fd60135fSmrg func_tr_sh_result=$1 1276fd60135fSmrg ;; 1277fd60135fSmrg esac 1278fd60135fSmrg} 1279fd60135fSmrg 1280fd60135fSmrg 1281fd60135fSmrg# func_verbose ARG... 1282fd60135fSmrg# ------------------- 1283fd60135fSmrg# Echo program name prefixed message in verbose mode only. 1284fd60135fSmrgfunc_verbose () 1285fd60135fSmrg{ 1286fd60135fSmrg $debug_cmd 1287fd60135fSmrg 1288fd60135fSmrg $opt_verbose && func_echo "$*" 1289fd60135fSmrg 1290fd60135fSmrg : 1291fd60135fSmrg} 1292fd60135fSmrg 1293fd60135fSmrg 1294fd60135fSmrg# func_warn_and_continue ARG... 1295fd60135fSmrg# ----------------------------- 1296fd60135fSmrg# Echo program name prefixed warning message to standard error. 1297fd60135fSmrgfunc_warn_and_continue () 1298fd60135fSmrg{ 1299fd60135fSmrg $debug_cmd 1300fd60135fSmrg 1301fd60135fSmrg $require_term_colors 1302fd60135fSmrg 1303fd60135fSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1304fd60135fSmrg} 1305fd60135fSmrg 1306fd60135fSmrg 1307fd60135fSmrg# func_warning CATEGORY ARG... 1308fd60135fSmrg# ---------------------------- 1309fd60135fSmrg# Echo program name prefixed warning message to standard error. Warning 1310fd60135fSmrg# messages can be filtered according to CATEGORY, where this function 1311fd60135fSmrg# elides messages where CATEGORY is not listed in the global variable 1312fd60135fSmrg# 'opt_warning_types'. 1313fd60135fSmrgfunc_warning () 1314fd60135fSmrg{ 1315fd60135fSmrg $debug_cmd 1316fd60135fSmrg 1317fd60135fSmrg # CATEGORY must be in the warning_categories list! 1318fd60135fSmrg case " $warning_categories " in 1319fd60135fSmrg *" $1 "*) ;; 1320fd60135fSmrg *) func_internal_error "invalid warning category '$1'" ;; 1321fd60135fSmrg esac 1322fd60135fSmrg 1323fd60135fSmrg _G_category=$1 1324fd60135fSmrg shift 1325fd60135fSmrg 1326fd60135fSmrg case " $opt_warning_types " in 1327fd60135fSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1328fd60135fSmrg esac 1329fd60135fSmrg} 1330fd60135fSmrg 1331fd60135fSmrg 1332fd60135fSmrg# func_sort_ver VER1 VER2 1333fd60135fSmrg# ----------------------- 1334fd60135fSmrg# 'sort -V' is not generally available. 1335fd60135fSmrg# Note this deviates from the version comparison in automake 1336fd60135fSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1337fd60135fSmrg# but this should suffice as we won't be specifying old 1338fd60135fSmrg# version formats or redundant trailing .0 in bootstrap.conf. 1339fd60135fSmrg# If we did want full compatibility then we should probably 1340fd60135fSmrg# use m4_version_compare from autoconf. 1341fd60135fSmrgfunc_sort_ver () 1342fd60135fSmrg{ 1343fd60135fSmrg $debug_cmd 1344fd60135fSmrg 1345fd60135fSmrg printf '%s\n%s\n' "$1" "$2" \ 1346fd60135fSmrg | 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 1347fd60135fSmrg} 1348fd60135fSmrg 1349fd60135fSmrg# func_lt_ver PREV CURR 1350fd60135fSmrg# --------------------- 1351fd60135fSmrg# Return true if PREV and CURR are in the correct order according to 1352fd60135fSmrg# func_sort_ver, otherwise false. Use it like this: 1353fd60135fSmrg# 1354fd60135fSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1355fd60135fSmrgfunc_lt_ver () 1356fd60135fSmrg{ 1357fd60135fSmrg $debug_cmd 1358fd60135fSmrg 1359fd60135fSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1360fd60135fSmrg} 1361fd60135fSmrg 1362fd60135fSmrg 1363fd60135fSmrg# Local variables: 1364fd60135fSmrg# mode: shell-script 1365fd60135fSmrg# sh-indentation: 2 1366fd60135fSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 1367fd60135fSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1368fd60135fSmrg# time-stamp-time-zone: "UTC" 1369fd60135fSmrg# End: 1370fd60135fSmrg#! /bin/sh 1371fd60135fSmrg 1372fd60135fSmrg# Set a version string for this script. 1373fd60135fSmrgscriptversion=2014-01-07.03; # UTC 1374fd60135fSmrg 1375fd60135fSmrg# A portable, pluggable option parser for Bourne shell. 1376fd60135fSmrg# Written by Gary V. Vaughan, 2010 1377fd60135fSmrg 1378fd60135fSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 1379fd60135fSmrg# This is free software; see the source for copying conditions. There is NO 1380fd60135fSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1381fd60135fSmrg 1382fd60135fSmrg# This program is free software: you can redistribute it and/or modify 1383fd60135fSmrg# it under the terms of the GNU General Public License as published by 1384fd60135fSmrg# the Free Software Foundation, either version 3 of the License, or 1385fd60135fSmrg# (at your option) any later version. 1386fd60135fSmrg 1387fd60135fSmrg# This program is distributed in the hope that it will be useful, 1388fd60135fSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1389fd60135fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1390fd60135fSmrg# GNU General Public License for more details. 1391fd60135fSmrg 1392fd60135fSmrg# You should have received a copy of the GNU General Public License 1393fd60135fSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 1394fd60135fSmrg 1395fd60135fSmrg# Please report bugs or propose patches to gary@gnu.org. 1396fd60135fSmrg 1397fd60135fSmrg 1398fd60135fSmrg## ------ ## 1399fd60135fSmrg## Usage. ## 1400fd60135fSmrg## ------ ## 1401fd60135fSmrg 1402fd60135fSmrg# This file is a library for parsing options in your shell scripts along 1403fd60135fSmrg# with assorted other useful supporting features that you can make use 1404fd60135fSmrg# of too. 1405fd60135fSmrg# 1406fd60135fSmrg# For the simplest scripts you might need only: 1407fd60135fSmrg# 1408fd60135fSmrg# #!/bin/sh 1409fd60135fSmrg# . relative/path/to/funclib.sh 1410fd60135fSmrg# . relative/path/to/options-parser 1411fd60135fSmrg# scriptversion=1.0 1412fd60135fSmrg# func_options ${1+"$@"} 1413fd60135fSmrg# eval set dummy "$func_options_result"; shift 1414fd60135fSmrg# ...rest of your script... 1415fd60135fSmrg# 1416fd60135fSmrg# In order for the '--version' option to work, you will need to have a 1417fd60135fSmrg# suitably formatted comment like the one at the top of this file 1418fd60135fSmrg# starting with '# Written by ' and ending with '# warranty; '. 1419fd60135fSmrg# 1420fd60135fSmrg# For '-h' and '--help' to work, you will also need a one line 1421fd60135fSmrg# description of your script's purpose in a comment directly above the 1422fd60135fSmrg# '# Written by ' line, like the one at the top of this file. 1423fd60135fSmrg# 1424fd60135fSmrg# The default options also support '--debug', which will turn on shell 1425fd60135fSmrg# execution tracing (see the comment above debug_cmd below for another 1426fd60135fSmrg# use), and '--verbose' and the func_verbose function to allow your script 1427fd60135fSmrg# to display verbose messages only when your user has specified 1428fd60135fSmrg# '--verbose'. 1429fd60135fSmrg# 1430fd60135fSmrg# After sourcing this file, you can plug processing for additional 1431fd60135fSmrg# options by amending the variables from the 'Configuration' section 1432fd60135fSmrg# below, and following the instructions in the 'Option parsing' 1433fd60135fSmrg# section further down. 1434fd60135fSmrg 1435fd60135fSmrg## -------------- ## 1436fd60135fSmrg## Configuration. ## 1437fd60135fSmrg## -------------- ## 1438fd60135fSmrg 1439fd60135fSmrg# You should override these variables in your script after sourcing this 1440fd60135fSmrg# file so that they reflect the customisations you have added to the 1441fd60135fSmrg# option parser. 1442fd60135fSmrg 1443fd60135fSmrg# The usage line for option parsing errors and the start of '-h' and 1444fd60135fSmrg# '--help' output messages. You can embed shell variables for delayed 1445fd60135fSmrg# expansion at the time the message is displayed, but you will need to 1446fd60135fSmrg# quote other shell meta-characters carefully to prevent them being 1447fd60135fSmrg# expanded when the contents are evaled. 1448fd60135fSmrgusage='$progpath [OPTION]...' 1449fd60135fSmrg 1450fd60135fSmrg# Short help message in response to '-h' and '--help'. Add to this or 1451fd60135fSmrg# override it after sourcing this library to reflect the full set of 1452fd60135fSmrg# options your script accepts. 1453fd60135fSmrgusage_message="\ 1454fd60135fSmrg --debug enable verbose shell tracing 1455fd60135fSmrg -W, --warnings=CATEGORY 1456fd60135fSmrg report the warnings falling in CATEGORY [all] 1457fd60135fSmrg -v, --verbose verbosely report processing 1458fd60135fSmrg --version print version information and exit 1459fd60135fSmrg -h, --help print short or long help message and exit 1460fd60135fSmrg" 1461fd60135fSmrg 1462fd60135fSmrg# Additional text appended to 'usage_message' in response to '--help'. 1463fd60135fSmrglong_help_message=" 1464fd60135fSmrgWarning categories include: 1465fd60135fSmrg 'all' show all warnings 1466fd60135fSmrg 'none' turn off all the warnings 1467fd60135fSmrg 'error' warnings are treated as fatal errors" 1468fd60135fSmrg 1469fd60135fSmrg# Help message printed before fatal option parsing errors. 1470fd60135fSmrgfatal_help="Try '\$progname --help' for more information." 1471fd60135fSmrg 1472fd60135fSmrg 1473fd60135fSmrg 1474fd60135fSmrg## ------------------------- ## 1475fd60135fSmrg## Hook function management. ## 1476fd60135fSmrg## ------------------------- ## 1477fd60135fSmrg 1478fd60135fSmrg# This section contains functions for adding, removing, and running hooks 1479fd60135fSmrg# to the main code. A hook is just a named list of of function, that can 1480fd60135fSmrg# be run in order later on. 1481fd60135fSmrg 1482fd60135fSmrg# func_hookable FUNC_NAME 1483fd60135fSmrg# ----------------------- 1484fd60135fSmrg# Declare that FUNC_NAME will run hooks added with 1485fd60135fSmrg# 'func_add_hook FUNC_NAME ...'. 1486fd60135fSmrgfunc_hookable () 1487fd60135fSmrg{ 1488fd60135fSmrg $debug_cmd 1489fd60135fSmrg 1490fd60135fSmrg func_append hookable_fns " $1" 1491fd60135fSmrg} 1492fd60135fSmrg 1493fd60135fSmrg 1494fd60135fSmrg# func_add_hook FUNC_NAME HOOK_FUNC 1495fd60135fSmrg# --------------------------------- 1496fd60135fSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1497fd60135fSmrg# first have been declared "hookable" by a call to 'func_hookable'. 1498fd60135fSmrgfunc_add_hook () 1499fd60135fSmrg{ 1500fd60135fSmrg $debug_cmd 1501fd60135fSmrg 1502fd60135fSmrg case " $hookable_fns " in 1503fd60135fSmrg *" $1 "*) ;; 1504fd60135fSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1505fd60135fSmrg esac 1506fd60135fSmrg 1507fd60135fSmrg eval func_append ${1}_hooks '" $2"' 1508fd60135fSmrg} 1509fd60135fSmrg 1510fd60135fSmrg 1511fd60135fSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 1512fd60135fSmrg# ------------------------------------ 1513fd60135fSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 1514fd60135fSmrgfunc_remove_hook () 1515fd60135fSmrg{ 1516fd60135fSmrg $debug_cmd 1517fd60135fSmrg 1518fd60135fSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1519fd60135fSmrg} 1520fd60135fSmrg 1521fd60135fSmrg 1522fd60135fSmrg# func_run_hooks FUNC_NAME [ARG]... 1523fd60135fSmrg# --------------------------------- 1524fd60135fSmrg# Run all hook functions registered to FUNC_NAME. 1525fd60135fSmrg# It is assumed that the list of hook functions contains nothing more 1526fd60135fSmrg# than a whitespace-delimited list of legal shell function names, and 1527fd60135fSmrg# no effort is wasted trying to catch shell meta-characters or preserve 1528fd60135fSmrg# whitespace. 1529fd60135fSmrgfunc_run_hooks () 1530fd60135fSmrg{ 1531fd60135fSmrg $debug_cmd 1532fd60135fSmrg 1533fd60135fSmrg case " $hookable_fns " in 1534fd60135fSmrg *" $1 "*) ;; 1535fd60135fSmrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 1536fd60135fSmrg esac 1537fd60135fSmrg 1538fd60135fSmrg eval _G_hook_fns=\$$1_hooks; shift 1539fd60135fSmrg 1540fd60135fSmrg for _G_hook in $_G_hook_fns; do 1541fd60135fSmrg eval $_G_hook '"$@"' 1542fd60135fSmrg 1543fd60135fSmrg # store returned options list back into positional 1544fd60135fSmrg # parameters for next 'cmd' execution. 1545fd60135fSmrg eval _G_hook_result=\$${_G_hook}_result 1546fd60135fSmrg eval set dummy "$_G_hook_result"; shift 1547fd60135fSmrg done 1548fd60135fSmrg 1549fd60135fSmrg func_quote_for_eval ${1+"$@"} 1550fd60135fSmrg func_run_hooks_result=$func_quote_for_eval_result 1551fd60135fSmrg} 1552fd60135fSmrg 1553fd60135fSmrg 1554fd60135fSmrg 1555fd60135fSmrg## --------------- ## 1556fd60135fSmrg## Option parsing. ## 1557fd60135fSmrg## --------------- ## 1558fd60135fSmrg 1559fd60135fSmrg# In order to add your own option parsing hooks, you must accept the 1560fd60135fSmrg# full positional parameter list in your hook function, remove any 1561fd60135fSmrg# options that you action, and then pass back the remaining unprocessed 1562fd60135fSmrg# options in '<hooked_function_name>_result', escaped suitably for 1563fd60135fSmrg# 'eval'. Like this: 1564fd60135fSmrg# 1565fd60135fSmrg# my_options_prep () 1566fd60135fSmrg# { 1567fd60135fSmrg# $debug_cmd 1568fd60135fSmrg# 1569fd60135fSmrg# # Extend the existing usage message. 1570fd60135fSmrg# usage_message=$usage_message' 1571fd60135fSmrg# -s, --silent don'\''t print informational messages 1572fd60135fSmrg# ' 1573fd60135fSmrg# 1574fd60135fSmrg# func_quote_for_eval ${1+"$@"} 1575fd60135fSmrg# my_options_prep_result=$func_quote_for_eval_result 1576fd60135fSmrg# } 1577fd60135fSmrg# func_add_hook func_options_prep my_options_prep 1578fd60135fSmrg# 1579fd60135fSmrg# 1580fd60135fSmrg# my_silent_option () 1581fd60135fSmrg# { 1582fd60135fSmrg# $debug_cmd 1583fd60135fSmrg# 1584fd60135fSmrg# # Note that for efficiency, we parse as many options as we can 1585fd60135fSmrg# # recognise in a loop before passing the remainder back to the 1586fd60135fSmrg# # caller on the first unrecognised argument we encounter. 1587fd60135fSmrg# while test $# -gt 0; do 1588fd60135fSmrg# opt=$1; shift 1589fd60135fSmrg# case $opt in 1590fd60135fSmrg# --silent|-s) opt_silent=: ;; 1591fd60135fSmrg# # Separate non-argument short options: 1592fd60135fSmrg# -s*) func_split_short_opt "$_G_opt" 1593fd60135fSmrg# set dummy "$func_split_short_opt_name" \ 1594fd60135fSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 1595fd60135fSmrg# shift 1596fd60135fSmrg# ;; 1597fd60135fSmrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 1598fd60135fSmrg# esac 1599fd60135fSmrg# done 1600fd60135fSmrg# 1601fd60135fSmrg# func_quote_for_eval ${1+"$@"} 1602fd60135fSmrg# my_silent_option_result=$func_quote_for_eval_result 1603fd60135fSmrg# } 1604fd60135fSmrg# func_add_hook func_parse_options my_silent_option 1605fd60135fSmrg# 1606fd60135fSmrg# 1607fd60135fSmrg# my_option_validation () 1608fd60135fSmrg# { 1609fd60135fSmrg# $debug_cmd 1610fd60135fSmrg# 1611fd60135fSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 1612fd60135fSmrg# '--silent' and '--verbose' options are mutually exclusive." 1613fd60135fSmrg# 1614fd60135fSmrg# func_quote_for_eval ${1+"$@"} 1615fd60135fSmrg# my_option_validation_result=$func_quote_for_eval_result 1616fd60135fSmrg# } 1617fd60135fSmrg# func_add_hook func_validate_options my_option_validation 1618fd60135fSmrg# 1619fd60135fSmrg# You'll alse need to manually amend $usage_message to reflect the extra 1620fd60135fSmrg# options you parse. It's preferable to append if you can, so that 1621fd60135fSmrg# multiple option parsing hooks can be added safely. 1622fd60135fSmrg 1623fd60135fSmrg 1624fd60135fSmrg# func_options [ARG]... 1625fd60135fSmrg# --------------------- 1626fd60135fSmrg# All the functions called inside func_options are hookable. See the 1627fd60135fSmrg# individual implementations for details. 1628fd60135fSmrgfunc_hookable func_options 1629fd60135fSmrgfunc_options () 1630fd60135fSmrg{ 1631fd60135fSmrg $debug_cmd 1632fd60135fSmrg 1633fd60135fSmrg func_options_prep ${1+"$@"} 1634fd60135fSmrg eval func_parse_options \ 1635fd60135fSmrg ${func_options_prep_result+"$func_options_prep_result"} 1636fd60135fSmrg eval func_validate_options \ 1637fd60135fSmrg ${func_parse_options_result+"$func_parse_options_result"} 1638fd60135fSmrg 1639fd60135fSmrg eval func_run_hooks func_options \ 1640fd60135fSmrg ${func_validate_options_result+"$func_validate_options_result"} 1641fd60135fSmrg 1642fd60135fSmrg # save modified positional parameters for caller 1643fd60135fSmrg func_options_result=$func_run_hooks_result 1644a96d7823Smrg} 1645a96d7823Smrg 1646a96d7823Smrg 1647fd60135fSmrg# func_options_prep [ARG]... 1648fd60135fSmrg# -------------------------- 1649fd60135fSmrg# All initialisations required before starting the option parse loop. 1650fd60135fSmrg# Note that when calling hook functions, we pass through the list of 1651fd60135fSmrg# positional parameters. If a hook function modifies that list, and 1652fd60135fSmrg# needs to propogate that back to rest of this script, then the complete 1653fd60135fSmrg# modified list must be put in 'func_run_hooks_result' before 1654fd60135fSmrg# returning. 1655fd60135fSmrgfunc_hookable func_options_prep 1656fd60135fSmrgfunc_options_prep () 1657a96d7823Smrg{ 1658fd60135fSmrg $debug_cmd 1659a96d7823Smrg 1660fd60135fSmrg # Option defaults: 1661fd60135fSmrg opt_verbose=false 1662fd60135fSmrg opt_warning_types= 1663fd60135fSmrg 1664fd60135fSmrg func_run_hooks func_options_prep ${1+"$@"} 1665fd60135fSmrg 1666fd60135fSmrg # save modified positional parameters for caller 1667fd60135fSmrg func_options_prep_result=$func_run_hooks_result 1668a96d7823Smrg} 1669a96d7823Smrg 1670a96d7823Smrg 1671fd60135fSmrg# func_parse_options [ARG]... 1672fd60135fSmrg# --------------------------- 1673fd60135fSmrg# The main option parsing loop. 1674fd60135fSmrgfunc_hookable func_parse_options 1675fd60135fSmrgfunc_parse_options () 1676a96d7823Smrg{ 1677fd60135fSmrg $debug_cmd 1678a96d7823Smrg 1679fd60135fSmrg func_parse_options_result= 1680a96d7823Smrg 1681fd60135fSmrg # this just eases exit handling 1682fd60135fSmrg while test $# -gt 0; do 1683fd60135fSmrg # Defer to hook functions for initial option parsing, so they 1684fd60135fSmrg # get priority in the event of reusing an option name. 1685fd60135fSmrg func_run_hooks func_parse_options ${1+"$@"} 1686a96d7823Smrg 1687fd60135fSmrg # Adjust func_parse_options positional parameters to match 1688fd60135fSmrg eval set dummy "$func_run_hooks_result"; shift 1689a96d7823Smrg 1690fd60135fSmrg # Break out of the loop if we already parsed every option. 1691fd60135fSmrg test $# -gt 0 || break 1692a96d7823Smrg 1693fd60135fSmrg _G_opt=$1 1694fd60135fSmrg shift 1695fd60135fSmrg case $_G_opt in 1696fd60135fSmrg --debug|-x) debug_cmd='set -x' 1697fd60135fSmrg func_echo "enabling shell trace mode" 1698fd60135fSmrg $debug_cmd 1699fd60135fSmrg ;; 1700fd60135fSmrg 1701fd60135fSmrg --no-warnings|--no-warning|--no-warn) 1702fd60135fSmrg set dummy --warnings none ${1+"$@"} 1703fd60135fSmrg shift 1704fd60135fSmrg ;; 1705a96d7823Smrg 1706fd60135fSmrg --warnings|--warning|-W) 1707fd60135fSmrg test $# = 0 && func_missing_arg $_G_opt && break 1708fd60135fSmrg case " $warning_categories $1" in 1709fd60135fSmrg *" $1 "*) 1710fd60135fSmrg # trailing space prevents matching last $1 above 1711fd60135fSmrg func_append_uniq opt_warning_types " $1" 1712fd60135fSmrg ;; 1713fd60135fSmrg *all) 1714fd60135fSmrg opt_warning_types=$warning_categories 1715fd60135fSmrg ;; 1716fd60135fSmrg *none) 1717fd60135fSmrg opt_warning_types=none 1718fd60135fSmrg warning_func=: 1719fd60135fSmrg ;; 1720fd60135fSmrg *error) 1721fd60135fSmrg opt_warning_types=$warning_categories 1722fd60135fSmrg warning_func=func_fatal_error 1723fd60135fSmrg ;; 1724fd60135fSmrg *) 1725fd60135fSmrg func_fatal_error \ 1726fd60135fSmrg "unsupported warning category: '$1'" 1727fd60135fSmrg ;; 1728fd60135fSmrg esac 1729fd60135fSmrg shift 1730fd60135fSmrg ;; 1731fd60135fSmrg 1732fd60135fSmrg --verbose|-v) opt_verbose=: ;; 1733fd60135fSmrg --version) func_version ;; 1734fd60135fSmrg -\?|-h) func_usage ;; 1735fd60135fSmrg --help) func_help ;; 1736fd60135fSmrg 1737fd60135fSmrg # Separate optargs to long options (plugins may need this): 1738fd60135fSmrg --*=*) func_split_equals "$_G_opt" 1739fd60135fSmrg set dummy "$func_split_equals_lhs" \ 1740fd60135fSmrg "$func_split_equals_rhs" ${1+"$@"} 1741fd60135fSmrg shift 1742fd60135fSmrg ;; 1743fd60135fSmrg 1744fd60135fSmrg # Separate optargs to short options: 1745fd60135fSmrg -W*) 1746fd60135fSmrg func_split_short_opt "$_G_opt" 1747fd60135fSmrg set dummy "$func_split_short_opt_name" \ 1748fd60135fSmrg "$func_split_short_opt_arg" ${1+"$@"} 1749fd60135fSmrg shift 1750fd60135fSmrg ;; 1751fd60135fSmrg 1752fd60135fSmrg # Separate non-argument short options: 1753fd60135fSmrg -\?*|-h*|-v*|-x*) 1754fd60135fSmrg func_split_short_opt "$_G_opt" 1755fd60135fSmrg set dummy "$func_split_short_opt_name" \ 1756fd60135fSmrg "-$func_split_short_opt_arg" ${1+"$@"} 1757fd60135fSmrg shift 1758fd60135fSmrg ;; 1759fd60135fSmrg 1760fd60135fSmrg --) break ;; 1761fd60135fSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1762fd60135fSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1763fd60135fSmrg esac 1764fd60135fSmrg done 1765fd60135fSmrg 1766fd60135fSmrg # save modified positional parameters for caller 1767fd60135fSmrg func_quote_for_eval ${1+"$@"} 1768fd60135fSmrg func_parse_options_result=$func_quote_for_eval_result 1769a96d7823Smrg} 1770a96d7823Smrg 1771a96d7823Smrg 1772fd60135fSmrg# func_validate_options [ARG]... 1773fd60135fSmrg# ------------------------------ 1774fd60135fSmrg# Perform any sanity checks on option settings and/or unconsumed 1775fd60135fSmrg# arguments. 1776fd60135fSmrgfunc_hookable func_validate_options 1777fd60135fSmrgfunc_validate_options () 1778a96d7823Smrg{ 1779fd60135fSmrg $debug_cmd 1780a96d7823Smrg 1781fd60135fSmrg # Display all warnings if -W was not given. 1782fd60135fSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1783a96d7823Smrg 1784fd60135fSmrg func_run_hooks func_validate_options ${1+"$@"} 1785a96d7823Smrg 1786fd60135fSmrg # Bail if the options were screwed! 1787fd60135fSmrg $exit_cmd $EXIT_FAILURE 1788fd60135fSmrg 1789fd60135fSmrg # save modified positional parameters for caller 1790fd60135fSmrg func_validate_options_result=$func_run_hooks_result 1791a96d7823Smrg} 1792a96d7823Smrg 1793a96d7823Smrg 1794a96d7823Smrg 1795fd60135fSmrg## ----------------- ## 1796fd60135fSmrg## Helper functions. ## 1797fd60135fSmrg## ----------------- ## 1798a96d7823Smrg 1799fd60135fSmrg# This section contains the helper functions used by the rest of the 1800fd60135fSmrg# hookable option parser framework in ascii-betical order. 1801fd60135fSmrg 1802fd60135fSmrg 1803fd60135fSmrg# func_fatal_help ARG... 1804fd60135fSmrg# ---------------------- 1805fd60135fSmrg# Echo program name prefixed message to standard error, followed by 1806fd60135fSmrg# a help hint, and exit. 1807fd60135fSmrgfunc_fatal_help () 1808a96d7823Smrg{ 1809fd60135fSmrg $debug_cmd 1810a96d7823Smrg 1811fd60135fSmrg eval \$ECHO \""Usage: $usage"\" 1812fd60135fSmrg eval \$ECHO \""$fatal_help"\" 1813fd60135fSmrg func_error ${1+"$@"} 1814fd60135fSmrg exit $EXIT_FAILURE 1815a96d7823Smrg} 1816a96d7823Smrg 1817fd60135fSmrg 1818fd60135fSmrg# func_help 1819fd60135fSmrg# --------- 1820fd60135fSmrg# Echo long help message to standard output and exit. 1821a96d7823Smrgfunc_help () 1822a96d7823Smrg{ 1823fd60135fSmrg $debug_cmd 1824fd60135fSmrg 1825fd60135fSmrg func_usage_message 1826fd60135fSmrg $ECHO "$long_help_message" 1827fd60135fSmrg exit 0 1828a96d7823Smrg} 1829a96d7823Smrg 1830fd60135fSmrg 1831fd60135fSmrg# func_missing_arg ARGNAME 1832fd60135fSmrg# ------------------------ 1833a96d7823Smrg# Echo program name prefixed message to standard error and set global 1834a96d7823Smrg# exit_cmd. 1835a96d7823Smrgfunc_missing_arg () 1836a96d7823Smrg{ 1837fd60135fSmrg $debug_cmd 1838a96d7823Smrg 1839fd60135fSmrg func_error "Missing argument for '$1'." 1840a96d7823Smrg exit_cmd=exit 1841a96d7823Smrg} 1842a96d7823Smrg 1843a96d7823Smrg 1844fd60135fSmrg# func_split_equals STRING 1845fd60135fSmrg# ------------------------ 1846fd60135fSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 1847fd60135fSmrg# splitting STRING at the '=' sign. 1848fd60135fSmrgtest -z "$_G_HAVE_XSI_OPS" \ 1849fd60135fSmrg && (eval 'x=a/b/c; 1850fd60135fSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 1851fd60135fSmrg && _G_HAVE_XSI_OPS=yes 1852fd60135fSmrg 1853fd60135fSmrgif test yes = "$_G_HAVE_XSI_OPS" 1854fd60135fSmrgthen 1855fd60135fSmrg # This is an XSI compatible shell, allowing a faster implementation... 1856fd60135fSmrg eval 'func_split_equals () 1857fd60135fSmrg { 1858fd60135fSmrg $debug_cmd 1859fd60135fSmrg 1860fd60135fSmrg func_split_equals_lhs=${1%%=*} 1861fd60135fSmrg func_split_equals_rhs=${1#*=} 1862fd60135fSmrg test "x$func_split_equals_lhs" = "x$1" \ 1863fd60135fSmrg && func_split_equals_rhs= 1864fd60135fSmrg }' 1865fd60135fSmrgelse 1866fd60135fSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 1867fd60135fSmrg func_split_equals () 1868fd60135fSmrg { 1869fd60135fSmrg $debug_cmd 1870fd60135fSmrg 1871fd60135fSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 1872fd60135fSmrg func_split_equals_rhs= 1873fd60135fSmrg test "x$func_split_equals_lhs" = "x$1" \ 1874fd60135fSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 1875fd60135fSmrg } 1876fd60135fSmrgfi #func_split_equals 1877fd60135fSmrg 1878fd60135fSmrg 1879fd60135fSmrg# func_split_short_opt SHORTOPT 1880fd60135fSmrg# ----------------------------- 1881a96d7823Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 1882a96d7823Smrg# variables after splitting SHORTOPT after the 2nd character. 1883fd60135fSmrgif test yes = "$_G_HAVE_XSI_OPS" 1884fd60135fSmrgthen 1885fd60135fSmrg # This is an XSI compatible shell, allowing a faster implementation... 1886fd60135fSmrg eval 'func_split_short_opt () 1887fd60135fSmrg { 1888fd60135fSmrg $debug_cmd 1889fd60135fSmrg 1890fd60135fSmrg func_split_short_opt_arg=${1#??} 1891fd60135fSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 1892fd60135fSmrg }' 1893fd60135fSmrgelse 1894fd60135fSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 1895fd60135fSmrg func_split_short_opt () 1896fd60135fSmrg { 1897fd60135fSmrg $debug_cmd 1898fd60135fSmrg 1899fd60135fSmrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 1900fd60135fSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 1901fd60135fSmrg } 1902fd60135fSmrgfi #func_split_short_opt 1903fd60135fSmrg 1904fd60135fSmrg 1905fd60135fSmrg# func_usage 1906fd60135fSmrg# ---------- 1907fd60135fSmrg# Echo short help message to standard output and exit. 1908fd60135fSmrgfunc_usage () 1909a96d7823Smrg{ 1910fd60135fSmrg $debug_cmd 1911a96d7823Smrg 1912fd60135fSmrg func_usage_message 1913fd60135fSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 1914fd60135fSmrg exit 0 1915fd60135fSmrg} 1916a96d7823Smrg 1917a96d7823Smrg 1918fd60135fSmrg# func_usage_message 1919fd60135fSmrg# ------------------ 1920fd60135fSmrg# Echo short help message to standard output. 1921fd60135fSmrgfunc_usage_message () 1922a96d7823Smrg{ 1923fd60135fSmrg $debug_cmd 1924a96d7823Smrg 1925fd60135fSmrg eval \$ECHO \""Usage: $usage"\" 1926fd60135fSmrg echo 1927fd60135fSmrg $SED -n 's|^# || 1928fd60135fSmrg /^Written by/{ 1929fd60135fSmrg x;p;x 1930fd60135fSmrg } 1931fd60135fSmrg h 1932fd60135fSmrg /^Written by/q' < "$progpath" 1933fd60135fSmrg echo 1934fd60135fSmrg eval \$ECHO \""$usage_message"\" 1935fd60135fSmrg} 1936a96d7823Smrg 1937a96d7823Smrg 1938fd60135fSmrg# func_version 1939fd60135fSmrg# ------------ 1940fd60135fSmrg# Echo version message to standard output and exit. 1941fd60135fSmrgfunc_version () 1942fd60135fSmrg{ 1943fd60135fSmrg $debug_cmd 1944a96d7823Smrg 1945fd60135fSmrg printf '%s\n' "$progname $scriptversion" 1946fd60135fSmrg $SED -n ' 1947fd60135fSmrg /(C)/!b go 1948fd60135fSmrg :more 1949fd60135fSmrg /\./!{ 1950fd60135fSmrg N 1951fd60135fSmrg s|\n# | | 1952fd60135fSmrg b more 1953fd60135fSmrg } 1954fd60135fSmrg :go 1955fd60135fSmrg /^# Written by /,/# warranty; / { 1956fd60135fSmrg s|^# || 1957fd60135fSmrg s|^# *$|| 1958fd60135fSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 1959fd60135fSmrg p 1960fd60135fSmrg } 1961fd60135fSmrg /^# Written by / { 1962fd60135fSmrg s|^# || 1963fd60135fSmrg p 1964fd60135fSmrg } 1965fd60135fSmrg /^warranty; /q' < "$progpath" 1966a96d7823Smrg 1967fd60135fSmrg exit $? 1968fd60135fSmrg} 1969a96d7823Smrg 1970a96d7823Smrg 1971fd60135fSmrg# Local variables: 1972fd60135fSmrg# mode: shell-script 1973fd60135fSmrg# sh-indentation: 2 1974fd60135fSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 1975fd60135fSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1976fd60135fSmrg# time-stamp-time-zone: "UTC" 1977fd60135fSmrg# End: 1978a96d7823Smrg 1979fd60135fSmrg# Set a version string. 1980fd60135fSmrgscriptversion='(GNU libtool) 2.4.6' 1981a96d7823Smrg 1982a96d7823Smrg 1983fd60135fSmrg# func_echo ARG... 1984fd60135fSmrg# ---------------- 1985fd60135fSmrg# Libtool also displays the current mode in messages, so override 1986fd60135fSmrg# funclib.sh func_echo with this custom definition. 1987fd60135fSmrgfunc_echo () 1988a96d7823Smrg{ 1989fd60135fSmrg $debug_cmd 1990a96d7823Smrg 1991fd60135fSmrg _G_message=$* 1992a96d7823Smrg 1993fd60135fSmrg func_echo_IFS=$IFS 1994fd60135fSmrg IFS=$nl 1995fd60135fSmrg for _G_line in $_G_message; do 1996fd60135fSmrg IFS=$func_echo_IFS 1997fd60135fSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 1998fd60135fSmrg done 1999fd60135fSmrg IFS=$func_echo_IFS 2000fd60135fSmrg} 2001a96d7823Smrg 2002fd60135fSmrg 2003fd60135fSmrg# func_warning ARG... 2004fd60135fSmrg# ------------------- 2005fd60135fSmrg# Libtool warnings are not categorized, so override funclib.sh 2006fd60135fSmrg# func_warning with this simpler definition. 2007fd60135fSmrgfunc_warning () 2008a96d7823Smrg{ 2009fd60135fSmrg $debug_cmd 2010a96d7823Smrg 2011fd60135fSmrg $warning_func ${1+"$@"} 2012fd60135fSmrg} 2013a96d7823Smrg 2014a96d7823Smrg 2015fd60135fSmrg## ---------------- ## 2016fd60135fSmrg## Options parsing. ## 2017fd60135fSmrg## ---------------- ## 2018fd60135fSmrg 2019fd60135fSmrg# Hook in the functions to make sure our own options are parsed during 2020fd60135fSmrg# the option parsing loop. 2021fd60135fSmrg 2022fd60135fSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 2023fd60135fSmrg 2024fd60135fSmrg# Short help message in response to '-h'. 2025fd60135fSmrgusage_message="Options: 2026fd60135fSmrg --config show all configuration variables 2027fd60135fSmrg --debug enable verbose shell tracing 2028fd60135fSmrg -n, --dry-run display commands without modifying any files 2029fd60135fSmrg --features display basic configuration information and exit 2030fd60135fSmrg --mode=MODE use operation mode MODE 2031fd60135fSmrg --no-warnings equivalent to '-Wnone' 2032fd60135fSmrg --preserve-dup-deps don't remove duplicate dependency libraries 2033fd60135fSmrg --quiet, --silent don't print informational messages 2034fd60135fSmrg --tag=TAG use configuration variables from tag TAG 2035fd60135fSmrg -v, --verbose print more informational messages than default 2036fd60135fSmrg --version print version information 2037fd60135fSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2038fd60135fSmrg -h, --help, --help-all print short, long, or detailed help message 2039fd60135fSmrg" 2040a96d7823Smrg 2041fd60135fSmrg# Additional text appended to 'usage_message' in response to '--help'. 2042fd60135fSmrgfunc_help () 2043a96d7823Smrg{ 2044fd60135fSmrg $debug_cmd 2045fd60135fSmrg 2046fd60135fSmrg func_usage_message 2047fd60135fSmrg $ECHO "$long_help_message 2048fd60135fSmrg 2049fd60135fSmrgMODE must be one of the following: 2050fd60135fSmrg 2051fd60135fSmrg clean remove files from the build directory 2052fd60135fSmrg compile compile a source file into a libtool object 2053fd60135fSmrg execute automatically set library path, then run a program 2054fd60135fSmrg finish complete the installation of libtool libraries 2055fd60135fSmrg install install libraries or executables 2056fd60135fSmrg link create a library or an executable 2057fd60135fSmrg uninstall remove libraries from an installed directory 2058fd60135fSmrg 2059fd60135fSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2060fd60135fSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2061fd60135fSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2062fd60135fSmrg 2063fd60135fSmrgWhen reporting a bug, please describe a test case to reproduce it and 2064fd60135fSmrginclude the following information: 2065fd60135fSmrg 2066fd60135fSmrg host-triplet: $host 2067fd60135fSmrg shell: $SHELL 2068fd60135fSmrg compiler: $LTCC 2069fd60135fSmrg compiler flags: $LTCFLAGS 2070fd60135fSmrg linker: $LD (gnu? $with_gnu_ld) 2071fd60135fSmrg version: $progname (GNU libtool) 2.4.6 2072fd60135fSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2073fd60135fSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2074fd60135fSmrg 2075fd60135fSmrgReport bugs to <bug-libtool@gnu.org>. 2076fd60135fSmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>. 2077fd60135fSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2078fd60135fSmrg exit 0 2079fd60135fSmrg} 2080a96d7823Smrg 2081a96d7823Smrg 2082fd60135fSmrg# func_lo2o OBJECT-NAME 2083fd60135fSmrg# --------------------- 2084fd60135fSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2085fd60135fSmrg# object suffix. 2086fd60135fSmrg 2087fd60135fSmrglo2o=s/\\.lo\$/.$objext/ 2088fd60135fSmrgo2lo=s/\\.$objext\$/.lo/ 2089fd60135fSmrg 2090fd60135fSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 2091fd60135fSmrg eval 'func_lo2o () 2092fd60135fSmrg { 2093fd60135fSmrg case $1 in 2094fd60135fSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2095fd60135fSmrg * ) func_lo2o_result=$1 ;; 2096fd60135fSmrg esac 2097fd60135fSmrg }' 2098fd60135fSmrg 2099fd60135fSmrg # func_xform LIBOBJ-OR-SOURCE 2100fd60135fSmrg # --------------------------- 2101fd60135fSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2102fd60135fSmrg # suffix to a '.lo' libtool-object suffix. 2103fd60135fSmrg eval 'func_xform () 2104fd60135fSmrg { 2105fd60135fSmrg func_xform_result=${1%.*}.lo 2106fd60135fSmrg }' 2107fd60135fSmrgelse 2108fd60135fSmrg # ...otherwise fall back to using sed. 2109fd60135fSmrg func_lo2o () 2110fd60135fSmrg { 2111fd60135fSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2112fd60135fSmrg } 2113fd60135fSmrg 2114fd60135fSmrg func_xform () 2115fd60135fSmrg { 2116fd60135fSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2117fd60135fSmrg } 2118fd60135fSmrgfi 2119a96d7823Smrg 2120a96d7823Smrg 2121fd60135fSmrg# func_fatal_configuration ARG... 2122fd60135fSmrg# ------------------------------- 2123a96d7823Smrg# Echo program name prefixed message to standard error, followed by 2124a96d7823Smrg# a configuration failure hint, and exit. 2125a96d7823Smrgfunc_fatal_configuration () 2126a96d7823Smrg{ 2127fd60135fSmrg func__fatal_error ${1+"$@"} \ 2128fd60135fSmrg "See the $PACKAGE documentation for more information." \ 2129fd60135fSmrg "Fatal configuration error." 2130a96d7823Smrg} 2131a96d7823Smrg 2132a96d7823Smrg 2133a96d7823Smrg# func_config 2134fd60135fSmrg# ----------- 2135a96d7823Smrg# Display the configuration for all the tags in this script. 2136a96d7823Smrgfunc_config () 2137a96d7823Smrg{ 2138a96d7823Smrg re_begincf='^# ### BEGIN LIBTOOL' 2139a96d7823Smrg re_endcf='^# ### END LIBTOOL' 2140a96d7823Smrg 2141a96d7823Smrg # Default configuration. 2142a96d7823Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2143a96d7823Smrg 2144a96d7823Smrg # Now print the configurations for the tags. 2145a96d7823Smrg for tagname in $taglist; do 2146a96d7823Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2147a96d7823Smrg done 2148a96d7823Smrg 2149a96d7823Smrg exit $? 2150a96d7823Smrg} 2151a96d7823Smrg 2152fd60135fSmrg 2153a96d7823Smrg# func_features 2154fd60135fSmrg# ------------- 2155a96d7823Smrg# Display the features supported by this script. 2156a96d7823Smrgfunc_features () 2157a96d7823Smrg{ 2158a96d7823Smrg echo "host: $host" 2159fd60135fSmrg if test yes = "$build_libtool_libs"; then 2160a96d7823Smrg echo "enable shared libraries" 2161a96d7823Smrg else 2162a96d7823Smrg echo "disable shared libraries" 2163a96d7823Smrg fi 2164fd60135fSmrg if test yes = "$build_old_libs"; then 2165a96d7823Smrg echo "enable static libraries" 2166a96d7823Smrg else 2167a96d7823Smrg echo "disable static libraries" 2168a96d7823Smrg fi 2169a96d7823Smrg 2170a96d7823Smrg exit $? 2171a96d7823Smrg} 2172a96d7823Smrg 2173fd60135fSmrg 2174fd60135fSmrg# func_enable_tag TAGNAME 2175fd60135fSmrg# ----------------------- 2176a96d7823Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2177a96d7823Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2178a96d7823Smrg# variable here. 2179a96d7823Smrgfunc_enable_tag () 2180a96d7823Smrg{ 2181fd60135fSmrg # Global variable: 2182fd60135fSmrg tagname=$1 2183a96d7823Smrg 2184fd60135fSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2185fd60135fSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2186fd60135fSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2187a96d7823Smrg 2188fd60135fSmrg # Validate tagname. 2189fd60135fSmrg case $tagname in 2190fd60135fSmrg *[!-_A-Za-z0-9,/]*) 2191fd60135fSmrg func_fatal_error "invalid tag name: $tagname" 2192fd60135fSmrg ;; 2193fd60135fSmrg esac 2194a96d7823Smrg 2195fd60135fSmrg # Don't test for the "default" C tag, as we know it's 2196fd60135fSmrg # there but not specially marked. 2197fd60135fSmrg case $tagname in 2198fd60135fSmrg CC) ;; 2199a96d7823Smrg *) 2200fd60135fSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2201fd60135fSmrg taglist="$taglist $tagname" 2202fd60135fSmrg 2203fd60135fSmrg # Evaluate the configuration. Be careful to quote the path 2204fd60135fSmrg # and the sed script, to avoid splitting on whitespace, but 2205fd60135fSmrg # also don't use non-portable quotes within backquotes within 2206fd60135fSmrg # quotes we have to do it in 2 steps: 2207fd60135fSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2208fd60135fSmrg eval "$extractedcf" 2209fd60135fSmrg else 2210fd60135fSmrg func_error "ignoring unknown tag $tagname" 2211fd60135fSmrg fi 2212fd60135fSmrg ;; 2213fd60135fSmrg esac 2214a96d7823Smrg} 2215a96d7823Smrg 2216fd60135fSmrg 2217a96d7823Smrg# func_check_version_match 2218fd60135fSmrg# ------------------------ 2219a96d7823Smrg# Ensure that we are using m4 macros, and libtool script from the same 2220a96d7823Smrg# release of libtool. 2221a96d7823Smrgfunc_check_version_match () 2222a96d7823Smrg{ 2223fd60135fSmrg if test "$package_revision" != "$macro_revision"; then 2224fd60135fSmrg if test "$VERSION" != "$macro_version"; then 2225fd60135fSmrg if test -z "$macro_version"; then 2226fd60135fSmrg cat >&2 <<_LT_EOF 2227a96d7823Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2228a96d7823Smrg$progname: definition of this LT_INIT comes from an older release. 2229a96d7823Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2230a96d7823Smrg$progname: and run autoconf again. 2231a96d7823Smrg_LT_EOF 2232fd60135fSmrg else 2233fd60135fSmrg cat >&2 <<_LT_EOF 2234a96d7823Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2235a96d7823Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2236a96d7823Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2237a96d7823Smrg$progname: and run autoconf again. 2238a96d7823Smrg_LT_EOF 2239fd60135fSmrg fi 2240fd60135fSmrg else 2241fd60135fSmrg cat >&2 <<_LT_EOF 2242a96d7823Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2243a96d7823Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2244a96d7823Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2245a96d7823Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 2246a96d7823Smrg_LT_EOF 2247fd60135fSmrg fi 2248a96d7823Smrg 2249fd60135fSmrg exit $EXIT_MISMATCH 2250fd60135fSmrg fi 2251a96d7823Smrg} 2252a96d7823Smrg 2253a96d7823Smrg 2254fd60135fSmrg# libtool_options_prep [ARG]... 2255fd60135fSmrg# ----------------------------- 2256fd60135fSmrg# Preparation for options parsed by libtool. 2257fd60135fSmrglibtool_options_prep () 2258fd60135fSmrg{ 2259fd60135fSmrg $debug_mode 2260a96d7823Smrg 2261fd60135fSmrg # Option defaults: 2262fd60135fSmrg opt_config=false 2263fd60135fSmrg opt_dlopen= 2264fd60135fSmrg opt_dry_run=false 2265fd60135fSmrg opt_help=false 2266fd60135fSmrg opt_mode= 2267fd60135fSmrg opt_preserve_dup_deps=false 2268fd60135fSmrg opt_quiet=false 2269a96d7823Smrg 2270fd60135fSmrg nonopt= 2271fd60135fSmrg preserve_args= 2272a96d7823Smrg 2273fd60135fSmrg # Shorthand for --mode=foo, only valid as the first argument 2274fd60135fSmrg case $1 in 2275fd60135fSmrg clean|clea|cle|cl) 2276fd60135fSmrg shift; set dummy --mode clean ${1+"$@"}; shift 2277fd60135fSmrg ;; 2278fd60135fSmrg compile|compil|compi|comp|com|co|c) 2279fd60135fSmrg shift; set dummy --mode compile ${1+"$@"}; shift 2280fd60135fSmrg ;; 2281fd60135fSmrg execute|execut|execu|exec|exe|ex|e) 2282fd60135fSmrg shift; set dummy --mode execute ${1+"$@"}; shift 2283fd60135fSmrg ;; 2284fd60135fSmrg finish|finis|fini|fin|fi|f) 2285fd60135fSmrg shift; set dummy --mode finish ${1+"$@"}; shift 2286fd60135fSmrg ;; 2287fd60135fSmrg install|instal|insta|inst|ins|in|i) 2288fd60135fSmrg shift; set dummy --mode install ${1+"$@"}; shift 2289fd60135fSmrg ;; 2290fd60135fSmrg link|lin|li|l) 2291fd60135fSmrg shift; set dummy --mode link ${1+"$@"}; shift 2292fd60135fSmrg ;; 2293fd60135fSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2294fd60135fSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2295fd60135fSmrg ;; 2296fd60135fSmrg esac 2297fd60135fSmrg 2298fd60135fSmrg # Pass back the list of options. 2299fd60135fSmrg func_quote_for_eval ${1+"$@"} 2300fd60135fSmrg libtool_options_prep_result=$func_quote_for_eval_result 2301fd60135fSmrg} 2302fd60135fSmrgfunc_add_hook func_options_prep libtool_options_prep 2303a96d7823Smrg 2304a96d7823Smrg 2305fd60135fSmrg# libtool_parse_options [ARG]... 2306fd60135fSmrg# --------------------------------- 2307fd60135fSmrg# Provide handling for libtool specific options. 2308fd60135fSmrglibtool_parse_options () 2309a96d7823Smrg{ 2310fd60135fSmrg $debug_cmd 2311a96d7823Smrg 2312fd60135fSmrg # Perform our own loop to consume as many options as possible in 2313fd60135fSmrg # each iteration. 2314fd60135fSmrg while test $# -gt 0; do 2315fd60135fSmrg _G_opt=$1 2316fd60135fSmrg shift 2317fd60135fSmrg case $_G_opt in 2318fd60135fSmrg --dry-run|--dryrun|-n) 2319fd60135fSmrg opt_dry_run=: 2320fd60135fSmrg ;; 2321fd60135fSmrg 2322fd60135fSmrg --config) func_config ;; 2323fd60135fSmrg 2324fd60135fSmrg --dlopen|-dlopen) 2325fd60135fSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 2326fd60135fSmrg}$1" 2327fd60135fSmrg shift 2328fd60135fSmrg ;; 2329fd60135fSmrg 2330fd60135fSmrg --preserve-dup-deps) 2331fd60135fSmrg opt_preserve_dup_deps=: ;; 2332fd60135fSmrg 2333fd60135fSmrg --features) func_features ;; 2334fd60135fSmrg 2335fd60135fSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2336fd60135fSmrg 2337fd60135fSmrg --help) opt_help=: ;; 2338fd60135fSmrg 2339fd60135fSmrg --help-all) opt_help=': help-all' ;; 2340fd60135fSmrg 2341fd60135fSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2342fd60135fSmrg opt_mode=$1 2343fd60135fSmrg case $1 in 2344fd60135fSmrg # Valid mode arguments: 2345fd60135fSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2346fd60135fSmrg 2347fd60135fSmrg # Catch anything else as an error 2348fd60135fSmrg *) func_error "invalid argument for $_G_opt" 2349fd60135fSmrg exit_cmd=exit 2350fd60135fSmrg break 2351fd60135fSmrg ;; 2352fd60135fSmrg esac 2353fd60135fSmrg shift 2354fd60135fSmrg ;; 2355fd60135fSmrg 2356fd60135fSmrg --no-silent|--no-quiet) 2357fd60135fSmrg opt_quiet=false 2358fd60135fSmrg func_append preserve_args " $_G_opt" 2359fd60135fSmrg ;; 2360fd60135fSmrg 2361fd60135fSmrg --no-warnings|--no-warning|--no-warn) 2362fd60135fSmrg opt_warning=false 2363fd60135fSmrg func_append preserve_args " $_G_opt" 2364fd60135fSmrg ;; 2365fd60135fSmrg 2366fd60135fSmrg --no-verbose) 2367fd60135fSmrg opt_verbose=false 2368fd60135fSmrg func_append preserve_args " $_G_opt" 2369fd60135fSmrg ;; 2370fd60135fSmrg 2371fd60135fSmrg --silent|--quiet) 2372fd60135fSmrg opt_quiet=: 2373fd60135fSmrg opt_verbose=false 2374fd60135fSmrg func_append preserve_args " $_G_opt" 2375fd60135fSmrg ;; 2376fd60135fSmrg 2377fd60135fSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2378fd60135fSmrg opt_tag=$1 2379fd60135fSmrg func_append preserve_args " $_G_opt $1" 2380fd60135fSmrg func_enable_tag "$1" 2381fd60135fSmrg shift 2382fd60135fSmrg ;; 2383fd60135fSmrg 2384fd60135fSmrg --verbose|-v) opt_quiet=false 2385fd60135fSmrg opt_verbose=: 2386fd60135fSmrg func_append preserve_args " $_G_opt" 2387fd60135fSmrg ;; 2388fd60135fSmrg 2389fd60135fSmrg # An option not handled by this hook function: 2390fd60135fSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 2391fd60135fSmrg esac 2392fd60135fSmrg done 2393a96d7823Smrg 2394a96d7823Smrg 2395fd60135fSmrg # save modified positional parameters for caller 2396fd60135fSmrg func_quote_for_eval ${1+"$@"} 2397fd60135fSmrg libtool_parse_options_result=$func_quote_for_eval_result 2398fd60135fSmrg} 2399fd60135fSmrgfunc_add_hook func_parse_options libtool_parse_options 2400a96d7823Smrg 2401a96d7823Smrg 2402a96d7823Smrg 2403fd60135fSmrg# libtool_validate_options [ARG]... 2404fd60135fSmrg# --------------------------------- 2405fd60135fSmrg# Perform any sanity checks on option settings and/or unconsumed 2406fd60135fSmrg# arguments. 2407fd60135fSmrglibtool_validate_options () 2408fd60135fSmrg{ 2409fd60135fSmrg # save first non-option argument 2410fd60135fSmrg if test 0 -lt $#; then 2411fd60135fSmrg nonopt=$1 2412fd60135fSmrg shift 2413a96d7823Smrg fi 2414a96d7823Smrg 2415fd60135fSmrg # preserve --debug 2416fd60135fSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2417a96d7823Smrg 2418fd60135fSmrg case $host in 2419fd60135fSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2420fd60135fSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2421fd60135fSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2422fd60135fSmrg # don't eliminate duplications in $postdeps and $predeps 2423fd60135fSmrg opt_duplicate_compiler_generated_deps=: 2424fd60135fSmrg ;; 2425fd60135fSmrg *) 2426fd60135fSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2427fd60135fSmrg ;; 2428fd60135fSmrg esac 2429a96d7823Smrg 2430fd60135fSmrg $opt_help || { 2431fd60135fSmrg # Sanity checks first: 2432fd60135fSmrg func_check_version_match 2433fd60135fSmrg 2434fd60135fSmrg test yes != "$build_libtool_libs" \ 2435fd60135fSmrg && test yes != "$build_old_libs" \ 2436fd60135fSmrg && func_fatal_configuration "not configured to build any kind of library" 2437fd60135fSmrg 2438fd60135fSmrg # Darwin sucks 2439fd60135fSmrg eval std_shrext=\"$shrext_cmds\" 2440fd60135fSmrg 2441fd60135fSmrg # Only execute mode is allowed to have -dlopen flags. 2442fd60135fSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2443fd60135fSmrg func_error "unrecognized option '-dlopen'" 2444fd60135fSmrg $ECHO "$help" 1>&2 2445fd60135fSmrg exit $EXIT_FAILURE 2446fd60135fSmrg fi 2447a96d7823Smrg 2448fd60135fSmrg # Change the help message to a mode-specific one. 2449fd60135fSmrg generic_help=$help 2450fd60135fSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 2451fd60135fSmrg } 2452a96d7823Smrg 2453fd60135fSmrg # Pass back the unparsed argument list 2454fd60135fSmrg func_quote_for_eval ${1+"$@"} 2455fd60135fSmrg libtool_validate_options_result=$func_quote_for_eval_result 2456a96d7823Smrg} 2457fd60135fSmrgfunc_add_hook func_validate_options libtool_validate_options 2458a96d7823Smrg 2459a96d7823Smrg 2460fd60135fSmrg# Process options as early as possible so that --help and --version 2461fd60135fSmrg# can return quickly. 2462fd60135fSmrgfunc_options ${1+"$@"} 2463fd60135fSmrgeval set dummy "$func_options_result"; shift 2464fd60135fSmrg 2465a96d7823Smrg 2466a96d7823Smrg 2467a96d7823Smrg## ----------- ## 2468a96d7823Smrg## Main. ## 2469a96d7823Smrg## ----------- ## 2470a96d7823Smrg 2471fd60135fSmrgmagic='%%%MAGIC variable%%%' 2472fd60135fSmrgmagic_exe='%%%MAGIC EXE variable%%%' 2473fd60135fSmrg 2474fd60135fSmrg# Global variables. 2475fd60135fSmrgextracted_archives= 2476fd60135fSmrgextracted_serial=0 2477fd60135fSmrg 2478fd60135fSmrg# If this variable is set in any of the actions, the command in it 2479fd60135fSmrg# will be execed at the end. This prevents here-documents from being 2480fd60135fSmrg# left over by shells. 2481fd60135fSmrgexec_cmd= 2482fd60135fSmrg 2483fd60135fSmrg 2484fd60135fSmrg# A function that is used when there is no print builtin or printf. 2485fd60135fSmrgfunc_fallback_echo () 2486fd60135fSmrg{ 2487fd60135fSmrg eval 'cat <<_LTECHO_EOF 2488fd60135fSmrg$1 2489fd60135fSmrg_LTECHO_EOF' 2490fd60135fSmrg} 2491fd60135fSmrg 2492fd60135fSmrg# func_generated_by_libtool 2493fd60135fSmrg# True iff stdin has been generated by Libtool. This function is only 2494fd60135fSmrg# a basic sanity check; it will hardly flush out determined imposters. 2495fd60135fSmrgfunc_generated_by_libtool_p () 2496fd60135fSmrg{ 2497fd60135fSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2498fd60135fSmrg} 2499fd60135fSmrg 2500a96d7823Smrg# func_lalib_p file 2501fd60135fSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2502a96d7823Smrg# This function is only a basic sanity check; it will hardly flush out 2503a96d7823Smrg# determined imposters. 2504a96d7823Smrgfunc_lalib_p () 2505a96d7823Smrg{ 2506a96d7823Smrg test -f "$1" && 2507fd60135fSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2508a96d7823Smrg} 2509a96d7823Smrg 2510a96d7823Smrg# func_lalib_unsafe_p file 2511fd60135fSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2512a96d7823Smrg# This function implements the same check as func_lalib_p without 2513a96d7823Smrg# resorting to external programs. To this end, it redirects stdin and 2514a96d7823Smrg# closes it afterwards, without saving the original file descriptor. 2515a96d7823Smrg# As a safety measure, use it only where a negative result would be 2516fd60135fSmrg# fatal anyway. Works if 'file' does not exist. 2517a96d7823Smrgfunc_lalib_unsafe_p () 2518a96d7823Smrg{ 2519a96d7823Smrg lalib_p=no 2520a96d7823Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2521a96d7823Smrg for lalib_p_l in 1 2 3 4 2522a96d7823Smrg do 2523a96d7823Smrg read lalib_p_line 2524fd60135fSmrg case $lalib_p_line in 2525a96d7823Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2526a96d7823Smrg esac 2527a96d7823Smrg done 2528a96d7823Smrg exec 0<&5 5<&- 2529a96d7823Smrg fi 2530fd60135fSmrg test yes = "$lalib_p" 2531a96d7823Smrg} 2532a96d7823Smrg 2533a96d7823Smrg# func_ltwrapper_script_p file 2534a96d7823Smrg# True iff FILE is a libtool wrapper script 2535a96d7823Smrg# This function is only a basic sanity check; it will hardly flush out 2536a96d7823Smrg# determined imposters. 2537a96d7823Smrgfunc_ltwrapper_script_p () 2538a96d7823Smrg{ 2539fd60135fSmrg test -f "$1" && 2540fd60135fSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2541a96d7823Smrg} 2542a96d7823Smrg 2543a96d7823Smrg# func_ltwrapper_executable_p file 2544a96d7823Smrg# True iff FILE is a libtool wrapper executable 2545a96d7823Smrg# This function is only a basic sanity check; it will hardly flush out 2546a96d7823Smrg# determined imposters. 2547a96d7823Smrgfunc_ltwrapper_executable_p () 2548a96d7823Smrg{ 2549a96d7823Smrg func_ltwrapper_exec_suffix= 2550a96d7823Smrg case $1 in 2551a96d7823Smrg *.exe) ;; 2552a96d7823Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2553a96d7823Smrg esac 2554a96d7823Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2555a96d7823Smrg} 2556a96d7823Smrg 2557a96d7823Smrg# func_ltwrapper_scriptname file 2558a96d7823Smrg# Assumes file is an ltwrapper_executable 2559a96d7823Smrg# uses $file to determine the appropriate filename for a 2560a96d7823Smrg# temporary ltwrapper_script. 2561a96d7823Smrgfunc_ltwrapper_scriptname () 2562a96d7823Smrg{ 2563a96d7823Smrg func_dirname_and_basename "$1" "" "." 2564a96d7823Smrg func_stripname '' '.exe' "$func_basename_result" 2565fd60135fSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2566a96d7823Smrg} 2567a96d7823Smrg 2568a96d7823Smrg# func_ltwrapper_p file 2569a96d7823Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2570a96d7823Smrg# This function is only a basic sanity check; it will hardly flush out 2571a96d7823Smrg# determined imposters. 2572a96d7823Smrgfunc_ltwrapper_p () 2573a96d7823Smrg{ 2574a96d7823Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2575a96d7823Smrg} 2576a96d7823Smrg 2577a96d7823Smrg 2578a96d7823Smrg# func_execute_cmds commands fail_cmd 2579a96d7823Smrg# Execute tilde-delimited COMMANDS. 2580a96d7823Smrg# If FAIL_CMD is given, eval that upon failure. 2581a96d7823Smrg# FAIL_CMD may read-access the current command in variable CMD! 2582a96d7823Smrgfunc_execute_cmds () 2583a96d7823Smrg{ 2584fd60135fSmrg $debug_cmd 2585fd60135fSmrg 2586a96d7823Smrg save_ifs=$IFS; IFS='~' 2587a96d7823Smrg for cmd in $1; do 2588fd60135fSmrg IFS=$sp$nl 2589a96d7823Smrg eval cmd=\"$cmd\" 2590fd60135fSmrg IFS=$save_ifs 2591a96d7823Smrg func_show_eval "$cmd" "${2-:}" 2592a96d7823Smrg done 2593a96d7823Smrg IFS=$save_ifs 2594a96d7823Smrg} 2595a96d7823Smrg 2596a96d7823Smrg 2597a96d7823Smrg# func_source file 2598a96d7823Smrg# Source FILE, adding directory component if necessary. 2599a96d7823Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2600a96d7823Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2601a96d7823Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2602fd60135fSmrg# 'FILE.' does not work on cygwin managed mounts. 2603a96d7823Smrgfunc_source () 2604a96d7823Smrg{ 2605fd60135fSmrg $debug_cmd 2606fd60135fSmrg 2607a96d7823Smrg case $1 in 2608a96d7823Smrg */* | *\\*) . "$1" ;; 2609a96d7823Smrg *) . "./$1" ;; 2610a96d7823Smrg esac 2611a96d7823Smrg} 2612a96d7823Smrg 2613a96d7823Smrg 2614a96d7823Smrg# func_resolve_sysroot PATH 2615a96d7823Smrg# Replace a leading = in PATH with a sysroot. Store the result into 2616a96d7823Smrg# func_resolve_sysroot_result 2617a96d7823Smrgfunc_resolve_sysroot () 2618a96d7823Smrg{ 2619a96d7823Smrg func_resolve_sysroot_result=$1 2620a96d7823Smrg case $func_resolve_sysroot_result in 2621a96d7823Smrg =*) 2622a96d7823Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 2623a96d7823Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2624a96d7823Smrg ;; 2625a96d7823Smrg esac 2626a96d7823Smrg} 2627a96d7823Smrg 2628a96d7823Smrg# func_replace_sysroot PATH 2629a96d7823Smrg# If PATH begins with the sysroot, replace it with = and 2630a96d7823Smrg# store the result into func_replace_sysroot_result. 2631a96d7823Smrgfunc_replace_sysroot () 2632a96d7823Smrg{ 2633fd60135fSmrg case $lt_sysroot:$1 in 2634a96d7823Smrg ?*:"$lt_sysroot"*) 2635a96d7823Smrg func_stripname "$lt_sysroot" '' "$1" 2636fd60135fSmrg func_replace_sysroot_result='='$func_stripname_result 2637a96d7823Smrg ;; 2638a96d7823Smrg *) 2639a96d7823Smrg # Including no sysroot. 2640a96d7823Smrg func_replace_sysroot_result=$1 2641a96d7823Smrg ;; 2642a96d7823Smrg esac 2643a96d7823Smrg} 2644a96d7823Smrg 2645a96d7823Smrg# func_infer_tag arg 2646a96d7823Smrg# Infer tagged configuration to use if any are available and 2647a96d7823Smrg# if one wasn't chosen via the "--tag" command line option. 2648a96d7823Smrg# Only attempt this if the compiler in the base compile 2649a96d7823Smrg# command doesn't match the default compiler. 2650a96d7823Smrg# arg is usually of the form 'gcc ...' 2651a96d7823Smrgfunc_infer_tag () 2652a96d7823Smrg{ 2653fd60135fSmrg $debug_cmd 2654fd60135fSmrg 2655a96d7823Smrg if test -n "$available_tags" && test -z "$tagname"; then 2656a96d7823Smrg CC_quoted= 2657a96d7823Smrg for arg in $CC; do 2658a96d7823Smrg func_append_quoted CC_quoted "$arg" 2659a96d7823Smrg done 2660a96d7823Smrg CC_expanded=`func_echo_all $CC` 2661a96d7823Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2662a96d7823Smrg case $@ in 2663a96d7823Smrg # Blanks in the command may have been stripped by the calling shell, 2664a96d7823Smrg # but not from the CC environment variable when configure was run. 2665a96d7823Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2666a96d7823Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2667a96d7823Smrg # Blanks at the start of $base_compile will cause this to fail 2668a96d7823Smrg # if we don't check for them as well. 2669a96d7823Smrg *) 2670a96d7823Smrg for z in $available_tags; do 2671a96d7823Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2672a96d7823Smrg # Evaluate the configuration. 2673fd60135fSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2674a96d7823Smrg CC_quoted= 2675a96d7823Smrg for arg in $CC; do 2676a96d7823Smrg # Double-quote args containing other shell metacharacters. 2677a96d7823Smrg func_append_quoted CC_quoted "$arg" 2678a96d7823Smrg done 2679a96d7823Smrg CC_expanded=`func_echo_all $CC` 2680a96d7823Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2681a96d7823Smrg case "$@ " in 2682a96d7823Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2683a96d7823Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2684a96d7823Smrg # The compiler in the base compile command matches 2685a96d7823Smrg # the one in the tagged configuration. 2686a96d7823Smrg # Assume this is the tagged configuration we want. 2687a96d7823Smrg tagname=$z 2688a96d7823Smrg break 2689a96d7823Smrg ;; 2690a96d7823Smrg esac 2691a96d7823Smrg fi 2692a96d7823Smrg done 2693a96d7823Smrg # If $tagname still isn't set, then no tagged configuration 2694a96d7823Smrg # was found and let the user know that the "--tag" command 2695a96d7823Smrg # line option must be used. 2696a96d7823Smrg if test -z "$tagname"; then 2697a96d7823Smrg func_echo "unable to infer tagged configuration" 2698fd60135fSmrg func_fatal_error "specify a tag with '--tag'" 2699a96d7823Smrg# else 2700a96d7823Smrg# func_verbose "using $tagname tagged configuration" 2701a96d7823Smrg fi 2702a96d7823Smrg ;; 2703a96d7823Smrg esac 2704a96d7823Smrg fi 2705a96d7823Smrg} 2706a96d7823Smrg 2707a96d7823Smrg 2708a96d7823Smrg 2709a96d7823Smrg# func_write_libtool_object output_name pic_name nonpic_name 2710a96d7823Smrg# Create a libtool object file (analogous to a ".la" file), 2711a96d7823Smrg# but don't create it if we're doing a dry run. 2712a96d7823Smrgfunc_write_libtool_object () 2713a96d7823Smrg{ 2714fd60135fSmrg write_libobj=$1 2715fd60135fSmrg if test yes = "$build_libtool_libs"; then 2716fd60135fSmrg write_lobj=\'$2\' 2717a96d7823Smrg else 2718a96d7823Smrg write_lobj=none 2719a96d7823Smrg fi 2720a96d7823Smrg 2721fd60135fSmrg if test yes = "$build_old_libs"; then 2722fd60135fSmrg write_oldobj=\'$3\' 2723a96d7823Smrg else 2724a96d7823Smrg write_oldobj=none 2725a96d7823Smrg fi 2726a96d7823Smrg 2727a96d7823Smrg $opt_dry_run || { 2728a96d7823Smrg cat >${write_libobj}T <<EOF 2729a96d7823Smrg# $write_libobj - a libtool object file 2730fd60135fSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2731a96d7823Smrg# 2732a96d7823Smrg# Please DO NOT delete this file! 2733a96d7823Smrg# It is necessary for linking the library. 2734a96d7823Smrg 2735a96d7823Smrg# Name of the PIC object. 2736a96d7823Smrgpic_object=$write_lobj 2737a96d7823Smrg 2738a96d7823Smrg# Name of the non-PIC object 2739a96d7823Smrgnon_pic_object=$write_oldobj 2740a96d7823Smrg 2741a96d7823SmrgEOF 2742fd60135fSmrg $MV "${write_libobj}T" "$write_libobj" 2743a96d7823Smrg } 2744a96d7823Smrg} 2745a96d7823Smrg 2746a96d7823Smrg 2747a96d7823Smrg################################################## 2748a96d7823Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2749a96d7823Smrg################################################## 2750a96d7823Smrg 2751a96d7823Smrg# func_convert_core_file_wine_to_w32 ARG 2752a96d7823Smrg# Helper function used by file name conversion functions when $build is *nix, 2753a96d7823Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2754a96d7823Smrg# correctly configured wine environment available, with the winepath program 2755a96d7823Smrg# in $build's $PATH. 2756a96d7823Smrg# 2757a96d7823Smrg# ARG is the $build file name to be converted to w32 format. 2758a96d7823Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 2759a96d7823Smrg# be empty on error (or when ARG is empty) 2760a96d7823Smrgfunc_convert_core_file_wine_to_w32 () 2761a96d7823Smrg{ 2762fd60135fSmrg $debug_cmd 2763fd60135fSmrg 2764fd60135fSmrg func_convert_core_file_wine_to_w32_result=$1 2765a96d7823Smrg if test -n "$1"; then 2766a96d7823Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 2767a96d7823Smrg # are forced to check the contents of stdout. On the other hand, if the 2768a96d7823Smrg # command is not found, the shell will set an exit code of 127 and print 2769a96d7823Smrg # *an error message* to stdout. So we must check for both error code of 2770a96d7823Smrg # zero AND non-empty stdout, which explains the odd construction: 2771a96d7823Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 2772fd60135fSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 2773a96d7823Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 2774fd60135fSmrg $SED -e "$sed_naive_backslashify"` 2775a96d7823Smrg else 2776a96d7823Smrg func_convert_core_file_wine_to_w32_result= 2777a96d7823Smrg fi 2778a96d7823Smrg fi 2779a96d7823Smrg} 2780a96d7823Smrg# end: func_convert_core_file_wine_to_w32 2781a96d7823Smrg 2782a96d7823Smrg 2783a96d7823Smrg# func_convert_core_path_wine_to_w32 ARG 2784a96d7823Smrg# Helper function used by path conversion functions when $build is *nix, and 2785a96d7823Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 2786a96d7823Smrg# configured wine environment available, with the winepath program in $build's 2787a96d7823Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 2788a96d7823Smrg# 2789a96d7823Smrg# ARG is path to be converted from $build format to win32. 2790a96d7823Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 2791a96d7823Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 2792a96d7823Smrg# are convertible, then the result may be empty. 2793a96d7823Smrgfunc_convert_core_path_wine_to_w32 () 2794a96d7823Smrg{ 2795fd60135fSmrg $debug_cmd 2796fd60135fSmrg 2797a96d7823Smrg # unfortunately, winepath doesn't convert paths, only file names 2798fd60135fSmrg func_convert_core_path_wine_to_w32_result= 2799a96d7823Smrg if test -n "$1"; then 2800a96d7823Smrg oldIFS=$IFS 2801a96d7823Smrg IFS=: 2802a96d7823Smrg for func_convert_core_path_wine_to_w32_f in $1; do 2803a96d7823Smrg IFS=$oldIFS 2804a96d7823Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 2805fd60135fSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 2806a96d7823Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 2807fd60135fSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 2808a96d7823Smrg else 2809a96d7823Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 2810a96d7823Smrg fi 2811a96d7823Smrg fi 2812a96d7823Smrg done 2813a96d7823Smrg IFS=$oldIFS 2814a96d7823Smrg fi 2815a96d7823Smrg} 2816a96d7823Smrg# end: func_convert_core_path_wine_to_w32 2817a96d7823Smrg 2818a96d7823Smrg 2819a96d7823Smrg# func_cygpath ARGS... 2820a96d7823Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 2821a96d7823Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 2822a96d7823Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 2823a96d7823Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 2824a96d7823Smrg# file name or path is assumed to be in w32 format, as previously converted 2825a96d7823Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 2826a96d7823Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 2827a96d7823Smrg# Cygwin format). Returns an empty string on error. 2828a96d7823Smrg# 2829a96d7823Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 2830a96d7823Smrg# be converted. 2831a96d7823Smrg# 2832a96d7823Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 2833a96d7823Smrg# environment variable; do not put it in $PATH. 2834a96d7823Smrgfunc_cygpath () 2835a96d7823Smrg{ 2836fd60135fSmrg $debug_cmd 2837fd60135fSmrg 2838a96d7823Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 2839a96d7823Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 2840a96d7823Smrg if test "$?" -ne 0; then 2841a96d7823Smrg # on failure, ensure result is empty 2842a96d7823Smrg func_cygpath_result= 2843a96d7823Smrg fi 2844a96d7823Smrg else 2845a96d7823Smrg func_cygpath_result= 2846fd60135fSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 2847a96d7823Smrg fi 2848a96d7823Smrg} 2849a96d7823Smrg#end: func_cygpath 2850a96d7823Smrg 2851a96d7823Smrg 2852a96d7823Smrg# func_convert_core_msys_to_w32 ARG 2853a96d7823Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 2854a96d7823Smrg# result in func_convert_core_msys_to_w32_result. 2855a96d7823Smrgfunc_convert_core_msys_to_w32 () 2856a96d7823Smrg{ 2857fd60135fSmrg $debug_cmd 2858fd60135fSmrg 2859a96d7823Smrg # awkward: cmd appends spaces to result 2860a96d7823Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 2861fd60135fSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 2862a96d7823Smrg} 2863a96d7823Smrg#end: func_convert_core_msys_to_w32 2864a96d7823Smrg 2865a96d7823Smrg 2866a96d7823Smrg# func_convert_file_check ARG1 ARG2 2867a96d7823Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 2868a96d7823Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 2869a96d7823Smrg# func_to_host_file_result to ARG1). 2870a96d7823Smrgfunc_convert_file_check () 2871a96d7823Smrg{ 2872fd60135fSmrg $debug_cmd 2873fd60135fSmrg 2874fd60135fSmrg if test -z "$2" && test -n "$1"; then 2875a96d7823Smrg func_error "Could not determine host file name corresponding to" 2876fd60135fSmrg func_error " '$1'" 2877a96d7823Smrg func_error "Continuing, but uninstalled executables may not work." 2878a96d7823Smrg # Fallback: 2879fd60135fSmrg func_to_host_file_result=$1 2880a96d7823Smrg fi 2881a96d7823Smrg} 2882a96d7823Smrg# end func_convert_file_check 2883a96d7823Smrg 2884a96d7823Smrg 2885a96d7823Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 2886a96d7823Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 2887a96d7823Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 2888a96d7823Smrg# func_to_host_file_result to a simplistic fallback value (see below). 2889a96d7823Smrgfunc_convert_path_check () 2890a96d7823Smrg{ 2891fd60135fSmrg $debug_cmd 2892fd60135fSmrg 2893a96d7823Smrg if test -z "$4" && test -n "$3"; then 2894a96d7823Smrg func_error "Could not determine the host path corresponding to" 2895fd60135fSmrg func_error " '$3'" 2896a96d7823Smrg func_error "Continuing, but uninstalled executables may not work." 2897a96d7823Smrg # Fallback. This is a deliberately simplistic "conversion" and 2898a96d7823Smrg # should not be "improved". See libtool.info. 2899a96d7823Smrg if test "x$1" != "x$2"; then 2900a96d7823Smrg lt_replace_pathsep_chars="s|$1|$2|g" 2901a96d7823Smrg func_to_host_path_result=`echo "$3" | 2902a96d7823Smrg $SED -e "$lt_replace_pathsep_chars"` 2903a96d7823Smrg else 2904fd60135fSmrg func_to_host_path_result=$3 2905a96d7823Smrg fi 2906a96d7823Smrg fi 2907a96d7823Smrg} 2908a96d7823Smrg# end func_convert_path_check 2909a96d7823Smrg 2910a96d7823Smrg 2911a96d7823Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 2912a96d7823Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 2913a96d7823Smrg# and appending REPL if ORIG matches BACKPAT. 2914a96d7823Smrgfunc_convert_path_front_back_pathsep () 2915a96d7823Smrg{ 2916fd60135fSmrg $debug_cmd 2917fd60135fSmrg 2918a96d7823Smrg case $4 in 2919fd60135fSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 2920a96d7823Smrg ;; 2921a96d7823Smrg esac 2922a96d7823Smrg case $4 in 2923a96d7823Smrg $2 ) func_append func_to_host_path_result "$3" 2924a96d7823Smrg ;; 2925a96d7823Smrg esac 2926a96d7823Smrg} 2927a96d7823Smrg# end func_convert_path_front_back_pathsep 2928a96d7823Smrg 2929a96d7823Smrg 2930a96d7823Smrg################################################## 2931a96d7823Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 2932a96d7823Smrg################################################## 2933fd60135fSmrg# invoked via '$to_host_file_cmd ARG' 2934a96d7823Smrg# 2935a96d7823Smrg# In each case, ARG is the path to be converted from $build to $host format. 2936a96d7823Smrg# Result will be available in $func_to_host_file_result. 2937a96d7823Smrg 2938a96d7823Smrg 2939a96d7823Smrg# func_to_host_file ARG 2940a96d7823Smrg# Converts the file name ARG from $build format to $host format. Return result 2941a96d7823Smrg# in func_to_host_file_result. 2942a96d7823Smrgfunc_to_host_file () 2943a96d7823Smrg{ 2944fd60135fSmrg $debug_cmd 2945fd60135fSmrg 2946a96d7823Smrg $to_host_file_cmd "$1" 2947a96d7823Smrg} 2948a96d7823Smrg# end func_to_host_file 2949a96d7823Smrg 2950a96d7823Smrg 2951a96d7823Smrg# func_to_tool_file ARG LAZY 2952a96d7823Smrg# converts the file name ARG from $build format to toolchain format. Return 2953a96d7823Smrg# result in func_to_tool_file_result. If the conversion in use is listed 2954a96d7823Smrg# in (the comma separated) LAZY, no conversion takes place. 2955a96d7823Smrgfunc_to_tool_file () 2956a96d7823Smrg{ 2957fd60135fSmrg $debug_cmd 2958fd60135fSmrg 2959a96d7823Smrg case ,$2, in 2960a96d7823Smrg *,"$to_tool_file_cmd",*) 2961a96d7823Smrg func_to_tool_file_result=$1 2962a96d7823Smrg ;; 2963a96d7823Smrg *) 2964a96d7823Smrg $to_tool_file_cmd "$1" 2965a96d7823Smrg func_to_tool_file_result=$func_to_host_file_result 2966a96d7823Smrg ;; 2967a96d7823Smrg esac 2968a96d7823Smrg} 2969a96d7823Smrg# end func_to_tool_file 2970a96d7823Smrg 2971a96d7823Smrg 2972a96d7823Smrg# func_convert_file_noop ARG 2973a96d7823Smrg# Copy ARG to func_to_host_file_result. 2974a96d7823Smrgfunc_convert_file_noop () 2975a96d7823Smrg{ 2976fd60135fSmrg func_to_host_file_result=$1 2977a96d7823Smrg} 2978a96d7823Smrg# end func_convert_file_noop 2979a96d7823Smrg 2980a96d7823Smrg 2981a96d7823Smrg# func_convert_file_msys_to_w32 ARG 2982a96d7823Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 2983a96d7823Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 2984a96d7823Smrg# func_to_host_file_result. 2985a96d7823Smrgfunc_convert_file_msys_to_w32 () 2986a96d7823Smrg{ 2987fd60135fSmrg $debug_cmd 2988fd60135fSmrg 2989fd60135fSmrg func_to_host_file_result=$1 2990a96d7823Smrg if test -n "$1"; then 2991a96d7823Smrg func_convert_core_msys_to_w32 "$1" 2992fd60135fSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 2993a96d7823Smrg fi 2994a96d7823Smrg func_convert_file_check "$1" "$func_to_host_file_result" 2995a96d7823Smrg} 2996a96d7823Smrg# end func_convert_file_msys_to_w32 2997a96d7823Smrg 2998a96d7823Smrg 2999a96d7823Smrg# func_convert_file_cygwin_to_w32 ARG 3000a96d7823Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3001a96d7823Smrg# func_to_host_file_result. 3002a96d7823Smrgfunc_convert_file_cygwin_to_w32 () 3003a96d7823Smrg{ 3004fd60135fSmrg $debug_cmd 3005fd60135fSmrg 3006fd60135fSmrg func_to_host_file_result=$1 3007a96d7823Smrg if test -n "$1"; then 3008a96d7823Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3009a96d7823Smrg # LT_CYGPATH in this case. 3010a96d7823Smrg func_to_host_file_result=`cygpath -m "$1"` 3011a96d7823Smrg fi 3012a96d7823Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3013a96d7823Smrg} 3014a96d7823Smrg# end func_convert_file_cygwin_to_w32 3015a96d7823Smrg 3016a96d7823Smrg 3017a96d7823Smrg# func_convert_file_nix_to_w32 ARG 3018a96d7823Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3019a96d7823Smrg# and a working winepath. Returns result in func_to_host_file_result. 3020a96d7823Smrgfunc_convert_file_nix_to_w32 () 3021a96d7823Smrg{ 3022fd60135fSmrg $debug_cmd 3023fd60135fSmrg 3024fd60135fSmrg func_to_host_file_result=$1 3025a96d7823Smrg if test -n "$1"; then 3026a96d7823Smrg func_convert_core_file_wine_to_w32 "$1" 3027fd60135fSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3028a96d7823Smrg fi 3029a96d7823Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3030a96d7823Smrg} 3031a96d7823Smrg# end func_convert_file_nix_to_w32 3032a96d7823Smrg 3033a96d7823Smrg 3034a96d7823Smrg# func_convert_file_msys_to_cygwin ARG 3035a96d7823Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3036a96d7823Smrg# Returns result in func_to_host_file_result. 3037a96d7823Smrgfunc_convert_file_msys_to_cygwin () 3038a96d7823Smrg{ 3039fd60135fSmrg $debug_cmd 3040fd60135fSmrg 3041fd60135fSmrg func_to_host_file_result=$1 3042a96d7823Smrg if test -n "$1"; then 3043a96d7823Smrg func_convert_core_msys_to_w32 "$1" 3044a96d7823Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3045fd60135fSmrg func_to_host_file_result=$func_cygpath_result 3046a96d7823Smrg fi 3047a96d7823Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3048a96d7823Smrg} 3049a96d7823Smrg# end func_convert_file_msys_to_cygwin 3050a96d7823Smrg 3051a96d7823Smrg 3052a96d7823Smrg# func_convert_file_nix_to_cygwin ARG 3053a96d7823Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3054a96d7823Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3055a96d7823Smrg# in func_to_host_file_result. 3056a96d7823Smrgfunc_convert_file_nix_to_cygwin () 3057a96d7823Smrg{ 3058fd60135fSmrg $debug_cmd 3059fd60135fSmrg 3060fd60135fSmrg func_to_host_file_result=$1 3061a96d7823Smrg if test -n "$1"; then 3062a96d7823Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3063a96d7823Smrg func_convert_core_file_wine_to_w32 "$1" 3064a96d7823Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3065fd60135fSmrg func_to_host_file_result=$func_cygpath_result 3066a96d7823Smrg fi 3067a96d7823Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3068a96d7823Smrg} 3069a96d7823Smrg# end func_convert_file_nix_to_cygwin 3070a96d7823Smrg 3071a96d7823Smrg 3072a96d7823Smrg############################################# 3073a96d7823Smrg# $build to $host PATH CONVERSION FUNCTIONS # 3074a96d7823Smrg############################################# 3075fd60135fSmrg# invoked via '$to_host_path_cmd ARG' 3076a96d7823Smrg# 3077a96d7823Smrg# In each case, ARG is the path to be converted from $build to $host format. 3078a96d7823Smrg# The result will be available in $func_to_host_path_result. 3079a96d7823Smrg# 3080a96d7823Smrg# Path separators are also converted from $build format to $host format. If 3081a96d7823Smrg# ARG begins or ends with a path separator character, it is preserved (but 3082a96d7823Smrg# converted to $host format) on output. 3083a96d7823Smrg# 3084a96d7823Smrg# All path conversion functions are named using the following convention: 3085a96d7823Smrg# file name conversion function : func_convert_file_X_to_Y () 3086a96d7823Smrg# path conversion function : func_convert_path_X_to_Y () 3087a96d7823Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3088a96d7823Smrg# same. If conversion functions are added for new $build/$host combinations, 3089a96d7823Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3090a96d7823Smrg# will break. 3091a96d7823Smrg 3092a96d7823Smrg 3093a96d7823Smrg# func_init_to_host_path_cmd 3094a96d7823Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3095a96d7823Smrg# appropriate value, based on the value of $to_host_file_cmd. 3096a96d7823Smrgto_host_path_cmd= 3097a96d7823Smrgfunc_init_to_host_path_cmd () 3098a96d7823Smrg{ 3099fd60135fSmrg $debug_cmd 3100fd60135fSmrg 3101a96d7823Smrg if test -z "$to_host_path_cmd"; then 3102a96d7823Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3103fd60135fSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 3104a96d7823Smrg fi 3105a96d7823Smrg} 3106a96d7823Smrg 3107a96d7823Smrg 3108a96d7823Smrg# func_to_host_path ARG 3109a96d7823Smrg# Converts the path ARG from $build format to $host format. Return result 3110a96d7823Smrg# in func_to_host_path_result. 3111a96d7823Smrgfunc_to_host_path () 3112a96d7823Smrg{ 3113fd60135fSmrg $debug_cmd 3114fd60135fSmrg 3115a96d7823Smrg func_init_to_host_path_cmd 3116a96d7823Smrg $to_host_path_cmd "$1" 3117a96d7823Smrg} 3118a96d7823Smrg# end func_to_host_path 3119a96d7823Smrg 3120a96d7823Smrg 3121a96d7823Smrg# func_convert_path_noop ARG 3122a96d7823Smrg# Copy ARG to func_to_host_path_result. 3123a96d7823Smrgfunc_convert_path_noop () 3124a96d7823Smrg{ 3125fd60135fSmrg func_to_host_path_result=$1 3126a96d7823Smrg} 3127a96d7823Smrg# end func_convert_path_noop 3128a96d7823Smrg 3129a96d7823Smrg 3130a96d7823Smrg# func_convert_path_msys_to_w32 ARG 3131a96d7823Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3132a96d7823Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3133a96d7823Smrg# func_to_host_path_result. 3134a96d7823Smrgfunc_convert_path_msys_to_w32 () 3135a96d7823Smrg{ 3136fd60135fSmrg $debug_cmd 3137fd60135fSmrg 3138fd60135fSmrg func_to_host_path_result=$1 3139a96d7823Smrg if test -n "$1"; then 3140a96d7823Smrg # Remove leading and trailing path separator characters from ARG. MSYS 3141a96d7823Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3142a96d7823Smrg # and winepath ignores them completely. 3143a96d7823Smrg func_stripname : : "$1" 3144a96d7823Smrg func_to_host_path_tmp1=$func_stripname_result 3145a96d7823Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3146fd60135fSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3147a96d7823Smrg func_convert_path_check : ";" \ 3148a96d7823Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3149a96d7823Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3150a96d7823Smrg fi 3151a96d7823Smrg} 3152a96d7823Smrg# end func_convert_path_msys_to_w32 3153a96d7823Smrg 3154a96d7823Smrg 3155a96d7823Smrg# func_convert_path_cygwin_to_w32 ARG 3156a96d7823Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 3157a96d7823Smrg# func_to_host_file_result. 3158a96d7823Smrgfunc_convert_path_cygwin_to_w32 () 3159a96d7823Smrg{ 3160fd60135fSmrg $debug_cmd 3161fd60135fSmrg 3162fd60135fSmrg func_to_host_path_result=$1 3163a96d7823Smrg if test -n "$1"; then 3164a96d7823Smrg # See func_convert_path_msys_to_w32: 3165a96d7823Smrg func_stripname : : "$1" 3166a96d7823Smrg func_to_host_path_tmp1=$func_stripname_result 3167a96d7823Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3168a96d7823Smrg func_convert_path_check : ";" \ 3169a96d7823Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3170a96d7823Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3171a96d7823Smrg fi 3172a96d7823Smrg} 3173a96d7823Smrg# end func_convert_path_cygwin_to_w32 3174a96d7823Smrg 3175a96d7823Smrg 3176a96d7823Smrg# func_convert_path_nix_to_w32 ARG 3177a96d7823Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3178a96d7823Smrg# a working winepath. Returns result in func_to_host_file_result. 3179a96d7823Smrgfunc_convert_path_nix_to_w32 () 3180a96d7823Smrg{ 3181fd60135fSmrg $debug_cmd 3182fd60135fSmrg 3183fd60135fSmrg func_to_host_path_result=$1 3184a96d7823Smrg if test -n "$1"; then 3185a96d7823Smrg # See func_convert_path_msys_to_w32: 3186a96d7823Smrg func_stripname : : "$1" 3187a96d7823Smrg func_to_host_path_tmp1=$func_stripname_result 3188a96d7823Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3189fd60135fSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3190a96d7823Smrg func_convert_path_check : ";" \ 3191a96d7823Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3192a96d7823Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3193a96d7823Smrg fi 3194a96d7823Smrg} 3195a96d7823Smrg# end func_convert_path_nix_to_w32 3196a96d7823Smrg 3197a96d7823Smrg 3198a96d7823Smrg# func_convert_path_msys_to_cygwin ARG 3199a96d7823Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3200a96d7823Smrg# Returns result in func_to_host_file_result. 3201a96d7823Smrgfunc_convert_path_msys_to_cygwin () 3202a96d7823Smrg{ 3203fd60135fSmrg $debug_cmd 3204fd60135fSmrg 3205fd60135fSmrg func_to_host_path_result=$1 3206a96d7823Smrg if test -n "$1"; then 3207a96d7823Smrg # See func_convert_path_msys_to_w32: 3208a96d7823Smrg func_stripname : : "$1" 3209a96d7823Smrg func_to_host_path_tmp1=$func_stripname_result 3210a96d7823Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3211a96d7823Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3212fd60135fSmrg func_to_host_path_result=$func_cygpath_result 3213a96d7823Smrg func_convert_path_check : : \ 3214a96d7823Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3215a96d7823Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3216a96d7823Smrg fi 3217a96d7823Smrg} 3218a96d7823Smrg# end func_convert_path_msys_to_cygwin 3219a96d7823Smrg 3220a96d7823Smrg 3221a96d7823Smrg# func_convert_path_nix_to_cygwin ARG 3222a96d7823Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3223a96d7823Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3224a96d7823Smrg# func_to_host_file_result. 3225a96d7823Smrgfunc_convert_path_nix_to_cygwin () 3226a96d7823Smrg{ 3227fd60135fSmrg $debug_cmd 3228fd60135fSmrg 3229fd60135fSmrg func_to_host_path_result=$1 3230a96d7823Smrg if test -n "$1"; then 3231a96d7823Smrg # Remove leading and trailing path separator characters from 3232a96d7823Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 3233a96d7823Smrg # into '.;' and ';.', and winepath ignores them completely. 3234a96d7823Smrg func_stripname : : "$1" 3235a96d7823Smrg func_to_host_path_tmp1=$func_stripname_result 3236a96d7823Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3237a96d7823Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3238fd60135fSmrg func_to_host_path_result=$func_cygpath_result 3239a96d7823Smrg func_convert_path_check : : \ 3240a96d7823Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3241a96d7823Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3242a96d7823Smrg fi 3243a96d7823Smrg} 3244a96d7823Smrg# end func_convert_path_nix_to_cygwin 3245a96d7823Smrg 3246a96d7823Smrg 3247fd60135fSmrg# func_dll_def_p FILE 3248fd60135fSmrg# True iff FILE is a Windows DLL '.def' file. 3249fd60135fSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3250fd60135fSmrgfunc_dll_def_p () 3251fd60135fSmrg{ 3252fd60135fSmrg $debug_cmd 3253fd60135fSmrg 3254fd60135fSmrg func_dll_def_p_tmp=`$SED -n \ 3255fd60135fSmrg -e 's/^[ ]*//' \ 3256fd60135fSmrg -e '/^\(;.*\)*$/d' \ 3257fd60135fSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3258fd60135fSmrg -e q \ 3259fd60135fSmrg "$1"` 3260fd60135fSmrg test DEF = "$func_dll_def_p_tmp" 3261fd60135fSmrg} 3262fd60135fSmrg 3263fd60135fSmrg 3264a96d7823Smrg# func_mode_compile arg... 3265a96d7823Smrgfunc_mode_compile () 3266a96d7823Smrg{ 3267fd60135fSmrg $debug_cmd 3268fd60135fSmrg 3269a96d7823Smrg # Get the compilation command and the source file. 3270a96d7823Smrg base_compile= 3271fd60135fSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3272a96d7823Smrg suppress_opt=yes 3273a96d7823Smrg suppress_output= 3274a96d7823Smrg arg_mode=normal 3275a96d7823Smrg libobj= 3276a96d7823Smrg later= 3277a96d7823Smrg pie_flag= 3278a96d7823Smrg 3279a96d7823Smrg for arg 3280a96d7823Smrg do 3281a96d7823Smrg case $arg_mode in 3282a96d7823Smrg arg ) 3283a96d7823Smrg # do not "continue". Instead, add this to base_compile 3284fd60135fSmrg lastarg=$arg 3285a96d7823Smrg arg_mode=normal 3286a96d7823Smrg ;; 3287a96d7823Smrg 3288a96d7823Smrg target ) 3289fd60135fSmrg libobj=$arg 3290a96d7823Smrg arg_mode=normal 3291a96d7823Smrg continue 3292a96d7823Smrg ;; 3293a96d7823Smrg 3294a96d7823Smrg normal ) 3295a96d7823Smrg # Accept any command-line options. 3296a96d7823Smrg case $arg in 3297a96d7823Smrg -o) 3298a96d7823Smrg test -n "$libobj" && \ 3299fd60135fSmrg func_fatal_error "you cannot specify '-o' more than once" 3300a96d7823Smrg arg_mode=target 3301a96d7823Smrg continue 3302a96d7823Smrg ;; 3303a96d7823Smrg 3304a96d7823Smrg -pie | -fpie | -fPIE) 3305a96d7823Smrg func_append pie_flag " $arg" 3306a96d7823Smrg continue 3307a96d7823Smrg ;; 3308a96d7823Smrg 3309a96d7823Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 3310a96d7823Smrg func_append later " $arg" 3311a96d7823Smrg continue 3312a96d7823Smrg ;; 3313a96d7823Smrg 3314a96d7823Smrg -no-suppress) 3315a96d7823Smrg suppress_opt=no 3316a96d7823Smrg continue 3317a96d7823Smrg ;; 3318a96d7823Smrg 3319a96d7823Smrg -Xcompiler) 3320a96d7823Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 3321a96d7823Smrg continue # The current "srcfile" will either be retained or 3322a96d7823Smrg ;; # replaced later. I would guess that would be a bug. 3323a96d7823Smrg 3324a96d7823Smrg -Wc,*) 3325a96d7823Smrg func_stripname '-Wc,' '' "$arg" 3326a96d7823Smrg args=$func_stripname_result 3327a96d7823Smrg lastarg= 3328fd60135fSmrg save_ifs=$IFS; IFS=, 3329a96d7823Smrg for arg in $args; do 3330fd60135fSmrg IFS=$save_ifs 3331a96d7823Smrg func_append_quoted lastarg "$arg" 3332a96d7823Smrg done 3333fd60135fSmrg IFS=$save_ifs 3334a96d7823Smrg func_stripname ' ' '' "$lastarg" 3335a96d7823Smrg lastarg=$func_stripname_result 3336a96d7823Smrg 3337a96d7823Smrg # Add the arguments to base_compile. 3338a96d7823Smrg func_append base_compile " $lastarg" 3339a96d7823Smrg continue 3340a96d7823Smrg ;; 3341a96d7823Smrg 3342a96d7823Smrg *) 3343a96d7823Smrg # Accept the current argument as the source file. 3344a96d7823Smrg # The previous "srcfile" becomes the current argument. 3345a96d7823Smrg # 3346fd60135fSmrg lastarg=$srcfile 3347fd60135fSmrg srcfile=$arg 3348a96d7823Smrg ;; 3349a96d7823Smrg esac # case $arg 3350a96d7823Smrg ;; 3351a96d7823Smrg esac # case $arg_mode 3352a96d7823Smrg 3353a96d7823Smrg # Aesthetically quote the previous argument. 3354a96d7823Smrg func_append_quoted base_compile "$lastarg" 3355a96d7823Smrg done # for arg 3356a96d7823Smrg 3357a96d7823Smrg case $arg_mode in 3358a96d7823Smrg arg) 3359a96d7823Smrg func_fatal_error "you must specify an argument for -Xcompile" 3360a96d7823Smrg ;; 3361a96d7823Smrg target) 3362fd60135fSmrg func_fatal_error "you must specify a target with '-o'" 3363a96d7823Smrg ;; 3364a96d7823Smrg *) 3365a96d7823Smrg # Get the name of the library object. 3366a96d7823Smrg test -z "$libobj" && { 3367a96d7823Smrg func_basename "$srcfile" 3368fd60135fSmrg libobj=$func_basename_result 3369a96d7823Smrg } 3370a96d7823Smrg ;; 3371a96d7823Smrg esac 3372a96d7823Smrg 3373a96d7823Smrg # Recognize several different file suffixes. 3374a96d7823Smrg # If the user specifies -o file.o, it is replaced with file.lo 3375a96d7823Smrg case $libobj in 3376a96d7823Smrg *.[cCFSifmso] | \ 3377a96d7823Smrg *.ada | *.adb | *.ads | *.asm | \ 3378a96d7823Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3379a96d7823Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3380a96d7823Smrg func_xform "$libobj" 3381a96d7823Smrg libobj=$func_xform_result 3382a96d7823Smrg ;; 3383a96d7823Smrg esac 3384a96d7823Smrg 3385a96d7823Smrg case $libobj in 3386a96d7823Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3387a96d7823Smrg *) 3388fd60135fSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 3389a96d7823Smrg ;; 3390a96d7823Smrg esac 3391a96d7823Smrg 3392a96d7823Smrg func_infer_tag $base_compile 3393a96d7823Smrg 3394a96d7823Smrg for arg in $later; do 3395a96d7823Smrg case $arg in 3396a96d7823Smrg -shared) 3397fd60135fSmrg test yes = "$build_libtool_libs" \ 3398fd60135fSmrg || func_fatal_configuration "cannot build a shared library" 3399a96d7823Smrg build_old_libs=no 3400a96d7823Smrg continue 3401a96d7823Smrg ;; 3402a96d7823Smrg 3403a96d7823Smrg -static) 3404a96d7823Smrg build_libtool_libs=no 3405a96d7823Smrg build_old_libs=yes 3406a96d7823Smrg continue 3407a96d7823Smrg ;; 3408a96d7823Smrg 3409a96d7823Smrg -prefer-pic) 3410a96d7823Smrg pic_mode=yes 3411a96d7823Smrg continue 3412a96d7823Smrg ;; 3413a96d7823Smrg 3414a96d7823Smrg -prefer-non-pic) 3415a96d7823Smrg pic_mode=no 3416a96d7823Smrg continue 3417a96d7823Smrg ;; 3418a96d7823Smrg esac 3419a96d7823Smrg done 3420a96d7823Smrg 3421a96d7823Smrg func_quote_for_eval "$libobj" 3422a96d7823Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 3423a96d7823Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3424fd60135fSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3425a96d7823Smrg func_dirname_and_basename "$obj" "/" "" 3426fd60135fSmrg objname=$func_basename_result 3427fd60135fSmrg xdir=$func_dirname_result 3428fd60135fSmrg lobj=$xdir$objdir/$objname 3429a96d7823Smrg 3430a96d7823Smrg test -z "$base_compile" && \ 3431a96d7823Smrg func_fatal_help "you must specify a compilation command" 3432a96d7823Smrg 3433a96d7823Smrg # Delete any leftover library objects. 3434fd60135fSmrg if test yes = "$build_old_libs"; then 3435a96d7823Smrg removelist="$obj $lobj $libobj ${libobj}T" 3436a96d7823Smrg else 3437a96d7823Smrg removelist="$lobj $libobj ${libobj}T" 3438a96d7823Smrg fi 3439a96d7823Smrg 3440a96d7823Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 3441a96d7823Smrg case $host_os in 3442a96d7823Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3443a96d7823Smrg pic_mode=default 3444a96d7823Smrg ;; 3445a96d7823Smrg esac 3446fd60135fSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3447a96d7823Smrg # non-PIC code in shared libraries is not supported 3448a96d7823Smrg pic_mode=default 3449a96d7823Smrg fi 3450a96d7823Smrg 3451a96d7823Smrg # Calculate the filename of the output object if compiler does 3452a96d7823Smrg # not support -o with -c 3453fd60135fSmrg if test no = "$compiler_c_o"; then 3454fd60135fSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3455fd60135fSmrg lockfile=$output_obj.lock 3456a96d7823Smrg else 3457a96d7823Smrg output_obj= 3458a96d7823Smrg need_locks=no 3459a96d7823Smrg lockfile= 3460a96d7823Smrg fi 3461a96d7823Smrg 3462a96d7823Smrg # Lock this critical section if it is needed 3463a96d7823Smrg # We use this script file to make the link, it avoids creating a new file 3464fd60135fSmrg if test yes = "$need_locks"; then 3465a96d7823Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3466a96d7823Smrg func_echo "Waiting for $lockfile to be removed" 3467a96d7823Smrg sleep 2 3468a96d7823Smrg done 3469fd60135fSmrg elif test warn = "$need_locks"; then 3470a96d7823Smrg if test -f "$lockfile"; then 3471a96d7823Smrg $ECHO "\ 3472a96d7823Smrg*** ERROR, $lockfile exists and contains: 3473a96d7823Smrg`cat $lockfile 2>/dev/null` 3474a96d7823Smrg 3475a96d7823SmrgThis indicates that another process is trying to use the same 3476a96d7823Smrgtemporary object file, and libtool could not work around it because 3477fd60135fSmrgyour compiler does not support '-c' and '-o' together. If you 3478a96d7823Smrgrepeat this compilation, it may succeed, by chance, but you had better 3479a96d7823Smrgavoid parallel builds (make -j) in this platform, or get a better 3480a96d7823Smrgcompiler." 3481a96d7823Smrg 3482a96d7823Smrg $opt_dry_run || $RM $removelist 3483a96d7823Smrg exit $EXIT_FAILURE 3484a96d7823Smrg fi 3485a96d7823Smrg func_append removelist " $output_obj" 3486a96d7823Smrg $ECHO "$srcfile" > "$lockfile" 3487a96d7823Smrg fi 3488a96d7823Smrg 3489a96d7823Smrg $opt_dry_run || $RM $removelist 3490a96d7823Smrg func_append removelist " $lockfile" 3491a96d7823Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3492a96d7823Smrg 3493a96d7823Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3494a96d7823Smrg srcfile=$func_to_tool_file_result 3495a96d7823Smrg func_quote_for_eval "$srcfile" 3496a96d7823Smrg qsrcfile=$func_quote_for_eval_result 3497a96d7823Smrg 3498a96d7823Smrg # Only build a PIC object if we are building libtool libraries. 3499fd60135fSmrg if test yes = "$build_libtool_libs"; then 3500a96d7823Smrg # Without this assignment, base_compile gets emptied. 3501a96d7823Smrg fbsd_hideous_sh_bug=$base_compile 3502a96d7823Smrg 3503fd60135fSmrg if test no != "$pic_mode"; then 3504a96d7823Smrg command="$base_compile $qsrcfile $pic_flag" 3505a96d7823Smrg else 3506a96d7823Smrg # Don't build PIC code 3507a96d7823Smrg command="$base_compile $qsrcfile" 3508a96d7823Smrg fi 3509a96d7823Smrg 3510a96d7823Smrg func_mkdir_p "$xdir$objdir" 3511a96d7823Smrg 3512a96d7823Smrg if test -z "$output_obj"; then 3513a96d7823Smrg # Place PIC objects in $objdir 3514a96d7823Smrg func_append command " -o $lobj" 3515a96d7823Smrg fi 3516a96d7823Smrg 3517a96d7823Smrg func_show_eval_locale "$command" \ 3518a96d7823Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3519a96d7823Smrg 3520fd60135fSmrg if test warn = "$need_locks" && 3521a96d7823Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3522a96d7823Smrg $ECHO "\ 3523a96d7823Smrg*** ERROR, $lockfile contains: 3524a96d7823Smrg`cat $lockfile 2>/dev/null` 3525a96d7823Smrg 3526a96d7823Smrgbut it should contain: 3527a96d7823Smrg$srcfile 3528a96d7823Smrg 3529a96d7823SmrgThis indicates that another process is trying to use the same 3530a96d7823Smrgtemporary object file, and libtool could not work around it because 3531fd60135fSmrgyour compiler does not support '-c' and '-o' together. If you 3532a96d7823Smrgrepeat this compilation, it may succeed, by chance, but you had better 3533a96d7823Smrgavoid parallel builds (make -j) in this platform, or get a better 3534a96d7823Smrgcompiler." 3535a96d7823Smrg 3536a96d7823Smrg $opt_dry_run || $RM $removelist 3537a96d7823Smrg exit $EXIT_FAILURE 3538a96d7823Smrg fi 3539a96d7823Smrg 3540a96d7823Smrg # Just move the object if needed, then go on to compile the next one 3541a96d7823Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3542a96d7823Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3543a96d7823Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3544a96d7823Smrg fi 3545a96d7823Smrg 3546a96d7823Smrg # Allow error messages only from the first compilation. 3547fd60135fSmrg if test yes = "$suppress_opt"; then 3548a96d7823Smrg suppress_output=' >/dev/null 2>&1' 3549a96d7823Smrg fi 3550a96d7823Smrg fi 3551a96d7823Smrg 3552a96d7823Smrg # Only build a position-dependent object if we build old libraries. 3553fd60135fSmrg if test yes = "$build_old_libs"; then 3554fd60135fSmrg if test yes != "$pic_mode"; then 3555a96d7823Smrg # Don't build PIC code 3556a96d7823Smrg command="$base_compile $qsrcfile$pie_flag" 3557a96d7823Smrg else 3558a96d7823Smrg command="$base_compile $qsrcfile $pic_flag" 3559a96d7823Smrg fi 3560fd60135fSmrg if test yes = "$compiler_c_o"; then 3561a96d7823Smrg func_append command " -o $obj" 3562a96d7823Smrg fi 3563a96d7823Smrg 3564a96d7823Smrg # Suppress compiler output if we already did a PIC compilation. 3565a96d7823Smrg func_append command "$suppress_output" 3566a96d7823Smrg func_show_eval_locale "$command" \ 3567a96d7823Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3568a96d7823Smrg 3569fd60135fSmrg if test warn = "$need_locks" && 3570a96d7823Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3571a96d7823Smrg $ECHO "\ 3572a96d7823Smrg*** ERROR, $lockfile contains: 3573a96d7823Smrg`cat $lockfile 2>/dev/null` 3574a96d7823Smrg 3575a96d7823Smrgbut it should contain: 3576a96d7823Smrg$srcfile 3577a96d7823Smrg 3578a96d7823SmrgThis indicates that another process is trying to use the same 3579a96d7823Smrgtemporary object file, and libtool could not work around it because 3580fd60135fSmrgyour compiler does not support '-c' and '-o' together. If you 3581a96d7823Smrgrepeat this compilation, it may succeed, by chance, but you had better 3582a96d7823Smrgavoid parallel builds (make -j) in this platform, or get a better 3583a96d7823Smrgcompiler." 3584a96d7823Smrg 3585a96d7823Smrg $opt_dry_run || $RM $removelist 3586a96d7823Smrg exit $EXIT_FAILURE 3587a96d7823Smrg fi 3588a96d7823Smrg 3589a96d7823Smrg # Just move the object if needed 3590a96d7823Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3591a96d7823Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3592a96d7823Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3593a96d7823Smrg fi 3594a96d7823Smrg fi 3595a96d7823Smrg 3596a96d7823Smrg $opt_dry_run || { 3597a96d7823Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3598a96d7823Smrg 3599a96d7823Smrg # Unlock the critical section if it was locked 3600fd60135fSmrg if test no != "$need_locks"; then 3601a96d7823Smrg removelist=$lockfile 3602a96d7823Smrg $RM "$lockfile" 3603a96d7823Smrg fi 3604a96d7823Smrg } 3605a96d7823Smrg 3606a96d7823Smrg exit $EXIT_SUCCESS 3607a96d7823Smrg} 3608a96d7823Smrg 3609a96d7823Smrg$opt_help || { 3610fd60135fSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3611a96d7823Smrg} 3612a96d7823Smrg 3613a96d7823Smrgfunc_mode_help () 3614a96d7823Smrg{ 3615a96d7823Smrg # We need to display help for each of the modes. 3616a96d7823Smrg case $opt_mode in 3617a96d7823Smrg "") 3618a96d7823Smrg # Generic help is extracted from the usage comments 3619a96d7823Smrg # at the start of this file. 3620a96d7823Smrg func_help 3621a96d7823Smrg ;; 3622a96d7823Smrg 3623a96d7823Smrg clean) 3624a96d7823Smrg $ECHO \ 3625a96d7823Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3626a96d7823Smrg 3627a96d7823SmrgRemove files from the build directory. 3628a96d7823Smrg 3629a96d7823SmrgRM is the name of the program to use to delete files associated with each FILE 3630fd60135fSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3631a96d7823Smrgto RM. 3632a96d7823Smrg 3633a96d7823SmrgIf FILE is a libtool library, object or program, all the files associated 3634a96d7823Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3635a96d7823Smrg ;; 3636a96d7823Smrg 3637a96d7823Smrg compile) 3638a96d7823Smrg $ECHO \ 3639a96d7823Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3640a96d7823Smrg 3641a96d7823SmrgCompile a source file into a libtool library object. 3642a96d7823Smrg 3643a96d7823SmrgThis mode accepts the following additional options: 3644a96d7823Smrg 3645a96d7823Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3646a96d7823Smrg -no-suppress do not suppress compiler output for multiple passes 3647a96d7823Smrg -prefer-pic try to build PIC objects only 3648a96d7823Smrg -prefer-non-pic try to build non-PIC objects only 3649fd60135fSmrg -shared do not build a '.o' file suitable for static linking 3650fd60135fSmrg -static only build a '.o' file suitable for static linking 3651a96d7823Smrg -Wc,FLAG pass FLAG directly to the compiler 3652a96d7823Smrg 3653fd60135fSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3654a96d7823Smrgfrom the given SOURCEFILE. 3655a96d7823Smrg 3656a96d7823SmrgThe output file name is determined by removing the directory component from 3657fd60135fSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 3658fd60135fSmrglibrary object suffix, '.lo'." 3659a96d7823Smrg ;; 3660a96d7823Smrg 3661a96d7823Smrg execute) 3662a96d7823Smrg $ECHO \ 3663a96d7823Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3664a96d7823Smrg 3665a96d7823SmrgAutomatically set library path, then run a program. 3666a96d7823Smrg 3667a96d7823SmrgThis mode accepts the following additional options: 3668a96d7823Smrg 3669a96d7823Smrg -dlopen FILE add the directory containing FILE to the library path 3670a96d7823Smrg 3671fd60135fSmrgThis mode sets the library path environment variable according to '-dlopen' 3672a96d7823Smrgflags. 3673a96d7823Smrg 3674a96d7823SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3675a96d7823Smrginto their corresponding uninstalled binary, and any of their required library 3676a96d7823Smrgdirectories are added to the library path. 3677a96d7823Smrg 3678a96d7823SmrgThen, COMMAND is executed, with ARGS as arguments." 3679a96d7823Smrg ;; 3680a96d7823Smrg 3681a96d7823Smrg finish) 3682a96d7823Smrg $ECHO \ 3683a96d7823Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3684a96d7823Smrg 3685a96d7823SmrgComplete the installation of libtool libraries. 3686a96d7823Smrg 3687a96d7823SmrgEach LIBDIR is a directory that contains libtool libraries. 3688a96d7823Smrg 3689a96d7823SmrgThe commands that this mode executes may require superuser privileges. Use 3690fd60135fSmrgthe '--dry-run' option if you just want to see what would be executed." 3691a96d7823Smrg ;; 3692a96d7823Smrg 3693a96d7823Smrg install) 3694a96d7823Smrg $ECHO \ 3695a96d7823Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3696a96d7823Smrg 3697a96d7823SmrgInstall executables or libraries. 3698a96d7823Smrg 3699a96d7823SmrgINSTALL-COMMAND is the installation command. The first component should be 3700fd60135fSmrgeither the 'install' or 'cp' program. 3701a96d7823Smrg 3702a96d7823SmrgThe following components of INSTALL-COMMAND are treated specially: 3703a96d7823Smrg 3704a96d7823Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3705a96d7823Smrg 3706a96d7823SmrgThe rest of the components are interpreted as arguments to that command (only 3707a96d7823SmrgBSD-compatible install options are recognized)." 3708a96d7823Smrg ;; 3709a96d7823Smrg 3710a96d7823Smrg link) 3711a96d7823Smrg $ECHO \ 3712a96d7823Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3713a96d7823Smrg 3714a96d7823SmrgLink object files or libraries together to form another library, or to 3715a96d7823Smrgcreate an executable program. 3716a96d7823Smrg 3717a96d7823SmrgLINK-COMMAND is a command using the C compiler that you would use to create 3718a96d7823Smrga program from several object files. 3719a96d7823Smrg 3720a96d7823SmrgThe following components of LINK-COMMAND are treated specially: 3721a96d7823Smrg 3722a96d7823Smrg -all-static do not do any dynamic linking at all 3723a96d7823Smrg -avoid-version do not add a version suffix if possible 3724a96d7823Smrg -bindir BINDIR specify path to binaries directory (for systems where 3725a96d7823Smrg libraries must be found in the PATH setting at runtime) 3726fd60135fSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3727a96d7823Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3728a96d7823Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3729a96d7823Smrg -export-symbols SYMFILE 3730a96d7823Smrg try to export only the symbols listed in SYMFILE 3731a96d7823Smrg -export-symbols-regex REGEX 3732a96d7823Smrg try to export only the symbols matching REGEX 3733a96d7823Smrg -LLIBDIR search LIBDIR for required installed libraries 3734a96d7823Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 3735a96d7823Smrg -module build a library that can dlopened 3736a96d7823Smrg -no-fast-install disable the fast-install mode 3737a96d7823Smrg -no-install link a not-installable executable 3738a96d7823Smrg -no-undefined declare that a library does not refer to external symbols 3739a96d7823Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3740fd60135fSmrg -objectlist FILE use a list of object files found in FILE to specify objects 3741fd60135fSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3742a96d7823Smrg -precious-files-regex REGEX 3743a96d7823Smrg don't remove output files matching REGEX 3744a96d7823Smrg -release RELEASE specify package release information 3745a96d7823Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 3746a96d7823Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3747a96d7823Smrg -shared only do dynamic linking of libtool libraries 3748a96d7823Smrg -shrext SUFFIX override the standard shared library file extension 3749a96d7823Smrg -static do not do any dynamic linking of uninstalled libtool libraries 3750a96d7823Smrg -static-libtool-libs 3751a96d7823Smrg do not do any dynamic linking of libtool libraries 3752a96d7823Smrg -version-info CURRENT[:REVISION[:AGE]] 3753a96d7823Smrg specify library version info [each variable defaults to 0] 3754a96d7823Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 3755a96d7823Smrg -Wc,FLAG 3756a96d7823Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 3757a96d7823Smrg -Wl,FLAG 3758a96d7823Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 3759a96d7823Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3760a96d7823Smrg 3761fd60135fSmrgAll other options (arguments beginning with '-') are ignored. 3762a96d7823Smrg 3763fd60135fSmrgEvery other argument is treated as a filename. Files ending in '.la' are 3764a96d7823Smrgtreated as uninstalled libtool libraries, other files are standard or library 3765a96d7823Smrgobject files. 3766a96d7823Smrg 3767fd60135fSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 3768fd60135fSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 3769a96d7823Smrgrequired, except when creating a convenience library. 3770a96d7823Smrg 3771fd60135fSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 3772fd60135fSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 3773a96d7823Smrg 3774fd60135fSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3775a96d7823Smrgis created, otherwise an executable program is created." 3776a96d7823Smrg ;; 3777a96d7823Smrg 3778a96d7823Smrg uninstall) 3779a96d7823Smrg $ECHO \ 3780a96d7823Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3781a96d7823Smrg 3782a96d7823SmrgRemove libraries from an installation directory. 3783a96d7823Smrg 3784a96d7823SmrgRM is the name of the program to use to delete files associated with each FILE 3785fd60135fSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3786a96d7823Smrgto RM. 3787a96d7823Smrg 3788a96d7823SmrgIf FILE is a libtool library, all the files associated with it are deleted. 3789a96d7823SmrgOtherwise, only FILE itself is deleted using RM." 3790a96d7823Smrg ;; 3791a96d7823Smrg 3792a96d7823Smrg *) 3793fd60135fSmrg func_fatal_help "invalid operation mode '$opt_mode'" 3794a96d7823Smrg ;; 3795a96d7823Smrg esac 3796a96d7823Smrg 3797a96d7823Smrg echo 3798fd60135fSmrg $ECHO "Try '$progname --help' for more information about other modes." 3799a96d7823Smrg} 3800a96d7823Smrg 3801a96d7823Smrg# Now that we've collected a possible --mode arg, show help if necessary 3802a96d7823Smrgif $opt_help; then 3803fd60135fSmrg if test : = "$opt_help"; then 3804a96d7823Smrg func_mode_help 3805a96d7823Smrg else 3806a96d7823Smrg { 3807a96d7823Smrg func_help noexit 3808a96d7823Smrg for opt_mode in compile link execute install finish uninstall clean; do 3809a96d7823Smrg func_mode_help 3810a96d7823Smrg done 3811fd60135fSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 3812a96d7823Smrg { 3813a96d7823Smrg func_help noexit 3814a96d7823Smrg for opt_mode in compile link execute install finish uninstall clean; do 3815a96d7823Smrg echo 3816a96d7823Smrg func_mode_help 3817a96d7823Smrg done 3818a96d7823Smrg } | 3819fd60135fSmrg $SED '1d 3820a96d7823Smrg /^When reporting/,/^Report/{ 3821a96d7823Smrg H 3822a96d7823Smrg d 3823a96d7823Smrg } 3824a96d7823Smrg $x 3825a96d7823Smrg /information about other modes/d 3826a96d7823Smrg /more detailed .*MODE/d 3827a96d7823Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 3828a96d7823Smrg fi 3829a96d7823Smrg exit $? 3830a96d7823Smrgfi 3831a96d7823Smrg 3832a96d7823Smrg 3833a96d7823Smrg# func_mode_execute arg... 3834a96d7823Smrgfunc_mode_execute () 3835a96d7823Smrg{ 3836fd60135fSmrg $debug_cmd 3837fd60135fSmrg 3838a96d7823Smrg # The first argument is the command name. 3839fd60135fSmrg cmd=$nonopt 3840a96d7823Smrg test -z "$cmd" && \ 3841a96d7823Smrg func_fatal_help "you must specify a COMMAND" 3842a96d7823Smrg 3843a96d7823Smrg # Handle -dlopen flags immediately. 3844a96d7823Smrg for file in $opt_dlopen; do 3845a96d7823Smrg test -f "$file" \ 3846fd60135fSmrg || func_fatal_help "'$file' is not a file" 3847a96d7823Smrg 3848a96d7823Smrg dir= 3849a96d7823Smrg case $file in 3850a96d7823Smrg *.la) 3851a96d7823Smrg func_resolve_sysroot "$file" 3852a96d7823Smrg file=$func_resolve_sysroot_result 3853a96d7823Smrg 3854a96d7823Smrg # Check to see that this really is a libtool archive. 3855a96d7823Smrg func_lalib_unsafe_p "$file" \ 3856fd60135fSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 3857a96d7823Smrg 3858a96d7823Smrg # Read the libtool library. 3859a96d7823Smrg dlname= 3860a96d7823Smrg library_names= 3861a96d7823Smrg func_source "$file" 3862a96d7823Smrg 3863a96d7823Smrg # Skip this library if it cannot be dlopened. 3864a96d7823Smrg if test -z "$dlname"; then 3865a96d7823Smrg # Warn if it was a shared library. 3866a96d7823Smrg test -n "$library_names" && \ 3867fd60135fSmrg func_warning "'$file' was not linked with '-export-dynamic'" 3868a96d7823Smrg continue 3869a96d7823Smrg fi 3870a96d7823Smrg 3871a96d7823Smrg func_dirname "$file" "" "." 3872fd60135fSmrg dir=$func_dirname_result 3873a96d7823Smrg 3874a96d7823Smrg if test -f "$dir/$objdir/$dlname"; then 3875a96d7823Smrg func_append dir "/$objdir" 3876a96d7823Smrg else 3877a96d7823Smrg if test ! -f "$dir/$dlname"; then 3878fd60135fSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3879a96d7823Smrg fi 3880a96d7823Smrg fi 3881a96d7823Smrg ;; 3882a96d7823Smrg 3883a96d7823Smrg *.lo) 3884a96d7823Smrg # Just add the directory containing the .lo file. 3885a96d7823Smrg func_dirname "$file" "" "." 3886fd60135fSmrg dir=$func_dirname_result 3887a96d7823Smrg ;; 3888a96d7823Smrg 3889a96d7823Smrg *) 3890fd60135fSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3891a96d7823Smrg continue 3892a96d7823Smrg ;; 3893a96d7823Smrg esac 3894a96d7823Smrg 3895a96d7823Smrg # Get the absolute pathname. 3896a96d7823Smrg absdir=`cd "$dir" && pwd` 3897fd60135fSmrg test -n "$absdir" && dir=$absdir 3898a96d7823Smrg 3899a96d7823Smrg # Now add the directory to shlibpath_var. 3900a96d7823Smrg if eval "test -z \"\$$shlibpath_var\""; then 3901a96d7823Smrg eval "$shlibpath_var=\"\$dir\"" 3902a96d7823Smrg else 3903a96d7823Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3904a96d7823Smrg fi 3905a96d7823Smrg done 3906a96d7823Smrg 3907a96d7823Smrg # This variable tells wrapper scripts just to set shlibpath_var 3908a96d7823Smrg # rather than running their programs. 3909fd60135fSmrg libtool_execute_magic=$magic 3910a96d7823Smrg 3911a96d7823Smrg # Check if any of the arguments is a wrapper script. 3912a96d7823Smrg args= 3913a96d7823Smrg for file 3914a96d7823Smrg do 3915a96d7823Smrg case $file in 3916a96d7823Smrg -* | *.la | *.lo ) ;; 3917a96d7823Smrg *) 3918a96d7823Smrg # Do a test to see if this is really a libtool program. 3919a96d7823Smrg if func_ltwrapper_script_p "$file"; then 3920a96d7823Smrg func_source "$file" 3921a96d7823Smrg # Transform arg to wrapped name. 3922fd60135fSmrg file=$progdir/$program 3923a96d7823Smrg elif func_ltwrapper_executable_p "$file"; then 3924a96d7823Smrg func_ltwrapper_scriptname "$file" 3925a96d7823Smrg func_source "$func_ltwrapper_scriptname_result" 3926a96d7823Smrg # Transform arg to wrapped name. 3927fd60135fSmrg file=$progdir/$program 3928a96d7823Smrg fi 3929a96d7823Smrg ;; 3930a96d7823Smrg esac 3931a96d7823Smrg # Quote arguments (to preserve shell metacharacters). 3932a96d7823Smrg func_append_quoted args "$file" 3933a96d7823Smrg done 3934a96d7823Smrg 3935fd60135fSmrg if $opt_dry_run; then 3936fd60135fSmrg # Display what would be done. 3937fd60135fSmrg if test -n "$shlibpath_var"; then 3938fd60135fSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 3939fd60135fSmrg echo "export $shlibpath_var" 3940fd60135fSmrg fi 3941fd60135fSmrg $ECHO "$cmd$args" 3942fd60135fSmrg exit $EXIT_SUCCESS 3943fd60135fSmrg else 3944a96d7823Smrg if test -n "$shlibpath_var"; then 3945a96d7823Smrg # Export the shlibpath_var. 3946a96d7823Smrg eval "export $shlibpath_var" 3947a96d7823Smrg fi 3948a96d7823Smrg 3949a96d7823Smrg # Restore saved environment variables 3950a96d7823Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 3951a96d7823Smrg do 3952a96d7823Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 3953a96d7823Smrg $lt_var=\$save_$lt_var; export $lt_var 3954a96d7823Smrg else 3955a96d7823Smrg $lt_unset $lt_var 3956a96d7823Smrg fi" 3957a96d7823Smrg done 3958a96d7823Smrg 3959a96d7823Smrg # Now prepare to actually exec the command. 3960fd60135fSmrg exec_cmd=\$cmd$args 3961a96d7823Smrg fi 3962a96d7823Smrg} 3963a96d7823Smrg 3964fd60135fSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 3965a96d7823Smrg 3966a96d7823Smrg 3967a96d7823Smrg# func_mode_finish arg... 3968a96d7823Smrgfunc_mode_finish () 3969a96d7823Smrg{ 3970fd60135fSmrg $debug_cmd 3971fd60135fSmrg 3972a96d7823Smrg libs= 3973a96d7823Smrg libdirs= 3974a96d7823Smrg admincmds= 3975a96d7823Smrg 3976a96d7823Smrg for opt in "$nonopt" ${1+"$@"} 3977a96d7823Smrg do 3978a96d7823Smrg if test -d "$opt"; then 3979a96d7823Smrg func_append libdirs " $opt" 3980a96d7823Smrg 3981a96d7823Smrg elif test -f "$opt"; then 3982a96d7823Smrg if func_lalib_unsafe_p "$opt"; then 3983a96d7823Smrg func_append libs " $opt" 3984a96d7823Smrg else 3985fd60135fSmrg func_warning "'$opt' is not a valid libtool archive" 3986a96d7823Smrg fi 3987a96d7823Smrg 3988a96d7823Smrg else 3989fd60135fSmrg func_fatal_error "invalid argument '$opt'" 3990a96d7823Smrg fi 3991a96d7823Smrg done 3992a96d7823Smrg 3993a96d7823Smrg if test -n "$libs"; then 3994a96d7823Smrg if test -n "$lt_sysroot"; then 3995a96d7823Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 3996a96d7823Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 3997a96d7823Smrg else 3998a96d7823Smrg sysroot_cmd= 3999a96d7823Smrg fi 4000a96d7823Smrg 4001a96d7823Smrg # Remove sysroot references 4002a96d7823Smrg if $opt_dry_run; then 4003a96d7823Smrg for lib in $libs; do 4004fd60135fSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4005a96d7823Smrg done 4006a96d7823Smrg else 4007a96d7823Smrg tmpdir=`func_mktempdir` 4008a96d7823Smrg for lib in $libs; do 4009fd60135fSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4010a96d7823Smrg > $tmpdir/tmp-la 4011a96d7823Smrg mv -f $tmpdir/tmp-la $lib 4012a96d7823Smrg done 4013a96d7823Smrg ${RM}r "$tmpdir" 4014a96d7823Smrg fi 4015a96d7823Smrg fi 4016a96d7823Smrg 4017a96d7823Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4018a96d7823Smrg for libdir in $libdirs; do 4019a96d7823Smrg if test -n "$finish_cmds"; then 4020a96d7823Smrg # Do each command in the finish commands. 4021a96d7823Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4022a96d7823Smrg'"$cmd"'"' 4023a96d7823Smrg fi 4024a96d7823Smrg if test -n "$finish_eval"; then 4025a96d7823Smrg # Do the single finish_eval. 4026a96d7823Smrg eval cmds=\"$finish_eval\" 4027a96d7823Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4028a96d7823Smrg $cmds" 4029a96d7823Smrg fi 4030a96d7823Smrg done 4031a96d7823Smrg fi 4032a96d7823Smrg 4033a96d7823Smrg # Exit here if they wanted silent mode. 4034fd60135fSmrg $opt_quiet && exit $EXIT_SUCCESS 4035a96d7823Smrg 4036a96d7823Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4037a96d7823Smrg echo "----------------------------------------------------------------------" 4038a96d7823Smrg echo "Libraries have been installed in:" 4039a96d7823Smrg for libdir in $libdirs; do 4040a96d7823Smrg $ECHO " $libdir" 4041a96d7823Smrg done 4042a96d7823Smrg echo 4043a96d7823Smrg echo "If you ever happen to want to link against installed libraries" 4044a96d7823Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4045fd60135fSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4046a96d7823Smrg echo "flag during linking and do at least one of the following:" 4047a96d7823Smrg if test -n "$shlibpath_var"; then 4048fd60135fSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4049a96d7823Smrg echo " during execution" 4050a96d7823Smrg fi 4051a96d7823Smrg if test -n "$runpath_var"; then 4052fd60135fSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4053a96d7823Smrg echo " during linking" 4054a96d7823Smrg fi 4055a96d7823Smrg if test -n "$hardcode_libdir_flag_spec"; then 4056a96d7823Smrg libdir=LIBDIR 4057a96d7823Smrg eval flag=\"$hardcode_libdir_flag_spec\" 4058a96d7823Smrg 4059fd60135fSmrg $ECHO " - use the '$flag' linker flag" 4060a96d7823Smrg fi 4061a96d7823Smrg if test -n "$admincmds"; then 4062a96d7823Smrg $ECHO " - have your system administrator run these commands:$admincmds" 4063a96d7823Smrg fi 4064a96d7823Smrg if test -f /etc/ld.so.conf; then 4065fd60135fSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4066a96d7823Smrg fi 4067a96d7823Smrg echo 4068a96d7823Smrg 4069a96d7823Smrg echo "See any operating system documentation about shared libraries for" 4070a96d7823Smrg case $host in 4071a96d7823Smrg solaris2.[6789]|solaris2.1[0-9]) 4072a96d7823Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4073a96d7823Smrg echo "pages." 4074a96d7823Smrg ;; 4075a96d7823Smrg *) 4076a96d7823Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4077a96d7823Smrg ;; 4078a96d7823Smrg esac 4079a96d7823Smrg echo "----------------------------------------------------------------------" 4080a96d7823Smrg fi 4081a96d7823Smrg exit $EXIT_SUCCESS 4082a96d7823Smrg} 4083a96d7823Smrg 4084fd60135fSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4085a96d7823Smrg 4086a96d7823Smrg 4087a96d7823Smrg# func_mode_install arg... 4088a96d7823Smrgfunc_mode_install () 4089a96d7823Smrg{ 4090fd60135fSmrg $debug_cmd 4091fd60135fSmrg 4092a96d7823Smrg # There may be an optional sh(1) argument at the beginning of 4093a96d7823Smrg # install_prog (especially on Windows NT). 4094fd60135fSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4095a96d7823Smrg # Allow the use of GNU shtool's install command. 4096fd60135fSmrg case $nonopt in *shtool*) :;; *) false;; esac 4097fd60135fSmrg then 4098a96d7823Smrg # Aesthetically quote it. 4099a96d7823Smrg func_quote_for_eval "$nonopt" 4100a96d7823Smrg install_prog="$func_quote_for_eval_result " 4101a96d7823Smrg arg=$1 4102a96d7823Smrg shift 4103a96d7823Smrg else 4104a96d7823Smrg install_prog= 4105a96d7823Smrg arg=$nonopt 4106a96d7823Smrg fi 4107a96d7823Smrg 4108a96d7823Smrg # The real first argument should be the name of the installation program. 4109a96d7823Smrg # Aesthetically quote it. 4110a96d7823Smrg func_quote_for_eval "$arg" 4111a96d7823Smrg func_append install_prog "$func_quote_for_eval_result" 4112a96d7823Smrg install_shared_prog=$install_prog 4113a96d7823Smrg case " $install_prog " in 4114a96d7823Smrg *[\\\ /]cp\ *) install_cp=: ;; 4115a96d7823Smrg *) install_cp=false ;; 4116a96d7823Smrg esac 4117a96d7823Smrg 4118a96d7823Smrg # We need to accept at least all the BSD install flags. 4119a96d7823Smrg dest= 4120a96d7823Smrg files= 4121a96d7823Smrg opts= 4122a96d7823Smrg prev= 4123a96d7823Smrg install_type= 4124fd60135fSmrg isdir=false 4125a96d7823Smrg stripme= 4126a96d7823Smrg no_mode=: 4127a96d7823Smrg for arg 4128a96d7823Smrg do 4129a96d7823Smrg arg2= 4130a96d7823Smrg if test -n "$dest"; then 4131a96d7823Smrg func_append files " $dest" 4132a96d7823Smrg dest=$arg 4133a96d7823Smrg continue 4134a96d7823Smrg fi 4135a96d7823Smrg 4136a96d7823Smrg case $arg in 4137fd60135fSmrg -d) isdir=: ;; 4138a96d7823Smrg -f) 4139a96d7823Smrg if $install_cp; then :; else 4140a96d7823Smrg prev=$arg 4141a96d7823Smrg fi 4142a96d7823Smrg ;; 4143a96d7823Smrg -g | -m | -o) 4144a96d7823Smrg prev=$arg 4145a96d7823Smrg ;; 4146a96d7823Smrg -s) 4147a96d7823Smrg stripme=" -s" 4148a96d7823Smrg continue 4149a96d7823Smrg ;; 4150a96d7823Smrg -*) 4151a96d7823Smrg ;; 4152a96d7823Smrg *) 4153a96d7823Smrg # If the previous option needed an argument, then skip it. 4154a96d7823Smrg if test -n "$prev"; then 4155fd60135fSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4156a96d7823Smrg arg2=$install_override_mode 4157a96d7823Smrg no_mode=false 4158a96d7823Smrg fi 4159a96d7823Smrg prev= 4160a96d7823Smrg else 4161a96d7823Smrg dest=$arg 4162a96d7823Smrg continue 4163a96d7823Smrg fi 4164a96d7823Smrg ;; 4165a96d7823Smrg esac 4166a96d7823Smrg 4167a96d7823Smrg # Aesthetically quote the argument. 4168a96d7823Smrg func_quote_for_eval "$arg" 4169a96d7823Smrg func_append install_prog " $func_quote_for_eval_result" 4170a96d7823Smrg if test -n "$arg2"; then 4171a96d7823Smrg func_quote_for_eval "$arg2" 4172a96d7823Smrg fi 4173a96d7823Smrg func_append install_shared_prog " $func_quote_for_eval_result" 4174a96d7823Smrg done 4175a96d7823Smrg 4176a96d7823Smrg test -z "$install_prog" && \ 4177a96d7823Smrg func_fatal_help "you must specify an install program" 4178a96d7823Smrg 4179a96d7823Smrg test -n "$prev" && \ 4180fd60135fSmrg func_fatal_help "the '$prev' option requires an argument" 4181a96d7823Smrg 4182a96d7823Smrg if test -n "$install_override_mode" && $no_mode; then 4183a96d7823Smrg if $install_cp; then :; else 4184a96d7823Smrg func_quote_for_eval "$install_override_mode" 4185a96d7823Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 4186a96d7823Smrg fi 4187a96d7823Smrg fi 4188a96d7823Smrg 4189a96d7823Smrg if test -z "$files"; then 4190a96d7823Smrg if test -z "$dest"; then 4191a96d7823Smrg func_fatal_help "no file or destination specified" 4192a96d7823Smrg else 4193a96d7823Smrg func_fatal_help "you must specify a destination" 4194a96d7823Smrg fi 4195a96d7823Smrg fi 4196a96d7823Smrg 4197a96d7823Smrg # Strip any trailing slash from the destination. 4198a96d7823Smrg func_stripname '' '/' "$dest" 4199a96d7823Smrg dest=$func_stripname_result 4200a96d7823Smrg 4201a96d7823Smrg # Check to see that the destination is a directory. 4202fd60135fSmrg test -d "$dest" && isdir=: 4203fd60135fSmrg if $isdir; then 4204fd60135fSmrg destdir=$dest 4205a96d7823Smrg destname= 4206a96d7823Smrg else 4207a96d7823Smrg func_dirname_and_basename "$dest" "" "." 4208fd60135fSmrg destdir=$func_dirname_result 4209fd60135fSmrg destname=$func_basename_result 4210a96d7823Smrg 4211a96d7823Smrg # Not a directory, so check to see that there is only one file specified. 4212a96d7823Smrg set dummy $files; shift 4213a96d7823Smrg test "$#" -gt 1 && \ 4214fd60135fSmrg func_fatal_help "'$dest' is not a directory" 4215a96d7823Smrg fi 4216a96d7823Smrg case $destdir in 4217a96d7823Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4218a96d7823Smrg *) 4219a96d7823Smrg for file in $files; do 4220a96d7823Smrg case $file in 4221a96d7823Smrg *.lo) ;; 4222a96d7823Smrg *) 4223fd60135fSmrg func_fatal_help "'$destdir' must be an absolute directory name" 4224a96d7823Smrg ;; 4225a96d7823Smrg esac 4226a96d7823Smrg done 4227a96d7823Smrg ;; 4228a96d7823Smrg esac 4229a96d7823Smrg 4230a96d7823Smrg # This variable tells wrapper scripts just to set variables rather 4231a96d7823Smrg # than running their programs. 4232fd60135fSmrg libtool_install_magic=$magic 4233a96d7823Smrg 4234a96d7823Smrg staticlibs= 4235a96d7823Smrg future_libdirs= 4236a96d7823Smrg current_libdirs= 4237a96d7823Smrg for file in $files; do 4238a96d7823Smrg 4239a96d7823Smrg # Do each installation. 4240a96d7823Smrg case $file in 4241a96d7823Smrg *.$libext) 4242a96d7823Smrg # Do the static libraries later. 4243a96d7823Smrg func_append staticlibs " $file" 4244a96d7823Smrg ;; 4245a96d7823Smrg 4246a96d7823Smrg *.la) 4247a96d7823Smrg func_resolve_sysroot "$file" 4248a96d7823Smrg file=$func_resolve_sysroot_result 4249a96d7823Smrg 4250a96d7823Smrg # Check to see that this really is a libtool archive. 4251a96d7823Smrg func_lalib_unsafe_p "$file" \ 4252fd60135fSmrg || func_fatal_help "'$file' is not a valid libtool archive" 4253a96d7823Smrg 4254a96d7823Smrg library_names= 4255a96d7823Smrg old_library= 4256a96d7823Smrg relink_command= 4257a96d7823Smrg func_source "$file" 4258a96d7823Smrg 4259a96d7823Smrg # Add the libdir to current_libdirs if it is the destination. 4260a96d7823Smrg if test "X$destdir" = "X$libdir"; then 4261a96d7823Smrg case "$current_libdirs " in 4262a96d7823Smrg *" $libdir "*) ;; 4263a96d7823Smrg *) func_append current_libdirs " $libdir" ;; 4264a96d7823Smrg esac 4265a96d7823Smrg else 4266a96d7823Smrg # Note the libdir as a future libdir. 4267a96d7823Smrg case "$future_libdirs " in 4268a96d7823Smrg *" $libdir "*) ;; 4269a96d7823Smrg *) func_append future_libdirs " $libdir" ;; 4270a96d7823Smrg esac 4271a96d7823Smrg fi 4272a96d7823Smrg 4273a96d7823Smrg func_dirname "$file" "/" "" 4274fd60135fSmrg dir=$func_dirname_result 4275a96d7823Smrg func_append dir "$objdir" 4276a96d7823Smrg 4277a96d7823Smrg if test -n "$relink_command"; then 4278a96d7823Smrg # Determine the prefix the user has applied to our future dir. 4279a96d7823Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4280a96d7823Smrg 4281a96d7823Smrg # Don't allow the user to place us outside of our expected 4282a96d7823Smrg # location b/c this prevents finding dependent libraries that 4283a96d7823Smrg # are installed to the same prefix. 4284a96d7823Smrg # At present, this check doesn't affect windows .dll's that 4285a96d7823Smrg # are installed into $libdir/../bin (currently, that works fine) 4286a96d7823Smrg # but it's something to keep an eye on. 4287a96d7823Smrg test "$inst_prefix_dir" = "$destdir" && \ 4288fd60135fSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4289a96d7823Smrg 4290a96d7823Smrg if test -n "$inst_prefix_dir"; then 4291a96d7823Smrg # Stick the inst_prefix_dir data into the link command. 4292a96d7823Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4293a96d7823Smrg else 4294a96d7823Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4295a96d7823Smrg fi 4296a96d7823Smrg 4297fd60135fSmrg func_warning "relinking '$file'" 4298a96d7823Smrg func_show_eval "$relink_command" \ 4299fd60135fSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4300a96d7823Smrg fi 4301a96d7823Smrg 4302a96d7823Smrg # See the names of the shared library. 4303a96d7823Smrg set dummy $library_names; shift 4304a96d7823Smrg if test -n "$1"; then 4305fd60135fSmrg realname=$1 4306a96d7823Smrg shift 4307a96d7823Smrg 4308fd60135fSmrg srcname=$realname 4309fd60135fSmrg test -n "$relink_command" && srcname=${realname}T 4310a96d7823Smrg 4311a96d7823Smrg # Install the shared library and build the symlinks. 4312a96d7823Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4313a96d7823Smrg 'exit $?' 4314fd60135fSmrg tstripme=$stripme 4315a96d7823Smrg case $host_os in 4316a96d7823Smrg cygwin* | mingw* | pw32* | cegcc*) 4317a96d7823Smrg case $realname in 4318a96d7823Smrg *.dll.a) 4319fd60135fSmrg tstripme= 4320fd60135fSmrg ;; 4321fd60135fSmrg esac 4322fd60135fSmrg ;; 4323fd60135fSmrg os2*) 4324fd60135fSmrg case $realname in 4325fd60135fSmrg *_dll.a) 4326fd60135fSmrg tstripme= 4327a96d7823Smrg ;; 4328a96d7823Smrg esac 4329a96d7823Smrg ;; 4330a96d7823Smrg esac 4331a96d7823Smrg if test -n "$tstripme" && test -n "$striplib"; then 4332a96d7823Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333a96d7823Smrg fi 4334a96d7823Smrg 4335a96d7823Smrg if test "$#" -gt 0; then 4336a96d7823Smrg # Delete the old symlinks, and create new ones. 4337fd60135fSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4338a96d7823Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4339a96d7823Smrg # so we also need to try rm && ln -s. 4340a96d7823Smrg for linkname 4341a96d7823Smrg do 4342a96d7823Smrg test "$linkname" != "$realname" \ 4343a96d7823Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344a96d7823Smrg done 4345a96d7823Smrg fi 4346a96d7823Smrg 4347a96d7823Smrg # Do each command in the postinstall commands. 4348fd60135fSmrg lib=$destdir/$realname 4349a96d7823Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4350a96d7823Smrg fi 4351a96d7823Smrg 4352a96d7823Smrg # Install the pseudo-library for information purposes. 4353a96d7823Smrg func_basename "$file" 4354fd60135fSmrg name=$func_basename_result 4355fd60135fSmrg instname=$dir/${name}i 4356a96d7823Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4357a96d7823Smrg 4358a96d7823Smrg # Maybe install the static library, too. 4359a96d7823Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4360a96d7823Smrg ;; 4361a96d7823Smrg 4362a96d7823Smrg *.lo) 4363a96d7823Smrg # Install (i.e. copy) a libtool object. 4364a96d7823Smrg 4365a96d7823Smrg # Figure out destination file name, if it wasn't already specified. 4366a96d7823Smrg if test -n "$destname"; then 4367fd60135fSmrg destfile=$destdir/$destname 4368a96d7823Smrg else 4369a96d7823Smrg func_basename "$file" 4370fd60135fSmrg destfile=$func_basename_result 4371fd60135fSmrg destfile=$destdir/$destfile 4372a96d7823Smrg fi 4373a96d7823Smrg 4374a96d7823Smrg # Deduce the name of the destination old-style object file. 4375a96d7823Smrg case $destfile in 4376a96d7823Smrg *.lo) 4377a96d7823Smrg func_lo2o "$destfile" 4378a96d7823Smrg staticdest=$func_lo2o_result 4379a96d7823Smrg ;; 4380a96d7823Smrg *.$objext) 4381fd60135fSmrg staticdest=$destfile 4382a96d7823Smrg destfile= 4383a96d7823Smrg ;; 4384a96d7823Smrg *) 4385fd60135fSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4386a96d7823Smrg ;; 4387a96d7823Smrg esac 4388a96d7823Smrg 4389a96d7823Smrg # Install the libtool object if requested. 4390a96d7823Smrg test -n "$destfile" && \ 4391a96d7823Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4392a96d7823Smrg 4393a96d7823Smrg # Install the old object if enabled. 4394fd60135fSmrg if test yes = "$build_old_libs"; then 4395a96d7823Smrg # Deduce the name of the old-style object file. 4396a96d7823Smrg func_lo2o "$file" 4397a96d7823Smrg staticobj=$func_lo2o_result 4398a96d7823Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4399a96d7823Smrg fi 4400a96d7823Smrg exit $EXIT_SUCCESS 4401a96d7823Smrg ;; 4402a96d7823Smrg 4403a96d7823Smrg *) 4404a96d7823Smrg # Figure out destination file name, if it wasn't already specified. 4405a96d7823Smrg if test -n "$destname"; then 4406fd60135fSmrg destfile=$destdir/$destname 4407a96d7823Smrg else 4408a96d7823Smrg func_basename "$file" 4409fd60135fSmrg destfile=$func_basename_result 4410fd60135fSmrg destfile=$destdir/$destfile 4411a96d7823Smrg fi 4412a96d7823Smrg 4413a96d7823Smrg # If the file is missing, and there is a .exe on the end, strip it 4414a96d7823Smrg # because it is most likely a libtool script we actually want to 4415a96d7823Smrg # install 4416fd60135fSmrg stripped_ext= 4417a96d7823Smrg case $file in 4418a96d7823Smrg *.exe) 4419a96d7823Smrg if test ! -f "$file"; then 4420a96d7823Smrg func_stripname '' '.exe' "$file" 4421a96d7823Smrg file=$func_stripname_result 4422fd60135fSmrg stripped_ext=.exe 4423a96d7823Smrg fi 4424a96d7823Smrg ;; 4425a96d7823Smrg esac 4426a96d7823Smrg 4427a96d7823Smrg # Do a test to see if this is really a libtool program. 4428a96d7823Smrg case $host in 4429a96d7823Smrg *cygwin* | *mingw*) 4430a96d7823Smrg if func_ltwrapper_executable_p "$file"; then 4431a96d7823Smrg func_ltwrapper_scriptname "$file" 4432a96d7823Smrg wrapper=$func_ltwrapper_scriptname_result 4433a96d7823Smrg else 4434a96d7823Smrg func_stripname '' '.exe' "$file" 4435a96d7823Smrg wrapper=$func_stripname_result 4436a96d7823Smrg fi 4437a96d7823Smrg ;; 4438a96d7823Smrg *) 4439a96d7823Smrg wrapper=$file 4440a96d7823Smrg ;; 4441a96d7823Smrg esac 4442a96d7823Smrg if func_ltwrapper_script_p "$wrapper"; then 4443a96d7823Smrg notinst_deplibs= 4444a96d7823Smrg relink_command= 4445a96d7823Smrg 4446a96d7823Smrg func_source "$wrapper" 4447a96d7823Smrg 4448a96d7823Smrg # Check the variables that should have been set. 4449a96d7823Smrg test -z "$generated_by_libtool_version" && \ 4450fd60135fSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4451a96d7823Smrg 4452fd60135fSmrg finalize=: 4453a96d7823Smrg for lib in $notinst_deplibs; do 4454a96d7823Smrg # Check to see that each library is installed. 4455a96d7823Smrg libdir= 4456a96d7823Smrg if test -f "$lib"; then 4457a96d7823Smrg func_source "$lib" 4458a96d7823Smrg fi 4459fd60135fSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4460a96d7823Smrg if test -n "$libdir" && test ! -f "$libfile"; then 4461fd60135fSmrg func_warning "'$lib' has not been installed in '$libdir'" 4462fd60135fSmrg finalize=false 4463a96d7823Smrg fi 4464a96d7823Smrg done 4465a96d7823Smrg 4466a96d7823Smrg relink_command= 4467a96d7823Smrg func_source "$wrapper" 4468a96d7823Smrg 4469a96d7823Smrg outputname= 4470fd60135fSmrg if test no = "$fast_install" && test -n "$relink_command"; then 4471a96d7823Smrg $opt_dry_run || { 4472fd60135fSmrg if $finalize; then 4473a96d7823Smrg tmpdir=`func_mktempdir` 4474a96d7823Smrg func_basename "$file$stripped_ext" 4475fd60135fSmrg file=$func_basename_result 4476fd60135fSmrg outputname=$tmpdir/$file 4477a96d7823Smrg # Replace the output file specification. 4478a96d7823Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4479a96d7823Smrg 4480fd60135fSmrg $opt_quiet || { 4481a96d7823Smrg func_quote_for_expand "$relink_command" 4482a96d7823Smrg eval "func_echo $func_quote_for_expand_result" 4483a96d7823Smrg } 4484a96d7823Smrg if eval "$relink_command"; then : 4485a96d7823Smrg else 4486fd60135fSmrg func_error "error: relink '$file' with the above command before installing it" 4487a96d7823Smrg $opt_dry_run || ${RM}r "$tmpdir" 4488a96d7823Smrg continue 4489a96d7823Smrg fi 4490fd60135fSmrg file=$outputname 4491a96d7823Smrg else 4492fd60135fSmrg func_warning "cannot relink '$file'" 4493a96d7823Smrg fi 4494a96d7823Smrg } 4495a96d7823Smrg else 4496a96d7823Smrg # Install the binary that we compiled earlier. 4497a96d7823Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4498a96d7823Smrg fi 4499a96d7823Smrg fi 4500a96d7823Smrg 4501a96d7823Smrg # remove .exe since cygwin /usr/bin/install will append another 4502a96d7823Smrg # one anyway 4503a96d7823Smrg case $install_prog,$host in 4504a96d7823Smrg */usr/bin/install*,*cygwin*) 4505a96d7823Smrg case $file:$destfile in 4506a96d7823Smrg *.exe:*.exe) 4507a96d7823Smrg # this is ok 4508a96d7823Smrg ;; 4509a96d7823Smrg *.exe:*) 4510a96d7823Smrg destfile=$destfile.exe 4511a96d7823Smrg ;; 4512a96d7823Smrg *:*.exe) 4513a96d7823Smrg func_stripname '' '.exe' "$destfile" 4514a96d7823Smrg destfile=$func_stripname_result 4515a96d7823Smrg ;; 4516a96d7823Smrg esac 4517a96d7823Smrg ;; 4518a96d7823Smrg esac 4519a96d7823Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4520a96d7823Smrg $opt_dry_run || if test -n "$outputname"; then 4521a96d7823Smrg ${RM}r "$tmpdir" 4522a96d7823Smrg fi 4523a96d7823Smrg ;; 4524a96d7823Smrg esac 4525a96d7823Smrg done 4526a96d7823Smrg 4527a96d7823Smrg for file in $staticlibs; do 4528a96d7823Smrg func_basename "$file" 4529fd60135fSmrg name=$func_basename_result 4530a96d7823Smrg 4531a96d7823Smrg # Set up the ranlib parameters. 4532fd60135fSmrg oldlib=$destdir/$name 4533a96d7823Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4534a96d7823Smrg tool_oldlib=$func_to_tool_file_result 4535a96d7823Smrg 4536a96d7823Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4537a96d7823Smrg 4538a96d7823Smrg if test -n "$stripme" && test -n "$old_striplib"; then 4539a96d7823Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4540a96d7823Smrg fi 4541a96d7823Smrg 4542a96d7823Smrg # Do each command in the postinstall commands. 4543a96d7823Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4544a96d7823Smrg done 4545a96d7823Smrg 4546a96d7823Smrg test -n "$future_libdirs" && \ 4547fd60135fSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 4548a96d7823Smrg 4549a96d7823Smrg if test -n "$current_libdirs"; then 4550a96d7823Smrg # Maybe just do a dry run. 4551a96d7823Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4552fd60135fSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4553a96d7823Smrg else 4554a96d7823Smrg exit $EXIT_SUCCESS 4555a96d7823Smrg fi 4556a96d7823Smrg} 4557a96d7823Smrg 4558fd60135fSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4559a96d7823Smrg 4560a96d7823Smrg 4561a96d7823Smrg# func_generate_dlsyms outputname originator pic_p 4562a96d7823Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4563a96d7823Smrg# a dlpreopen symbol table. 4564a96d7823Smrgfunc_generate_dlsyms () 4565a96d7823Smrg{ 4566fd60135fSmrg $debug_cmd 4567fd60135fSmrg 4568fd60135fSmrg my_outputname=$1 4569fd60135fSmrg my_originator=$2 4570fd60135fSmrg my_pic_p=${3-false} 4571fd60135fSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4572a96d7823Smrg my_dlsyms= 4573a96d7823Smrg 4574fd60135fSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4575a96d7823Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4576fd60135fSmrg my_dlsyms=${my_outputname}S.c 4577a96d7823Smrg else 4578a96d7823Smrg func_error "not configured to extract global symbols from dlpreopened files" 4579a96d7823Smrg fi 4580a96d7823Smrg fi 4581a96d7823Smrg 4582a96d7823Smrg if test -n "$my_dlsyms"; then 4583a96d7823Smrg case $my_dlsyms in 4584a96d7823Smrg "") ;; 4585a96d7823Smrg *.c) 4586a96d7823Smrg # Discover the nlist of each of the dlfiles. 4587fd60135fSmrg nlist=$output_objdir/$my_outputname.nm 4588a96d7823Smrg 4589a96d7823Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4590a96d7823Smrg 4591a96d7823Smrg # Parse the name list into a source file. 4592a96d7823Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4593a96d7823Smrg 4594a96d7823Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4595fd60135fSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4596fd60135fSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4597a96d7823Smrg 4598a96d7823Smrg#ifdef __cplusplus 4599a96d7823Smrgextern \"C\" { 4600a96d7823Smrg#endif 4601a96d7823Smrg 4602fd60135fSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4603a96d7823Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4604a96d7823Smrg#endif 4605a96d7823Smrg 4606a96d7823Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4607fd60135fSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4608fd60135fSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4609a96d7823Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4610a96d7823Smrg# define LT_DLSYM_CONST 4611fd60135fSmrg#elif defined __osf__ 4612a96d7823Smrg/* This system does not cope well with relocations in const data. */ 4613a96d7823Smrg# define LT_DLSYM_CONST 4614a96d7823Smrg#else 4615a96d7823Smrg# define LT_DLSYM_CONST const 4616a96d7823Smrg#endif 4617a96d7823Smrg 4618fd60135fSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4619fd60135fSmrg 4620a96d7823Smrg/* External symbol declarations for the compiler. */\ 4621a96d7823Smrg" 4622a96d7823Smrg 4623fd60135fSmrg if test yes = "$dlself"; then 4624fd60135fSmrg func_verbose "generating symbol list for '$output'" 4625a96d7823Smrg 4626a96d7823Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4627a96d7823Smrg 4628a96d7823Smrg # Add our own program objects to the symbol list. 4629a96d7823Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4630a96d7823Smrg for progfile in $progfiles; do 4631a96d7823Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4632fd60135fSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4633a96d7823Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4634a96d7823Smrg done 4635a96d7823Smrg 4636a96d7823Smrg if test -n "$exclude_expsyms"; then 4637a96d7823Smrg $opt_dry_run || { 4638a96d7823Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4639a96d7823Smrg eval '$MV "$nlist"T "$nlist"' 4640a96d7823Smrg } 4641a96d7823Smrg fi 4642a96d7823Smrg 4643a96d7823Smrg if test -n "$export_symbols_regex"; then 4644a96d7823Smrg $opt_dry_run || { 4645a96d7823Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4646a96d7823Smrg eval '$MV "$nlist"T "$nlist"' 4647a96d7823Smrg } 4648a96d7823Smrg fi 4649a96d7823Smrg 4650a96d7823Smrg # Prepare the list of exported symbols 4651a96d7823Smrg if test -z "$export_symbols"; then 4652fd60135fSmrg export_symbols=$output_objdir/$outputname.exp 4653a96d7823Smrg $opt_dry_run || { 4654a96d7823Smrg $RM $export_symbols 4655fd60135fSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4656a96d7823Smrg case $host in 4657a96d7823Smrg *cygwin* | *mingw* | *cegcc* ) 4658a96d7823Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4659a96d7823Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4660a96d7823Smrg ;; 4661a96d7823Smrg esac 4662a96d7823Smrg } 4663a96d7823Smrg else 4664a96d7823Smrg $opt_dry_run || { 4665fd60135fSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4666a96d7823Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4667a96d7823Smrg eval '$MV "$nlist"T "$nlist"' 4668a96d7823Smrg case $host in 4669a96d7823Smrg *cygwin* | *mingw* | *cegcc* ) 4670a96d7823Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4671a96d7823Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4672a96d7823Smrg ;; 4673a96d7823Smrg esac 4674a96d7823Smrg } 4675a96d7823Smrg fi 4676a96d7823Smrg fi 4677a96d7823Smrg 4678a96d7823Smrg for dlprefile in $dlprefiles; do 4679fd60135fSmrg func_verbose "extracting global C symbols from '$dlprefile'" 4680a96d7823Smrg func_basename "$dlprefile" 4681fd60135fSmrg name=$func_basename_result 4682a96d7823Smrg case $host in 4683a96d7823Smrg *cygwin* | *mingw* | *cegcc* ) 4684a96d7823Smrg # if an import library, we need to obtain dlname 4685a96d7823Smrg if func_win32_import_lib_p "$dlprefile"; then 4686a96d7823Smrg func_tr_sh "$dlprefile" 4687a96d7823Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4688fd60135fSmrg dlprefile_dlbasename= 4689a96d7823Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4690a96d7823Smrg # Use subshell, to avoid clobbering current variable values 4691a96d7823Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4692fd60135fSmrg if test -n "$dlprefile_dlname"; then 4693a96d7823Smrg func_basename "$dlprefile_dlname" 4694fd60135fSmrg dlprefile_dlbasename=$func_basename_result 4695a96d7823Smrg else 4696a96d7823Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 4697a96d7823Smrg $sharedlib_from_linklib_cmd "$dlprefile" 4698a96d7823Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4699a96d7823Smrg fi 4700a96d7823Smrg fi 4701a96d7823Smrg $opt_dry_run || { 4702fd60135fSmrg if test -n "$dlprefile_dlbasename"; then 4703a96d7823Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4704a96d7823Smrg else 4705a96d7823Smrg func_warning "Could not compute DLL name from $name" 4706a96d7823Smrg eval '$ECHO ": $name " >> "$nlist"' 4707a96d7823Smrg fi 4708a96d7823Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4709a96d7823Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4710a96d7823Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4711a96d7823Smrg } 4712a96d7823Smrg else # not an import lib 4713a96d7823Smrg $opt_dry_run || { 4714a96d7823Smrg eval '$ECHO ": $name " >> "$nlist"' 4715a96d7823Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4716a96d7823Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4717a96d7823Smrg } 4718a96d7823Smrg fi 4719a96d7823Smrg ;; 4720a96d7823Smrg *) 4721a96d7823Smrg $opt_dry_run || { 4722a96d7823Smrg eval '$ECHO ": $name " >> "$nlist"' 4723a96d7823Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4724a96d7823Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4725a96d7823Smrg } 4726a96d7823Smrg ;; 4727a96d7823Smrg esac 4728a96d7823Smrg done 4729a96d7823Smrg 4730a96d7823Smrg $opt_dry_run || { 4731a96d7823Smrg # Make sure we have at least an empty file. 4732a96d7823Smrg test -f "$nlist" || : > "$nlist" 4733a96d7823Smrg 4734a96d7823Smrg if test -n "$exclude_expsyms"; then 4735a96d7823Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4736a96d7823Smrg $MV "$nlist"T "$nlist" 4737a96d7823Smrg fi 4738a96d7823Smrg 4739a96d7823Smrg # Try sorting and uniquifying the output. 4740a96d7823Smrg if $GREP -v "^: " < "$nlist" | 4741a96d7823Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4742a96d7823Smrg sort -k 3 4743a96d7823Smrg else 4744a96d7823Smrg sort +2 4745a96d7823Smrg fi | 4746a96d7823Smrg uniq > "$nlist"S; then 4747a96d7823Smrg : 4748a96d7823Smrg else 4749a96d7823Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 4750a96d7823Smrg fi 4751a96d7823Smrg 4752a96d7823Smrg if test -f "$nlist"S; then 4753a96d7823Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4754a96d7823Smrg else 4755a96d7823Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4756a96d7823Smrg fi 4757a96d7823Smrg 4758fd60135fSmrg func_show_eval '$RM "${nlist}I"' 4759fd60135fSmrg if test -n "$global_symbol_to_import"; then 4760fd60135fSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 4761fd60135fSmrg fi 4762fd60135fSmrg 4763a96d7823Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4764a96d7823Smrg 4765a96d7823Smrg/* The mapping between symbol names and symbols. */ 4766a96d7823Smrgtypedef struct { 4767a96d7823Smrg const char *name; 4768a96d7823Smrg void *address; 4769a96d7823Smrg} lt_dlsymlist; 4770a96d7823Smrgextern LT_DLSYM_CONST lt_dlsymlist 4771fd60135fSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 4772fd60135fSmrg" 4773fd60135fSmrg 4774fd60135fSmrg if test -s "$nlist"I; then 4775fd60135fSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4776fd60135fSmrgstatic void lt_syminit(void) 4777fd60135fSmrg{ 4778fd60135fSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 4779fd60135fSmrg for (; symbol->name; ++symbol) 4780fd60135fSmrg {" 4781fd60135fSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 4782fd60135fSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4783fd60135fSmrg } 4784fd60135fSmrg}" 4785fd60135fSmrg fi 4786fd60135fSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4787a96d7823SmrgLT_DLSYM_CONST lt_dlsymlist 4788a96d7823Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 4789fd60135fSmrg{ {\"$my_originator\", (void *) 0}," 4790fd60135fSmrg 4791fd60135fSmrg if test -s "$nlist"I; then 4792fd60135fSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4793fd60135fSmrg {\"@INIT@\", (void *) <_syminit}," 4794fd60135fSmrg fi 4795a96d7823Smrg 4796a96d7823Smrg case $need_lib_prefix in 4797a96d7823Smrg no) 4798a96d7823Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4799a96d7823Smrg ;; 4800a96d7823Smrg *) 4801a96d7823Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4802a96d7823Smrg ;; 4803a96d7823Smrg esac 4804a96d7823Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4805a96d7823Smrg {0, (void *) 0} 4806a96d7823Smrg}; 4807a96d7823Smrg 4808a96d7823Smrg/* This works around a problem in FreeBSD linker */ 4809a96d7823Smrg#ifdef FREEBSD_WORKAROUND 4810a96d7823Smrgstatic const void *lt_preloaded_setup() { 4811a96d7823Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 4812a96d7823Smrg} 4813a96d7823Smrg#endif 4814a96d7823Smrg 4815a96d7823Smrg#ifdef __cplusplus 4816a96d7823Smrg} 4817a96d7823Smrg#endif\ 4818a96d7823Smrg" 4819a96d7823Smrg } # !$opt_dry_run 4820a96d7823Smrg 4821a96d7823Smrg pic_flag_for_symtable= 4822a96d7823Smrg case "$compile_command " in 4823a96d7823Smrg *" -static "*) ;; 4824a96d7823Smrg *) 4825a96d7823Smrg case $host in 4826a96d7823Smrg # compiling the symbol table file with pic_flag works around 4827a96d7823Smrg # a FreeBSD bug that causes programs to crash when -lm is 4828a96d7823Smrg # linked before any other PIC object. But we must not use 4829a96d7823Smrg # pic_flag when linking with -static. The problem exists in 4830a96d7823Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4831a96d7823Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4832a96d7823Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4833a96d7823Smrg *-*-hpux*) 4834a96d7823Smrg pic_flag_for_symtable=" $pic_flag" ;; 4835a96d7823Smrg *) 4836fd60135fSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4837a96d7823Smrg ;; 4838a96d7823Smrg esac 4839a96d7823Smrg ;; 4840a96d7823Smrg esac 4841a96d7823Smrg symtab_cflags= 4842a96d7823Smrg for arg in $LTCFLAGS; do 4843a96d7823Smrg case $arg in 4844a96d7823Smrg -pie | -fpie | -fPIE) ;; 4845a96d7823Smrg *) func_append symtab_cflags " $arg" ;; 4846a96d7823Smrg esac 4847a96d7823Smrg done 4848a96d7823Smrg 4849a96d7823Smrg # Now compile the dynamic symbol file. 4850a96d7823Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4851a96d7823Smrg 4852a96d7823Smrg # Clean up the generated files. 4853fd60135fSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4854a96d7823Smrg 4855a96d7823Smrg # Transform the symbol file into the correct name. 4856fd60135fSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 4857a96d7823Smrg case $host in 4858a96d7823Smrg *cygwin* | *mingw* | *cegcc* ) 4859a96d7823Smrg if test -f "$output_objdir/$my_outputname.def"; then 4860a96d7823Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4861a96d7823Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4862a96d7823Smrg else 4863a96d7823Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4864a96d7823Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4865a96d7823Smrg fi 4866a96d7823Smrg ;; 4867a96d7823Smrg *) 4868a96d7823Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4869a96d7823Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4870a96d7823Smrg ;; 4871a96d7823Smrg esac 4872a96d7823Smrg ;; 4873a96d7823Smrg *) 4874fd60135fSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 4875a96d7823Smrg ;; 4876a96d7823Smrg esac 4877a96d7823Smrg else 4878a96d7823Smrg # We keep going just in case the user didn't refer to 4879a96d7823Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4880a96d7823Smrg # really was required. 4881a96d7823Smrg 4882a96d7823Smrg # Nullify the symbol file. 4883a96d7823Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 4884a96d7823Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4885a96d7823Smrg fi 4886a96d7823Smrg} 4887a96d7823Smrg 4888fd60135fSmrg# func_cygming_gnu_implib_p ARG 4889fd60135fSmrg# This predicate returns with zero status (TRUE) if 4890fd60135fSmrg# ARG is a GNU/binutils-style import library. Returns 4891fd60135fSmrg# with nonzero status (FALSE) otherwise. 4892fd60135fSmrgfunc_cygming_gnu_implib_p () 4893fd60135fSmrg{ 4894fd60135fSmrg $debug_cmd 4895fd60135fSmrg 4896fd60135fSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4897fd60135fSmrg 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)$'` 4898fd60135fSmrg test -n "$func_cygming_gnu_implib_tmp" 4899fd60135fSmrg} 4900fd60135fSmrg 4901fd60135fSmrg# func_cygming_ms_implib_p ARG 4902fd60135fSmrg# This predicate returns with zero status (TRUE) if 4903fd60135fSmrg# ARG is an MS-style import library. Returns 4904fd60135fSmrg# with nonzero status (FALSE) otherwise. 4905fd60135fSmrgfunc_cygming_ms_implib_p () 4906fd60135fSmrg{ 4907fd60135fSmrg $debug_cmd 4908fd60135fSmrg 4909fd60135fSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4910fd60135fSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 4911fd60135fSmrg test -n "$func_cygming_ms_implib_tmp" 4912fd60135fSmrg} 4913fd60135fSmrg 4914a96d7823Smrg# func_win32_libid arg 4915a96d7823Smrg# return the library type of file 'arg' 4916a96d7823Smrg# 4917a96d7823Smrg# Need a lot of goo to handle *both* DLLs and import libs 4918a96d7823Smrg# Has to be a shell function in order to 'eat' the argument 4919a96d7823Smrg# that is supplied when $file_magic_command is called. 4920a96d7823Smrg# Despite the name, also deal with 64 bit binaries. 4921a96d7823Smrgfunc_win32_libid () 4922a96d7823Smrg{ 4923fd60135fSmrg $debug_cmd 4924fd60135fSmrg 4925fd60135fSmrg win32_libid_type=unknown 4926a96d7823Smrg win32_fileres=`file -L $1 2>/dev/null` 4927a96d7823Smrg case $win32_fileres in 4928a96d7823Smrg *ar\ archive\ import\ library*) # definitely import 4929a96d7823Smrg win32_libid_type="x86 archive import" 4930a96d7823Smrg ;; 4931a96d7823Smrg *ar\ archive*) # could be an import, or static 4932a96d7823Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 4933a96d7823Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 4934a96d7823Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 4935fd60135fSmrg case $nm_interface in 4936fd60135fSmrg "MS dumpbin") 4937fd60135fSmrg if func_cygming_ms_implib_p "$1" || 4938fd60135fSmrg func_cygming_gnu_implib_p "$1" 4939fd60135fSmrg then 4940fd60135fSmrg win32_nmres=import 4941fd60135fSmrg else 4942fd60135fSmrg win32_nmres= 4943fd60135fSmrg fi 4944fd60135fSmrg ;; 4945fd60135fSmrg *) 4946fd60135fSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4947fd60135fSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 4948fd60135fSmrg $SED -n -e ' 4949a96d7823Smrg 1,100{ 4950a96d7823Smrg / I /{ 4951fd60135fSmrg s|.*|import| 4952a96d7823Smrg p 4953a96d7823Smrg q 4954a96d7823Smrg } 4955a96d7823Smrg }'` 4956fd60135fSmrg ;; 4957fd60135fSmrg esac 4958a96d7823Smrg case $win32_nmres in 4959a96d7823Smrg import*) win32_libid_type="x86 archive import";; 4960a96d7823Smrg *) win32_libid_type="x86 archive static";; 4961a96d7823Smrg esac 4962a96d7823Smrg fi 4963a96d7823Smrg ;; 4964a96d7823Smrg *DLL*) 4965a96d7823Smrg win32_libid_type="x86 DLL" 4966a96d7823Smrg ;; 4967a96d7823Smrg *executable*) # but shell scripts are "executable" too... 4968a96d7823Smrg case $win32_fileres in 4969a96d7823Smrg *MS\ Windows\ PE\ Intel*) 4970a96d7823Smrg win32_libid_type="x86 DLL" 4971a96d7823Smrg ;; 4972a96d7823Smrg esac 4973a96d7823Smrg ;; 4974a96d7823Smrg esac 4975a96d7823Smrg $ECHO "$win32_libid_type" 4976a96d7823Smrg} 4977a96d7823Smrg 4978a96d7823Smrg# func_cygming_dll_for_implib ARG 4979a96d7823Smrg# 4980a96d7823Smrg# Platform-specific function to extract the 4981a96d7823Smrg# name of the DLL associated with the specified 4982a96d7823Smrg# import library ARG. 4983a96d7823Smrg# Invoked by eval'ing the libtool variable 4984a96d7823Smrg# $sharedlib_from_linklib_cmd 4985a96d7823Smrg# Result is available in the variable 4986a96d7823Smrg# $sharedlib_from_linklib_result 4987a96d7823Smrgfunc_cygming_dll_for_implib () 4988a96d7823Smrg{ 4989fd60135fSmrg $debug_cmd 4990fd60135fSmrg 4991a96d7823Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 4992a96d7823Smrg} 4993a96d7823Smrg 4994a96d7823Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 4995a96d7823Smrg# 4996a96d7823Smrg# The is the core of a fallback implementation of a 4997a96d7823Smrg# platform-specific function to extract the name of the 4998a96d7823Smrg# DLL associated with the specified import library LIBNAME. 4999a96d7823Smrg# 5000a96d7823Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5001a96d7823Smrg# on the platform and compiler that created the implib. 5002a96d7823Smrg# 5003a96d7823Smrg# Echos the name of the DLL associated with the 5004a96d7823Smrg# specified import library. 5005a96d7823Smrgfunc_cygming_dll_for_implib_fallback_core () 5006a96d7823Smrg{ 5007fd60135fSmrg $debug_cmd 5008fd60135fSmrg 5009a96d7823Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5010a96d7823Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5011a96d7823Smrg $SED '/^Contents of section '"$match_literal"':/{ 5012a96d7823Smrg # Place marker at beginning of archive member dllname section 5013a96d7823Smrg s/.*/====MARK====/ 5014a96d7823Smrg p 5015a96d7823Smrg d 5016a96d7823Smrg } 5017a96d7823Smrg # These lines can sometimes be longer than 43 characters, but 5018a96d7823Smrg # are always uninteresting 5019a96d7823Smrg /:[ ]*file format pe[i]\{,1\}-/d 5020a96d7823Smrg /^In archive [^:]*:/d 5021a96d7823Smrg # Ensure marker is printed 5022a96d7823Smrg /^====MARK====/p 5023a96d7823Smrg # Remove all lines with less than 43 characters 5024a96d7823Smrg /^.\{43\}/!d 5025a96d7823Smrg # From remaining lines, remove first 43 characters 5026a96d7823Smrg s/^.\{43\}//' | 5027a96d7823Smrg $SED -n ' 5028a96d7823Smrg # Join marker and all lines until next marker into a single line 5029a96d7823Smrg /^====MARK====/ b para 5030a96d7823Smrg H 5031a96d7823Smrg $ b para 5032a96d7823Smrg b 5033a96d7823Smrg :para 5034a96d7823Smrg x 5035a96d7823Smrg s/\n//g 5036a96d7823Smrg # Remove the marker 5037a96d7823Smrg s/^====MARK====// 5038a96d7823Smrg # Remove trailing dots and whitespace 5039a96d7823Smrg s/[\. \t]*$// 5040a96d7823Smrg # Print 5041a96d7823Smrg /./p' | 5042a96d7823Smrg # we now have a list, one entry per line, of the stringified 5043a96d7823Smrg # contents of the appropriate section of all members of the 5044fd60135fSmrg # archive that possess that section. Heuristic: eliminate 5045fd60135fSmrg # all those that have a first or second character that is 5046a96d7823Smrg # a '.' (that is, objdump's representation of an unprintable 5047a96d7823Smrg # character.) This should work for all archives with less than 5048a96d7823Smrg # 0x302f exports -- but will fail for DLLs whose name actually 5049a96d7823Smrg # begins with a literal '.' or a single character followed by 5050a96d7823Smrg # a '.'. 5051a96d7823Smrg # 5052a96d7823Smrg # Of those that remain, print the first one. 5053a96d7823Smrg $SED -e '/^\./d;/^.\./d;q' 5054a96d7823Smrg} 5055a96d7823Smrg 5056a96d7823Smrg# func_cygming_dll_for_implib_fallback ARG 5057a96d7823Smrg# Platform-specific function to extract the 5058a96d7823Smrg# name of the DLL associated with the specified 5059a96d7823Smrg# import library ARG. 5060a96d7823Smrg# 5061a96d7823Smrg# This fallback implementation is for use when $DLLTOOL 5062a96d7823Smrg# does not support the --identify-strict option. 5063a96d7823Smrg# Invoked by eval'ing the libtool variable 5064a96d7823Smrg# $sharedlib_from_linklib_cmd 5065a96d7823Smrg# Result is available in the variable 5066a96d7823Smrg# $sharedlib_from_linklib_result 5067a96d7823Smrgfunc_cygming_dll_for_implib_fallback () 5068a96d7823Smrg{ 5069fd60135fSmrg $debug_cmd 5070fd60135fSmrg 5071fd60135fSmrg if func_cygming_gnu_implib_p "$1"; then 5072a96d7823Smrg # binutils import library 5073a96d7823Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5074fd60135fSmrg elif func_cygming_ms_implib_p "$1"; then 5075a96d7823Smrg # ms-generated import library 5076a96d7823Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5077a96d7823Smrg else 5078a96d7823Smrg # unknown 5079fd60135fSmrg sharedlib_from_linklib_result= 5080a96d7823Smrg fi 5081a96d7823Smrg} 5082a96d7823Smrg 5083a96d7823Smrg 5084a96d7823Smrg# func_extract_an_archive dir oldlib 5085a96d7823Smrgfunc_extract_an_archive () 5086a96d7823Smrg{ 5087fd60135fSmrg $debug_cmd 5088fd60135fSmrg 5089fd60135fSmrg f_ex_an_ar_dir=$1; shift 5090fd60135fSmrg f_ex_an_ar_oldlib=$1 5091fd60135fSmrg if test yes = "$lock_old_archive_extraction"; then 5092a96d7823Smrg lockfile=$f_ex_an_ar_oldlib.lock 5093a96d7823Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5094a96d7823Smrg func_echo "Waiting for $lockfile to be removed" 5095a96d7823Smrg sleep 2 5096a96d7823Smrg done 5097a96d7823Smrg fi 5098a96d7823Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5099a96d7823Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5100fd60135fSmrg if test yes = "$lock_old_archive_extraction"; then 5101a96d7823Smrg $opt_dry_run || rm -f "$lockfile" 5102a96d7823Smrg fi 5103a96d7823Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5104a96d7823Smrg : 5105a96d7823Smrg else 5106a96d7823Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5107a96d7823Smrg fi 5108a96d7823Smrg} 5109a96d7823Smrg 5110a96d7823Smrg 5111a96d7823Smrg# func_extract_archives gentop oldlib ... 5112a96d7823Smrgfunc_extract_archives () 5113a96d7823Smrg{ 5114fd60135fSmrg $debug_cmd 5115fd60135fSmrg 5116fd60135fSmrg my_gentop=$1; shift 5117a96d7823Smrg my_oldlibs=${1+"$@"} 5118fd60135fSmrg my_oldobjs= 5119fd60135fSmrg my_xlib= 5120fd60135fSmrg my_xabs= 5121fd60135fSmrg my_xdir= 5122a96d7823Smrg 5123a96d7823Smrg for my_xlib in $my_oldlibs; do 5124a96d7823Smrg # Extract the objects. 5125a96d7823Smrg case $my_xlib in 5126fd60135fSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5127a96d7823Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5128a96d7823Smrg esac 5129a96d7823Smrg func_basename "$my_xlib" 5130fd60135fSmrg my_xlib=$func_basename_result 5131a96d7823Smrg my_xlib_u=$my_xlib 5132a96d7823Smrg while :; do 5133a96d7823Smrg case " $extracted_archives " in 5134a96d7823Smrg *" $my_xlib_u "*) 5135a96d7823Smrg func_arith $extracted_serial + 1 5136a96d7823Smrg extracted_serial=$func_arith_result 5137a96d7823Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5138a96d7823Smrg *) break ;; 5139a96d7823Smrg esac 5140a96d7823Smrg done 5141a96d7823Smrg extracted_archives="$extracted_archives $my_xlib_u" 5142fd60135fSmrg my_xdir=$my_gentop/$my_xlib_u 5143a96d7823Smrg 5144a96d7823Smrg func_mkdir_p "$my_xdir" 5145a96d7823Smrg 5146a96d7823Smrg case $host in 5147a96d7823Smrg *-darwin*) 5148a96d7823Smrg func_verbose "Extracting $my_xabs" 5149a96d7823Smrg # Do not bother doing anything if just a dry run 5150a96d7823Smrg $opt_dry_run || { 5151a96d7823Smrg darwin_orig_dir=`pwd` 5152a96d7823Smrg cd $my_xdir || exit $? 5153a96d7823Smrg darwin_archive=$my_xabs 5154a96d7823Smrg darwin_curdir=`pwd` 5155fd60135fSmrg func_basename "$darwin_archive" 5156fd60135fSmrg darwin_base_archive=$func_basename_result 5157a96d7823Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5158a96d7823Smrg if test -n "$darwin_arches"; then 5159a96d7823Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5160a96d7823Smrg darwin_arch= 5161a96d7823Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5162fd60135fSmrg for darwin_arch in $darwin_arches; do 5163fd60135fSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5164fd60135fSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5165fd60135fSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5166fd60135fSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5167a96d7823Smrg cd "$darwin_curdir" 5168fd60135fSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5169a96d7823Smrg done # $darwin_arches 5170a96d7823Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5171fd60135fSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5172a96d7823Smrg darwin_file= 5173a96d7823Smrg darwin_files= 5174a96d7823Smrg for darwin_file in $darwin_filelist; do 5175a96d7823Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5176a96d7823Smrg $LIPO -create -output "$darwin_file" $darwin_files 5177a96d7823Smrg done # $darwin_filelist 5178a96d7823Smrg $RM -rf unfat-$$ 5179a96d7823Smrg cd "$darwin_orig_dir" 5180a96d7823Smrg else 5181a96d7823Smrg cd $darwin_orig_dir 5182a96d7823Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5183a96d7823Smrg fi # $darwin_arches 5184a96d7823Smrg } # !$opt_dry_run 5185a96d7823Smrg ;; 5186a96d7823Smrg *) 5187a96d7823Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5188a96d7823Smrg ;; 5189a96d7823Smrg esac 5190a96d7823Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5191a96d7823Smrg done 5192a96d7823Smrg 5193fd60135fSmrg func_extract_archives_result=$my_oldobjs 5194a96d7823Smrg} 5195a96d7823Smrg 5196a96d7823Smrg 5197a96d7823Smrg# func_emit_wrapper [arg=no] 5198a96d7823Smrg# 5199a96d7823Smrg# Emit a libtool wrapper script on stdout. 5200a96d7823Smrg# Don't directly open a file because we may want to 5201a96d7823Smrg# incorporate the script contents within a cygwin/mingw 5202a96d7823Smrg# wrapper executable. Must ONLY be called from within 5203a96d7823Smrg# func_mode_link because it depends on a number of variables 5204a96d7823Smrg# set therein. 5205a96d7823Smrg# 5206a96d7823Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5207a96d7823Smrg# variable will take. If 'yes', then the emitted script 5208fd60135fSmrg# will assume that the directory where it is stored is 5209a96d7823Smrg# the $objdir directory. This is a cygwin/mingw-specific 5210a96d7823Smrg# behavior. 5211a96d7823Smrgfunc_emit_wrapper () 5212a96d7823Smrg{ 5213a96d7823Smrg func_emit_wrapper_arg1=${1-no} 5214a96d7823Smrg 5215a96d7823Smrg $ECHO "\ 5216a96d7823Smrg#! $SHELL 5217a96d7823Smrg 5218a96d7823Smrg# $output - temporary wrapper script for $objdir/$outputname 5219fd60135fSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5220a96d7823Smrg# 5221a96d7823Smrg# The $output program cannot be directly executed until all the libtool 5222a96d7823Smrg# libraries that it depends on are installed. 5223a96d7823Smrg# 5224a96d7823Smrg# This wrapper script should never be moved out of the build directory. 5225a96d7823Smrg# If it is, it will not operate correctly. 5226a96d7823Smrg 5227a96d7823Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5228a96d7823Smrg# metacharacters that are still active within double-quoted strings. 5229a96d7823Smrgsed_quote_subst='$sed_quote_subst' 5230a96d7823Smrg 5231a96d7823Smrg# Be Bourne compatible 5232a96d7823Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5233a96d7823Smrg emulate sh 5234a96d7823Smrg NULLCMD=: 5235a96d7823Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5236a96d7823Smrg # is contrary to our usage. Disable this feature. 5237a96d7823Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5238a96d7823Smrg setopt NO_GLOB_SUBST 5239a96d7823Smrgelse 5240a96d7823Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5241a96d7823Smrgfi 5242a96d7823SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5243a96d7823SmrgDUALCASE=1; export DUALCASE # for MKS sh 5244a96d7823Smrg 5245a96d7823Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5246a96d7823Smrg# if CDPATH is set. 5247a96d7823Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5248a96d7823Smrg 5249a96d7823Smrgrelink_command=\"$relink_command\" 5250a96d7823Smrg 5251a96d7823Smrg# This environment variable determines our operation mode. 5252a96d7823Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5253a96d7823Smrg # install mode needs the following variables: 5254a96d7823Smrg generated_by_libtool_version='$macro_version' 5255a96d7823Smrg notinst_deplibs='$notinst_deplibs' 5256a96d7823Smrgelse 5257a96d7823Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5258a96d7823Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5259a96d7823Smrg file=\"\$0\"" 5260a96d7823Smrg 5261a96d7823Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 5262a96d7823Smrg $ECHO "\ 5263a96d7823Smrg 5264a96d7823Smrg# A function that is used when there is no print builtin or printf. 5265a96d7823Smrgfunc_fallback_echo () 5266a96d7823Smrg{ 5267a96d7823Smrg eval 'cat <<_LTECHO_EOF 5268a96d7823Smrg\$1 5269a96d7823Smrg_LTECHO_EOF' 5270a96d7823Smrg} 5271a96d7823Smrg ECHO=\"$qECHO\" 5272a96d7823Smrg fi 5273a96d7823Smrg 5274a96d7823Smrg# Very basic option parsing. These options are (a) specific to 5275a96d7823Smrg# the libtool wrapper, (b) are identical between the wrapper 5276fd60135fSmrg# /script/ and the wrapper /executable/ that is used only on 5277a96d7823Smrg# windows platforms, and (c) all begin with the string "--lt-" 5278fd60135fSmrg# (application programs are unlikely to have options that match 5279a96d7823Smrg# this pattern). 5280a96d7823Smrg# 5281a96d7823Smrg# There are only two supported options: --lt-debug and 5282a96d7823Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 5283a96d7823Smrg# 5284a96d7823Smrg# The first argument to this parsing function should be the 5285a96d7823Smrg# script's $0 value, followed by "$@". 5286a96d7823Smrglt_option_debug= 5287a96d7823Smrgfunc_parse_lt_options () 5288a96d7823Smrg{ 5289a96d7823Smrg lt_script_arg0=\$0 5290a96d7823Smrg shift 5291a96d7823Smrg for lt_opt 5292a96d7823Smrg do 5293a96d7823Smrg case \"\$lt_opt\" in 5294a96d7823Smrg --lt-debug) lt_option_debug=1 ;; 5295a96d7823Smrg --lt-dump-script) 5296a96d7823Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5297a96d7823Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5298a96d7823Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5299a96d7823Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 5300a96d7823Smrg exit 0 5301a96d7823Smrg ;; 5302a96d7823Smrg --lt-*) 5303a96d7823Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5304a96d7823Smrg exit 1 5305a96d7823Smrg ;; 5306a96d7823Smrg esac 5307a96d7823Smrg done 5308a96d7823Smrg 5309a96d7823Smrg # Print the debug banner immediately: 5310a96d7823Smrg if test -n \"\$lt_option_debug\"; then 5311fd60135fSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5312a96d7823Smrg fi 5313a96d7823Smrg} 5314a96d7823Smrg 5315a96d7823Smrg# Used when --lt-debug. Prints its arguments to stdout 5316a96d7823Smrg# (redirection is the responsibility of the caller) 5317a96d7823Smrgfunc_lt_dump_args () 5318a96d7823Smrg{ 5319a96d7823Smrg lt_dump_args_N=1; 5320a96d7823Smrg for lt_arg 5321a96d7823Smrg do 5322fd60135fSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5323a96d7823Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5324a96d7823Smrg done 5325a96d7823Smrg} 5326a96d7823Smrg 5327a96d7823Smrg# Core function for launching the target application 5328a96d7823Smrgfunc_exec_program_core () 5329a96d7823Smrg{ 5330a96d7823Smrg" 5331a96d7823Smrg case $host in 5332a96d7823Smrg # Backslashes separate directories on plain windows 5333a96d7823Smrg *-*-mingw | *-*-os2* | *-cegcc*) 5334a96d7823Smrg $ECHO "\ 5335a96d7823Smrg if test -n \"\$lt_option_debug\"; then 5336fd60135fSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5337a96d7823Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5338a96d7823Smrg fi 5339a96d7823Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5340a96d7823Smrg" 5341a96d7823Smrg ;; 5342a96d7823Smrg 5343a96d7823Smrg *) 5344a96d7823Smrg $ECHO "\ 5345a96d7823Smrg if test -n \"\$lt_option_debug\"; then 5346fd60135fSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5347a96d7823Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5348a96d7823Smrg fi 5349a96d7823Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5350a96d7823Smrg" 5351a96d7823Smrg ;; 5352a96d7823Smrg esac 5353a96d7823Smrg $ECHO "\ 5354a96d7823Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5355a96d7823Smrg exit 1 5356a96d7823Smrg} 5357a96d7823Smrg 5358a96d7823Smrg# A function to encapsulate launching the target application 5359a96d7823Smrg# Strips options in the --lt-* namespace from \$@ and 5360a96d7823Smrg# launches target application with the remaining arguments. 5361a96d7823Smrgfunc_exec_program () 5362a96d7823Smrg{ 5363a96d7823Smrg case \" \$* \" in 5364a96d7823Smrg *\\ --lt-*) 5365a96d7823Smrg for lt_wr_arg 5366a96d7823Smrg do 5367a96d7823Smrg case \$lt_wr_arg in 5368a96d7823Smrg --lt-*) ;; 5369a96d7823Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5370a96d7823Smrg esac 5371a96d7823Smrg shift 5372a96d7823Smrg done ;; 5373a96d7823Smrg esac 5374a96d7823Smrg func_exec_program_core \${1+\"\$@\"} 5375a96d7823Smrg} 5376a96d7823Smrg 5377a96d7823Smrg # Parse options 5378a96d7823Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5379a96d7823Smrg 5380a96d7823Smrg # Find the directory that this script lives in. 5381a96d7823Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5382a96d7823Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5383a96d7823Smrg 5384a96d7823Smrg # Follow symbolic links until we get to the real thisdir. 5385a96d7823Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5386a96d7823Smrg while test -n \"\$file\"; do 5387a96d7823Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5388a96d7823Smrg 5389a96d7823Smrg # If there was a directory component, then change thisdir. 5390a96d7823Smrg if test \"x\$destdir\" != \"x\$file\"; then 5391a96d7823Smrg case \"\$destdir\" in 5392a96d7823Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5393a96d7823Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5394a96d7823Smrg esac 5395a96d7823Smrg fi 5396a96d7823Smrg 5397a96d7823Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5398a96d7823Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5399a96d7823Smrg done 5400a96d7823Smrg 5401a96d7823Smrg # Usually 'no', except on cygwin/mingw when embedded into 5402a96d7823Smrg # the cwrapper. 5403a96d7823Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5404a96d7823Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5405a96d7823Smrg # special case for '.' 5406a96d7823Smrg if test \"\$thisdir\" = \".\"; then 5407a96d7823Smrg thisdir=\`pwd\` 5408a96d7823Smrg fi 5409a96d7823Smrg # remove .libs from thisdir 5410a96d7823Smrg case \"\$thisdir\" in 5411a96d7823Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5412a96d7823Smrg $objdir ) thisdir=. ;; 5413a96d7823Smrg esac 5414a96d7823Smrg fi 5415a96d7823Smrg 5416a96d7823Smrg # Try to get the absolute directory name. 5417a96d7823Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5418a96d7823Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5419a96d7823Smrg" 5420a96d7823Smrg 5421fd60135fSmrg if test yes = "$fast_install"; then 5422a96d7823Smrg $ECHO "\ 5423a96d7823Smrg program=lt-'$outputname'$exeext 5424a96d7823Smrg progdir=\"\$thisdir/$objdir\" 5425a96d7823Smrg 5426a96d7823Smrg if test ! -f \"\$progdir/\$program\" || 5427fd60135fSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5428a96d7823Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5429a96d7823Smrg 5430a96d7823Smrg file=\"\$\$-\$program\" 5431a96d7823Smrg 5432a96d7823Smrg if test ! -d \"\$progdir\"; then 5433a96d7823Smrg $MKDIR \"\$progdir\" 5434a96d7823Smrg else 5435a96d7823Smrg $RM \"\$progdir/\$file\" 5436a96d7823Smrg fi" 5437a96d7823Smrg 5438a96d7823Smrg $ECHO "\ 5439a96d7823Smrg 5440a96d7823Smrg # relink executable if necessary 5441a96d7823Smrg if test -n \"\$relink_command\"; then 5442a96d7823Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5443a96d7823Smrg else 5444fd60135fSmrg \$ECHO \"\$relink_command_output\" >&2 5445a96d7823Smrg $RM \"\$progdir/\$file\" 5446a96d7823Smrg exit 1 5447a96d7823Smrg fi 5448a96d7823Smrg fi 5449a96d7823Smrg 5450a96d7823Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5451a96d7823Smrg { $RM \"\$progdir/\$program\"; 5452a96d7823Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5453a96d7823Smrg $RM \"\$progdir/\$file\" 5454a96d7823Smrg fi" 5455a96d7823Smrg else 5456a96d7823Smrg $ECHO "\ 5457a96d7823Smrg program='$outputname' 5458a96d7823Smrg progdir=\"\$thisdir/$objdir\" 5459a96d7823Smrg" 5460a96d7823Smrg fi 5461a96d7823Smrg 5462a96d7823Smrg $ECHO "\ 5463a96d7823Smrg 5464a96d7823Smrg if test -f \"\$progdir/\$program\"; then" 5465a96d7823Smrg 5466a96d7823Smrg # fixup the dll searchpath if we need to. 5467a96d7823Smrg # 5468a96d7823Smrg # Fix the DLL searchpath if we need to. Do this before prepending 5469a96d7823Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 5470a96d7823Smrg # libraries must come first. 5471a96d7823Smrg if test -n "$dllsearchpath"; then 5472a96d7823Smrg $ECHO "\ 5473a96d7823Smrg # Add the dll search path components to the executable PATH 5474a96d7823Smrg PATH=$dllsearchpath:\$PATH 5475a96d7823Smrg" 5476a96d7823Smrg fi 5477a96d7823Smrg 5478a96d7823Smrg # Export our shlibpath_var if we have one. 5479fd60135fSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5480a96d7823Smrg $ECHO "\ 5481a96d7823Smrg # Add our own library path to $shlibpath_var 5482a96d7823Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5483a96d7823Smrg 5484a96d7823Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5485a96d7823Smrg # The second colon is a workaround for a bug in BeOS R4 sed 5486a96d7823Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5487a96d7823Smrg 5488a96d7823Smrg export $shlibpath_var 5489a96d7823Smrg" 5490a96d7823Smrg fi 5491a96d7823Smrg 5492a96d7823Smrg $ECHO "\ 5493a96d7823Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5494a96d7823Smrg # Run the actual program with our arguments. 5495a96d7823Smrg func_exec_program \${1+\"\$@\"} 5496a96d7823Smrg fi 5497a96d7823Smrg else 5498a96d7823Smrg # The program doesn't exist. 5499fd60135fSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5500a96d7823Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5501a96d7823Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5502a96d7823Smrg exit 1 5503a96d7823Smrg fi 5504a96d7823Smrgfi\ 5505a96d7823Smrg" 5506a96d7823Smrg} 5507a96d7823Smrg 5508a96d7823Smrg 5509a96d7823Smrg# func_emit_cwrapperexe_src 5510a96d7823Smrg# emit the source code for a wrapper executable on stdout 5511a96d7823Smrg# Must ONLY be called from within func_mode_link because 5512a96d7823Smrg# it depends on a number of variable set therein. 5513a96d7823Smrgfunc_emit_cwrapperexe_src () 5514a96d7823Smrg{ 5515a96d7823Smrg cat <<EOF 5516a96d7823Smrg 5517a96d7823Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5518fd60135fSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5519a96d7823Smrg 5520a96d7823Smrg The $output program cannot be directly executed until all the libtool 5521a96d7823Smrg libraries that it depends on are installed. 5522a96d7823Smrg 5523a96d7823Smrg This wrapper executable should never be moved out of the build directory. 5524a96d7823Smrg If it is, it will not operate correctly. 5525a96d7823Smrg*/ 5526a96d7823SmrgEOF 5527a96d7823Smrg cat <<"EOF" 5528a96d7823Smrg#ifdef _MSC_VER 5529a96d7823Smrg# define _CRT_SECURE_NO_DEPRECATE 1 5530a96d7823Smrg#endif 5531a96d7823Smrg#include <stdio.h> 5532a96d7823Smrg#include <stdlib.h> 5533a96d7823Smrg#ifdef _MSC_VER 5534a96d7823Smrg# include <direct.h> 5535a96d7823Smrg# include <process.h> 5536a96d7823Smrg# include <io.h> 5537a96d7823Smrg#else 5538a96d7823Smrg# include <unistd.h> 5539a96d7823Smrg# include <stdint.h> 5540a96d7823Smrg# ifdef __CYGWIN__ 5541a96d7823Smrg# include <io.h> 5542a96d7823Smrg# endif 5543a96d7823Smrg#endif 5544a96d7823Smrg#include <malloc.h> 5545a96d7823Smrg#include <stdarg.h> 5546a96d7823Smrg#include <assert.h> 5547a96d7823Smrg#include <string.h> 5548a96d7823Smrg#include <ctype.h> 5549a96d7823Smrg#include <errno.h> 5550a96d7823Smrg#include <fcntl.h> 5551a96d7823Smrg#include <sys/stat.h> 5552a96d7823Smrg 5553fd60135fSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5554fd60135fSmrg 5555a96d7823Smrg/* declarations of non-ANSI functions */ 5556fd60135fSmrg#if defined __MINGW32__ 5557a96d7823Smrg# ifdef __STRICT_ANSI__ 5558a96d7823Smrgint _putenv (const char *); 5559a96d7823Smrg# endif 5560fd60135fSmrg#elif defined __CYGWIN__ 5561a96d7823Smrg# ifdef __STRICT_ANSI__ 5562a96d7823Smrgchar *realpath (const char *, char *); 5563a96d7823Smrgint putenv (char *); 5564a96d7823Smrgint setenv (const char *, const char *, int); 5565a96d7823Smrg# endif 5566fd60135fSmrg/* #elif defined other_platform || defined ... */ 5567a96d7823Smrg#endif 5568a96d7823Smrg 5569a96d7823Smrg/* portability defines, excluding path handling macros */ 5570fd60135fSmrg#if defined _MSC_VER 5571a96d7823Smrg# define setmode _setmode 5572a96d7823Smrg# define stat _stat 5573a96d7823Smrg# define chmod _chmod 5574a96d7823Smrg# define getcwd _getcwd 5575a96d7823Smrg# define putenv _putenv 5576a96d7823Smrg# define S_IXUSR _S_IEXEC 5577fd60135fSmrg#elif defined __MINGW32__ 5578a96d7823Smrg# define setmode _setmode 5579a96d7823Smrg# define stat _stat 5580a96d7823Smrg# define chmod _chmod 5581a96d7823Smrg# define getcwd _getcwd 5582a96d7823Smrg# define putenv _putenv 5583fd60135fSmrg#elif defined __CYGWIN__ 5584a96d7823Smrg# define HAVE_SETENV 5585a96d7823Smrg# define FOPEN_WB "wb" 5586fd60135fSmrg/* #elif defined other platforms ... */ 5587a96d7823Smrg#endif 5588a96d7823Smrg 5589fd60135fSmrg#if defined PATH_MAX 5590a96d7823Smrg# define LT_PATHMAX PATH_MAX 5591fd60135fSmrg#elif defined MAXPATHLEN 5592a96d7823Smrg# define LT_PATHMAX MAXPATHLEN 5593a96d7823Smrg#else 5594a96d7823Smrg# define LT_PATHMAX 1024 5595a96d7823Smrg#endif 5596a96d7823Smrg 5597a96d7823Smrg#ifndef S_IXOTH 5598a96d7823Smrg# define S_IXOTH 0 5599a96d7823Smrg#endif 5600a96d7823Smrg#ifndef S_IXGRP 5601a96d7823Smrg# define S_IXGRP 0 5602a96d7823Smrg#endif 5603a96d7823Smrg 5604a96d7823Smrg/* path handling portability macros */ 5605a96d7823Smrg#ifndef DIR_SEPARATOR 5606a96d7823Smrg# define DIR_SEPARATOR '/' 5607a96d7823Smrg# define PATH_SEPARATOR ':' 5608a96d7823Smrg#endif 5609a96d7823Smrg 5610fd60135fSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5611fd60135fSmrg defined __OS2__ 5612a96d7823Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 5613a96d7823Smrg# define FOPEN_WB "wb" 5614a96d7823Smrg# ifndef DIR_SEPARATOR_2 5615a96d7823Smrg# define DIR_SEPARATOR_2 '\\' 5616a96d7823Smrg# endif 5617a96d7823Smrg# ifndef PATH_SEPARATOR_2 5618a96d7823Smrg# define PATH_SEPARATOR_2 ';' 5619a96d7823Smrg# endif 5620a96d7823Smrg#endif 5621a96d7823Smrg 5622a96d7823Smrg#ifndef DIR_SEPARATOR_2 5623a96d7823Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5624a96d7823Smrg#else /* DIR_SEPARATOR_2 */ 5625a96d7823Smrg# define IS_DIR_SEPARATOR(ch) \ 5626a96d7823Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5627a96d7823Smrg#endif /* DIR_SEPARATOR_2 */ 5628a96d7823Smrg 5629a96d7823Smrg#ifndef PATH_SEPARATOR_2 5630a96d7823Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5631a96d7823Smrg#else /* PATH_SEPARATOR_2 */ 5632a96d7823Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5633a96d7823Smrg#endif /* PATH_SEPARATOR_2 */ 5634a96d7823Smrg 5635a96d7823Smrg#ifndef FOPEN_WB 5636a96d7823Smrg# define FOPEN_WB "w" 5637a96d7823Smrg#endif 5638a96d7823Smrg#ifndef _O_BINARY 5639a96d7823Smrg# define _O_BINARY 0 5640a96d7823Smrg#endif 5641a96d7823Smrg 5642a96d7823Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5643a96d7823Smrg#define XFREE(stale) do { \ 5644fd60135fSmrg if (stale) { free (stale); stale = 0; } \ 5645a96d7823Smrg} while (0) 5646a96d7823Smrg 5647fd60135fSmrg#if defined LT_DEBUGWRAPPER 5648a96d7823Smrgstatic int lt_debug = 1; 5649a96d7823Smrg#else 5650a96d7823Smrgstatic int lt_debug = 0; 5651a96d7823Smrg#endif 5652a96d7823Smrg 5653a96d7823Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5654a96d7823Smrg 5655a96d7823Smrgvoid *xmalloc (size_t num); 5656a96d7823Smrgchar *xstrdup (const char *string); 5657a96d7823Smrgconst char *base_name (const char *name); 5658a96d7823Smrgchar *find_executable (const char *wrapper); 5659a96d7823Smrgchar *chase_symlinks (const char *pathspec); 5660a96d7823Smrgint make_executable (const char *path); 5661a96d7823Smrgint check_executable (const char *path); 5662a96d7823Smrgchar *strendzap (char *str, const char *pat); 5663a96d7823Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5664a96d7823Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5665a96d7823Smrgstatic const char *nonnull (const char *s); 5666a96d7823Smrgstatic const char *nonempty (const char *s); 5667a96d7823Smrgvoid lt_setenv (const char *name, const char *value); 5668a96d7823Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5669a96d7823Smrgvoid lt_update_exe_path (const char *name, const char *value); 5670a96d7823Smrgvoid lt_update_lib_path (const char *name, const char *value); 5671a96d7823Smrgchar **prepare_spawn (char **argv); 5672a96d7823Smrgvoid lt_dump_script (FILE *f); 5673a96d7823SmrgEOF 5674a96d7823Smrg 5675a96d7823Smrg cat <<EOF 5676fd60135fSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5677fd60135fSmrg# define externally_visible volatile 5678fd60135fSmrg#else 5679fd60135fSmrg# define externally_visible __attribute__((externally_visible)) volatile 5680fd60135fSmrg#endif 5681fd60135fSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5682a96d7823Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5683a96d7823SmrgEOF 5684a96d7823Smrg 5685fd60135fSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5686a96d7823Smrg func_to_host_path "$temp_rpath" 5687a96d7823Smrg cat <<EOF 5688a96d7823Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5689a96d7823SmrgEOF 5690a96d7823Smrg else 5691a96d7823Smrg cat <<"EOF" 5692a96d7823Smrgconst char * LIB_PATH_VALUE = ""; 5693a96d7823SmrgEOF 5694a96d7823Smrg fi 5695a96d7823Smrg 5696a96d7823Smrg if test -n "$dllsearchpath"; then 5697a96d7823Smrg func_to_host_path "$dllsearchpath:" 5698a96d7823Smrg cat <<EOF 5699a96d7823Smrgconst char * EXE_PATH_VARNAME = "PATH"; 5700a96d7823Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5701a96d7823SmrgEOF 5702a96d7823Smrg else 5703a96d7823Smrg cat <<"EOF" 5704a96d7823Smrgconst char * EXE_PATH_VARNAME = ""; 5705a96d7823Smrgconst char * EXE_PATH_VALUE = ""; 5706a96d7823SmrgEOF 5707a96d7823Smrg fi 5708a96d7823Smrg 5709fd60135fSmrg if test yes = "$fast_install"; then 5710a96d7823Smrg cat <<EOF 5711a96d7823Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5712a96d7823SmrgEOF 5713a96d7823Smrg else 5714a96d7823Smrg cat <<EOF 5715a96d7823Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5716a96d7823SmrgEOF 5717a96d7823Smrg fi 5718a96d7823Smrg 5719a96d7823Smrg 5720a96d7823Smrg cat <<"EOF" 5721a96d7823Smrg 5722a96d7823Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5723a96d7823Smrg 5724a96d7823Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5725a96d7823Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5726a96d7823Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5727a96d7823Smrg 5728a96d7823Smrgint 5729a96d7823Smrgmain (int argc, char *argv[]) 5730a96d7823Smrg{ 5731a96d7823Smrg char **newargz; 5732a96d7823Smrg int newargc; 5733a96d7823Smrg char *tmp_pathspec; 5734a96d7823Smrg char *actual_cwrapper_path; 5735a96d7823Smrg char *actual_cwrapper_name; 5736a96d7823Smrg char *target_name; 5737a96d7823Smrg char *lt_argv_zero; 5738fd60135fSmrg int rval = 127; 5739a96d7823Smrg 5740a96d7823Smrg int i; 5741a96d7823Smrg 5742a96d7823Smrg program_name = (char *) xstrdup (base_name (argv[0])); 5743fd60135fSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 5744a96d7823Smrg 5745a96d7823Smrg /* very simple arg parsing; don't want to rely on getopt 5746a96d7823Smrg * also, copy all non cwrapper options to newargz, except 5747a96d7823Smrg * argz[0], which is handled differently 5748a96d7823Smrg */ 5749a96d7823Smrg newargc=0; 5750a96d7823Smrg for (i = 1; i < argc; i++) 5751a96d7823Smrg { 5752fd60135fSmrg if (STREQ (argv[i], dumpscript_opt)) 5753a96d7823Smrg { 5754a96d7823SmrgEOF 5755fd60135fSmrg case $host in 5756a96d7823Smrg *mingw* | *cygwin* ) 5757a96d7823Smrg # make stdout use "unix" line endings 5758a96d7823Smrg echo " setmode(1,_O_BINARY);" 5759a96d7823Smrg ;; 5760a96d7823Smrg esac 5761a96d7823Smrg 5762a96d7823Smrg cat <<"EOF" 5763a96d7823Smrg lt_dump_script (stdout); 5764a96d7823Smrg return 0; 5765a96d7823Smrg } 5766fd60135fSmrg if (STREQ (argv[i], debug_opt)) 5767a96d7823Smrg { 5768a96d7823Smrg lt_debug = 1; 5769a96d7823Smrg continue; 5770a96d7823Smrg } 5771fd60135fSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 5772a96d7823Smrg { 5773a96d7823Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 5774a96d7823Smrg namespace, but it is not one of the ones we know about and 5775a96d7823Smrg have already dealt with, above (inluding dump-script), then 5776a96d7823Smrg report an error. Otherwise, targets might begin to believe 5777a96d7823Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 5778a96d7823Smrg namespace. The first time any user complains about this, we'll 5779a96d7823Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 5780a96d7823Smrg or a configure.ac-settable value. 5781a96d7823Smrg */ 5782a96d7823Smrg lt_fatal (__FILE__, __LINE__, 5783a96d7823Smrg "unrecognized %s option: '%s'", 5784a96d7823Smrg ltwrapper_option_prefix, argv[i]); 5785a96d7823Smrg } 5786a96d7823Smrg /* otherwise ... */ 5787a96d7823Smrg newargz[++newargc] = xstrdup (argv[i]); 5788a96d7823Smrg } 5789a96d7823Smrg newargz[++newargc] = NULL; 5790a96d7823Smrg 5791a96d7823SmrgEOF 5792a96d7823Smrg cat <<EOF 5793a96d7823Smrg /* The GNU banner must be the first non-error debug message */ 5794fd60135fSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 5795a96d7823SmrgEOF 5796a96d7823Smrg cat <<"EOF" 5797a96d7823Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 5798a96d7823Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 5799a96d7823Smrg 5800a96d7823Smrg tmp_pathspec = find_executable (argv[0]); 5801a96d7823Smrg if (tmp_pathspec == NULL) 5802a96d7823Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 5803a96d7823Smrg lt_debugprintf (__FILE__, __LINE__, 5804a96d7823Smrg "(main) found exe (before symlink chase) at: %s\n", 5805a96d7823Smrg tmp_pathspec); 5806a96d7823Smrg 5807a96d7823Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 5808a96d7823Smrg lt_debugprintf (__FILE__, __LINE__, 5809a96d7823Smrg "(main) found exe (after symlink chase) at: %s\n", 5810a96d7823Smrg actual_cwrapper_path); 5811a96d7823Smrg XFREE (tmp_pathspec); 5812a96d7823Smrg 5813a96d7823Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5814a96d7823Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 5815a96d7823Smrg 5816a96d7823Smrg /* wrapper name transforms */ 5817a96d7823Smrg strendzap (actual_cwrapper_name, ".exe"); 5818a96d7823Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5819a96d7823Smrg XFREE (actual_cwrapper_name); 5820a96d7823Smrg actual_cwrapper_name = tmp_pathspec; 5821a96d7823Smrg tmp_pathspec = 0; 5822a96d7823Smrg 5823a96d7823Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 5824a96d7823Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5825a96d7823Smrg strendzap (target_name, ".exe"); 5826a96d7823Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5827a96d7823Smrg XFREE (target_name); 5828a96d7823Smrg target_name = tmp_pathspec; 5829a96d7823Smrg tmp_pathspec = 0; 5830a96d7823Smrg 5831a96d7823Smrg lt_debugprintf (__FILE__, __LINE__, 5832a96d7823Smrg "(main) libtool target name: %s\n", 5833a96d7823Smrg target_name); 5834a96d7823SmrgEOF 5835a96d7823Smrg 5836a96d7823Smrg cat <<EOF 5837a96d7823Smrg newargz[0] = 5838a96d7823Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 5839a96d7823Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5840a96d7823Smrg strcpy (newargz[0], actual_cwrapper_path); 5841a96d7823Smrg strcat (newargz[0], "$objdir"); 5842a96d7823Smrg strcat (newargz[0], "/"); 5843a96d7823SmrgEOF 5844a96d7823Smrg 5845a96d7823Smrg cat <<"EOF" 5846a96d7823Smrg /* stop here, and copy so we don't have to do this twice */ 5847a96d7823Smrg tmp_pathspec = xstrdup (newargz[0]); 5848a96d7823Smrg 5849a96d7823Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5850a96d7823Smrg strcat (newargz[0], actual_cwrapper_name); 5851a96d7823Smrg 5852a96d7823Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 5853a96d7823Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5854a96d7823Smrg XFREE (tmp_pathspec); 5855a96d7823Smrg tmp_pathspec = NULL; 5856a96d7823SmrgEOF 5857a96d7823Smrg 5858a96d7823Smrg case $host_os in 5859a96d7823Smrg mingw*) 5860a96d7823Smrg cat <<"EOF" 5861a96d7823Smrg { 5862a96d7823Smrg char* p; 5863a96d7823Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 5864a96d7823Smrg { 5865a96d7823Smrg *p = '/'; 5866a96d7823Smrg } 5867a96d7823Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5868a96d7823Smrg { 5869a96d7823Smrg *p = '/'; 5870a96d7823Smrg } 5871a96d7823Smrg } 5872a96d7823SmrgEOF 5873a96d7823Smrg ;; 5874a96d7823Smrg esac 5875a96d7823Smrg 5876a96d7823Smrg cat <<"EOF" 5877a96d7823Smrg XFREE (target_name); 5878a96d7823Smrg XFREE (actual_cwrapper_path); 5879a96d7823Smrg XFREE (actual_cwrapper_name); 5880a96d7823Smrg 5881a96d7823Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5882a96d7823Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 5883a96d7823Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 5884a96d7823Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 5885a96d7823Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 5886a96d7823Smrg libraries must come first. */ 5887a96d7823Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 5888a96d7823Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 5889a96d7823Smrg 5890a96d7823Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 5891a96d7823Smrg nonnull (lt_argv_zero)); 5892a96d7823Smrg for (i = 0; i < newargc; i++) 5893a96d7823Smrg { 5894a96d7823Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 5895a96d7823Smrg i, nonnull (newargz[i])); 5896a96d7823Smrg } 5897a96d7823Smrg 5898a96d7823SmrgEOF 5899a96d7823Smrg 5900a96d7823Smrg case $host_os in 5901a96d7823Smrg mingw*) 5902a96d7823Smrg cat <<"EOF" 5903a96d7823Smrg /* execv doesn't actually work on mingw as expected on unix */ 5904a96d7823Smrg newargz = prepare_spawn (newargz); 5905fd60135fSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5906a96d7823Smrg if (rval == -1) 5907a96d7823Smrg { 5908a96d7823Smrg /* failed to start process */ 5909a96d7823Smrg lt_debugprintf (__FILE__, __LINE__, 5910a96d7823Smrg "(main) failed to launch target \"%s\": %s\n", 5911a96d7823Smrg lt_argv_zero, nonnull (strerror (errno))); 5912a96d7823Smrg return 127; 5913a96d7823Smrg } 5914a96d7823Smrg return rval; 5915a96d7823SmrgEOF 5916a96d7823Smrg ;; 5917a96d7823Smrg *) 5918a96d7823Smrg cat <<"EOF" 5919a96d7823Smrg execv (lt_argv_zero, newargz); 5920a96d7823Smrg return rval; /* =127, but avoids unused variable warning */ 5921a96d7823SmrgEOF 5922a96d7823Smrg ;; 5923a96d7823Smrg esac 5924a96d7823Smrg 5925a96d7823Smrg cat <<"EOF" 5926a96d7823Smrg} 5927a96d7823Smrg 5928a96d7823Smrgvoid * 5929a96d7823Smrgxmalloc (size_t num) 5930a96d7823Smrg{ 5931a96d7823Smrg void *p = (void *) malloc (num); 5932a96d7823Smrg if (!p) 5933a96d7823Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5934a96d7823Smrg 5935a96d7823Smrg return p; 5936a96d7823Smrg} 5937a96d7823Smrg 5938a96d7823Smrgchar * 5939a96d7823Smrgxstrdup (const char *string) 5940a96d7823Smrg{ 5941a96d7823Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 5942a96d7823Smrg string) : NULL; 5943a96d7823Smrg} 5944a96d7823Smrg 5945a96d7823Smrgconst char * 5946a96d7823Smrgbase_name (const char *name) 5947a96d7823Smrg{ 5948a96d7823Smrg const char *base; 5949a96d7823Smrg 5950fd60135fSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 5951a96d7823Smrg /* Skip over the disk name in MSDOS pathnames. */ 5952a96d7823Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 5953a96d7823Smrg name += 2; 5954a96d7823Smrg#endif 5955a96d7823Smrg 5956a96d7823Smrg for (base = name; *name; name++) 5957a96d7823Smrg if (IS_DIR_SEPARATOR (*name)) 5958a96d7823Smrg base = name + 1; 5959a96d7823Smrg return base; 5960a96d7823Smrg} 5961a96d7823Smrg 5962a96d7823Smrgint 5963a96d7823Smrgcheck_executable (const char *path) 5964a96d7823Smrg{ 5965a96d7823Smrg struct stat st; 5966a96d7823Smrg 5967a96d7823Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 5968a96d7823Smrg nonempty (path)); 5969a96d7823Smrg if ((!path) || (!*path)) 5970a96d7823Smrg return 0; 5971a96d7823Smrg 5972a96d7823Smrg if ((stat (path, &st) >= 0) 5973a96d7823Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 5974a96d7823Smrg return 1; 5975a96d7823Smrg else 5976a96d7823Smrg return 0; 5977a96d7823Smrg} 5978a96d7823Smrg 5979a96d7823Smrgint 5980a96d7823Smrgmake_executable (const char *path) 5981a96d7823Smrg{ 5982a96d7823Smrg int rval = 0; 5983a96d7823Smrg struct stat st; 5984a96d7823Smrg 5985a96d7823Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 5986a96d7823Smrg nonempty (path)); 5987a96d7823Smrg if ((!path) || (!*path)) 5988a96d7823Smrg return 0; 5989a96d7823Smrg 5990a96d7823Smrg if (stat (path, &st) >= 0) 5991a96d7823Smrg { 5992a96d7823Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 5993a96d7823Smrg } 5994a96d7823Smrg return rval; 5995a96d7823Smrg} 5996a96d7823Smrg 5997a96d7823Smrg/* Searches for the full path of the wrapper. Returns 5998a96d7823Smrg newly allocated full path name if found, NULL otherwise 5999a96d7823Smrg Does not chase symlinks, even on platforms that support them. 6000a96d7823Smrg*/ 6001a96d7823Smrgchar * 6002a96d7823Smrgfind_executable (const char *wrapper) 6003a96d7823Smrg{ 6004a96d7823Smrg int has_slash = 0; 6005a96d7823Smrg const char *p; 6006a96d7823Smrg const char *p_next; 6007a96d7823Smrg /* static buffer for getcwd */ 6008a96d7823Smrg char tmp[LT_PATHMAX + 1]; 6009fd60135fSmrg size_t tmp_len; 6010a96d7823Smrg char *concat_name; 6011a96d7823Smrg 6012a96d7823Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6013a96d7823Smrg nonempty (wrapper)); 6014a96d7823Smrg 6015a96d7823Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6016a96d7823Smrg return NULL; 6017a96d7823Smrg 6018a96d7823Smrg /* Absolute path? */ 6019fd60135fSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6020a96d7823Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6021a96d7823Smrg { 6022a96d7823Smrg concat_name = xstrdup (wrapper); 6023a96d7823Smrg if (check_executable (concat_name)) 6024a96d7823Smrg return concat_name; 6025a96d7823Smrg XFREE (concat_name); 6026a96d7823Smrg } 6027a96d7823Smrg else 6028a96d7823Smrg { 6029a96d7823Smrg#endif 6030a96d7823Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6031a96d7823Smrg { 6032a96d7823Smrg concat_name = xstrdup (wrapper); 6033a96d7823Smrg if (check_executable (concat_name)) 6034a96d7823Smrg return concat_name; 6035a96d7823Smrg XFREE (concat_name); 6036a96d7823Smrg } 6037fd60135fSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6038a96d7823Smrg } 6039a96d7823Smrg#endif 6040a96d7823Smrg 6041a96d7823Smrg for (p = wrapper; *p; p++) 6042a96d7823Smrg if (*p == '/') 6043a96d7823Smrg { 6044a96d7823Smrg has_slash = 1; 6045a96d7823Smrg break; 6046a96d7823Smrg } 6047a96d7823Smrg if (!has_slash) 6048a96d7823Smrg { 6049a96d7823Smrg /* no slashes; search PATH */ 6050a96d7823Smrg const char *path = getenv ("PATH"); 6051a96d7823Smrg if (path != NULL) 6052a96d7823Smrg { 6053a96d7823Smrg for (p = path; *p; p = p_next) 6054a96d7823Smrg { 6055a96d7823Smrg const char *q; 6056a96d7823Smrg size_t p_len; 6057a96d7823Smrg for (q = p; *q; q++) 6058a96d7823Smrg if (IS_PATH_SEPARATOR (*q)) 6059a96d7823Smrg break; 6060fd60135fSmrg p_len = (size_t) (q - p); 6061a96d7823Smrg p_next = (*q == '\0' ? q : q + 1); 6062a96d7823Smrg if (p_len == 0) 6063a96d7823Smrg { 6064a96d7823Smrg /* empty path: current directory */ 6065a96d7823Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6066a96d7823Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6067a96d7823Smrg nonnull (strerror (errno))); 6068a96d7823Smrg tmp_len = strlen (tmp); 6069a96d7823Smrg concat_name = 6070a96d7823Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6071a96d7823Smrg memcpy (concat_name, tmp, tmp_len); 6072a96d7823Smrg concat_name[tmp_len] = '/'; 6073a96d7823Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6074a96d7823Smrg } 6075a96d7823Smrg else 6076a96d7823Smrg { 6077a96d7823Smrg concat_name = 6078a96d7823Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6079a96d7823Smrg memcpy (concat_name, p, p_len); 6080a96d7823Smrg concat_name[p_len] = '/'; 6081a96d7823Smrg strcpy (concat_name + p_len + 1, wrapper); 6082a96d7823Smrg } 6083a96d7823Smrg if (check_executable (concat_name)) 6084a96d7823Smrg return concat_name; 6085a96d7823Smrg XFREE (concat_name); 6086a96d7823Smrg } 6087a96d7823Smrg } 6088a96d7823Smrg /* not found in PATH; assume curdir */ 6089a96d7823Smrg } 6090a96d7823Smrg /* Relative path | not found in path: prepend cwd */ 6091a96d7823Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6092a96d7823Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6093a96d7823Smrg nonnull (strerror (errno))); 6094a96d7823Smrg tmp_len = strlen (tmp); 6095a96d7823Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6096a96d7823Smrg memcpy (concat_name, tmp, tmp_len); 6097a96d7823Smrg concat_name[tmp_len] = '/'; 6098a96d7823Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6099a96d7823Smrg 6100a96d7823Smrg if (check_executable (concat_name)) 6101a96d7823Smrg return concat_name; 6102a96d7823Smrg XFREE (concat_name); 6103a96d7823Smrg return NULL; 6104a96d7823Smrg} 6105a96d7823Smrg 6106a96d7823Smrgchar * 6107a96d7823Smrgchase_symlinks (const char *pathspec) 6108a96d7823Smrg{ 6109a96d7823Smrg#ifndef S_ISLNK 6110a96d7823Smrg return xstrdup (pathspec); 6111a96d7823Smrg#else 6112a96d7823Smrg char buf[LT_PATHMAX]; 6113a96d7823Smrg struct stat s; 6114a96d7823Smrg char *tmp_pathspec = xstrdup (pathspec); 6115a96d7823Smrg char *p; 6116a96d7823Smrg int has_symlinks = 0; 6117a96d7823Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6118a96d7823Smrg { 6119a96d7823Smrg lt_debugprintf (__FILE__, __LINE__, 6120a96d7823Smrg "checking path component for symlinks: %s\n", 6121a96d7823Smrg tmp_pathspec); 6122a96d7823Smrg if (lstat (tmp_pathspec, &s) == 0) 6123a96d7823Smrg { 6124a96d7823Smrg if (S_ISLNK (s.st_mode) != 0) 6125a96d7823Smrg { 6126a96d7823Smrg has_symlinks = 1; 6127a96d7823Smrg break; 6128a96d7823Smrg } 6129a96d7823Smrg 6130a96d7823Smrg /* search backwards for last DIR_SEPARATOR */ 6131a96d7823Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6132a96d7823Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6133a96d7823Smrg p--; 6134a96d7823Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6135a96d7823Smrg { 6136a96d7823Smrg /* no more DIR_SEPARATORS left */ 6137a96d7823Smrg break; 6138a96d7823Smrg } 6139a96d7823Smrg *p = '\0'; 6140a96d7823Smrg } 6141a96d7823Smrg else 6142a96d7823Smrg { 6143a96d7823Smrg lt_fatal (__FILE__, __LINE__, 6144a96d7823Smrg "error accessing file \"%s\": %s", 6145a96d7823Smrg tmp_pathspec, nonnull (strerror (errno))); 6146a96d7823Smrg } 6147a96d7823Smrg } 6148a96d7823Smrg XFREE (tmp_pathspec); 6149a96d7823Smrg 6150a96d7823Smrg if (!has_symlinks) 6151a96d7823Smrg { 6152a96d7823Smrg return xstrdup (pathspec); 6153a96d7823Smrg } 6154a96d7823Smrg 6155a96d7823Smrg tmp_pathspec = realpath (pathspec, buf); 6156a96d7823Smrg if (tmp_pathspec == 0) 6157a96d7823Smrg { 6158a96d7823Smrg lt_fatal (__FILE__, __LINE__, 6159a96d7823Smrg "could not follow symlinks for %s", pathspec); 6160a96d7823Smrg } 6161a96d7823Smrg return xstrdup (tmp_pathspec); 6162a96d7823Smrg#endif 6163a96d7823Smrg} 6164a96d7823Smrg 6165a96d7823Smrgchar * 6166a96d7823Smrgstrendzap (char *str, const char *pat) 6167a96d7823Smrg{ 6168a96d7823Smrg size_t len, patlen; 6169a96d7823Smrg 6170a96d7823Smrg assert (str != NULL); 6171a96d7823Smrg assert (pat != NULL); 6172a96d7823Smrg 6173a96d7823Smrg len = strlen (str); 6174a96d7823Smrg patlen = strlen (pat); 6175a96d7823Smrg 6176a96d7823Smrg if (patlen <= len) 6177a96d7823Smrg { 6178a96d7823Smrg str += len - patlen; 6179fd60135fSmrg if (STREQ (str, pat)) 6180a96d7823Smrg *str = '\0'; 6181a96d7823Smrg } 6182a96d7823Smrg return str; 6183a96d7823Smrg} 6184a96d7823Smrg 6185a96d7823Smrgvoid 6186a96d7823Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6187a96d7823Smrg{ 6188a96d7823Smrg va_list args; 6189a96d7823Smrg if (lt_debug) 6190a96d7823Smrg { 6191a96d7823Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6192a96d7823Smrg va_start (args, fmt); 6193a96d7823Smrg (void) vfprintf (stderr, fmt, args); 6194a96d7823Smrg va_end (args); 6195a96d7823Smrg } 6196a96d7823Smrg} 6197a96d7823Smrg 6198a96d7823Smrgstatic void 6199a96d7823Smrglt_error_core (int exit_status, const char *file, 6200a96d7823Smrg int line, const char *mode, 6201a96d7823Smrg const char *message, va_list ap) 6202a96d7823Smrg{ 6203a96d7823Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6204a96d7823Smrg vfprintf (stderr, message, ap); 6205a96d7823Smrg fprintf (stderr, ".\n"); 6206a96d7823Smrg 6207a96d7823Smrg if (exit_status >= 0) 6208a96d7823Smrg exit (exit_status); 6209a96d7823Smrg} 6210a96d7823Smrg 6211a96d7823Smrgvoid 6212a96d7823Smrglt_fatal (const char *file, int line, const char *message, ...) 6213a96d7823Smrg{ 6214a96d7823Smrg va_list ap; 6215a96d7823Smrg va_start (ap, message); 6216a96d7823Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6217a96d7823Smrg va_end (ap); 6218a96d7823Smrg} 6219a96d7823Smrg 6220a96d7823Smrgstatic const char * 6221a96d7823Smrgnonnull (const char *s) 6222a96d7823Smrg{ 6223a96d7823Smrg return s ? s : "(null)"; 6224a96d7823Smrg} 6225a96d7823Smrg 6226a96d7823Smrgstatic const char * 6227a96d7823Smrgnonempty (const char *s) 6228a96d7823Smrg{ 6229a96d7823Smrg return (s && !*s) ? "(empty)" : nonnull (s); 6230a96d7823Smrg} 6231a96d7823Smrg 6232a96d7823Smrgvoid 6233a96d7823Smrglt_setenv (const char *name, const char *value) 6234a96d7823Smrg{ 6235a96d7823Smrg lt_debugprintf (__FILE__, __LINE__, 6236a96d7823Smrg "(lt_setenv) setting '%s' to '%s'\n", 6237a96d7823Smrg nonnull (name), nonnull (value)); 6238a96d7823Smrg { 6239a96d7823Smrg#ifdef HAVE_SETENV 6240a96d7823Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6241a96d7823Smrg char *str = xstrdup (value); 6242a96d7823Smrg setenv (name, str, 1); 6243a96d7823Smrg#else 6244fd60135fSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6245a96d7823Smrg char *str = XMALLOC (char, len); 6246a96d7823Smrg sprintf (str, "%s=%s", name, value); 6247a96d7823Smrg if (putenv (str) != EXIT_SUCCESS) 6248a96d7823Smrg { 6249a96d7823Smrg XFREE (str); 6250a96d7823Smrg } 6251a96d7823Smrg#endif 6252a96d7823Smrg } 6253a96d7823Smrg} 6254a96d7823Smrg 6255a96d7823Smrgchar * 6256a96d7823Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6257a96d7823Smrg{ 6258a96d7823Smrg char *new_value; 6259a96d7823Smrg if (orig_value && *orig_value) 6260a96d7823Smrg { 6261fd60135fSmrg size_t orig_value_len = strlen (orig_value); 6262fd60135fSmrg size_t add_len = strlen (add); 6263a96d7823Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6264a96d7823Smrg if (to_end) 6265a96d7823Smrg { 6266a96d7823Smrg strcpy (new_value, orig_value); 6267a96d7823Smrg strcpy (new_value + orig_value_len, add); 6268a96d7823Smrg } 6269a96d7823Smrg else 6270a96d7823Smrg { 6271a96d7823Smrg strcpy (new_value, add); 6272a96d7823Smrg strcpy (new_value + add_len, orig_value); 6273a96d7823Smrg } 6274a96d7823Smrg } 6275a96d7823Smrg else 6276a96d7823Smrg { 6277a96d7823Smrg new_value = xstrdup (add); 6278a96d7823Smrg } 6279a96d7823Smrg return new_value; 6280a96d7823Smrg} 6281a96d7823Smrg 6282a96d7823Smrgvoid 6283a96d7823Smrglt_update_exe_path (const char *name, const char *value) 6284a96d7823Smrg{ 6285a96d7823Smrg lt_debugprintf (__FILE__, __LINE__, 6286a96d7823Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6287a96d7823Smrg nonnull (name), nonnull (value)); 6288a96d7823Smrg 6289a96d7823Smrg if (name && *name && value && *value) 6290a96d7823Smrg { 6291a96d7823Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6292a96d7823Smrg /* some systems can't cope with a ':'-terminated path #' */ 6293fd60135fSmrg size_t len = strlen (new_value); 6294fd60135fSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6295a96d7823Smrg { 6296fd60135fSmrg new_value[--len] = '\0'; 6297a96d7823Smrg } 6298a96d7823Smrg lt_setenv (name, new_value); 6299a96d7823Smrg XFREE (new_value); 6300a96d7823Smrg } 6301a96d7823Smrg} 6302a96d7823Smrg 6303a96d7823Smrgvoid 6304a96d7823Smrglt_update_lib_path (const char *name, const char *value) 6305a96d7823Smrg{ 6306a96d7823Smrg lt_debugprintf (__FILE__, __LINE__, 6307a96d7823Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6308a96d7823Smrg nonnull (name), nonnull (value)); 6309a96d7823Smrg 6310a96d7823Smrg if (name && *name && value && *value) 6311a96d7823Smrg { 6312a96d7823Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6313a96d7823Smrg lt_setenv (name, new_value); 6314a96d7823Smrg XFREE (new_value); 6315a96d7823Smrg } 6316a96d7823Smrg} 6317a96d7823Smrg 6318a96d7823SmrgEOF 6319a96d7823Smrg case $host_os in 6320a96d7823Smrg mingw*) 6321a96d7823Smrg cat <<"EOF" 6322a96d7823Smrg 6323a96d7823Smrg/* Prepares an argument vector before calling spawn(). 6324a96d7823Smrg Note that spawn() does not by itself call the command interpreter 6325a96d7823Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6326a96d7823Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6327a96d7823Smrg GetVersionEx(&v); 6328a96d7823Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6329a96d7823Smrg }) ? "cmd.exe" : "command.com"). 6330a96d7823Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 6331a96d7823Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6332a96d7823Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6333a96d7823Smrg special way: 6334a96d7823Smrg - Space and tab are interpreted as delimiters. They are not treated as 6335a96d7823Smrg delimiters if they are surrounded by double quotes: "...". 6336a96d7823Smrg - Unescaped double quotes are removed from the input. Their only effect is 6337a96d7823Smrg that within double quotes, space and tab are treated like normal 6338a96d7823Smrg characters. 6339a96d7823Smrg - Backslashes not followed by double quotes are not special. 6340a96d7823Smrg - But 2*n+1 backslashes followed by a double quote become 6341a96d7823Smrg n backslashes followed by a double quote (n >= 0): 6342a96d7823Smrg \" -> " 6343a96d7823Smrg \\\" -> \" 6344a96d7823Smrg \\\\\" -> \\" 6345a96d7823Smrg */ 6346a96d7823Smrg#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" 6347a96d7823Smrg#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" 6348a96d7823Smrgchar ** 6349a96d7823Smrgprepare_spawn (char **argv) 6350a96d7823Smrg{ 6351a96d7823Smrg size_t argc; 6352a96d7823Smrg char **new_argv; 6353a96d7823Smrg size_t i; 6354a96d7823Smrg 6355a96d7823Smrg /* Count number of arguments. */ 6356a96d7823Smrg for (argc = 0; argv[argc] != NULL; argc++) 6357a96d7823Smrg ; 6358a96d7823Smrg 6359a96d7823Smrg /* Allocate new argument vector. */ 6360a96d7823Smrg new_argv = XMALLOC (char *, argc + 1); 6361a96d7823Smrg 6362a96d7823Smrg /* Put quoted arguments into the new argument vector. */ 6363a96d7823Smrg for (i = 0; i < argc; i++) 6364a96d7823Smrg { 6365a96d7823Smrg const char *string = argv[i]; 6366a96d7823Smrg 6367a96d7823Smrg if (string[0] == '\0') 6368a96d7823Smrg new_argv[i] = xstrdup ("\"\""); 6369a96d7823Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6370a96d7823Smrg { 6371a96d7823Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6372a96d7823Smrg size_t length; 6373a96d7823Smrg unsigned int backslashes; 6374a96d7823Smrg const char *s; 6375a96d7823Smrg char *quoted_string; 6376a96d7823Smrg char *p; 6377a96d7823Smrg 6378a96d7823Smrg length = 0; 6379a96d7823Smrg backslashes = 0; 6380a96d7823Smrg if (quote_around) 6381a96d7823Smrg length++; 6382a96d7823Smrg for (s = string; *s != '\0'; s++) 6383a96d7823Smrg { 6384a96d7823Smrg char c = *s; 6385a96d7823Smrg if (c == '"') 6386a96d7823Smrg length += backslashes + 1; 6387a96d7823Smrg length++; 6388a96d7823Smrg if (c == '\\') 6389a96d7823Smrg backslashes++; 6390a96d7823Smrg else 6391a96d7823Smrg backslashes = 0; 6392a96d7823Smrg } 6393a96d7823Smrg if (quote_around) 6394a96d7823Smrg length += backslashes + 1; 6395a96d7823Smrg 6396a96d7823Smrg quoted_string = XMALLOC (char, length + 1); 6397a96d7823Smrg 6398a96d7823Smrg p = quoted_string; 6399a96d7823Smrg backslashes = 0; 6400a96d7823Smrg if (quote_around) 6401a96d7823Smrg *p++ = '"'; 6402a96d7823Smrg for (s = string; *s != '\0'; s++) 6403a96d7823Smrg { 6404a96d7823Smrg char c = *s; 6405a96d7823Smrg if (c == '"') 6406a96d7823Smrg { 6407a96d7823Smrg unsigned int j; 6408a96d7823Smrg for (j = backslashes + 1; j > 0; j--) 6409a96d7823Smrg *p++ = '\\'; 6410a96d7823Smrg } 6411a96d7823Smrg *p++ = c; 6412a96d7823Smrg if (c == '\\') 6413a96d7823Smrg backslashes++; 6414a96d7823Smrg else 6415a96d7823Smrg backslashes = 0; 6416a96d7823Smrg } 6417a96d7823Smrg if (quote_around) 6418a96d7823Smrg { 6419a96d7823Smrg unsigned int j; 6420a96d7823Smrg for (j = backslashes; j > 0; j--) 6421a96d7823Smrg *p++ = '\\'; 6422a96d7823Smrg *p++ = '"'; 6423a96d7823Smrg } 6424a96d7823Smrg *p = '\0'; 6425a96d7823Smrg 6426a96d7823Smrg new_argv[i] = quoted_string; 6427a96d7823Smrg } 6428a96d7823Smrg else 6429a96d7823Smrg new_argv[i] = (char *) string; 6430a96d7823Smrg } 6431a96d7823Smrg new_argv[argc] = NULL; 6432a96d7823Smrg 6433a96d7823Smrg return new_argv; 6434a96d7823Smrg} 6435a96d7823SmrgEOF 6436a96d7823Smrg ;; 6437a96d7823Smrg esac 6438a96d7823Smrg 6439a96d7823Smrg cat <<"EOF" 6440a96d7823Smrgvoid lt_dump_script (FILE* f) 6441a96d7823Smrg{ 6442a96d7823SmrgEOF 6443a96d7823Smrg func_emit_wrapper yes | 6444a96d7823Smrg $SED -n -e ' 6445a96d7823Smrgs/^\(.\{79\}\)\(..*\)/\1\ 6446a96d7823Smrg\2/ 6447a96d7823Smrgh 6448a96d7823Smrgs/\([\\"]\)/\\\1/g 6449a96d7823Smrgs/$/\\n/ 6450a96d7823Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6451a96d7823Smrgg 6452a96d7823SmrgD' 6453a96d7823Smrg cat <<"EOF" 6454a96d7823Smrg} 6455a96d7823SmrgEOF 6456a96d7823Smrg} 6457a96d7823Smrg# end: func_emit_cwrapperexe_src 6458a96d7823Smrg 6459a96d7823Smrg# func_win32_import_lib_p ARG 6460a96d7823Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6461a96d7823Smrgfunc_win32_import_lib_p () 6462a96d7823Smrg{ 6463fd60135fSmrg $debug_cmd 6464fd60135fSmrg 6465a96d7823Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6466a96d7823Smrg *import*) : ;; 6467a96d7823Smrg *) false ;; 6468a96d7823Smrg esac 6469a96d7823Smrg} 6470a96d7823Smrg 6471fd60135fSmrg# func_suncc_cstd_abi 6472fd60135fSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6473fd60135fSmrg# Several compiler flags select an ABI that is incompatible with the 6474fd60135fSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6475fd60135fSmrgfunc_suncc_cstd_abi () 6476fd60135fSmrg{ 6477fd60135fSmrg $debug_cmd 6478fd60135fSmrg 6479fd60135fSmrg case " $compile_command " in 6480fd60135fSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6481fd60135fSmrg suncc_use_cstd_abi=no 6482fd60135fSmrg ;; 6483fd60135fSmrg *) 6484fd60135fSmrg suncc_use_cstd_abi=yes 6485fd60135fSmrg ;; 6486fd60135fSmrg esac 6487fd60135fSmrg} 6488fd60135fSmrg 6489a96d7823Smrg# func_mode_link arg... 6490a96d7823Smrgfunc_mode_link () 6491a96d7823Smrg{ 6492fd60135fSmrg $debug_cmd 6493fd60135fSmrg 6494a96d7823Smrg case $host in 6495a96d7823Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6496a96d7823Smrg # It is impossible to link a dll without this setting, and 6497a96d7823Smrg # we shouldn't force the makefile maintainer to figure out 6498fd60135fSmrg # what system we are compiling for in order to pass an extra 6499a96d7823Smrg # flag for every libtool invocation. 6500a96d7823Smrg # allow_undefined=no 6501a96d7823Smrg 6502a96d7823Smrg # FIXME: Unfortunately, there are problems with the above when trying 6503fd60135fSmrg # to make a dll that has undefined symbols, in which case not 6504a96d7823Smrg # even a static library is built. For now, we need to specify 6505a96d7823Smrg # -no-undefined on the libtool link line when we can be certain 6506a96d7823Smrg # that all symbols are satisfied, otherwise we get a static library. 6507a96d7823Smrg allow_undefined=yes 6508a96d7823Smrg ;; 6509a96d7823Smrg *) 6510a96d7823Smrg allow_undefined=yes 6511a96d7823Smrg ;; 6512a96d7823Smrg esac 6513a96d7823Smrg libtool_args=$nonopt 6514a96d7823Smrg base_compile="$nonopt $@" 6515a96d7823Smrg compile_command=$nonopt 6516a96d7823Smrg finalize_command=$nonopt 6517a96d7823Smrg 6518a96d7823Smrg compile_rpath= 6519a96d7823Smrg finalize_rpath= 6520a96d7823Smrg compile_shlibpath= 6521a96d7823Smrg finalize_shlibpath= 6522a96d7823Smrg convenience= 6523a96d7823Smrg old_convenience= 6524a96d7823Smrg deplibs= 6525a96d7823Smrg old_deplibs= 6526a96d7823Smrg compiler_flags= 6527a96d7823Smrg linker_flags= 6528a96d7823Smrg dllsearchpath= 6529a96d7823Smrg lib_search_path=`pwd` 6530a96d7823Smrg inst_prefix_dir= 6531a96d7823Smrg new_inherited_linker_flags= 6532a96d7823Smrg 6533a96d7823Smrg avoid_version=no 6534a96d7823Smrg bindir= 6535a96d7823Smrg dlfiles= 6536a96d7823Smrg dlprefiles= 6537a96d7823Smrg dlself=no 6538a96d7823Smrg export_dynamic=no 6539a96d7823Smrg export_symbols= 6540a96d7823Smrg export_symbols_regex= 6541a96d7823Smrg generated= 6542a96d7823Smrg libobjs= 6543a96d7823Smrg ltlibs= 6544a96d7823Smrg module=no 6545a96d7823Smrg no_install=no 6546a96d7823Smrg objs= 6547fd60135fSmrg os2dllname= 6548a96d7823Smrg non_pic_objects= 6549a96d7823Smrg precious_files_regex= 6550a96d7823Smrg prefer_static_libs=no 6551fd60135fSmrg preload=false 6552a96d7823Smrg prev= 6553a96d7823Smrg prevarg= 6554a96d7823Smrg release= 6555a96d7823Smrg rpath= 6556a96d7823Smrg xrpath= 6557a96d7823Smrg perm_rpath= 6558a96d7823Smrg temp_rpath= 6559a96d7823Smrg thread_safe=no 6560a96d7823Smrg vinfo= 6561a96d7823Smrg vinfo_number=no 6562a96d7823Smrg weak_libs= 6563fd60135fSmrg single_module=$wl-single_module 6564a96d7823Smrg func_infer_tag $base_compile 6565a96d7823Smrg 6566a96d7823Smrg # We need to know -static, to get the right output filenames. 6567a96d7823Smrg for arg 6568a96d7823Smrg do 6569a96d7823Smrg case $arg in 6570a96d7823Smrg -shared) 6571fd60135fSmrg test yes != "$build_libtool_libs" \ 6572fd60135fSmrg && func_fatal_configuration "cannot build a shared library" 6573a96d7823Smrg build_old_libs=no 6574a96d7823Smrg break 6575a96d7823Smrg ;; 6576a96d7823Smrg -all-static | -static | -static-libtool-libs) 6577a96d7823Smrg case $arg in 6578a96d7823Smrg -all-static) 6579fd60135fSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6580a96d7823Smrg func_warning "complete static linking is impossible in this configuration" 6581a96d7823Smrg fi 6582a96d7823Smrg if test -n "$link_static_flag"; then 6583a96d7823Smrg dlopen_self=$dlopen_self_static 6584a96d7823Smrg fi 6585a96d7823Smrg prefer_static_libs=yes 6586a96d7823Smrg ;; 6587a96d7823Smrg -static) 6588a96d7823Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6589a96d7823Smrg dlopen_self=$dlopen_self_static 6590a96d7823Smrg fi 6591a96d7823Smrg prefer_static_libs=built 6592a96d7823Smrg ;; 6593a96d7823Smrg -static-libtool-libs) 6594a96d7823Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6595a96d7823Smrg dlopen_self=$dlopen_self_static 6596a96d7823Smrg fi 6597a96d7823Smrg prefer_static_libs=yes 6598a96d7823Smrg ;; 6599a96d7823Smrg esac 6600a96d7823Smrg build_libtool_libs=no 6601a96d7823Smrg build_old_libs=yes 6602a96d7823Smrg break 6603a96d7823Smrg ;; 6604a96d7823Smrg esac 6605a96d7823Smrg done 6606a96d7823Smrg 6607a96d7823Smrg # See if our shared archives depend on static archives. 6608a96d7823Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6609a96d7823Smrg 6610a96d7823Smrg # Go through the arguments, transforming them on the way. 6611a96d7823Smrg while test "$#" -gt 0; do 6612fd60135fSmrg arg=$1 6613a96d7823Smrg shift 6614a96d7823Smrg func_quote_for_eval "$arg" 6615a96d7823Smrg qarg=$func_quote_for_eval_unquoted_result 6616a96d7823Smrg func_append libtool_args " $func_quote_for_eval_result" 6617a96d7823Smrg 6618a96d7823Smrg # If the previous option needs an argument, assign it. 6619a96d7823Smrg if test -n "$prev"; then 6620a96d7823Smrg case $prev in 6621a96d7823Smrg output) 6622a96d7823Smrg func_append compile_command " @OUTPUT@" 6623a96d7823Smrg func_append finalize_command " @OUTPUT@" 6624a96d7823Smrg ;; 6625a96d7823Smrg esac 6626a96d7823Smrg 6627a96d7823Smrg case $prev in 6628a96d7823Smrg bindir) 6629fd60135fSmrg bindir=$arg 6630a96d7823Smrg prev= 6631a96d7823Smrg continue 6632a96d7823Smrg ;; 6633a96d7823Smrg dlfiles|dlprefiles) 6634fd60135fSmrg $preload || { 6635a96d7823Smrg # Add the symbol object into the linking commands. 6636a96d7823Smrg func_append compile_command " @SYMFILE@" 6637a96d7823Smrg func_append finalize_command " @SYMFILE@" 6638fd60135fSmrg preload=: 6639fd60135fSmrg } 6640a96d7823Smrg case $arg in 6641a96d7823Smrg *.la | *.lo) ;; # We handle these cases below. 6642a96d7823Smrg force) 6643fd60135fSmrg if test no = "$dlself"; then 6644a96d7823Smrg dlself=needless 6645a96d7823Smrg export_dynamic=yes 6646a96d7823Smrg fi 6647a96d7823Smrg prev= 6648a96d7823Smrg continue 6649a96d7823Smrg ;; 6650a96d7823Smrg self) 6651fd60135fSmrg if test dlprefiles = "$prev"; then 6652a96d7823Smrg dlself=yes 6653fd60135fSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6654a96d7823Smrg dlself=yes 6655a96d7823Smrg else 6656a96d7823Smrg dlself=needless 6657a96d7823Smrg export_dynamic=yes 6658a96d7823Smrg fi 6659a96d7823Smrg prev= 6660a96d7823Smrg continue 6661a96d7823Smrg ;; 6662a96d7823Smrg *) 6663fd60135fSmrg if test dlfiles = "$prev"; then 6664a96d7823Smrg func_append dlfiles " $arg" 6665a96d7823Smrg else 6666a96d7823Smrg func_append dlprefiles " $arg" 6667a96d7823Smrg fi 6668a96d7823Smrg prev= 6669a96d7823Smrg continue 6670a96d7823Smrg ;; 6671a96d7823Smrg esac 6672a96d7823Smrg ;; 6673a96d7823Smrg expsyms) 6674fd60135fSmrg export_symbols=$arg 6675a96d7823Smrg test -f "$arg" \ 6676fd60135fSmrg || func_fatal_error "symbol file '$arg' does not exist" 6677a96d7823Smrg prev= 6678a96d7823Smrg continue 6679a96d7823Smrg ;; 6680a96d7823Smrg expsyms_regex) 6681fd60135fSmrg export_symbols_regex=$arg 6682a96d7823Smrg prev= 6683a96d7823Smrg continue 6684a96d7823Smrg ;; 6685a96d7823Smrg framework) 6686a96d7823Smrg case $host in 6687a96d7823Smrg *-*-darwin*) 6688a96d7823Smrg case "$deplibs " in 6689a96d7823Smrg *" $qarg.ltframework "*) ;; 6690a96d7823Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6691a96d7823Smrg ;; 6692a96d7823Smrg esac 6693a96d7823Smrg ;; 6694a96d7823Smrg esac 6695a96d7823Smrg prev= 6696a96d7823Smrg continue 6697a96d7823Smrg ;; 6698a96d7823Smrg inst_prefix) 6699fd60135fSmrg inst_prefix_dir=$arg 6700fd60135fSmrg prev= 6701fd60135fSmrg continue 6702fd60135fSmrg ;; 6703fd60135fSmrg mllvm) 6704fd60135fSmrg # Clang does not use LLVM to link, so we can simply discard any 6705fd60135fSmrg # '-mllvm $arg' options when doing the link step. 6706a96d7823Smrg prev= 6707a96d7823Smrg continue 6708a96d7823Smrg ;; 6709a96d7823Smrg objectlist) 6710a96d7823Smrg if test -f "$arg"; then 6711a96d7823Smrg save_arg=$arg 6712a96d7823Smrg moreargs= 6713a96d7823Smrg for fil in `cat "$save_arg"` 6714a96d7823Smrg do 6715a96d7823Smrg# func_append moreargs " $fil" 6716a96d7823Smrg arg=$fil 6717a96d7823Smrg # A libtool-controlled object. 6718a96d7823Smrg 6719a96d7823Smrg # Check to see that this really is a libtool object. 6720a96d7823Smrg if func_lalib_unsafe_p "$arg"; then 6721a96d7823Smrg pic_object= 6722a96d7823Smrg non_pic_object= 6723a96d7823Smrg 6724a96d7823Smrg # Read the .lo file 6725a96d7823Smrg func_source "$arg" 6726a96d7823Smrg 6727a96d7823Smrg if test -z "$pic_object" || 6728a96d7823Smrg test -z "$non_pic_object" || 6729fd60135fSmrg test none = "$pic_object" && 6730fd60135fSmrg test none = "$non_pic_object"; then 6731fd60135fSmrg func_fatal_error "cannot find name of object for '$arg'" 6732a96d7823Smrg fi 6733a96d7823Smrg 6734a96d7823Smrg # Extract subdirectory from the argument. 6735a96d7823Smrg func_dirname "$arg" "/" "" 6736fd60135fSmrg xdir=$func_dirname_result 6737a96d7823Smrg 6738fd60135fSmrg if test none != "$pic_object"; then 6739a96d7823Smrg # Prepend the subdirectory the object is found in. 6740fd60135fSmrg pic_object=$xdir$pic_object 6741a96d7823Smrg 6742fd60135fSmrg if test dlfiles = "$prev"; then 6743fd60135fSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6744a96d7823Smrg func_append dlfiles " $pic_object" 6745a96d7823Smrg prev= 6746a96d7823Smrg continue 6747a96d7823Smrg else 6748a96d7823Smrg # If libtool objects are unsupported, then we need to preload. 6749a96d7823Smrg prev=dlprefiles 6750a96d7823Smrg fi 6751a96d7823Smrg fi 6752a96d7823Smrg 6753a96d7823Smrg # CHECK ME: I think I busted this. -Ossama 6754fd60135fSmrg if test dlprefiles = "$prev"; then 6755a96d7823Smrg # Preload the old-style object. 6756a96d7823Smrg func_append dlprefiles " $pic_object" 6757a96d7823Smrg prev= 6758a96d7823Smrg fi 6759a96d7823Smrg 6760a96d7823Smrg # A PIC object. 6761a96d7823Smrg func_append libobjs " $pic_object" 6762fd60135fSmrg arg=$pic_object 6763a96d7823Smrg fi 6764a96d7823Smrg 6765a96d7823Smrg # Non-PIC object. 6766fd60135fSmrg if test none != "$non_pic_object"; then 6767a96d7823Smrg # Prepend the subdirectory the object is found in. 6768fd60135fSmrg non_pic_object=$xdir$non_pic_object 6769a96d7823Smrg 6770a96d7823Smrg # A standard non-PIC object 6771a96d7823Smrg func_append non_pic_objects " $non_pic_object" 6772fd60135fSmrg if test -z "$pic_object" || test none = "$pic_object"; then 6773fd60135fSmrg arg=$non_pic_object 6774a96d7823Smrg fi 6775a96d7823Smrg else 6776a96d7823Smrg # If the PIC object exists, use it instead. 6777a96d7823Smrg # $xdir was prepended to $pic_object above. 6778fd60135fSmrg non_pic_object=$pic_object 6779a96d7823Smrg func_append non_pic_objects " $non_pic_object" 6780a96d7823Smrg fi 6781a96d7823Smrg else 6782a96d7823Smrg # Only an error if not doing a dry-run. 6783a96d7823Smrg if $opt_dry_run; then 6784a96d7823Smrg # Extract subdirectory from the argument. 6785a96d7823Smrg func_dirname "$arg" "/" "" 6786fd60135fSmrg xdir=$func_dirname_result 6787a96d7823Smrg 6788a96d7823Smrg func_lo2o "$arg" 6789a96d7823Smrg pic_object=$xdir$objdir/$func_lo2o_result 6790a96d7823Smrg non_pic_object=$xdir$func_lo2o_result 6791a96d7823Smrg func_append libobjs " $pic_object" 6792a96d7823Smrg func_append non_pic_objects " $non_pic_object" 6793a96d7823Smrg else 6794fd60135fSmrg func_fatal_error "'$arg' is not a valid libtool object" 6795a96d7823Smrg fi 6796a96d7823Smrg fi 6797a96d7823Smrg done 6798a96d7823Smrg else 6799fd60135fSmrg func_fatal_error "link input file '$arg' does not exist" 6800a96d7823Smrg fi 6801a96d7823Smrg arg=$save_arg 6802a96d7823Smrg prev= 6803a96d7823Smrg continue 6804a96d7823Smrg ;; 6805fd60135fSmrg os2dllname) 6806fd60135fSmrg os2dllname=$arg 6807fd60135fSmrg prev= 6808fd60135fSmrg continue 6809fd60135fSmrg ;; 6810a96d7823Smrg precious_regex) 6811fd60135fSmrg precious_files_regex=$arg 6812a96d7823Smrg prev= 6813a96d7823Smrg continue 6814a96d7823Smrg ;; 6815a96d7823Smrg release) 6816fd60135fSmrg release=-$arg 6817a96d7823Smrg prev= 6818a96d7823Smrg continue 6819a96d7823Smrg ;; 6820a96d7823Smrg rpath | xrpath) 6821a96d7823Smrg # We need an absolute path. 6822a96d7823Smrg case $arg in 6823a96d7823Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6824a96d7823Smrg *) 6825a96d7823Smrg func_fatal_error "only absolute run-paths are allowed" 6826a96d7823Smrg ;; 6827a96d7823Smrg esac 6828fd60135fSmrg if test rpath = "$prev"; then 6829a96d7823Smrg case "$rpath " in 6830a96d7823Smrg *" $arg "*) ;; 6831a96d7823Smrg *) func_append rpath " $arg" ;; 6832a96d7823Smrg esac 6833a96d7823Smrg else 6834a96d7823Smrg case "$xrpath " in 6835a96d7823Smrg *" $arg "*) ;; 6836a96d7823Smrg *) func_append xrpath " $arg" ;; 6837a96d7823Smrg esac 6838a96d7823Smrg fi 6839a96d7823Smrg prev= 6840a96d7823Smrg continue 6841a96d7823Smrg ;; 6842a96d7823Smrg shrext) 6843fd60135fSmrg shrext_cmds=$arg 6844a96d7823Smrg prev= 6845a96d7823Smrg continue 6846a96d7823Smrg ;; 6847a96d7823Smrg weak) 6848a96d7823Smrg func_append weak_libs " $arg" 6849a96d7823Smrg prev= 6850a96d7823Smrg continue 6851a96d7823Smrg ;; 6852a96d7823Smrg xcclinker) 6853a96d7823Smrg func_append linker_flags " $qarg" 6854a96d7823Smrg func_append compiler_flags " $qarg" 6855a96d7823Smrg prev= 6856a96d7823Smrg func_append compile_command " $qarg" 6857a96d7823Smrg func_append finalize_command " $qarg" 6858a96d7823Smrg continue 6859a96d7823Smrg ;; 6860a96d7823Smrg xcompiler) 6861a96d7823Smrg func_append compiler_flags " $qarg" 6862a96d7823Smrg prev= 6863a96d7823Smrg func_append compile_command " $qarg" 6864a96d7823Smrg func_append finalize_command " $qarg" 6865a96d7823Smrg continue 6866a96d7823Smrg ;; 6867a96d7823Smrg xlinker) 6868a96d7823Smrg func_append linker_flags " $qarg" 6869a96d7823Smrg func_append compiler_flags " $wl$qarg" 6870a96d7823Smrg prev= 6871a96d7823Smrg func_append compile_command " $wl$qarg" 6872a96d7823Smrg func_append finalize_command " $wl$qarg" 6873a96d7823Smrg continue 6874a96d7823Smrg ;; 6875a96d7823Smrg *) 6876a96d7823Smrg eval "$prev=\"\$arg\"" 6877a96d7823Smrg prev= 6878a96d7823Smrg continue 6879a96d7823Smrg ;; 6880a96d7823Smrg esac 6881a96d7823Smrg fi # test -n "$prev" 6882a96d7823Smrg 6883fd60135fSmrg prevarg=$arg 6884a96d7823Smrg 6885a96d7823Smrg case $arg in 6886a96d7823Smrg -all-static) 6887a96d7823Smrg if test -n "$link_static_flag"; then 6888a96d7823Smrg # See comment for -static flag below, for more details. 6889a96d7823Smrg func_append compile_command " $link_static_flag" 6890a96d7823Smrg func_append finalize_command " $link_static_flag" 6891a96d7823Smrg fi 6892a96d7823Smrg continue 6893a96d7823Smrg ;; 6894a96d7823Smrg 6895a96d7823Smrg -allow-undefined) 6896a96d7823Smrg # FIXME: remove this flag sometime in the future. 6897fd60135fSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 6898a96d7823Smrg ;; 6899a96d7823Smrg 6900a96d7823Smrg -avoid-version) 6901a96d7823Smrg avoid_version=yes 6902a96d7823Smrg continue 6903a96d7823Smrg ;; 6904a96d7823Smrg 6905a96d7823Smrg -bindir) 6906a96d7823Smrg prev=bindir 6907a96d7823Smrg continue 6908a96d7823Smrg ;; 6909a96d7823Smrg 6910a96d7823Smrg -dlopen) 6911a96d7823Smrg prev=dlfiles 6912a96d7823Smrg continue 6913a96d7823Smrg ;; 6914a96d7823Smrg 6915a96d7823Smrg -dlpreopen) 6916a96d7823Smrg prev=dlprefiles 6917a96d7823Smrg continue 6918a96d7823Smrg ;; 6919a96d7823Smrg 6920a96d7823Smrg -export-dynamic) 6921a96d7823Smrg export_dynamic=yes 6922a96d7823Smrg continue 6923a96d7823Smrg ;; 6924a96d7823Smrg 6925a96d7823Smrg -export-symbols | -export-symbols-regex) 6926a96d7823Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 6927a96d7823Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 6928a96d7823Smrg fi 6929fd60135fSmrg if test X-export-symbols = "X$arg"; then 6930a96d7823Smrg prev=expsyms 6931a96d7823Smrg else 6932a96d7823Smrg prev=expsyms_regex 6933a96d7823Smrg fi 6934a96d7823Smrg continue 6935a96d7823Smrg ;; 6936a96d7823Smrg 6937a96d7823Smrg -framework) 6938a96d7823Smrg prev=framework 6939a96d7823Smrg continue 6940a96d7823Smrg ;; 6941a96d7823Smrg 6942a96d7823Smrg -inst-prefix-dir) 6943a96d7823Smrg prev=inst_prefix 6944a96d7823Smrg continue 6945a96d7823Smrg ;; 6946a96d7823Smrg 6947a96d7823Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 6948a96d7823Smrg # so, if we see these flags be careful not to treat them like -L 6949a96d7823Smrg -L[A-Z][A-Z]*:*) 6950a96d7823Smrg case $with_gcc/$host in 6951a96d7823Smrg no/*-*-irix* | /*-*-irix*) 6952a96d7823Smrg func_append compile_command " $arg" 6953a96d7823Smrg func_append finalize_command " $arg" 6954a96d7823Smrg ;; 6955a96d7823Smrg esac 6956a96d7823Smrg continue 6957a96d7823Smrg ;; 6958a96d7823Smrg 6959a96d7823Smrg -L*) 6960a96d7823Smrg func_stripname "-L" '' "$arg" 6961a96d7823Smrg if test -z "$func_stripname_result"; then 6962a96d7823Smrg if test "$#" -gt 0; then 6963fd60135fSmrg func_fatal_error "require no space between '-L' and '$1'" 6964a96d7823Smrg else 6965fd60135fSmrg func_fatal_error "need path for '-L' option" 6966a96d7823Smrg fi 6967a96d7823Smrg fi 6968a96d7823Smrg func_resolve_sysroot "$func_stripname_result" 6969a96d7823Smrg dir=$func_resolve_sysroot_result 6970a96d7823Smrg # We need an absolute path. 6971a96d7823Smrg case $dir in 6972a96d7823Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6973a96d7823Smrg *) 6974a96d7823Smrg absdir=`cd "$dir" && pwd` 6975a96d7823Smrg test -z "$absdir" && \ 6976fd60135fSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 6977fd60135fSmrg dir=$absdir 6978a96d7823Smrg ;; 6979a96d7823Smrg esac 6980a96d7823Smrg case "$deplibs " in 6981a96d7823Smrg *" -L$dir "* | *" $arg "*) 6982a96d7823Smrg # Will only happen for absolute or sysroot arguments 6983a96d7823Smrg ;; 6984a96d7823Smrg *) 6985a96d7823Smrg # Preserve sysroot, but never include relative directories 6986a96d7823Smrg case $dir in 6987a96d7823Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 6988a96d7823Smrg *) func_append deplibs " -L$dir" ;; 6989a96d7823Smrg esac 6990a96d7823Smrg func_append lib_search_path " $dir" 6991a96d7823Smrg ;; 6992a96d7823Smrg esac 6993a96d7823Smrg case $host in 6994a96d7823Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6995a96d7823Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 6996a96d7823Smrg case :$dllsearchpath: in 6997a96d7823Smrg *":$dir:"*) ;; 6998a96d7823Smrg ::) dllsearchpath=$dir;; 6999a96d7823Smrg *) func_append dllsearchpath ":$dir";; 7000a96d7823Smrg esac 7001a96d7823Smrg case :$dllsearchpath: in 7002a96d7823Smrg *":$testbindir:"*) ;; 7003a96d7823Smrg ::) dllsearchpath=$testbindir;; 7004a96d7823Smrg *) func_append dllsearchpath ":$testbindir";; 7005a96d7823Smrg esac 7006a96d7823Smrg ;; 7007a96d7823Smrg esac 7008a96d7823Smrg continue 7009a96d7823Smrg ;; 7010a96d7823Smrg 7011a96d7823Smrg -l*) 7012fd60135fSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7013a96d7823Smrg case $host in 7014a96d7823Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7015a96d7823Smrg # These systems don't actually have a C or math library (as such) 7016a96d7823Smrg continue 7017a96d7823Smrg ;; 7018a96d7823Smrg *-*-os2*) 7019a96d7823Smrg # These systems don't actually have a C library (as such) 7020fd60135fSmrg test X-lc = "X$arg" && continue 7021a96d7823Smrg ;; 7022fd60135fSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7023a96d7823Smrg # Do not include libc due to us having libc/libc_r. 7024fd60135fSmrg test X-lc = "X$arg" && continue 7025a96d7823Smrg ;; 7026a96d7823Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7027a96d7823Smrg # Rhapsody C and math libraries are in the System framework 7028a96d7823Smrg func_append deplibs " System.ltframework" 7029a96d7823Smrg continue 7030a96d7823Smrg ;; 7031a96d7823Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7032a96d7823Smrg # Causes problems with __ctype 7033fd60135fSmrg test X-lc = "X$arg" && continue 7034a96d7823Smrg ;; 7035a96d7823Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7036a96d7823Smrg # Compiler inserts libc in the correct place for threads to work 7037fd60135fSmrg test X-lc = "X$arg" && continue 7038a96d7823Smrg ;; 7039a96d7823Smrg esac 7040fd60135fSmrg elif test X-lc_r = "X$arg"; then 7041a96d7823Smrg case $host in 7042fd60135fSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7043a96d7823Smrg # Do not include libc_r directly, use -pthread flag. 7044a96d7823Smrg continue 7045a96d7823Smrg ;; 7046a96d7823Smrg esac 7047a96d7823Smrg fi 7048a96d7823Smrg func_append deplibs " $arg" 7049a96d7823Smrg continue 7050a96d7823Smrg ;; 7051a96d7823Smrg 7052fd60135fSmrg -mllvm) 7053fd60135fSmrg prev=mllvm 7054fd60135fSmrg continue 7055fd60135fSmrg ;; 7056fd60135fSmrg 7057a96d7823Smrg -module) 7058a96d7823Smrg module=yes 7059a96d7823Smrg continue 7060a96d7823Smrg ;; 7061a96d7823Smrg 7062a96d7823Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7063a96d7823Smrg # classes, name mangling, and exception handling. 7064a96d7823Smrg # Darwin uses the -arch flag to determine output architecture. 7065a96d7823Smrg -model|-arch|-isysroot|--sysroot) 7066a96d7823Smrg func_append compiler_flags " $arg" 7067a96d7823Smrg func_append compile_command " $arg" 7068a96d7823Smrg func_append finalize_command " $arg" 7069a96d7823Smrg prev=xcompiler 7070a96d7823Smrg continue 7071a96d7823Smrg ;; 7072a96d7823Smrg 7073a96d7823Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7074a96d7823Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7075a96d7823Smrg func_append compiler_flags " $arg" 7076a96d7823Smrg func_append compile_command " $arg" 7077a96d7823Smrg func_append finalize_command " $arg" 7078a96d7823Smrg case "$new_inherited_linker_flags " in 7079a96d7823Smrg *" $arg "*) ;; 7080a96d7823Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7081a96d7823Smrg esac 7082a96d7823Smrg continue 7083a96d7823Smrg ;; 7084a96d7823Smrg 7085a96d7823Smrg -multi_module) 7086fd60135fSmrg single_module=$wl-multi_module 7087a96d7823Smrg continue 7088a96d7823Smrg ;; 7089a96d7823Smrg 7090a96d7823Smrg -no-fast-install) 7091a96d7823Smrg fast_install=no 7092a96d7823Smrg continue 7093a96d7823Smrg ;; 7094a96d7823Smrg 7095a96d7823Smrg -no-install) 7096a96d7823Smrg case $host in 7097a96d7823Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7098a96d7823Smrg # The PATH hackery in wrapper scripts is required on Windows 7099a96d7823Smrg # and Darwin in order for the loader to find any dlls it needs. 7100fd60135fSmrg func_warning "'-no-install' is ignored for $host" 7101fd60135fSmrg func_warning "assuming '-no-fast-install' instead" 7102a96d7823Smrg fast_install=no 7103a96d7823Smrg ;; 7104a96d7823Smrg *) no_install=yes ;; 7105a96d7823Smrg esac 7106a96d7823Smrg continue 7107a96d7823Smrg ;; 7108a96d7823Smrg 7109a96d7823Smrg -no-undefined) 7110a96d7823Smrg allow_undefined=no 7111a96d7823Smrg continue 7112a96d7823Smrg ;; 7113a96d7823Smrg 7114a96d7823Smrg -objectlist) 7115a96d7823Smrg prev=objectlist 7116a96d7823Smrg continue 7117a96d7823Smrg ;; 7118a96d7823Smrg 7119fd60135fSmrg -os2dllname) 7120fd60135fSmrg prev=os2dllname 7121fd60135fSmrg continue 7122fd60135fSmrg ;; 7123fd60135fSmrg 7124a96d7823Smrg -o) prev=output ;; 7125a96d7823Smrg 7126a96d7823Smrg -precious-files-regex) 7127a96d7823Smrg prev=precious_regex 7128a96d7823Smrg continue 7129a96d7823Smrg ;; 7130a96d7823Smrg 7131a96d7823Smrg -release) 7132a96d7823Smrg prev=release 7133a96d7823Smrg continue 7134a96d7823Smrg ;; 7135a96d7823Smrg 7136a96d7823Smrg -rpath) 7137a96d7823Smrg prev=rpath 7138a96d7823Smrg continue 7139a96d7823Smrg ;; 7140a96d7823Smrg 7141a96d7823Smrg -R) 7142a96d7823Smrg prev=xrpath 7143a96d7823Smrg continue 7144a96d7823Smrg ;; 7145a96d7823Smrg 7146a96d7823Smrg -R*) 7147a96d7823Smrg func_stripname '-R' '' "$arg" 7148a96d7823Smrg dir=$func_stripname_result 7149a96d7823Smrg # We need an absolute path. 7150a96d7823Smrg case $dir in 7151a96d7823Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7152a96d7823Smrg =*) 7153a96d7823Smrg func_stripname '=' '' "$dir" 7154a96d7823Smrg dir=$lt_sysroot$func_stripname_result 7155a96d7823Smrg ;; 7156a96d7823Smrg *) 7157a96d7823Smrg func_fatal_error "only absolute run-paths are allowed" 7158a96d7823Smrg ;; 7159a96d7823Smrg esac 7160a96d7823Smrg case "$xrpath " in 7161a96d7823Smrg *" $dir "*) ;; 7162a96d7823Smrg *) func_append xrpath " $dir" ;; 7163a96d7823Smrg esac 7164a96d7823Smrg continue 7165a96d7823Smrg ;; 7166a96d7823Smrg 7167a96d7823Smrg -shared) 7168a96d7823Smrg # The effects of -shared are defined in a previous loop. 7169a96d7823Smrg continue 7170a96d7823Smrg ;; 7171a96d7823Smrg 7172a96d7823Smrg -shrext) 7173a96d7823Smrg prev=shrext 7174a96d7823Smrg continue 7175a96d7823Smrg ;; 7176a96d7823Smrg 7177a96d7823Smrg -static | -static-libtool-libs) 7178a96d7823Smrg # The effects of -static are defined in a previous loop. 7179a96d7823Smrg # We used to do the same as -all-static on platforms that 7180a96d7823Smrg # didn't have a PIC flag, but the assumption that the effects 7181a96d7823Smrg # would be equivalent was wrong. It would break on at least 7182a96d7823Smrg # Digital Unix and AIX. 7183a96d7823Smrg continue 7184a96d7823Smrg ;; 7185a96d7823Smrg 7186a96d7823Smrg -thread-safe) 7187a96d7823Smrg thread_safe=yes 7188a96d7823Smrg continue 7189a96d7823Smrg ;; 7190a96d7823Smrg 7191a96d7823Smrg -version-info) 7192a96d7823Smrg prev=vinfo 7193a96d7823Smrg continue 7194a96d7823Smrg ;; 7195a96d7823Smrg 7196a96d7823Smrg -version-number) 7197a96d7823Smrg prev=vinfo 7198a96d7823Smrg vinfo_number=yes 7199a96d7823Smrg continue 7200a96d7823Smrg ;; 7201a96d7823Smrg 7202a96d7823Smrg -weak) 7203a96d7823Smrg prev=weak 7204a96d7823Smrg continue 7205a96d7823Smrg ;; 7206a96d7823Smrg 7207a96d7823Smrg -Wc,*) 7208a96d7823Smrg func_stripname '-Wc,' '' "$arg" 7209a96d7823Smrg args=$func_stripname_result 7210a96d7823Smrg arg= 7211fd60135fSmrg save_ifs=$IFS; IFS=, 7212a96d7823Smrg for flag in $args; do 7213fd60135fSmrg IFS=$save_ifs 7214a96d7823Smrg func_quote_for_eval "$flag" 7215a96d7823Smrg func_append arg " $func_quote_for_eval_result" 7216a96d7823Smrg func_append compiler_flags " $func_quote_for_eval_result" 7217a96d7823Smrg done 7218fd60135fSmrg IFS=$save_ifs 7219a96d7823Smrg func_stripname ' ' '' "$arg" 7220a96d7823Smrg arg=$func_stripname_result 7221a96d7823Smrg ;; 7222a96d7823Smrg 7223a96d7823Smrg -Wl,*) 7224a96d7823Smrg func_stripname '-Wl,' '' "$arg" 7225a96d7823Smrg args=$func_stripname_result 7226a96d7823Smrg arg= 7227fd60135fSmrg save_ifs=$IFS; IFS=, 7228a96d7823Smrg for flag in $args; do 7229fd60135fSmrg IFS=$save_ifs 7230a96d7823Smrg func_quote_for_eval "$flag" 7231a96d7823Smrg func_append arg " $wl$func_quote_for_eval_result" 7232a96d7823Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 7233a96d7823Smrg func_append linker_flags " $func_quote_for_eval_result" 7234a96d7823Smrg done 7235fd60135fSmrg IFS=$save_ifs 7236a96d7823Smrg func_stripname ' ' '' "$arg" 7237a96d7823Smrg arg=$func_stripname_result 7238a96d7823Smrg ;; 7239a96d7823Smrg 7240a96d7823Smrg -Xcompiler) 7241a96d7823Smrg prev=xcompiler 7242a96d7823Smrg continue 7243a96d7823Smrg ;; 7244a96d7823Smrg 7245a96d7823Smrg -Xlinker) 7246a96d7823Smrg prev=xlinker 7247a96d7823Smrg continue 7248a96d7823Smrg ;; 7249a96d7823Smrg 7250a96d7823Smrg -XCClinker) 7251a96d7823Smrg prev=xcclinker 7252a96d7823Smrg continue 7253a96d7823Smrg ;; 7254a96d7823Smrg 7255a96d7823Smrg # -msg_* for osf cc 7256a96d7823Smrg -msg_*) 7257a96d7823Smrg func_quote_for_eval "$arg" 7258fd60135fSmrg arg=$func_quote_for_eval_result 7259a96d7823Smrg ;; 7260a96d7823Smrg 7261a96d7823Smrg # Flags to be passed through unchanged, with rationale: 7262a96d7823Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7263a96d7823Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 7264a96d7823Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7265a96d7823Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7266a96d7823Smrg # -q* compiler args for the IBM compiler 7267a96d7823Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7268a96d7823Smrg # -F/path path to uninstalled frameworks, gcc on darwin 7269a96d7823Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7270fd60135fSmrg # -fstack-protector* stack protector flags for GCC 7271a96d7823Smrg # @file GCC response files 7272a96d7823Smrg # -tp=* Portland pgcc target processor selection 7273a96d7823Smrg # --sysroot=* for sysroot support 7274fd60135fSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7275fd60135fSmrg # -stdlib=* select c++ std lib with clang 7276a96d7823Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7277a96d7823Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7278c7b4381aSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 7279a96d7823Smrg func_quote_for_eval "$arg" 7280fd60135fSmrg arg=$func_quote_for_eval_result 7281a96d7823Smrg func_append compile_command " $arg" 7282a96d7823Smrg func_append finalize_command " $arg" 7283a96d7823Smrg func_append compiler_flags " $arg" 7284a96d7823Smrg continue 7285a96d7823Smrg ;; 7286a96d7823Smrg 7287fd60135fSmrg -Z*) 7288fd60135fSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7289fd60135fSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 7290fd60135fSmrg compiler_flags="$compiler_flags $arg" 7291fd60135fSmrg func_append compile_command " $arg" 7292fd60135fSmrg func_append finalize_command " $arg" 7293fd60135fSmrg case $arg in 7294fd60135fSmrg -Zlinker | -Zstack) 7295fd60135fSmrg prev=xcompiler 7296fd60135fSmrg ;; 7297fd60135fSmrg esac 7298fd60135fSmrg continue 7299fd60135fSmrg else 7300fd60135fSmrg # Otherwise treat like 'Some other compiler flag' below 7301fd60135fSmrg func_quote_for_eval "$arg" 7302fd60135fSmrg arg=$func_quote_for_eval_result 7303fd60135fSmrg fi 7304fd60135fSmrg ;; 7305fd60135fSmrg 7306a96d7823Smrg # Some other compiler flag. 7307a96d7823Smrg -* | +*) 7308a96d7823Smrg func_quote_for_eval "$arg" 7309fd60135fSmrg arg=$func_quote_for_eval_result 7310a96d7823Smrg ;; 7311a96d7823Smrg 7312a96d7823Smrg *.$objext) 7313a96d7823Smrg # A standard object. 7314a96d7823Smrg func_append objs " $arg" 7315a96d7823Smrg ;; 7316a96d7823Smrg 7317a96d7823Smrg *.lo) 7318a96d7823Smrg # A libtool-controlled object. 7319a96d7823Smrg 7320a96d7823Smrg # Check to see that this really is a libtool object. 7321a96d7823Smrg if func_lalib_unsafe_p "$arg"; then 7322a96d7823Smrg pic_object= 7323a96d7823Smrg non_pic_object= 7324a96d7823Smrg 7325a96d7823Smrg # Read the .lo file 7326a96d7823Smrg func_source "$arg" 7327a96d7823Smrg 7328a96d7823Smrg if test -z "$pic_object" || 7329a96d7823Smrg test -z "$non_pic_object" || 7330fd60135fSmrg test none = "$pic_object" && 7331fd60135fSmrg test none = "$non_pic_object"; then 7332fd60135fSmrg func_fatal_error "cannot find name of object for '$arg'" 7333a96d7823Smrg fi 7334a96d7823Smrg 7335a96d7823Smrg # Extract subdirectory from the argument. 7336a96d7823Smrg func_dirname "$arg" "/" "" 7337fd60135fSmrg xdir=$func_dirname_result 7338a96d7823Smrg 7339fd60135fSmrg test none = "$pic_object" || { 7340a96d7823Smrg # Prepend the subdirectory the object is found in. 7341fd60135fSmrg pic_object=$xdir$pic_object 7342a96d7823Smrg 7343fd60135fSmrg if test dlfiles = "$prev"; then 7344fd60135fSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7345a96d7823Smrg func_append dlfiles " $pic_object" 7346a96d7823Smrg prev= 7347a96d7823Smrg continue 7348a96d7823Smrg else 7349a96d7823Smrg # If libtool objects are unsupported, then we need to preload. 7350a96d7823Smrg prev=dlprefiles 7351a96d7823Smrg fi 7352a96d7823Smrg fi 7353a96d7823Smrg 7354a96d7823Smrg # CHECK ME: I think I busted this. -Ossama 7355fd60135fSmrg if test dlprefiles = "$prev"; then 7356a96d7823Smrg # Preload the old-style object. 7357a96d7823Smrg func_append dlprefiles " $pic_object" 7358a96d7823Smrg prev= 7359a96d7823Smrg fi 7360a96d7823Smrg 7361a96d7823Smrg # A PIC object. 7362a96d7823Smrg func_append libobjs " $pic_object" 7363fd60135fSmrg arg=$pic_object 7364fd60135fSmrg } 7365a96d7823Smrg 7366a96d7823Smrg # Non-PIC object. 7367fd60135fSmrg if test none != "$non_pic_object"; then 7368a96d7823Smrg # Prepend the subdirectory the object is found in. 7369fd60135fSmrg non_pic_object=$xdir$non_pic_object 7370a96d7823Smrg 7371a96d7823Smrg # A standard non-PIC object 7372a96d7823Smrg func_append non_pic_objects " $non_pic_object" 7373fd60135fSmrg if test -z "$pic_object" || test none = "$pic_object"; then 7374fd60135fSmrg arg=$non_pic_object 7375a96d7823Smrg fi 7376a96d7823Smrg else 7377a96d7823Smrg # If the PIC object exists, use it instead. 7378a96d7823Smrg # $xdir was prepended to $pic_object above. 7379fd60135fSmrg non_pic_object=$pic_object 7380a96d7823Smrg func_append non_pic_objects " $non_pic_object" 7381a96d7823Smrg fi 7382a96d7823Smrg else 7383a96d7823Smrg # Only an error if not doing a dry-run. 7384a96d7823Smrg if $opt_dry_run; then 7385a96d7823Smrg # Extract subdirectory from the argument. 7386a96d7823Smrg func_dirname "$arg" "/" "" 7387fd60135fSmrg xdir=$func_dirname_result 7388a96d7823Smrg 7389a96d7823Smrg func_lo2o "$arg" 7390a96d7823Smrg pic_object=$xdir$objdir/$func_lo2o_result 7391a96d7823Smrg non_pic_object=$xdir$func_lo2o_result 7392a96d7823Smrg func_append libobjs " $pic_object" 7393a96d7823Smrg func_append non_pic_objects " $non_pic_object" 7394a96d7823Smrg else 7395fd60135fSmrg func_fatal_error "'$arg' is not a valid libtool object" 7396a96d7823Smrg fi 7397a96d7823Smrg fi 7398a96d7823Smrg ;; 7399a96d7823Smrg 7400a96d7823Smrg *.$libext) 7401a96d7823Smrg # An archive. 7402a96d7823Smrg func_append deplibs " $arg" 7403a96d7823Smrg func_append old_deplibs " $arg" 7404a96d7823Smrg continue 7405a96d7823Smrg ;; 7406a96d7823Smrg 7407a96d7823Smrg *.la) 7408a96d7823Smrg # A libtool-controlled library. 7409a96d7823Smrg 7410a96d7823Smrg func_resolve_sysroot "$arg" 7411fd60135fSmrg if test dlfiles = "$prev"; then 7412a96d7823Smrg # This library was specified with -dlopen. 7413a96d7823Smrg func_append dlfiles " $func_resolve_sysroot_result" 7414a96d7823Smrg prev= 7415fd60135fSmrg elif test dlprefiles = "$prev"; then 7416a96d7823Smrg # The library was specified with -dlpreopen. 7417a96d7823Smrg func_append dlprefiles " $func_resolve_sysroot_result" 7418a96d7823Smrg prev= 7419a96d7823Smrg else 7420a96d7823Smrg func_append deplibs " $func_resolve_sysroot_result" 7421a96d7823Smrg fi 7422a96d7823Smrg continue 7423a96d7823Smrg ;; 7424a96d7823Smrg 7425a96d7823Smrg # Some other compiler argument. 7426a96d7823Smrg *) 7427a96d7823Smrg # Unknown arguments in both finalize_command and compile_command need 7428a96d7823Smrg # to be aesthetically quoted because they are evaled later. 7429a96d7823Smrg func_quote_for_eval "$arg" 7430fd60135fSmrg arg=$func_quote_for_eval_result 7431a96d7823Smrg ;; 7432a96d7823Smrg esac # arg 7433a96d7823Smrg 7434a96d7823Smrg # Now actually substitute the argument into the commands. 7435a96d7823Smrg if test -n "$arg"; then 7436a96d7823Smrg func_append compile_command " $arg" 7437a96d7823Smrg func_append finalize_command " $arg" 7438a96d7823Smrg fi 7439a96d7823Smrg done # argument parsing loop 7440a96d7823Smrg 7441a96d7823Smrg test -n "$prev" && \ 7442fd60135fSmrg func_fatal_help "the '$prevarg' option requires an argument" 7443a96d7823Smrg 7444fd60135fSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7445a96d7823Smrg eval arg=\"$export_dynamic_flag_spec\" 7446a96d7823Smrg func_append compile_command " $arg" 7447a96d7823Smrg func_append finalize_command " $arg" 7448a96d7823Smrg fi 7449a96d7823Smrg 7450a96d7823Smrg oldlibs= 7451a96d7823Smrg # calculate the name of the file, without its directory 7452a96d7823Smrg func_basename "$output" 7453fd60135fSmrg outputname=$func_basename_result 7454fd60135fSmrg libobjs_save=$libobjs 7455a96d7823Smrg 7456a96d7823Smrg if test -n "$shlibpath_var"; then 7457a96d7823Smrg # get the directories listed in $shlibpath_var 7458fd60135fSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7459a96d7823Smrg else 7460a96d7823Smrg shlib_search_path= 7461a96d7823Smrg fi 7462a96d7823Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7463a96d7823Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7464a96d7823Smrg 7465fd60135fSmrg # Definition is injected by LT_CONFIG during libtool generation. 7466fd60135fSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7467fd60135fSmrg 7468a96d7823Smrg func_dirname "$output" "/" "" 7469fd60135fSmrg output_objdir=$func_dirname_result$objdir 7470a96d7823Smrg func_to_tool_file "$output_objdir/" 7471a96d7823Smrg tool_output_objdir=$func_to_tool_file_result 7472a96d7823Smrg # Create the object directory. 7473a96d7823Smrg func_mkdir_p "$output_objdir" 7474a96d7823Smrg 7475a96d7823Smrg # Determine the type of output 7476a96d7823Smrg case $output in 7477a96d7823Smrg "") 7478a96d7823Smrg func_fatal_help "you must specify an output file" 7479a96d7823Smrg ;; 7480a96d7823Smrg *.$libext) linkmode=oldlib ;; 7481a96d7823Smrg *.lo | *.$objext) linkmode=obj ;; 7482a96d7823Smrg *.la) linkmode=lib ;; 7483a96d7823Smrg *) linkmode=prog ;; # Anything else should be a program. 7484a96d7823Smrg esac 7485a96d7823Smrg 7486a96d7823Smrg specialdeplibs= 7487a96d7823Smrg 7488a96d7823Smrg libs= 7489a96d7823Smrg # Find all interdependent deplibs by searching for libraries 7490a96d7823Smrg # that are linked more than once (e.g. -la -lb -la) 7491a96d7823Smrg for deplib in $deplibs; do 7492fd60135fSmrg if $opt_preserve_dup_deps; then 7493a96d7823Smrg case "$libs " in 7494a96d7823Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7495a96d7823Smrg esac 7496a96d7823Smrg fi 7497a96d7823Smrg func_append libs " $deplib" 7498a96d7823Smrg done 7499a96d7823Smrg 7500fd60135fSmrg if test lib = "$linkmode"; then 7501a96d7823Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7502a96d7823Smrg 7503a96d7823Smrg # Compute libraries that are listed more than once in $predeps 7504a96d7823Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7505a96d7823Smrg # not to be eliminated). 7506a96d7823Smrg pre_post_deps= 7507a96d7823Smrg if $opt_duplicate_compiler_generated_deps; then 7508a96d7823Smrg for pre_post_dep in $predeps $postdeps; do 7509a96d7823Smrg case "$pre_post_deps " in 7510a96d7823Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7511a96d7823Smrg esac 7512a96d7823Smrg func_append pre_post_deps " $pre_post_dep" 7513a96d7823Smrg done 7514a96d7823Smrg fi 7515a96d7823Smrg pre_post_deps= 7516a96d7823Smrg fi 7517a96d7823Smrg 7518a96d7823Smrg deplibs= 7519a96d7823Smrg newdependency_libs= 7520a96d7823Smrg newlib_search_path= 7521a96d7823Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7522a96d7823Smrg notinst_deplibs= # not-installed libtool libraries 7523a96d7823Smrg notinst_path= # paths that contain not-installed libtool libraries 7524a96d7823Smrg 7525a96d7823Smrg case $linkmode in 7526a96d7823Smrg lib) 7527a96d7823Smrg passes="conv dlpreopen link" 7528a96d7823Smrg for file in $dlfiles $dlprefiles; do 7529a96d7823Smrg case $file in 7530a96d7823Smrg *.la) ;; 7531a96d7823Smrg *) 7532fd60135fSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7533a96d7823Smrg ;; 7534a96d7823Smrg esac 7535a96d7823Smrg done 7536a96d7823Smrg ;; 7537a96d7823Smrg prog) 7538a96d7823Smrg compile_deplibs= 7539a96d7823Smrg finalize_deplibs= 7540fd60135fSmrg alldeplibs=false 7541a96d7823Smrg newdlfiles= 7542a96d7823Smrg newdlprefiles= 7543a96d7823Smrg passes="conv scan dlopen dlpreopen link" 7544a96d7823Smrg ;; 7545a96d7823Smrg *) passes="conv" 7546a96d7823Smrg ;; 7547a96d7823Smrg esac 7548a96d7823Smrg 7549a96d7823Smrg for pass in $passes; do 7550a96d7823Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 7551a96d7823Smrg # so that -L comes before libs that need it for instance... 7552fd60135fSmrg if test lib,link = "$linkmode,$pass"; then 7553a96d7823Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 7554a96d7823Smrg ## order, and fix it there properly 7555a96d7823Smrg tmp_deplibs= 7556a96d7823Smrg for deplib in $deplibs; do 7557a96d7823Smrg tmp_deplibs="$deplib $tmp_deplibs" 7558a96d7823Smrg done 7559fd60135fSmrg deplibs=$tmp_deplibs 7560a96d7823Smrg fi 7561a96d7823Smrg 7562fd60135fSmrg if test lib,link = "$linkmode,$pass" || 7563fd60135fSmrg test prog,scan = "$linkmode,$pass"; then 7564fd60135fSmrg libs=$deplibs 7565a96d7823Smrg deplibs= 7566a96d7823Smrg fi 7567fd60135fSmrg if test prog = "$linkmode"; then 7568a96d7823Smrg case $pass in 7569fd60135fSmrg dlopen) libs=$dlfiles ;; 7570fd60135fSmrg dlpreopen) libs=$dlprefiles ;; 7571c7b4381aSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7572a96d7823Smrg esac 7573a96d7823Smrg fi 7574fd60135fSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 7575a96d7823Smrg # Collect and forward deplibs of preopened libtool libs 7576a96d7823Smrg for lib in $dlprefiles; do 7577a96d7823Smrg # Ignore non-libtool-libs 7578a96d7823Smrg dependency_libs= 7579a96d7823Smrg func_resolve_sysroot "$lib" 7580a96d7823Smrg case $lib in 7581a96d7823Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 7582a96d7823Smrg esac 7583a96d7823Smrg 7584a96d7823Smrg # Collect preopened libtool deplibs, except any this library 7585a96d7823Smrg # has declared as weak libs 7586a96d7823Smrg for deplib in $dependency_libs; do 7587a96d7823Smrg func_basename "$deplib" 7588a96d7823Smrg deplib_base=$func_basename_result 7589a96d7823Smrg case " $weak_libs " in 7590a96d7823Smrg *" $deplib_base "*) ;; 7591a96d7823Smrg *) func_append deplibs " $deplib" ;; 7592a96d7823Smrg esac 7593a96d7823Smrg done 7594a96d7823Smrg done 7595fd60135fSmrg libs=$dlprefiles 7596a96d7823Smrg fi 7597fd60135fSmrg if test dlopen = "$pass"; then 7598a96d7823Smrg # Collect dlpreopened libraries 7599fd60135fSmrg save_deplibs=$deplibs 7600a96d7823Smrg deplibs= 7601a96d7823Smrg fi 7602a96d7823Smrg 7603a96d7823Smrg for deplib in $libs; do 7604a96d7823Smrg lib= 7605fd60135fSmrg found=false 7606a96d7823Smrg case $deplib in 7607a96d7823Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7608a96d7823Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7609fd60135fSmrg if test prog,link = "$linkmode,$pass"; then 7610a96d7823Smrg compile_deplibs="$deplib $compile_deplibs" 7611a96d7823Smrg finalize_deplibs="$deplib $finalize_deplibs" 7612a96d7823Smrg else 7613a96d7823Smrg func_append compiler_flags " $deplib" 7614fd60135fSmrg if test lib = "$linkmode"; then 7615a96d7823Smrg case "$new_inherited_linker_flags " in 7616a96d7823Smrg *" $deplib "*) ;; 7617a96d7823Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7618a96d7823Smrg esac 7619a96d7823Smrg fi 7620a96d7823Smrg fi 7621a96d7823Smrg continue 7622a96d7823Smrg ;; 7623a96d7823Smrg -l*) 7624fd60135fSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7625fd60135fSmrg func_warning "'-l' is ignored for archives/objects" 7626a96d7823Smrg continue 7627a96d7823Smrg fi 7628a96d7823Smrg func_stripname '-l' '' "$deplib" 7629a96d7823Smrg name=$func_stripname_result 7630fd60135fSmrg if test lib = "$linkmode"; then 7631a96d7823Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7632a96d7823Smrg else 7633a96d7823Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7634a96d7823Smrg fi 7635a96d7823Smrg for searchdir in $searchdirs; do 7636a96d7823Smrg for search_ext in .la $std_shrext .so .a; do 7637a96d7823Smrg # Search the libtool library 7638fd60135fSmrg lib=$searchdir/lib$name$search_ext 7639a96d7823Smrg if test -f "$lib"; then 7640fd60135fSmrg if test .la = "$search_ext"; then 7641fd60135fSmrg found=: 7642a96d7823Smrg else 7643fd60135fSmrg found=false 7644a96d7823Smrg fi 7645a96d7823Smrg break 2 7646a96d7823Smrg fi 7647a96d7823Smrg done 7648a96d7823Smrg done 7649fd60135fSmrg if $found; then 7650fd60135fSmrg # deplib is a libtool library 7651a96d7823Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7652a96d7823Smrg # We need to do some special things here, and not later. 7653fd60135fSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7654a96d7823Smrg case " $predeps $postdeps " in 7655a96d7823Smrg *" $deplib "*) 7656a96d7823Smrg if func_lalib_p "$lib"; then 7657a96d7823Smrg library_names= 7658a96d7823Smrg old_library= 7659a96d7823Smrg func_source "$lib" 7660a96d7823Smrg for l in $old_library $library_names; do 7661fd60135fSmrg ll=$l 7662a96d7823Smrg done 7663fd60135fSmrg if test "X$ll" = "X$old_library"; then # only static version available 7664fd60135fSmrg found=false 7665a96d7823Smrg func_dirname "$lib" "" "." 7666fd60135fSmrg ladir=$func_dirname_result 7667a96d7823Smrg lib=$ladir/$old_library 7668fd60135fSmrg if test prog,link = "$linkmode,$pass"; then 7669a96d7823Smrg compile_deplibs="$deplib $compile_deplibs" 7670a96d7823Smrg finalize_deplibs="$deplib $finalize_deplibs" 7671a96d7823Smrg else 7672a96d7823Smrg deplibs="$deplib $deplibs" 7673fd60135fSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7674a96d7823Smrg fi 7675a96d7823Smrg continue 7676a96d7823Smrg fi 7677a96d7823Smrg fi 7678a96d7823Smrg ;; 7679a96d7823Smrg *) ;; 7680a96d7823Smrg esac 7681a96d7823Smrg fi 7682fd60135fSmrg else 7683fd60135fSmrg # deplib doesn't seem to be a libtool library 7684fd60135fSmrg if test prog,link = "$linkmode,$pass"; then 7685fd60135fSmrg compile_deplibs="$deplib $compile_deplibs" 7686fd60135fSmrg finalize_deplibs="$deplib $finalize_deplibs" 7687fd60135fSmrg else 7688fd60135fSmrg deplibs="$deplib $deplibs" 7689fd60135fSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7690fd60135fSmrg fi 7691fd60135fSmrg continue 7692a96d7823Smrg fi 7693a96d7823Smrg ;; # -l 7694a96d7823Smrg *.ltframework) 7695fd60135fSmrg if test prog,link = "$linkmode,$pass"; then 7696a96d7823Smrg compile_deplibs="$deplib $compile_deplibs" 7697a96d7823Smrg finalize_deplibs="$deplib $finalize_deplibs" 7698a96d7823Smrg else 7699a96d7823Smrg deplibs="$deplib $deplibs" 7700fd60135fSmrg if test lib = "$linkmode"; then 7701a96d7823Smrg case "$new_inherited_linker_flags " in 7702a96d7823Smrg *" $deplib "*) ;; 7703a96d7823Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7704a96d7823Smrg esac 7705a96d7823Smrg fi 7706a96d7823Smrg fi 7707a96d7823Smrg continue 7708a96d7823Smrg ;; 7709a96d7823Smrg -L*) 7710a96d7823Smrg case $linkmode in 7711a96d7823Smrg lib) 7712a96d7823Smrg deplibs="$deplib $deplibs" 7713fd60135fSmrg test conv = "$pass" && continue 7714a96d7823Smrg newdependency_libs="$deplib $newdependency_libs" 7715a96d7823Smrg func_stripname '-L' '' "$deplib" 7716a96d7823Smrg func_resolve_sysroot "$func_stripname_result" 7717a96d7823Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 7718a96d7823Smrg ;; 7719a96d7823Smrg prog) 7720fd60135fSmrg if test conv = "$pass"; then 7721a96d7823Smrg deplibs="$deplib $deplibs" 7722a96d7823Smrg continue 7723a96d7823Smrg fi 7724fd60135fSmrg if test scan = "$pass"; then 7725a96d7823Smrg deplibs="$deplib $deplibs" 7726a96d7823Smrg else 7727a96d7823Smrg compile_deplibs="$deplib $compile_deplibs" 7728a96d7823Smrg finalize_deplibs="$deplib $finalize_deplibs" 7729a96d7823Smrg fi 7730a96d7823Smrg func_stripname '-L' '' "$deplib" 7731a96d7823Smrg func_resolve_sysroot "$func_stripname_result" 7732a96d7823Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 7733a96d7823Smrg ;; 7734a96d7823Smrg *) 7735fd60135fSmrg func_warning "'-L' is ignored for archives/objects" 7736a96d7823Smrg ;; 7737a96d7823Smrg esac # linkmode 7738a96d7823Smrg continue 7739a96d7823Smrg ;; # -L 7740a96d7823Smrg -R*) 7741fd60135fSmrg if test link = "$pass"; then 7742a96d7823Smrg func_stripname '-R' '' "$deplib" 7743a96d7823Smrg func_resolve_sysroot "$func_stripname_result" 7744a96d7823Smrg dir=$func_resolve_sysroot_result 7745a96d7823Smrg # Make sure the xrpath contains only unique directories. 7746a96d7823Smrg case "$xrpath " in 7747a96d7823Smrg *" $dir "*) ;; 7748a96d7823Smrg *) func_append xrpath " $dir" ;; 7749a96d7823Smrg esac 7750a96d7823Smrg fi 7751a96d7823Smrg deplibs="$deplib $deplibs" 7752a96d7823Smrg continue 7753a96d7823Smrg ;; 7754a96d7823Smrg *.la) 7755a96d7823Smrg func_resolve_sysroot "$deplib" 7756a96d7823Smrg lib=$func_resolve_sysroot_result 7757a96d7823Smrg ;; 7758a96d7823Smrg *.$libext) 7759fd60135fSmrg if test conv = "$pass"; then 7760a96d7823Smrg deplibs="$deplib $deplibs" 7761a96d7823Smrg continue 7762a96d7823Smrg fi 7763a96d7823Smrg case $linkmode in 7764a96d7823Smrg lib) 7765a96d7823Smrg # Linking convenience modules into shared libraries is allowed, 7766a96d7823Smrg # but linking other static libraries is non-portable. 7767a96d7823Smrg case " $dlpreconveniencelibs " in 7768a96d7823Smrg *" $deplib "*) ;; 7769a96d7823Smrg *) 7770fd60135fSmrg valid_a_lib=false 7771a96d7823Smrg case $deplibs_check_method in 7772a96d7823Smrg match_pattern*) 7773a96d7823Smrg set dummy $deplibs_check_method; shift 7774a96d7823Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7775a96d7823Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7776a96d7823Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 7777fd60135fSmrg valid_a_lib=: 7778a96d7823Smrg fi 7779a96d7823Smrg ;; 7780a96d7823Smrg pass_all) 7781fd60135fSmrg valid_a_lib=: 7782a96d7823Smrg ;; 7783a96d7823Smrg esac 7784fd60135fSmrg if $valid_a_lib; then 7785fd60135fSmrg echo 7786fd60135fSmrg $ECHO "*** Warning: Linking the shared library $output against the" 7787fd60135fSmrg $ECHO "*** static library $deplib is not portable!" 7788fd60135fSmrg deplibs="$deplib $deplibs" 7789fd60135fSmrg else 7790a96d7823Smrg echo 7791a96d7823Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 7792a96d7823Smrg echo "*** I have the capability to make that library automatically link in when" 7793a96d7823Smrg echo "*** you link to this library. But I can only do this if you have a" 7794a96d7823Smrg echo "*** shared version of the library, which you do not appear to have" 7795a96d7823Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 7796a96d7823Smrg echo "*** that it is just a static archive that I should not use here." 7797a96d7823Smrg fi 7798a96d7823Smrg ;; 7799a96d7823Smrg esac 7800a96d7823Smrg continue 7801a96d7823Smrg ;; 7802a96d7823Smrg prog) 7803fd60135fSmrg if test link != "$pass"; then 7804a96d7823Smrg deplibs="$deplib $deplibs" 7805a96d7823Smrg else 7806a96d7823Smrg compile_deplibs="$deplib $compile_deplibs" 7807a96d7823Smrg finalize_deplibs="$deplib $finalize_deplibs" 7808a96d7823Smrg fi 7809a96d7823Smrg continue 7810a96d7823Smrg ;; 7811a96d7823Smrg esac # linkmode 7812a96d7823Smrg ;; # *.$libext 7813a96d7823Smrg *.lo | *.$objext) 7814fd60135fSmrg if test conv = "$pass"; then 7815a96d7823Smrg deplibs="$deplib $deplibs" 7816fd60135fSmrg elif test prog = "$linkmode"; then 7817fd60135fSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7818a96d7823Smrg # If there is no dlopen support or we're linking statically, 7819a96d7823Smrg # we need to preload. 7820a96d7823Smrg func_append newdlprefiles " $deplib" 7821a96d7823Smrg compile_deplibs="$deplib $compile_deplibs" 7822a96d7823Smrg finalize_deplibs="$deplib $finalize_deplibs" 7823a96d7823Smrg else 7824a96d7823Smrg func_append newdlfiles " $deplib" 7825a96d7823Smrg fi 7826a96d7823Smrg fi 7827a96d7823Smrg continue 7828a96d7823Smrg ;; 7829a96d7823Smrg %DEPLIBS%) 7830fd60135fSmrg alldeplibs=: 7831a96d7823Smrg continue 7832a96d7823Smrg ;; 7833a96d7823Smrg esac # case $deplib 7834a96d7823Smrg 7835fd60135fSmrg $found || test -f "$lib" \ 7836fd60135fSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7837a96d7823Smrg 7838a96d7823Smrg # Check to see that this really is a libtool archive. 7839a96d7823Smrg func_lalib_unsafe_p "$lib" \ 7840fd60135fSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 7841a96d7823Smrg 7842a96d7823Smrg func_dirname "$lib" "" "." 7843fd60135fSmrg ladir=$func_dirname_result 7844a96d7823Smrg 7845a96d7823Smrg dlname= 7846a96d7823Smrg dlopen= 7847a96d7823Smrg dlpreopen= 7848a96d7823Smrg libdir= 7849a96d7823Smrg library_names= 7850a96d7823Smrg old_library= 7851a96d7823Smrg inherited_linker_flags= 7852a96d7823Smrg # If the library was installed with an old release of libtool, 7853a96d7823Smrg # it will not redefine variables installed, or shouldnotlink 7854a96d7823Smrg installed=yes 7855a96d7823Smrg shouldnotlink=no 7856a96d7823Smrg avoidtemprpath= 7857a96d7823Smrg 7858a96d7823Smrg 7859a96d7823Smrg # Read the .la file 7860a96d7823Smrg func_source "$lib" 7861a96d7823Smrg 7862a96d7823Smrg # Convert "-framework foo" to "foo.ltframework" 7863a96d7823Smrg if test -n "$inherited_linker_flags"; then 7864a96d7823Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7865a96d7823Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7866a96d7823Smrg case " $new_inherited_linker_flags " in 7867a96d7823Smrg *" $tmp_inherited_linker_flag "*) ;; 7868a96d7823Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7869a96d7823Smrg esac 7870a96d7823Smrg done 7871a96d7823Smrg fi 7872a96d7823Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7873fd60135fSmrg if test lib,link = "$linkmode,$pass" || 7874fd60135fSmrg test prog,scan = "$linkmode,$pass" || 7875fd60135fSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 7876a96d7823Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 7877a96d7823Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7878a96d7823Smrg fi 7879a96d7823Smrg 7880fd60135fSmrg if test conv = "$pass"; then 7881a96d7823Smrg # Only check for convenience libraries 7882a96d7823Smrg deplibs="$lib $deplibs" 7883a96d7823Smrg if test -z "$libdir"; then 7884a96d7823Smrg if test -z "$old_library"; then 7885fd60135fSmrg func_fatal_error "cannot find name of link library for '$lib'" 7886a96d7823Smrg fi 7887a96d7823Smrg # It is a libtool convenience library, so add in its objects. 7888a96d7823Smrg func_append convenience " $ladir/$objdir/$old_library" 7889a96d7823Smrg func_append old_convenience " $ladir/$objdir/$old_library" 7890fd60135fSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 7891fd60135fSmrg func_fatal_error "'$lib' is not a convenience library" 7892a96d7823Smrg fi 7893c7b4381aSmrg tmp_libs= 7894c7b4381aSmrg for deplib in $dependency_libs; do 7895c7b4381aSmrg deplibs="$deplib $deplibs" 7896c7b4381aSmrg if $opt_preserve_dup_deps; then 7897c7b4381aSmrg case "$tmp_libs " in 7898c7b4381aSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7899c7b4381aSmrg esac 7900c7b4381aSmrg fi 7901c7b4381aSmrg func_append tmp_libs " $deplib" 7902c7b4381aSmrg done 7903a96d7823Smrg continue 7904a96d7823Smrg fi # $pass = conv 7905a96d7823Smrg 7906a96d7823Smrg 7907a96d7823Smrg # Get the name of the library we link against. 7908a96d7823Smrg linklib= 7909a96d7823Smrg if test -n "$old_library" && 7910fd60135fSmrg { test yes = "$prefer_static_libs" || 7911fd60135fSmrg test built,no = "$prefer_static_libs,$installed"; }; then 7912a96d7823Smrg linklib=$old_library 7913a96d7823Smrg else 7914a96d7823Smrg for l in $old_library $library_names; do 7915fd60135fSmrg linklib=$l 7916a96d7823Smrg done 7917a96d7823Smrg fi 7918a96d7823Smrg if test -z "$linklib"; then 7919fd60135fSmrg func_fatal_error "cannot find name of link library for '$lib'" 7920a96d7823Smrg fi 7921a96d7823Smrg 7922a96d7823Smrg # This library was specified with -dlopen. 7923fd60135fSmrg if test dlopen = "$pass"; then 7924fd60135fSmrg test -z "$libdir" \ 7925fd60135fSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 7926a96d7823Smrg if test -z "$dlname" || 7927fd60135fSmrg test yes != "$dlopen_support" || 7928fd60135fSmrg test no = "$build_libtool_libs" 7929fd60135fSmrg then 7930a96d7823Smrg # If there is no dlname, no dlopen support or we're linking 7931a96d7823Smrg # statically, we need to preload. We also need to preload any 7932a96d7823Smrg # dependent libraries so libltdl's deplib preloader doesn't 7933a96d7823Smrg # bomb out in the load deplibs phase. 7934a96d7823Smrg func_append dlprefiles " $lib $dependency_libs" 7935a96d7823Smrg else 7936a96d7823Smrg func_append newdlfiles " $lib" 7937a96d7823Smrg fi 7938a96d7823Smrg continue 7939a96d7823Smrg fi # $pass = dlopen 7940a96d7823Smrg 7941a96d7823Smrg # We need an absolute path. 7942a96d7823Smrg case $ladir in 7943fd60135fSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 7944a96d7823Smrg *) 7945a96d7823Smrg abs_ladir=`cd "$ladir" && pwd` 7946a96d7823Smrg if test -z "$abs_ladir"; then 7947fd60135fSmrg func_warning "cannot determine absolute directory name of '$ladir'" 7948a96d7823Smrg func_warning "passing it literally to the linker, although it might fail" 7949fd60135fSmrg abs_ladir=$ladir 7950a96d7823Smrg fi 7951a96d7823Smrg ;; 7952a96d7823Smrg esac 7953a96d7823Smrg func_basename "$lib" 7954fd60135fSmrg laname=$func_basename_result 7955a96d7823Smrg 7956a96d7823Smrg # Find the relevant object directory and library name. 7957fd60135fSmrg if test yes = "$installed"; then 7958a96d7823Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7959fd60135fSmrg func_warning "library '$lib' was moved." 7960fd60135fSmrg dir=$ladir 7961fd60135fSmrg absdir=$abs_ladir 7962fd60135fSmrg libdir=$abs_ladir 7963a96d7823Smrg else 7964fd60135fSmrg dir=$lt_sysroot$libdir 7965fd60135fSmrg absdir=$lt_sysroot$libdir 7966a96d7823Smrg fi 7967fd60135fSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 7968a96d7823Smrg else 7969a96d7823Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7970fd60135fSmrg dir=$ladir 7971fd60135fSmrg absdir=$abs_ladir 7972a96d7823Smrg # Remove this search path later 7973a96d7823Smrg func_append notinst_path " $abs_ladir" 7974a96d7823Smrg else 7975fd60135fSmrg dir=$ladir/$objdir 7976fd60135fSmrg absdir=$abs_ladir/$objdir 7977a96d7823Smrg # Remove this search path later 7978a96d7823Smrg func_append notinst_path " $abs_ladir" 7979a96d7823Smrg fi 7980a96d7823Smrg fi # $installed = yes 7981a96d7823Smrg func_stripname 'lib' '.la' "$laname" 7982a96d7823Smrg name=$func_stripname_result 7983a96d7823Smrg 7984a96d7823Smrg # This library was specified with -dlpreopen. 7985fd60135fSmrg if test dlpreopen = "$pass"; then 7986fd60135fSmrg if test -z "$libdir" && test prog = "$linkmode"; then 7987fd60135fSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 7988a96d7823Smrg fi 7989fd60135fSmrg case $host in 7990a96d7823Smrg # special handling for platforms with PE-DLLs. 7991a96d7823Smrg *cygwin* | *mingw* | *cegcc* ) 7992a96d7823Smrg # Linker will automatically link against shared library if both 7993a96d7823Smrg # static and shared are present. Therefore, ensure we extract 7994a96d7823Smrg # symbols from the import library if a shared library is present 7995a96d7823Smrg # (otherwise, the dlopen module name will be incorrect). We do 7996a96d7823Smrg # this by putting the import library name into $newdlprefiles. 7997a96d7823Smrg # We recover the dlopen module name by 'saving' the la file 7998a96d7823Smrg # name in a special purpose variable, and (later) extracting the 7999a96d7823Smrg # dlname from the la file. 8000a96d7823Smrg if test -n "$dlname"; then 8001a96d7823Smrg func_tr_sh "$dir/$linklib" 8002a96d7823Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8003a96d7823Smrg func_append newdlprefiles " $dir/$linklib" 8004a96d7823Smrg else 8005a96d7823Smrg func_append newdlprefiles " $dir/$old_library" 8006a96d7823Smrg # Keep a list of preopened convenience libraries to check 8007a96d7823Smrg # that they are being used correctly in the link pass. 8008a96d7823Smrg test -z "$libdir" && \ 8009a96d7823Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8010a96d7823Smrg fi 8011a96d7823Smrg ;; 8012a96d7823Smrg * ) 8013a96d7823Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8014a96d7823Smrg # are required to link). 8015a96d7823Smrg if test -n "$old_library"; then 8016a96d7823Smrg func_append newdlprefiles " $dir/$old_library" 8017a96d7823Smrg # Keep a list of preopened convenience libraries to check 8018a96d7823Smrg # that they are being used correctly in the link pass. 8019a96d7823Smrg test -z "$libdir" && \ 8020a96d7823Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8021a96d7823Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8022a96d7823Smrg elif test -n "$dlname"; then 8023a96d7823Smrg func_append newdlprefiles " $dir/$dlname" 8024a96d7823Smrg else 8025a96d7823Smrg func_append newdlprefiles " $dir/$linklib" 8026a96d7823Smrg fi 8027a96d7823Smrg ;; 8028a96d7823Smrg esac 8029a96d7823Smrg fi # $pass = dlpreopen 8030a96d7823Smrg 8031a96d7823Smrg if test -z "$libdir"; then 8032a96d7823Smrg # Link the convenience library 8033fd60135fSmrg if test lib = "$linkmode"; then 8034a96d7823Smrg deplibs="$dir/$old_library $deplibs" 8035fd60135fSmrg elif test prog,link = "$linkmode,$pass"; then 8036a96d7823Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8037a96d7823Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8038a96d7823Smrg else 8039a96d7823Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8040a96d7823Smrg fi 8041a96d7823Smrg continue 8042a96d7823Smrg fi 8043a96d7823Smrg 8044a96d7823Smrg 8045fd60135fSmrg if test prog = "$linkmode" && test link != "$pass"; then 8046a96d7823Smrg func_append newlib_search_path " $ladir" 8047a96d7823Smrg deplibs="$lib $deplibs" 8048a96d7823Smrg 8049fd60135fSmrg linkalldeplibs=false 8050fd60135fSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8051fd60135fSmrg test no = "$build_libtool_libs"; then 8052fd60135fSmrg linkalldeplibs=: 8053a96d7823Smrg fi 8054a96d7823Smrg 8055a96d7823Smrg tmp_libs= 8056a96d7823Smrg for deplib in $dependency_libs; do 8057a96d7823Smrg case $deplib in 8058a96d7823Smrg -L*) func_stripname '-L' '' "$deplib" 8059a96d7823Smrg func_resolve_sysroot "$func_stripname_result" 8060a96d7823Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8061a96d7823Smrg ;; 8062a96d7823Smrg esac 8063a96d7823Smrg # Need to link against all dependency_libs? 8064fd60135fSmrg if $linkalldeplibs; then 8065a96d7823Smrg deplibs="$deplib $deplibs" 8066a96d7823Smrg else 8067a96d7823Smrg # Need to hardcode shared library paths 8068a96d7823Smrg # or/and link against static libraries 8069a96d7823Smrg newdependency_libs="$deplib $newdependency_libs" 8070a96d7823Smrg fi 8071fd60135fSmrg if $opt_preserve_dup_deps; then 8072a96d7823Smrg case "$tmp_libs " in 8073a96d7823Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8074a96d7823Smrg esac 8075a96d7823Smrg fi 8076a96d7823Smrg func_append tmp_libs " $deplib" 8077a96d7823Smrg done # for deplib 8078a96d7823Smrg continue 8079a96d7823Smrg fi # $linkmode = prog... 8080a96d7823Smrg 8081fd60135fSmrg if test prog,link = "$linkmode,$pass"; then 8082a96d7823Smrg if test -n "$library_names" && 8083fd60135fSmrg { { test no = "$prefer_static_libs" || 8084fd60135fSmrg test built,yes = "$prefer_static_libs,$installed"; } || 8085a96d7823Smrg test -z "$old_library"; }; then 8086a96d7823Smrg # We need to hardcode the library path 8087fd60135fSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8088a96d7823Smrg # Make sure the rpath contains only unique directories. 8089fd60135fSmrg case $temp_rpath: in 8090a96d7823Smrg *"$absdir:"*) ;; 8091a96d7823Smrg *) func_append temp_rpath "$absdir:" ;; 8092a96d7823Smrg esac 8093a96d7823Smrg fi 8094a96d7823Smrg 8095a96d7823Smrg # Hardcode the library path. 8096a96d7823Smrg # Skip directories that are in the system default run-time 8097a96d7823Smrg # search path. 8098a96d7823Smrg case " $sys_lib_dlsearch_path " in 8099a96d7823Smrg *" $absdir "*) ;; 8100a96d7823Smrg *) 8101a96d7823Smrg case "$compile_rpath " in 8102a96d7823Smrg *" $absdir "*) ;; 8103a96d7823Smrg *) func_append compile_rpath " $absdir" ;; 8104a96d7823Smrg esac 8105a96d7823Smrg ;; 8106a96d7823Smrg esac 8107a96d7823Smrg case " $sys_lib_dlsearch_path " in 8108a96d7823Smrg *" $libdir "*) ;; 8109a96d7823Smrg *) 8110a96d7823Smrg case "$finalize_rpath " in 8111a96d7823Smrg *" $libdir "*) ;; 8112a96d7823Smrg *) func_append finalize_rpath " $libdir" ;; 8113a96d7823Smrg esac 8114a96d7823Smrg ;; 8115a96d7823Smrg esac 8116a96d7823Smrg fi # $linkmode,$pass = prog,link... 8117a96d7823Smrg 8118fd60135fSmrg if $alldeplibs && 8119fd60135fSmrg { test pass_all = "$deplibs_check_method" || 8120fd60135fSmrg { test yes = "$build_libtool_libs" && 8121a96d7823Smrg test -n "$library_names"; }; }; then 8122a96d7823Smrg # We only need to search for static libraries 8123a96d7823Smrg continue 8124a96d7823Smrg fi 8125a96d7823Smrg fi 8126a96d7823Smrg 8127a96d7823Smrg link_static=no # Whether the deplib will be linked statically 8128a96d7823Smrg use_static_libs=$prefer_static_libs 8129fd60135fSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 8130a96d7823Smrg use_static_libs=no 8131a96d7823Smrg fi 8132a96d7823Smrg if test -n "$library_names" && 8133fd60135fSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8134a96d7823Smrg case $host in 8135fd60135fSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 8136a96d7823Smrg # No point in relinking DLLs because paths are not encoded 8137a96d7823Smrg func_append notinst_deplibs " $lib" 8138a96d7823Smrg need_relink=no 8139a96d7823Smrg ;; 8140a96d7823Smrg *) 8141fd60135fSmrg if test no = "$installed"; then 8142a96d7823Smrg func_append notinst_deplibs " $lib" 8143a96d7823Smrg need_relink=yes 8144a96d7823Smrg fi 8145a96d7823Smrg ;; 8146a96d7823Smrg esac 8147a96d7823Smrg # This is a shared library 8148a96d7823Smrg 8149a96d7823Smrg # Warn about portability, can't link against -module's on some 8150a96d7823Smrg # systems (darwin). Don't bleat about dlopened modules though! 8151fd60135fSmrg dlopenmodule= 8152a96d7823Smrg for dlpremoduletest in $dlprefiles; do 8153a96d7823Smrg if test "X$dlpremoduletest" = "X$lib"; then 8154fd60135fSmrg dlopenmodule=$dlpremoduletest 8155a96d7823Smrg break 8156a96d7823Smrg fi 8157a96d7823Smrg done 8158fd60135fSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8159a96d7823Smrg echo 8160fd60135fSmrg if test prog = "$linkmode"; then 8161a96d7823Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8162a96d7823Smrg else 8163a96d7823Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8164a96d7823Smrg fi 8165a96d7823Smrg $ECHO "*** $linklib is not portable!" 8166a96d7823Smrg fi 8167fd60135fSmrg if test lib = "$linkmode" && 8168fd60135fSmrg test yes = "$hardcode_into_libs"; then 8169a96d7823Smrg # Hardcode the library path. 8170a96d7823Smrg # Skip directories that are in the system default run-time 8171a96d7823Smrg # search path. 8172a96d7823Smrg case " $sys_lib_dlsearch_path " in 8173a96d7823Smrg *" $absdir "*) ;; 8174a96d7823Smrg *) 8175a96d7823Smrg case "$compile_rpath " in 8176a96d7823Smrg *" $absdir "*) ;; 8177a96d7823Smrg *) func_append compile_rpath " $absdir" ;; 8178a96d7823Smrg esac 8179a96d7823Smrg ;; 8180a96d7823Smrg esac 8181a96d7823Smrg case " $sys_lib_dlsearch_path " in 8182a96d7823Smrg *" $libdir "*) ;; 8183a96d7823Smrg *) 8184a96d7823Smrg case "$finalize_rpath " in 8185a96d7823Smrg *" $libdir "*) ;; 8186a96d7823Smrg *) func_append finalize_rpath " $libdir" ;; 8187a96d7823Smrg esac 8188a96d7823Smrg ;; 8189a96d7823Smrg esac 8190a96d7823Smrg fi 8191a96d7823Smrg 8192a96d7823Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8193a96d7823Smrg # figure out the soname 8194a96d7823Smrg set dummy $library_names 8195a96d7823Smrg shift 8196fd60135fSmrg realname=$1 8197a96d7823Smrg shift 8198a96d7823Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8199a96d7823Smrg # use dlname if we got it. it's perfectly good, no? 8200a96d7823Smrg if test -n "$dlname"; then 8201fd60135fSmrg soname=$dlname 8202a96d7823Smrg elif test -n "$soname_spec"; then 8203a96d7823Smrg # bleh windows 8204a96d7823Smrg case $host in 8205fd60135fSmrg *cygwin* | mingw* | *cegcc* | *os2*) 8206a96d7823Smrg func_arith $current - $age 8207a96d7823Smrg major=$func_arith_result 8208fd60135fSmrg versuffix=-$major 8209a96d7823Smrg ;; 8210a96d7823Smrg esac 8211a96d7823Smrg eval soname=\"$soname_spec\" 8212a96d7823Smrg else 8213fd60135fSmrg soname=$realname 8214a96d7823Smrg fi 8215a96d7823Smrg 8216a96d7823Smrg # Make a new name for the extract_expsyms_cmds to use 8217fd60135fSmrg soroot=$soname 8218a96d7823Smrg func_basename "$soroot" 8219fd60135fSmrg soname=$func_basename_result 8220a96d7823Smrg func_stripname 'lib' '.dll' "$soname" 8221a96d7823Smrg newlib=libimp-$func_stripname_result.a 8222a96d7823Smrg 8223a96d7823Smrg # If the library has no export list, then create one now 8224a96d7823Smrg if test -f "$output_objdir/$soname-def"; then : 8225a96d7823Smrg else 8226fd60135fSmrg func_verbose "extracting exported symbol list from '$soname'" 8227a96d7823Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8228a96d7823Smrg fi 8229a96d7823Smrg 8230a96d7823Smrg # Create $newlib 8231a96d7823Smrg if test -f "$output_objdir/$newlib"; then :; else 8232fd60135fSmrg func_verbose "generating import library for '$soname'" 8233a96d7823Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8234a96d7823Smrg fi 8235a96d7823Smrg # make sure the library variables are pointing to the new library 8236a96d7823Smrg dir=$output_objdir 8237a96d7823Smrg linklib=$newlib 8238a96d7823Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8239a96d7823Smrg 8240fd60135fSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8241a96d7823Smrg add_shlibpath= 8242a96d7823Smrg add_dir= 8243a96d7823Smrg add= 8244a96d7823Smrg lib_linked=yes 8245a96d7823Smrg case $hardcode_action in 8246a96d7823Smrg immediate | unsupported) 8247fd60135fSmrg if test no = "$hardcode_direct"; then 8248fd60135fSmrg add=$dir/$linklib 8249a96d7823Smrg case $host in 8250fd60135fSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8251fd60135fSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8252a96d7823Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8253fd60135fSmrg *-*-unixware7*) add_dir=-L$dir ;; 8254a96d7823Smrg *-*-darwin* ) 8255fd60135fSmrg # if the lib is a (non-dlopened) module then we cannot 8256a96d7823Smrg # link against it, someone is ignoring the earlier warnings 8257a96d7823Smrg if /usr/bin/file -L $add 2> /dev/null | 8258fd60135fSmrg $GREP ": [^:]* bundle" >/dev/null; then 8259a96d7823Smrg if test "X$dlopenmodule" != "X$lib"; then 8260a96d7823Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8261fd60135fSmrg if test -z "$old_library"; then 8262a96d7823Smrg echo 8263a96d7823Smrg echo "*** And there doesn't seem to be a static archive available" 8264a96d7823Smrg echo "*** The link will probably fail, sorry" 8265a96d7823Smrg else 8266fd60135fSmrg add=$dir/$old_library 8267a96d7823Smrg fi 8268a96d7823Smrg elif test -n "$old_library"; then 8269fd60135fSmrg add=$dir/$old_library 8270a96d7823Smrg fi 8271a96d7823Smrg fi 8272a96d7823Smrg esac 8273fd60135fSmrg elif test no = "$hardcode_minus_L"; then 8274a96d7823Smrg case $host in 8275fd60135fSmrg *-*-sunos*) add_shlibpath=$dir ;; 8276a96d7823Smrg esac 8277fd60135fSmrg add_dir=-L$dir 8278fd60135fSmrg add=-l$name 8279fd60135fSmrg elif test no = "$hardcode_shlibpath_var"; then 8280fd60135fSmrg add_shlibpath=$dir 8281fd60135fSmrg add=-l$name 8282a96d7823Smrg else 8283a96d7823Smrg lib_linked=no 8284a96d7823Smrg fi 8285a96d7823Smrg ;; 8286a96d7823Smrg relink) 8287fd60135fSmrg if test yes = "$hardcode_direct" && 8288fd60135fSmrg test no = "$hardcode_direct_absolute"; then 8289fd60135fSmrg add=$dir/$linklib 8290fd60135fSmrg elif test yes = "$hardcode_minus_L"; then 8291fd60135fSmrg add_dir=-L$absdir 8292a96d7823Smrg # Try looking first in the location we're being installed to. 8293a96d7823Smrg if test -n "$inst_prefix_dir"; then 8294a96d7823Smrg case $libdir in 8295a96d7823Smrg [\\/]*) 8296a96d7823Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8297a96d7823Smrg ;; 8298a96d7823Smrg esac 8299a96d7823Smrg fi 8300fd60135fSmrg add=-l$name 8301fd60135fSmrg elif test yes = "$hardcode_shlibpath_var"; then 8302fd60135fSmrg add_shlibpath=$dir 8303fd60135fSmrg add=-l$name 8304a96d7823Smrg else 8305a96d7823Smrg lib_linked=no 8306a96d7823Smrg fi 8307a96d7823Smrg ;; 8308a96d7823Smrg *) lib_linked=no ;; 8309a96d7823Smrg esac 8310a96d7823Smrg 8311fd60135fSmrg if test yes != "$lib_linked"; then 8312a96d7823Smrg func_fatal_configuration "unsupported hardcode properties" 8313a96d7823Smrg fi 8314a96d7823Smrg 8315a96d7823Smrg if test -n "$add_shlibpath"; then 8316a96d7823Smrg case :$compile_shlibpath: in 8317a96d7823Smrg *":$add_shlibpath:"*) ;; 8318a96d7823Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8319a96d7823Smrg esac 8320a96d7823Smrg fi 8321fd60135fSmrg if test prog = "$linkmode"; then 8322a96d7823Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8323a96d7823Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8324a96d7823Smrg else 8325a96d7823Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8326a96d7823Smrg test -n "$add" && deplibs="$add $deplibs" 8327fd60135fSmrg if test yes != "$hardcode_direct" && 8328fd60135fSmrg test yes != "$hardcode_minus_L" && 8329fd60135fSmrg test yes = "$hardcode_shlibpath_var"; then 8330a96d7823Smrg case :$finalize_shlibpath: in 8331a96d7823Smrg *":$libdir:"*) ;; 8332a96d7823Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8333a96d7823Smrg esac 8334a96d7823Smrg fi 8335a96d7823Smrg fi 8336a96d7823Smrg fi 8337a96d7823Smrg 8338fd60135fSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8339a96d7823Smrg add_shlibpath= 8340a96d7823Smrg add_dir= 8341a96d7823Smrg add= 8342a96d7823Smrg # Finalize command for both is simple: just hardcode it. 8343fd60135fSmrg if test yes = "$hardcode_direct" && 8344fd60135fSmrg test no = "$hardcode_direct_absolute"; then 8345fd60135fSmrg add=$libdir/$linklib 8346fd60135fSmrg elif test yes = "$hardcode_minus_L"; then 8347fd60135fSmrg add_dir=-L$libdir 8348fd60135fSmrg add=-l$name 8349fd60135fSmrg elif test yes = "$hardcode_shlibpath_var"; then 8350a96d7823Smrg case :$finalize_shlibpath: in 8351a96d7823Smrg *":$libdir:"*) ;; 8352a96d7823Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8353a96d7823Smrg esac 8354fd60135fSmrg add=-l$name 8355fd60135fSmrg elif test yes = "$hardcode_automatic"; then 8356a96d7823Smrg if test -n "$inst_prefix_dir" && 8357fd60135fSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8358fd60135fSmrg add=$inst_prefix_dir$libdir/$linklib 8359a96d7823Smrg else 8360fd60135fSmrg add=$libdir/$linklib 8361a96d7823Smrg fi 8362a96d7823Smrg else 8363a96d7823Smrg # We cannot seem to hardcode it, guess we'll fake it. 8364fd60135fSmrg add_dir=-L$libdir 8365a96d7823Smrg # Try looking first in the location we're being installed to. 8366a96d7823Smrg if test -n "$inst_prefix_dir"; then 8367a96d7823Smrg case $libdir in 8368a96d7823Smrg [\\/]*) 8369a96d7823Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8370a96d7823Smrg ;; 8371a96d7823Smrg esac 8372a96d7823Smrg fi 8373fd60135fSmrg add=-l$name 8374a96d7823Smrg fi 8375a96d7823Smrg 8376fd60135fSmrg if test prog = "$linkmode"; then 8377a96d7823Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8378a96d7823Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8379a96d7823Smrg else 8380a96d7823Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8381a96d7823Smrg test -n "$add" && deplibs="$add $deplibs" 8382a96d7823Smrg fi 8383a96d7823Smrg fi 8384fd60135fSmrg elif test prog = "$linkmode"; then 8385a96d7823Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8386a96d7823Smrg # is not unsupported. This is valid on all known static and 8387a96d7823Smrg # shared platforms. 8388fd60135fSmrg if test unsupported != "$hardcode_direct"; then 8389fd60135fSmrg test -n "$old_library" && linklib=$old_library 8390a96d7823Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8391a96d7823Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8392a96d7823Smrg else 8393a96d7823Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8394a96d7823Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8395a96d7823Smrg fi 8396fd60135fSmrg elif test yes = "$build_libtool_libs"; then 8397a96d7823Smrg # Not a shared library 8398fd60135fSmrg if test pass_all != "$deplibs_check_method"; then 8399a96d7823Smrg # We're trying link a shared library against a static one 8400a96d7823Smrg # but the system doesn't support it. 8401a96d7823Smrg 8402a96d7823Smrg # Just print a warning and add the library to dependency_libs so 8403a96d7823Smrg # that the program can be linked against the static library. 8404a96d7823Smrg echo 8405fd60135fSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8406a96d7823Smrg echo "*** I have the capability to make that library automatically link in when" 8407a96d7823Smrg echo "*** you link to this library. But I can only do this if you have a" 8408a96d7823Smrg echo "*** shared version of the library, which you do not appear to have." 8409fd60135fSmrg if test yes = "$module"; then 8410a96d7823Smrg echo "*** But as you try to build a module library, libtool will still create " 8411a96d7823Smrg echo "*** a static module, that should work as long as the dlopening application" 8412a96d7823Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8413a96d7823Smrg if test -z "$global_symbol_pipe"; then 8414a96d7823Smrg echo 8415a96d7823Smrg echo "*** However, this would only work if libtool was able to extract symbol" 8416fd60135fSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8417a96d7823Smrg echo "*** not find such a program. So, this module is probably useless." 8418fd60135fSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8419a96d7823Smrg fi 8420fd60135fSmrg if test no = "$build_old_libs"; then 8421a96d7823Smrg build_libtool_libs=module 8422a96d7823Smrg build_old_libs=yes 8423a96d7823Smrg else 8424a96d7823Smrg build_libtool_libs=no 8425a96d7823Smrg fi 8426a96d7823Smrg fi 8427a96d7823Smrg else 8428a96d7823Smrg deplibs="$dir/$old_library $deplibs" 8429a96d7823Smrg link_static=yes 8430a96d7823Smrg fi 8431a96d7823Smrg fi # link shared/static library? 8432a96d7823Smrg 8433fd60135fSmrg if test lib = "$linkmode"; then 8434a96d7823Smrg if test -n "$dependency_libs" && 8435fd60135fSmrg { test yes != "$hardcode_into_libs" || 8436fd60135fSmrg test yes = "$build_old_libs" || 8437fd60135fSmrg test yes = "$link_static"; }; then 8438a96d7823Smrg # Extract -R from dependency_libs 8439a96d7823Smrg temp_deplibs= 8440a96d7823Smrg for libdir in $dependency_libs; do 8441a96d7823Smrg case $libdir in 8442a96d7823Smrg -R*) func_stripname '-R' '' "$libdir" 8443a96d7823Smrg temp_xrpath=$func_stripname_result 8444a96d7823Smrg case " $xrpath " in 8445a96d7823Smrg *" $temp_xrpath "*) ;; 8446a96d7823Smrg *) func_append xrpath " $temp_xrpath";; 8447a96d7823Smrg esac;; 8448a96d7823Smrg *) func_append temp_deplibs " $libdir";; 8449a96d7823Smrg esac 8450a96d7823Smrg done 8451fd60135fSmrg dependency_libs=$temp_deplibs 8452a96d7823Smrg fi 8453a96d7823Smrg 8454a96d7823Smrg func_append newlib_search_path " $absdir" 8455a96d7823Smrg # Link against this library 8456fd60135fSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8457a96d7823Smrg # ... and its dependency_libs 8458a96d7823Smrg tmp_libs= 8459a96d7823Smrg for deplib in $dependency_libs; do 8460a96d7823Smrg newdependency_libs="$deplib $newdependency_libs" 8461a96d7823Smrg case $deplib in 8462a96d7823Smrg -L*) func_stripname '-L' '' "$deplib" 8463a96d7823Smrg func_resolve_sysroot "$func_stripname_result";; 8464a96d7823Smrg *) func_resolve_sysroot "$deplib" ;; 8465a96d7823Smrg esac 8466fd60135fSmrg if $opt_preserve_dup_deps; then 8467a96d7823Smrg case "$tmp_libs " in 8468a96d7823Smrg *" $func_resolve_sysroot_result "*) 8469a96d7823Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8470a96d7823Smrg esac 8471a96d7823Smrg fi 8472a96d7823Smrg func_append tmp_libs " $func_resolve_sysroot_result" 8473a96d7823Smrg done 8474a96d7823Smrg 8475fd60135fSmrg if test no != "$link_all_deplibs"; then 8476a96d7823Smrg # Add the search paths of all dependency libraries 8477a96d7823Smrg for deplib in $dependency_libs; do 8478a96d7823Smrg path= 8479a96d7823Smrg case $deplib in 8480fd60135fSmrg -L*) path=$deplib ;; 8481a96d7823Smrg *.la) 8482a96d7823Smrg func_resolve_sysroot "$deplib" 8483a96d7823Smrg deplib=$func_resolve_sysroot_result 8484a96d7823Smrg func_dirname "$deplib" "" "." 8485a96d7823Smrg dir=$func_dirname_result 8486a96d7823Smrg # We need an absolute path. 8487a96d7823Smrg case $dir in 8488fd60135fSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8489a96d7823Smrg *) 8490a96d7823Smrg absdir=`cd "$dir" && pwd` 8491a96d7823Smrg if test -z "$absdir"; then 8492fd60135fSmrg func_warning "cannot determine absolute directory name of '$dir'" 8493fd60135fSmrg absdir=$dir 8494a96d7823Smrg fi 8495a96d7823Smrg ;; 8496a96d7823Smrg esac 8497a96d7823Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8498a96d7823Smrg case $host in 8499a96d7823Smrg *-*-darwin*) 8500a96d7823Smrg depdepl= 8501fd60135fSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8502fd60135fSmrg if test -n "$deplibrary_names"; then 8503fd60135fSmrg for tmp in $deplibrary_names; do 8504a96d7823Smrg depdepl=$tmp 8505a96d7823Smrg done 8506fd60135fSmrg if test -f "$absdir/$objdir/$depdepl"; then 8507fd60135fSmrg depdepl=$absdir/$objdir/$depdepl 8508fd60135fSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8509a96d7823Smrg if test -z "$darwin_install_name"; then 8510fd60135fSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8511a96d7823Smrg fi 8512fd60135fSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8513fd60135fSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8514a96d7823Smrg path= 8515a96d7823Smrg fi 8516a96d7823Smrg fi 8517a96d7823Smrg ;; 8518a96d7823Smrg *) 8519fd60135fSmrg path=-L$absdir/$objdir 8520a96d7823Smrg ;; 8521a96d7823Smrg esac 8522a96d7823Smrg else 8523fd60135fSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8524a96d7823Smrg test -z "$libdir" && \ 8525fd60135fSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 8526a96d7823Smrg test "$absdir" != "$libdir" && \ 8527fd60135fSmrg func_warning "'$deplib' seems to be moved" 8528a96d7823Smrg 8529fd60135fSmrg path=-L$absdir 8530a96d7823Smrg fi 8531a96d7823Smrg ;; 8532a96d7823Smrg esac 8533a96d7823Smrg case " $deplibs " in 8534a96d7823Smrg *" $path "*) ;; 8535a96d7823Smrg *) deplibs="$path $deplibs" ;; 8536a96d7823Smrg esac 8537a96d7823Smrg done 8538a96d7823Smrg fi # link_all_deplibs != no 8539a96d7823Smrg fi # linkmode = lib 8540a96d7823Smrg done # for deplib in $libs 8541fd60135fSmrg if test link = "$pass"; then 8542fd60135fSmrg if test prog = "$linkmode"; then 8543a96d7823Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8544a96d7823Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8545a96d7823Smrg else 8546a96d7823Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8547a96d7823Smrg fi 8548a96d7823Smrg fi 8549fd60135fSmrg dependency_libs=$newdependency_libs 8550fd60135fSmrg if test dlpreopen = "$pass"; then 8551a96d7823Smrg # Link the dlpreopened libraries before other libraries 8552a96d7823Smrg for deplib in $save_deplibs; do 8553a96d7823Smrg deplibs="$deplib $deplibs" 8554a96d7823Smrg done 8555a96d7823Smrg fi 8556fd60135fSmrg if test dlopen != "$pass"; then 8557fd60135fSmrg test conv = "$pass" || { 8558a96d7823Smrg # Make sure lib_search_path contains only unique directories. 8559a96d7823Smrg lib_search_path= 8560a96d7823Smrg for dir in $newlib_search_path; do 8561a96d7823Smrg case "$lib_search_path " in 8562a96d7823Smrg *" $dir "*) ;; 8563a96d7823Smrg *) func_append lib_search_path " $dir" ;; 8564a96d7823Smrg esac 8565a96d7823Smrg done 8566a96d7823Smrg newlib_search_path= 8567fd60135fSmrg } 8568a96d7823Smrg 8569fd60135fSmrg if test prog,link = "$linkmode,$pass"; then 8570a96d7823Smrg vars="compile_deplibs finalize_deplibs" 8571fd60135fSmrg else 8572fd60135fSmrg vars=deplibs 8573a96d7823Smrg fi 8574a96d7823Smrg for var in $vars dependency_libs; do 8575a96d7823Smrg # Add libraries to $var in reverse order 8576a96d7823Smrg eval tmp_libs=\"\$$var\" 8577a96d7823Smrg new_libs= 8578a96d7823Smrg for deplib in $tmp_libs; do 8579a96d7823Smrg # FIXME: Pedantically, this is the right thing to do, so 8580a96d7823Smrg # that some nasty dependency loop isn't accidentally 8581a96d7823Smrg # broken: 8582a96d7823Smrg #new_libs="$deplib $new_libs" 8583a96d7823Smrg # Pragmatically, this seems to cause very few problems in 8584a96d7823Smrg # practice: 8585a96d7823Smrg case $deplib in 8586a96d7823Smrg -L*) new_libs="$deplib $new_libs" ;; 8587a96d7823Smrg -R*) ;; 8588a96d7823Smrg *) 8589a96d7823Smrg # And here is the reason: when a library appears more 8590a96d7823Smrg # than once as an explicit dependence of a library, or 8591a96d7823Smrg # is implicitly linked in more than once by the 8592a96d7823Smrg # compiler, it is considered special, and multiple 8593a96d7823Smrg # occurrences thereof are not removed. Compare this 8594a96d7823Smrg # with having the same library being listed as a 8595a96d7823Smrg # dependency of multiple other libraries: in this case, 8596a96d7823Smrg # we know (pedantically, we assume) the library does not 8597a96d7823Smrg # need to be listed more than once, so we keep only the 8598a96d7823Smrg # last copy. This is not always right, but it is rare 8599a96d7823Smrg # enough that we require users that really mean to play 8600a96d7823Smrg # such unportable linking tricks to link the library 8601a96d7823Smrg # using -Wl,-lname, so that libtool does not consider it 8602a96d7823Smrg # for duplicate removal. 8603a96d7823Smrg case " $specialdeplibs " in 8604a96d7823Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8605a96d7823Smrg *) 8606a96d7823Smrg case " $new_libs " in 8607a96d7823Smrg *" $deplib "*) ;; 8608a96d7823Smrg *) new_libs="$deplib $new_libs" ;; 8609a96d7823Smrg esac 8610a96d7823Smrg ;; 8611a96d7823Smrg esac 8612a96d7823Smrg ;; 8613a96d7823Smrg esac 8614a96d7823Smrg done 8615a96d7823Smrg tmp_libs= 8616a96d7823Smrg for deplib in $new_libs; do 8617a96d7823Smrg case $deplib in 8618a96d7823Smrg -L*) 8619a96d7823Smrg case " $tmp_libs " in 8620a96d7823Smrg *" $deplib "*) ;; 8621a96d7823Smrg *) func_append tmp_libs " $deplib" ;; 8622a96d7823Smrg esac 8623a96d7823Smrg ;; 8624a96d7823Smrg *) func_append tmp_libs " $deplib" ;; 8625a96d7823Smrg esac 8626a96d7823Smrg done 8627a96d7823Smrg eval $var=\"$tmp_libs\" 8628a96d7823Smrg done # for var 8629a96d7823Smrg fi 8630fd60135fSmrg 8631fd60135fSmrg # Add Sun CC postdeps if required: 8632fd60135fSmrg test CXX = "$tagname" && { 8633fd60135fSmrg case $host_os in 8634fd60135fSmrg linux*) 8635fd60135fSmrg case `$CC -V 2>&1 | sed 5q` in 8636fd60135fSmrg *Sun\ C*) # Sun C++ 5.9 8637fd60135fSmrg func_suncc_cstd_abi 8638fd60135fSmrg 8639fd60135fSmrg if test no != "$suncc_use_cstd_abi"; then 8640fd60135fSmrg func_append postdeps ' -library=Cstd -library=Crun' 8641fd60135fSmrg fi 8642fd60135fSmrg ;; 8643fd60135fSmrg esac 8644fd60135fSmrg ;; 8645fd60135fSmrg 8646fd60135fSmrg solaris*) 8647fd60135fSmrg func_cc_basename "$CC" 8648fd60135fSmrg case $func_cc_basename_result in 8649fd60135fSmrg CC* | sunCC*) 8650fd60135fSmrg func_suncc_cstd_abi 8651fd60135fSmrg 8652fd60135fSmrg if test no != "$suncc_use_cstd_abi"; then 8653fd60135fSmrg func_append postdeps ' -library=Cstd -library=Crun' 8654fd60135fSmrg fi 8655fd60135fSmrg ;; 8656fd60135fSmrg esac 8657fd60135fSmrg ;; 8658fd60135fSmrg esac 8659fd60135fSmrg } 8660fd60135fSmrg 8661a96d7823Smrg # Last step: remove runtime libs from dependency_libs 8662a96d7823Smrg # (they stay in deplibs) 8663a96d7823Smrg tmp_libs= 8664fd60135fSmrg for i in $dependency_libs; do 8665a96d7823Smrg case " $predeps $postdeps $compiler_lib_search_path " in 8666a96d7823Smrg *" $i "*) 8667fd60135fSmrg i= 8668a96d7823Smrg ;; 8669a96d7823Smrg esac 8670fd60135fSmrg if test -n "$i"; then 8671a96d7823Smrg func_append tmp_libs " $i" 8672a96d7823Smrg fi 8673a96d7823Smrg done 8674a96d7823Smrg dependency_libs=$tmp_libs 8675a96d7823Smrg done # for pass 8676fd60135fSmrg if test prog = "$linkmode"; then 8677fd60135fSmrg dlfiles=$newdlfiles 8678a96d7823Smrg fi 8679fd60135fSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8680fd60135fSmrg dlprefiles=$newdlprefiles 8681a96d7823Smrg fi 8682a96d7823Smrg 8683a96d7823Smrg case $linkmode in 8684a96d7823Smrg oldlib) 8685fd60135fSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8686fd60135fSmrg func_warning "'-dlopen' is ignored for archives" 8687a96d7823Smrg fi 8688a96d7823Smrg 8689a96d7823Smrg case " $deplibs" in 8690a96d7823Smrg *\ -l* | *\ -L*) 8691fd60135fSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 8692a96d7823Smrg esac 8693a96d7823Smrg 8694a96d7823Smrg test -n "$rpath" && \ 8695fd60135fSmrg func_warning "'-rpath' is ignored for archives" 8696a96d7823Smrg 8697a96d7823Smrg test -n "$xrpath" && \ 8698fd60135fSmrg func_warning "'-R' is ignored for archives" 8699a96d7823Smrg 8700a96d7823Smrg test -n "$vinfo" && \ 8701fd60135fSmrg func_warning "'-version-info/-version-number' is ignored for archives" 8702a96d7823Smrg 8703a96d7823Smrg test -n "$release" && \ 8704fd60135fSmrg func_warning "'-release' is ignored for archives" 8705a96d7823Smrg 8706a96d7823Smrg test -n "$export_symbols$export_symbols_regex" && \ 8707fd60135fSmrg func_warning "'-export-symbols' is ignored for archives" 8708a96d7823Smrg 8709a96d7823Smrg # Now set the variables for building old libraries. 8710a96d7823Smrg build_libtool_libs=no 8711fd60135fSmrg oldlibs=$output 8712a96d7823Smrg func_append objs "$old_deplibs" 8713a96d7823Smrg ;; 8714a96d7823Smrg 8715a96d7823Smrg lib) 8716fd60135fSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 8717a96d7823Smrg case $outputname in 8718a96d7823Smrg lib*) 8719a96d7823Smrg func_stripname 'lib' '.la' "$outputname" 8720a96d7823Smrg name=$func_stripname_result 8721a96d7823Smrg eval shared_ext=\"$shrext_cmds\" 8722a96d7823Smrg eval libname=\"$libname_spec\" 8723a96d7823Smrg ;; 8724a96d7823Smrg *) 8725fd60135fSmrg test no = "$module" \ 8726fd60135fSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 8727a96d7823Smrg 8728fd60135fSmrg if test no != "$need_lib_prefix"; then 8729a96d7823Smrg # Add the "lib" prefix for modules if required 8730a96d7823Smrg func_stripname '' '.la' "$outputname" 8731a96d7823Smrg name=$func_stripname_result 8732a96d7823Smrg eval shared_ext=\"$shrext_cmds\" 8733a96d7823Smrg eval libname=\"$libname_spec\" 8734a96d7823Smrg else 8735a96d7823Smrg func_stripname '' '.la' "$outputname" 8736a96d7823Smrg libname=$func_stripname_result 8737a96d7823Smrg fi 8738a96d7823Smrg ;; 8739a96d7823Smrg esac 8740a96d7823Smrg 8741a96d7823Smrg if test -n "$objs"; then 8742fd60135fSmrg if test pass_all != "$deplibs_check_method"; then 8743fd60135fSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8744a96d7823Smrg else 8745a96d7823Smrg echo 8746a96d7823Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8747a96d7823Smrg $ECHO "*** objects $objs is not portable!" 8748a96d7823Smrg func_append libobjs " $objs" 8749a96d7823Smrg fi 8750a96d7823Smrg fi 8751a96d7823Smrg 8752fd60135fSmrg test no = "$dlself" \ 8753fd60135fSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 8754a96d7823Smrg 8755a96d7823Smrg set dummy $rpath 8756a96d7823Smrg shift 8757fd60135fSmrg test 1 -lt "$#" \ 8758fd60135fSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 8759a96d7823Smrg 8760fd60135fSmrg install_libdir=$1 8761a96d7823Smrg 8762a96d7823Smrg oldlibs= 8763a96d7823Smrg if test -z "$rpath"; then 8764fd60135fSmrg if test yes = "$build_libtool_libs"; then 8765a96d7823Smrg # Building a libtool convenience library. 8766fd60135fSmrg # Some compilers have problems with a '.al' extension so 8767a96d7823Smrg # convenience libraries should have the same extension an 8768a96d7823Smrg # archive normally would. 8769a96d7823Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 8770a96d7823Smrg build_libtool_libs=convenience 8771a96d7823Smrg build_old_libs=yes 8772a96d7823Smrg fi 8773a96d7823Smrg 8774a96d7823Smrg test -n "$vinfo" && \ 8775fd60135fSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8776a96d7823Smrg 8777a96d7823Smrg test -n "$release" && \ 8778fd60135fSmrg func_warning "'-release' is ignored for convenience libraries" 8779a96d7823Smrg else 8780a96d7823Smrg 8781a96d7823Smrg # Parse the version information argument. 8782fd60135fSmrg save_ifs=$IFS; IFS=: 8783a96d7823Smrg set dummy $vinfo 0 0 0 8784a96d7823Smrg shift 8785fd60135fSmrg IFS=$save_ifs 8786a96d7823Smrg 8787a96d7823Smrg test -n "$7" && \ 8788fd60135fSmrg func_fatal_help "too many parameters to '-version-info'" 8789a96d7823Smrg 8790a96d7823Smrg # convert absolute version numbers to libtool ages 8791a96d7823Smrg # this retains compatibility with .la files and attempts 8792a96d7823Smrg # to make the code below a bit more comprehensible 8793a96d7823Smrg 8794a96d7823Smrg case $vinfo_number in 8795a96d7823Smrg yes) 8796fd60135fSmrg number_major=$1 8797fd60135fSmrg number_minor=$2 8798fd60135fSmrg number_revision=$3 8799a96d7823Smrg # 8800a96d7823Smrg # There are really only two kinds -- those that 8801a96d7823Smrg # use the current revision as the major version 8802a96d7823Smrg # and those that subtract age and use age as 8803a96d7823Smrg # a minor version. But, then there is irix 8804fd60135fSmrg # that has an extra 1 added just for fun 8805a96d7823Smrg # 8806a96d7823Smrg case $version_type in 8807a96d7823Smrg # correct linux to gnu/linux during the next big refactor 8808fd60135fSmrg darwin|freebsd-elf|linux|osf|windows|none) 8809a96d7823Smrg func_arith $number_major + $number_minor 8810a96d7823Smrg current=$func_arith_result 8811fd60135fSmrg age=$number_minor 8812fd60135fSmrg revision=$number_revision 8813a96d7823Smrg ;; 8814fd60135fSmrg freebsd-aout|qnx|sunos) 8815fd60135fSmrg current=$number_major 8816fd60135fSmrg revision=$number_minor 8817fd60135fSmrg age=0 8818a96d7823Smrg ;; 8819a96d7823Smrg irix|nonstopux) 8820a96d7823Smrg func_arith $number_major + $number_minor 8821a96d7823Smrg current=$func_arith_result 8822fd60135fSmrg age=$number_minor 8823fd60135fSmrg revision=$number_minor 8824a96d7823Smrg lt_irix_increment=no 8825a96d7823Smrg ;; 8826a96d7823Smrg esac 8827a96d7823Smrg ;; 8828a96d7823Smrg no) 8829fd60135fSmrg current=$1 8830fd60135fSmrg revision=$2 8831fd60135fSmrg age=$3 8832a96d7823Smrg ;; 8833a96d7823Smrg esac 8834a96d7823Smrg 8835a96d7823Smrg # Check that each of the things are valid numbers. 8836a96d7823Smrg case $current in 8837a96d7823Smrg 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]) ;; 8838a96d7823Smrg *) 8839fd60135fSmrg func_error "CURRENT '$current' must be a nonnegative integer" 8840fd60135fSmrg func_fatal_error "'$vinfo' is not valid version information" 8841a96d7823Smrg ;; 8842a96d7823Smrg esac 8843a96d7823Smrg 8844a96d7823Smrg case $revision in 8845a96d7823Smrg 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]) ;; 8846a96d7823Smrg *) 8847fd60135fSmrg func_error "REVISION '$revision' must be a nonnegative integer" 8848fd60135fSmrg func_fatal_error "'$vinfo' is not valid version information" 8849a96d7823Smrg ;; 8850a96d7823Smrg esac 8851a96d7823Smrg 8852a96d7823Smrg case $age in 8853a96d7823Smrg 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]) ;; 8854a96d7823Smrg *) 8855fd60135fSmrg func_error "AGE '$age' must be a nonnegative integer" 8856fd60135fSmrg func_fatal_error "'$vinfo' is not valid version information" 8857a96d7823Smrg ;; 8858a96d7823Smrg esac 8859a96d7823Smrg 8860a96d7823Smrg if test "$age" -gt "$current"; then 8861fd60135fSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 8862fd60135fSmrg func_fatal_error "'$vinfo' is not valid version information" 8863a96d7823Smrg fi 8864a96d7823Smrg 8865a96d7823Smrg # Calculate the version variables. 8866a96d7823Smrg major= 8867a96d7823Smrg versuffix= 8868a96d7823Smrg verstring= 8869a96d7823Smrg case $version_type in 8870a96d7823Smrg none) ;; 8871a96d7823Smrg 8872a96d7823Smrg darwin) 8873a96d7823Smrg # Like Linux, but with the current version available in 8874a96d7823Smrg # verstring for coding it into the library header 8875a96d7823Smrg func_arith $current - $age 8876a96d7823Smrg major=.$func_arith_result 8877fd60135fSmrg versuffix=$major.$age.$revision 8878a96d7823Smrg # Darwin ld doesn't like 0 for these options... 8879a96d7823Smrg func_arith $current + 1 8880a96d7823Smrg minor_current=$func_arith_result 8881fd60135fSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8882a96d7823Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8883fd60135fSmrg # On Darwin other compilers 8884fd60135fSmrg case $CC in 8885fd60135fSmrg nagfor*) 8886fd60135fSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8887fd60135fSmrg ;; 8888fd60135fSmrg *) 8889fd60135fSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8890fd60135fSmrg ;; 8891fd60135fSmrg esac 8892a96d7823Smrg ;; 8893a96d7823Smrg 8894a96d7823Smrg freebsd-aout) 8895fd60135fSmrg major=.$current 8896fd60135fSmrg versuffix=.$current.$revision 8897a96d7823Smrg ;; 8898a96d7823Smrg 8899a96d7823Smrg freebsd-elf) 8900fd60135fSmrg func_arith $current - $age 8901fd60135fSmrg major=.$func_arith_result 8902fd60135fSmrg versuffix=$major.$age.$revision 8903a96d7823Smrg ;; 8904a96d7823Smrg 8905a96d7823Smrg irix | nonstopux) 8906fd60135fSmrg if test no = "$lt_irix_increment"; then 8907a96d7823Smrg func_arith $current - $age 8908a96d7823Smrg else 8909a96d7823Smrg func_arith $current - $age + 1 8910a96d7823Smrg fi 8911a96d7823Smrg major=$func_arith_result 8912a96d7823Smrg 8913a96d7823Smrg case $version_type in 8914a96d7823Smrg nonstopux) verstring_prefix=nonstopux ;; 8915a96d7823Smrg *) verstring_prefix=sgi ;; 8916a96d7823Smrg esac 8917fd60135fSmrg verstring=$verstring_prefix$major.$revision 8918a96d7823Smrg 8919a96d7823Smrg # Add in all the interfaces that we are compatible with. 8920a96d7823Smrg loop=$revision 8921fd60135fSmrg while test 0 -ne "$loop"; do 8922a96d7823Smrg func_arith $revision - $loop 8923a96d7823Smrg iface=$func_arith_result 8924a96d7823Smrg func_arith $loop - 1 8925a96d7823Smrg loop=$func_arith_result 8926fd60135fSmrg verstring=$verstring_prefix$major.$iface:$verstring 8927a96d7823Smrg done 8928a96d7823Smrg 8929fd60135fSmrg # Before this point, $major must not contain '.'. 8930a96d7823Smrg major=.$major 8931fd60135fSmrg versuffix=$major.$revision 8932a96d7823Smrg ;; 8933a96d7823Smrg 8934a96d7823Smrg linux) # correct to gnu/linux during the next big refactor 8935a96d7823Smrg func_arith $current - $age 8936a96d7823Smrg major=.$func_arith_result 8937fd60135fSmrg versuffix=$major.$age.$revision 8938a96d7823Smrg ;; 8939a96d7823Smrg 8940a96d7823Smrg osf) 8941a96d7823Smrg func_arith $current - $age 8942a96d7823Smrg major=.$func_arith_result 8943fd60135fSmrg versuffix=.$current.$age.$revision 8944fd60135fSmrg verstring=$current.$age.$revision 8945a96d7823Smrg 8946a96d7823Smrg # Add in all the interfaces that we are compatible with. 8947a96d7823Smrg loop=$age 8948fd60135fSmrg while test 0 -ne "$loop"; do 8949a96d7823Smrg func_arith $current - $loop 8950a96d7823Smrg iface=$func_arith_result 8951a96d7823Smrg func_arith $loop - 1 8952a96d7823Smrg loop=$func_arith_result 8953fd60135fSmrg verstring=$verstring:$iface.0 8954a96d7823Smrg done 8955a96d7823Smrg 8956a96d7823Smrg # Make executables depend on our current version. 8957fd60135fSmrg func_append verstring ":$current.0" 8958a96d7823Smrg ;; 8959a96d7823Smrg 8960a96d7823Smrg qnx) 8961fd60135fSmrg major=.$current 8962fd60135fSmrg versuffix=.$current 8963fd60135fSmrg ;; 8964fd60135fSmrg 8965fd60135fSmrg sco) 8966fd60135fSmrg major=.$current 8967fd60135fSmrg versuffix=.$current 8968a96d7823Smrg ;; 8969a96d7823Smrg 8970a96d7823Smrg sunos) 8971fd60135fSmrg major=.$current 8972fd60135fSmrg versuffix=.$current.$revision 8973a96d7823Smrg ;; 8974a96d7823Smrg 8975a96d7823Smrg windows) 8976a96d7823Smrg # Use '-' rather than '.', since we only want one 8977fd60135fSmrg # extension on DOS 8.3 file systems. 8978a96d7823Smrg func_arith $current - $age 8979a96d7823Smrg major=$func_arith_result 8980fd60135fSmrg versuffix=-$major 8981a96d7823Smrg ;; 8982a96d7823Smrg 8983a96d7823Smrg *) 8984fd60135fSmrg func_fatal_configuration "unknown library version type '$version_type'" 8985a96d7823Smrg ;; 8986a96d7823Smrg esac 8987a96d7823Smrg 8988a96d7823Smrg # Clear the version info if we defaulted, and they specified a release. 8989a96d7823Smrg if test -z "$vinfo" && test -n "$release"; then 8990a96d7823Smrg major= 8991a96d7823Smrg case $version_type in 8992a96d7823Smrg darwin) 8993a96d7823Smrg # we can't check for "0.0" in archive_cmds due to quoting 8994a96d7823Smrg # problems, so we reset it completely 8995a96d7823Smrg verstring= 8996a96d7823Smrg ;; 8997a96d7823Smrg *) 8998fd60135fSmrg verstring=0.0 8999a96d7823Smrg ;; 9000a96d7823Smrg esac 9001fd60135fSmrg if test no = "$need_version"; then 9002a96d7823Smrg versuffix= 9003a96d7823Smrg else 9004fd60135fSmrg versuffix=.0.0 9005a96d7823Smrg fi 9006a96d7823Smrg fi 9007a96d7823Smrg 9008a96d7823Smrg # Remove version info from name if versioning should be avoided 9009fd60135fSmrg if test yes,no = "$avoid_version,$need_version"; then 9010a96d7823Smrg major= 9011a96d7823Smrg versuffix= 9012fd60135fSmrg verstring= 9013a96d7823Smrg fi 9014a96d7823Smrg 9015a96d7823Smrg # Check to see if the archive will have undefined symbols. 9016fd60135fSmrg if test yes = "$allow_undefined"; then 9017fd60135fSmrg if test unsupported = "$allow_undefined_flag"; then 9018fd60135fSmrg if test yes = "$build_old_libs"; then 9019fd60135fSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9020fd60135fSmrg build_libtool_libs=no 9021fd60135fSmrg else 9022fd60135fSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9023fd60135fSmrg fi 9024a96d7823Smrg fi 9025a96d7823Smrg else 9026a96d7823Smrg # Don't allow undefined symbols. 9027fd60135fSmrg allow_undefined_flag=$no_undefined_flag 9028a96d7823Smrg fi 9029a96d7823Smrg 9030a96d7823Smrg fi 9031a96d7823Smrg 9032fd60135fSmrg func_generate_dlsyms "$libname" "$libname" : 9033a96d7823Smrg func_append libobjs " $symfileobj" 9034fd60135fSmrg test " " = "$libobjs" && libobjs= 9035a96d7823Smrg 9036fd60135fSmrg if test relink != "$opt_mode"; then 9037a96d7823Smrg # Remove our outputs, but don't remove object files since they 9038a96d7823Smrg # may have been created when compiling PIC objects. 9039a96d7823Smrg removelist= 9040a96d7823Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9041a96d7823Smrg for p in $tempremovelist; do 9042a96d7823Smrg case $p in 9043a96d7823Smrg *.$objext | *.gcno) 9044a96d7823Smrg ;; 9045fd60135fSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9046fd60135fSmrg if test -n "$precious_files_regex"; then 9047a96d7823Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9048a96d7823Smrg then 9049a96d7823Smrg continue 9050a96d7823Smrg fi 9051a96d7823Smrg fi 9052a96d7823Smrg func_append removelist " $p" 9053a96d7823Smrg ;; 9054a96d7823Smrg *) ;; 9055a96d7823Smrg esac 9056a96d7823Smrg done 9057a96d7823Smrg test -n "$removelist" && \ 9058a96d7823Smrg func_show_eval "${RM}r \$removelist" 9059a96d7823Smrg fi 9060a96d7823Smrg 9061a96d7823Smrg # Now set the variables for building old libraries. 9062fd60135fSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9063a96d7823Smrg func_append oldlibs " $output_objdir/$libname.$libext" 9064a96d7823Smrg 9065a96d7823Smrg # Transform .lo files to .o files. 9066fd60135fSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9067a96d7823Smrg fi 9068a96d7823Smrg 9069a96d7823Smrg # Eliminate all temporary directories. 9070a96d7823Smrg #for path in $notinst_path; do 9071a96d7823Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9072a96d7823Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9073a96d7823Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9074a96d7823Smrg #done 9075a96d7823Smrg 9076a96d7823Smrg if test -n "$xrpath"; then 9077a96d7823Smrg # If the user specified any rpath flags, then add them. 9078a96d7823Smrg temp_xrpath= 9079a96d7823Smrg for libdir in $xrpath; do 9080a96d7823Smrg func_replace_sysroot "$libdir" 9081a96d7823Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9082a96d7823Smrg case "$finalize_rpath " in 9083a96d7823Smrg *" $libdir "*) ;; 9084a96d7823Smrg *) func_append finalize_rpath " $libdir" ;; 9085a96d7823Smrg esac 9086a96d7823Smrg done 9087fd60135fSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9088a96d7823Smrg dependency_libs="$temp_xrpath $dependency_libs" 9089a96d7823Smrg fi 9090a96d7823Smrg fi 9091a96d7823Smrg 9092a96d7823Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9093fd60135fSmrg old_dlfiles=$dlfiles 9094a96d7823Smrg dlfiles= 9095a96d7823Smrg for lib in $old_dlfiles; do 9096a96d7823Smrg case " $dlprefiles $dlfiles " in 9097a96d7823Smrg *" $lib "*) ;; 9098a96d7823Smrg *) func_append dlfiles " $lib" ;; 9099a96d7823Smrg esac 9100a96d7823Smrg done 9101a96d7823Smrg 9102a96d7823Smrg # Make sure dlprefiles contains only unique files 9103fd60135fSmrg old_dlprefiles=$dlprefiles 9104a96d7823Smrg dlprefiles= 9105a96d7823Smrg for lib in $old_dlprefiles; do 9106a96d7823Smrg case "$dlprefiles " in 9107a96d7823Smrg *" $lib "*) ;; 9108a96d7823Smrg *) func_append dlprefiles " $lib" ;; 9109a96d7823Smrg esac 9110a96d7823Smrg done 9111a96d7823Smrg 9112fd60135fSmrg if test yes = "$build_libtool_libs"; then 9113a96d7823Smrg if test -n "$rpath"; then 9114a96d7823Smrg case $host in 9115a96d7823Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9116a96d7823Smrg # these systems don't actually have a c library (as such)! 9117a96d7823Smrg ;; 9118a96d7823Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9119a96d7823Smrg # Rhapsody C library is in the System framework 9120a96d7823Smrg func_append deplibs " System.ltframework" 9121a96d7823Smrg ;; 9122a96d7823Smrg *-*-netbsd*) 9123a96d7823Smrg # Don't link with libc until the a.out ld.so is fixed. 9124a96d7823Smrg ;; 9125a96d7823Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9126a96d7823Smrg # Do not include libc due to us having libc/libc_r. 9127a96d7823Smrg ;; 9128a96d7823Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9129a96d7823Smrg # Causes problems with __ctype 9130a96d7823Smrg ;; 9131a96d7823Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9132a96d7823Smrg # Compiler inserts libc in the correct place for threads to work 9133a96d7823Smrg ;; 9134a96d7823Smrg *) 9135a96d7823Smrg # Add libc to deplibs on all other systems if necessary. 9136fd60135fSmrg if test yes = "$build_libtool_need_lc"; then 9137a96d7823Smrg func_append deplibs " -lc" 9138a96d7823Smrg fi 9139a96d7823Smrg ;; 9140a96d7823Smrg esac 9141a96d7823Smrg fi 9142a96d7823Smrg 9143a96d7823Smrg # Transform deplibs into only deplibs that can be linked in shared. 9144a96d7823Smrg name_save=$name 9145a96d7823Smrg libname_save=$libname 9146a96d7823Smrg release_save=$release 9147a96d7823Smrg versuffix_save=$versuffix 9148a96d7823Smrg major_save=$major 9149a96d7823Smrg # I'm not sure if I'm treating the release correctly. I think 9150a96d7823Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9151a96d7823Smrg # add it in twice. Is that correct? 9152fd60135fSmrg release= 9153fd60135fSmrg versuffix= 9154fd60135fSmrg major= 9155a96d7823Smrg newdeplibs= 9156a96d7823Smrg droppeddeps=no 9157a96d7823Smrg case $deplibs_check_method in 9158a96d7823Smrg pass_all) 9159a96d7823Smrg # Don't check for shared/static. Everything works. 9160a96d7823Smrg # This might be a little naive. We might want to check 9161a96d7823Smrg # whether the library exists or not. But this is on 9162a96d7823Smrg # osf3 & osf4 and I'm not really sure... Just 9163a96d7823Smrg # implementing what was already the behavior. 9164a96d7823Smrg newdeplibs=$deplibs 9165a96d7823Smrg ;; 9166a96d7823Smrg test_compile) 9167a96d7823Smrg # This code stresses the "libraries are programs" paradigm to its 9168a96d7823Smrg # limits. Maybe even breaks it. We compile a program, linking it 9169a96d7823Smrg # against the deplibs as a proxy for the library. Then we can check 9170a96d7823Smrg # whether they linked in statically or dynamically with ldd. 9171a96d7823Smrg $opt_dry_run || $RM conftest.c 9172a96d7823Smrg cat > conftest.c <<EOF 9173a96d7823Smrg int main() { return 0; } 9174a96d7823SmrgEOF 9175a96d7823Smrg $opt_dry_run || $RM conftest 9176a96d7823Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9177a96d7823Smrg ldd_output=`ldd conftest` 9178a96d7823Smrg for i in $deplibs; do 9179a96d7823Smrg case $i in 9180a96d7823Smrg -l*) 9181a96d7823Smrg func_stripname -l '' "$i" 9182a96d7823Smrg name=$func_stripname_result 9183fd60135fSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9184a96d7823Smrg case " $predeps $postdeps " in 9185a96d7823Smrg *" $i "*) 9186a96d7823Smrg func_append newdeplibs " $i" 9187fd60135fSmrg i= 9188a96d7823Smrg ;; 9189a96d7823Smrg esac 9190a96d7823Smrg fi 9191fd60135fSmrg if test -n "$i"; then 9192a96d7823Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9193a96d7823Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9194a96d7823Smrg set dummy $deplib_matches; shift 9195a96d7823Smrg deplib_match=$1 9196fd60135fSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9197a96d7823Smrg func_append newdeplibs " $i" 9198a96d7823Smrg else 9199a96d7823Smrg droppeddeps=yes 9200a96d7823Smrg echo 9201a96d7823Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9202a96d7823Smrg echo "*** I have the capability to make that library automatically link in when" 9203a96d7823Smrg echo "*** you link to this library. But I can only do this if you have a" 9204a96d7823Smrg echo "*** shared version of the library, which I believe you do not have" 9205a96d7823Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 9206a96d7823Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9207a96d7823Smrg fi 9208a96d7823Smrg fi 9209a96d7823Smrg ;; 9210a96d7823Smrg *) 9211a96d7823Smrg func_append newdeplibs " $i" 9212a96d7823Smrg ;; 9213a96d7823Smrg esac 9214a96d7823Smrg done 9215a96d7823Smrg else 9216a96d7823Smrg # Error occurred in the first compile. Let's try to salvage 9217a96d7823Smrg # the situation: Compile a separate program for each library. 9218a96d7823Smrg for i in $deplibs; do 9219a96d7823Smrg case $i in 9220a96d7823Smrg -l*) 9221a96d7823Smrg func_stripname -l '' "$i" 9222a96d7823Smrg name=$func_stripname_result 9223a96d7823Smrg $opt_dry_run || $RM conftest 9224a96d7823Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9225a96d7823Smrg ldd_output=`ldd conftest` 9226fd60135fSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9227a96d7823Smrg case " $predeps $postdeps " in 9228a96d7823Smrg *" $i "*) 9229a96d7823Smrg func_append newdeplibs " $i" 9230fd60135fSmrg i= 9231a96d7823Smrg ;; 9232a96d7823Smrg esac 9233a96d7823Smrg fi 9234fd60135fSmrg if test -n "$i"; then 9235a96d7823Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9236a96d7823Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9237a96d7823Smrg set dummy $deplib_matches; shift 9238a96d7823Smrg deplib_match=$1 9239fd60135fSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9240a96d7823Smrg func_append newdeplibs " $i" 9241a96d7823Smrg else 9242a96d7823Smrg droppeddeps=yes 9243a96d7823Smrg echo 9244a96d7823Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9245a96d7823Smrg echo "*** I have the capability to make that library automatically link in when" 9246a96d7823Smrg echo "*** you link to this library. But I can only do this if you have a" 9247a96d7823Smrg echo "*** shared version of the library, which you do not appear to have" 9248a96d7823Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 9249a96d7823Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9250a96d7823Smrg fi 9251a96d7823Smrg fi 9252a96d7823Smrg else 9253a96d7823Smrg droppeddeps=yes 9254a96d7823Smrg echo 9255a96d7823Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9256a96d7823Smrg echo "*** make it link in! You will probably need to install it or some" 9257a96d7823Smrg echo "*** library that it depends on before this library will be fully" 9258a96d7823Smrg echo "*** functional. Installing it before continuing would be even better." 9259a96d7823Smrg fi 9260a96d7823Smrg ;; 9261a96d7823Smrg *) 9262a96d7823Smrg func_append newdeplibs " $i" 9263a96d7823Smrg ;; 9264a96d7823Smrg esac 9265a96d7823Smrg done 9266a96d7823Smrg fi 9267a96d7823Smrg ;; 9268a96d7823Smrg file_magic*) 9269a96d7823Smrg set dummy $deplibs_check_method; shift 9270a96d7823Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9271a96d7823Smrg for a_deplib in $deplibs; do 9272a96d7823Smrg case $a_deplib in 9273a96d7823Smrg -l*) 9274a96d7823Smrg func_stripname -l '' "$a_deplib" 9275a96d7823Smrg name=$func_stripname_result 9276fd60135fSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9277a96d7823Smrg case " $predeps $postdeps " in 9278a96d7823Smrg *" $a_deplib "*) 9279a96d7823Smrg func_append newdeplibs " $a_deplib" 9280fd60135fSmrg a_deplib= 9281a96d7823Smrg ;; 9282a96d7823Smrg esac 9283a96d7823Smrg fi 9284fd60135fSmrg if test -n "$a_deplib"; then 9285a96d7823Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9286a96d7823Smrg if test -n "$file_magic_glob"; then 9287a96d7823Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9288a96d7823Smrg else 9289a96d7823Smrg libnameglob=$libname 9290a96d7823Smrg fi 9291fd60135fSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9292a96d7823Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9293fd60135fSmrg if test yes = "$want_nocaseglob"; then 9294a96d7823Smrg shopt -s nocaseglob 9295a96d7823Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9296a96d7823Smrg $nocaseglob 9297a96d7823Smrg else 9298a96d7823Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9299a96d7823Smrg fi 9300a96d7823Smrg for potent_lib in $potential_libs; do 9301a96d7823Smrg # Follow soft links. 9302a96d7823Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9303a96d7823Smrg $GREP " -> " >/dev/null; then 9304a96d7823Smrg continue 9305a96d7823Smrg fi 9306a96d7823Smrg # The statement above tries to avoid entering an 9307a96d7823Smrg # endless loop below, in case of cyclic links. 9308a96d7823Smrg # We might still enter an endless loop, since a link 9309a96d7823Smrg # loop can be closed while we follow links, 9310a96d7823Smrg # but so what? 9311fd60135fSmrg potlib=$potent_lib 9312a96d7823Smrg while test -h "$potlib" 2>/dev/null; do 9313fd60135fSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9314a96d7823Smrg case $potliblink in 9315fd60135fSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9316fd60135fSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9317a96d7823Smrg esac 9318a96d7823Smrg done 9319a96d7823Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9320a96d7823Smrg $SED -e 10q | 9321a96d7823Smrg $EGREP "$file_magic_regex" > /dev/null; then 9322a96d7823Smrg func_append newdeplibs " $a_deplib" 9323fd60135fSmrg a_deplib= 9324a96d7823Smrg break 2 9325a96d7823Smrg fi 9326a96d7823Smrg done 9327a96d7823Smrg done 9328a96d7823Smrg fi 9329fd60135fSmrg if test -n "$a_deplib"; then 9330a96d7823Smrg droppeddeps=yes 9331a96d7823Smrg echo 9332a96d7823Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9333a96d7823Smrg echo "*** I have the capability to make that library automatically link in when" 9334a96d7823Smrg echo "*** you link to this library. But I can only do this if you have a" 9335a96d7823Smrg echo "*** shared version of the library, which you do not appear to have" 9336a96d7823Smrg echo "*** because I did check the linker path looking for a file starting" 9337fd60135fSmrg if test -z "$potlib"; then 9338a96d7823Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9339a96d7823Smrg else 9340a96d7823Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9341a96d7823Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 9342a96d7823Smrg fi 9343a96d7823Smrg fi 9344a96d7823Smrg ;; 9345a96d7823Smrg *) 9346a96d7823Smrg # Add a -L argument. 9347a96d7823Smrg func_append newdeplibs " $a_deplib" 9348a96d7823Smrg ;; 9349a96d7823Smrg esac 9350a96d7823Smrg done # Gone through all deplibs. 9351a96d7823Smrg ;; 9352a96d7823Smrg match_pattern*) 9353a96d7823Smrg set dummy $deplibs_check_method; shift 9354a96d7823Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9355a96d7823Smrg for a_deplib in $deplibs; do 9356a96d7823Smrg case $a_deplib in 9357a96d7823Smrg -l*) 9358a96d7823Smrg func_stripname -l '' "$a_deplib" 9359a96d7823Smrg name=$func_stripname_result 9360fd60135fSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9361a96d7823Smrg case " $predeps $postdeps " in 9362a96d7823Smrg *" $a_deplib "*) 9363a96d7823Smrg func_append newdeplibs " $a_deplib" 9364fd60135fSmrg a_deplib= 9365a96d7823Smrg ;; 9366a96d7823Smrg esac 9367a96d7823Smrg fi 9368fd60135fSmrg if test -n "$a_deplib"; then 9369a96d7823Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9370a96d7823Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9371a96d7823Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9372a96d7823Smrg for potent_lib in $potential_libs; do 9373fd60135fSmrg potlib=$potent_lib # see symlink-check above in file_magic test 9374a96d7823Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9375a96d7823Smrg $EGREP "$match_pattern_regex" > /dev/null; then 9376a96d7823Smrg func_append newdeplibs " $a_deplib" 9377fd60135fSmrg a_deplib= 9378a96d7823Smrg break 2 9379a96d7823Smrg fi 9380a96d7823Smrg done 9381a96d7823Smrg done 9382a96d7823Smrg fi 9383fd60135fSmrg if test -n "$a_deplib"; then 9384a96d7823Smrg droppeddeps=yes 9385a96d7823Smrg echo 9386a96d7823Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9387a96d7823Smrg echo "*** I have the capability to make that library automatically link in when" 9388a96d7823Smrg echo "*** you link to this library. But I can only do this if you have a" 9389a96d7823Smrg echo "*** shared version of the library, which you do not appear to have" 9390a96d7823Smrg echo "*** because I did check the linker path looking for a file starting" 9391fd60135fSmrg if test -z "$potlib"; then 9392a96d7823Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9393a96d7823Smrg else 9394a96d7823Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9395a96d7823Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9396a96d7823Smrg fi 9397a96d7823Smrg fi 9398a96d7823Smrg ;; 9399a96d7823Smrg *) 9400a96d7823Smrg # Add a -L argument. 9401a96d7823Smrg func_append newdeplibs " $a_deplib" 9402a96d7823Smrg ;; 9403a96d7823Smrg esac 9404a96d7823Smrg done # Gone through all deplibs. 9405a96d7823Smrg ;; 9406a96d7823Smrg none | unknown | *) 9407fd60135fSmrg newdeplibs= 9408a96d7823Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9409fd60135fSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9410fd60135fSmrg for i in $predeps $postdeps; do 9411a96d7823Smrg # can't use Xsed below, because $i might contain '/' 9412fd60135fSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9413a96d7823Smrg done 9414a96d7823Smrg fi 9415a96d7823Smrg case $tmp_deplibs in 9416a96d7823Smrg *[!\ \ ]*) 9417a96d7823Smrg echo 9418fd60135fSmrg if test none = "$deplibs_check_method"; then 9419a96d7823Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9420a96d7823Smrg else 9421a96d7823Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 9422a96d7823Smrg fi 9423a96d7823Smrg echo "*** All declared inter-library dependencies are being dropped." 9424a96d7823Smrg droppeddeps=yes 9425a96d7823Smrg ;; 9426a96d7823Smrg esac 9427a96d7823Smrg ;; 9428a96d7823Smrg esac 9429a96d7823Smrg versuffix=$versuffix_save 9430a96d7823Smrg major=$major_save 9431a96d7823Smrg release=$release_save 9432a96d7823Smrg libname=$libname_save 9433a96d7823Smrg name=$name_save 9434a96d7823Smrg 9435a96d7823Smrg case $host in 9436a96d7823Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9437a96d7823Smrg # On Rhapsody replace the C library with the System framework 9438a96d7823Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9439a96d7823Smrg ;; 9440a96d7823Smrg esac 9441a96d7823Smrg 9442fd60135fSmrg if test yes = "$droppeddeps"; then 9443fd60135fSmrg if test yes = "$module"; then 9444a96d7823Smrg echo 9445a96d7823Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9446a96d7823Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9447a96d7823Smrg echo "*** a static module, that should work as long as the dlopening" 9448a96d7823Smrg echo "*** application is linked with the -dlopen flag." 9449a96d7823Smrg if test -z "$global_symbol_pipe"; then 9450a96d7823Smrg echo 9451a96d7823Smrg echo "*** However, this would only work if libtool was able to extract symbol" 9452fd60135fSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9453a96d7823Smrg echo "*** not find such a program. So, this module is probably useless." 9454fd60135fSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9455a96d7823Smrg fi 9456fd60135fSmrg if test no = "$build_old_libs"; then 9457fd60135fSmrg oldlibs=$output_objdir/$libname.$libext 9458a96d7823Smrg build_libtool_libs=module 9459a96d7823Smrg build_old_libs=yes 9460a96d7823Smrg else 9461a96d7823Smrg build_libtool_libs=no 9462a96d7823Smrg fi 9463a96d7823Smrg else 9464a96d7823Smrg echo "*** The inter-library dependencies that have been dropped here will be" 9465a96d7823Smrg echo "*** automatically added whenever a program is linked with this library" 9466a96d7823Smrg echo "*** or is declared to -dlopen it." 9467a96d7823Smrg 9468fd60135fSmrg if test no = "$allow_undefined"; then 9469a96d7823Smrg echo 9470a96d7823Smrg echo "*** Since this library must not contain undefined symbols," 9471a96d7823Smrg echo "*** because either the platform does not support them or" 9472a96d7823Smrg echo "*** it was explicitly requested with -no-undefined," 9473a96d7823Smrg echo "*** libtool will only create a static version of it." 9474fd60135fSmrg if test no = "$build_old_libs"; then 9475fd60135fSmrg oldlibs=$output_objdir/$libname.$libext 9476a96d7823Smrg build_libtool_libs=module 9477a96d7823Smrg build_old_libs=yes 9478a96d7823Smrg else 9479a96d7823Smrg build_libtool_libs=no 9480a96d7823Smrg fi 9481a96d7823Smrg fi 9482a96d7823Smrg fi 9483a96d7823Smrg fi 9484a96d7823Smrg # Done checking deplibs! 9485a96d7823Smrg deplibs=$newdeplibs 9486a96d7823Smrg fi 9487a96d7823Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9488a96d7823Smrg case $host in 9489a96d7823Smrg *-*-darwin*) 9490a96d7823Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9491a96d7823Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9492a96d7823Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9493a96d7823Smrg ;; 9494a96d7823Smrg esac 9495a96d7823Smrg 9496a96d7823Smrg # move library search paths that coincide with paths to not yet 9497a96d7823Smrg # installed libraries to the beginning of the library search list 9498a96d7823Smrg new_libs= 9499a96d7823Smrg for path in $notinst_path; do 9500a96d7823Smrg case " $new_libs " in 9501a96d7823Smrg *" -L$path/$objdir "*) ;; 9502a96d7823Smrg *) 9503a96d7823Smrg case " $deplibs " in 9504a96d7823Smrg *" -L$path/$objdir "*) 9505a96d7823Smrg func_append new_libs " -L$path/$objdir" ;; 9506a96d7823Smrg esac 9507a96d7823Smrg ;; 9508a96d7823Smrg esac 9509a96d7823Smrg done 9510a96d7823Smrg for deplib in $deplibs; do 9511a96d7823Smrg case $deplib in 9512a96d7823Smrg -L*) 9513a96d7823Smrg case " $new_libs " in 9514a96d7823Smrg *" $deplib "*) ;; 9515a96d7823Smrg *) func_append new_libs " $deplib" ;; 9516a96d7823Smrg esac 9517a96d7823Smrg ;; 9518a96d7823Smrg *) func_append new_libs " $deplib" ;; 9519a96d7823Smrg esac 9520a96d7823Smrg done 9521fd60135fSmrg deplibs=$new_libs 9522a96d7823Smrg 9523a96d7823Smrg # All the library-specific variables (install_libdir is set above). 9524a96d7823Smrg library_names= 9525a96d7823Smrg old_library= 9526a96d7823Smrg dlname= 9527a96d7823Smrg 9528a96d7823Smrg # Test again, we may have decided not to build it any more 9529fd60135fSmrg if test yes = "$build_libtool_libs"; then 9530fd60135fSmrg # Remove $wl instances when linking with ld. 9531a96d7823Smrg # FIXME: should test the right _cmds variable. 9532a96d7823Smrg case $archive_cmds in 9533a96d7823Smrg *\$LD\ *) wl= ;; 9534a96d7823Smrg esac 9535fd60135fSmrg if test yes = "$hardcode_into_libs"; then 9536a96d7823Smrg # Hardcode the library paths 9537a96d7823Smrg hardcode_libdirs= 9538a96d7823Smrg dep_rpath= 9539fd60135fSmrg rpath=$finalize_rpath 9540fd60135fSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9541a96d7823Smrg for libdir in $rpath; do 9542a96d7823Smrg if test -n "$hardcode_libdir_flag_spec"; then 9543a96d7823Smrg if test -n "$hardcode_libdir_separator"; then 9544a96d7823Smrg func_replace_sysroot "$libdir" 9545a96d7823Smrg libdir=$func_replace_sysroot_result 9546a96d7823Smrg if test -z "$hardcode_libdirs"; then 9547fd60135fSmrg hardcode_libdirs=$libdir 9548a96d7823Smrg else 9549a96d7823Smrg # Just accumulate the unique libdirs. 9550a96d7823Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9551a96d7823Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9552a96d7823Smrg ;; 9553a96d7823Smrg *) 9554a96d7823Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9555a96d7823Smrg ;; 9556a96d7823Smrg esac 9557a96d7823Smrg fi 9558a96d7823Smrg else 9559a96d7823Smrg eval flag=\"$hardcode_libdir_flag_spec\" 9560a96d7823Smrg func_append dep_rpath " $flag" 9561a96d7823Smrg fi 9562a96d7823Smrg elif test -n "$runpath_var"; then 9563a96d7823Smrg case "$perm_rpath " in 9564a96d7823Smrg *" $libdir "*) ;; 9565a96d7823Smrg *) func_append perm_rpath " $libdir" ;; 9566a96d7823Smrg esac 9567a96d7823Smrg fi 9568a96d7823Smrg done 9569a96d7823Smrg # Substitute the hardcoded libdirs into the rpath. 9570a96d7823Smrg if test -n "$hardcode_libdir_separator" && 9571a96d7823Smrg test -n "$hardcode_libdirs"; then 9572fd60135fSmrg libdir=$hardcode_libdirs 9573a96d7823Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9574a96d7823Smrg fi 9575a96d7823Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9576a96d7823Smrg # We should set the runpath_var. 9577a96d7823Smrg rpath= 9578a96d7823Smrg for dir in $perm_rpath; do 9579a96d7823Smrg func_append rpath "$dir:" 9580a96d7823Smrg done 9581a96d7823Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9582a96d7823Smrg fi 9583a96d7823Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9584a96d7823Smrg fi 9585a96d7823Smrg 9586fd60135fSmrg shlibpath=$finalize_shlibpath 9587fd60135fSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9588a96d7823Smrg if test -n "$shlibpath"; then 9589a96d7823Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9590a96d7823Smrg fi 9591a96d7823Smrg 9592a96d7823Smrg # Get the real and link names of the library. 9593a96d7823Smrg eval shared_ext=\"$shrext_cmds\" 9594a96d7823Smrg eval library_names=\"$library_names_spec\" 9595a96d7823Smrg set dummy $library_names 9596a96d7823Smrg shift 9597fd60135fSmrg realname=$1 9598a96d7823Smrg shift 9599a96d7823Smrg 9600a96d7823Smrg if test -n "$soname_spec"; then 9601a96d7823Smrg eval soname=\"$soname_spec\" 9602a96d7823Smrg else 9603fd60135fSmrg soname=$realname 9604a96d7823Smrg fi 9605a96d7823Smrg if test -z "$dlname"; then 9606a96d7823Smrg dlname=$soname 9607a96d7823Smrg fi 9608a96d7823Smrg 9609fd60135fSmrg lib=$output_objdir/$realname 9610a96d7823Smrg linknames= 9611a96d7823Smrg for link 9612a96d7823Smrg do 9613a96d7823Smrg func_append linknames " $link" 9614a96d7823Smrg done 9615a96d7823Smrg 9616a96d7823Smrg # Use standard objects if they are pic 9617a96d7823Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9618a96d7823Smrg test "X$libobjs" = "X " && libobjs= 9619a96d7823Smrg 9620a96d7823Smrg delfiles= 9621a96d7823Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9622a96d7823Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9623fd60135fSmrg export_symbols=$output_objdir/$libname.uexp 9624a96d7823Smrg func_append delfiles " $export_symbols" 9625a96d7823Smrg fi 9626a96d7823Smrg 9627a96d7823Smrg orig_export_symbols= 9628a96d7823Smrg case $host_os in 9629a96d7823Smrg cygwin* | mingw* | cegcc*) 9630a96d7823Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9631a96d7823Smrg # exporting using user supplied symfile 9632fd60135fSmrg func_dll_def_p "$export_symbols" || { 9633a96d7823Smrg # and it's NOT already a .def file. Must figure out 9634a96d7823Smrg # which of the given symbols are data symbols and tag 9635a96d7823Smrg # them as such. So, trigger use of export_symbols_cmds. 9636a96d7823Smrg # export_symbols gets reassigned inside the "prepare 9637a96d7823Smrg # the list of exported symbols" if statement, so the 9638a96d7823Smrg # include_expsyms logic still works. 9639fd60135fSmrg orig_export_symbols=$export_symbols 9640a96d7823Smrg export_symbols= 9641a96d7823Smrg always_export_symbols=yes 9642fd60135fSmrg } 9643a96d7823Smrg fi 9644a96d7823Smrg ;; 9645a96d7823Smrg esac 9646a96d7823Smrg 9647a96d7823Smrg # Prepare the list of exported symbols 9648a96d7823Smrg if test -z "$export_symbols"; then 9649fd60135fSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9650fd60135fSmrg func_verbose "generating symbol list for '$libname.la'" 9651fd60135fSmrg export_symbols=$output_objdir/$libname.exp 9652a96d7823Smrg $opt_dry_run || $RM $export_symbols 9653a96d7823Smrg cmds=$export_symbols_cmds 9654fd60135fSmrg save_ifs=$IFS; IFS='~' 9655a96d7823Smrg for cmd1 in $cmds; do 9656fd60135fSmrg IFS=$save_ifs 9657a96d7823Smrg # Take the normal branch if the nm_file_list_spec branch 9658a96d7823Smrg # doesn't work or if tool conversion is not needed. 9659a96d7823Smrg case $nm_file_list_spec~$to_tool_file_cmd in 9660a96d7823Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9661a96d7823Smrg try_normal_branch=yes 9662a96d7823Smrg eval cmd=\"$cmd1\" 9663a96d7823Smrg func_len " $cmd" 9664a96d7823Smrg len=$func_len_result 9665a96d7823Smrg ;; 9666a96d7823Smrg *) 9667a96d7823Smrg try_normal_branch=no 9668a96d7823Smrg ;; 9669a96d7823Smrg esac 9670fd60135fSmrg if test yes = "$try_normal_branch" \ 9671a96d7823Smrg && { test "$len" -lt "$max_cmd_len" \ 9672a96d7823Smrg || test "$max_cmd_len" -le -1; } 9673a96d7823Smrg then 9674a96d7823Smrg func_show_eval "$cmd" 'exit $?' 9675a96d7823Smrg skipped_export=false 9676a96d7823Smrg elif test -n "$nm_file_list_spec"; then 9677a96d7823Smrg func_basename "$output" 9678a96d7823Smrg output_la=$func_basename_result 9679a96d7823Smrg save_libobjs=$libobjs 9680a96d7823Smrg save_output=$output 9681fd60135fSmrg output=$output_objdir/$output_la.nm 9682a96d7823Smrg func_to_tool_file "$output" 9683a96d7823Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9684a96d7823Smrg func_append delfiles " $output" 9685a96d7823Smrg func_verbose "creating $NM input file list: $output" 9686a96d7823Smrg for obj in $save_libobjs; do 9687a96d7823Smrg func_to_tool_file "$obj" 9688a96d7823Smrg $ECHO "$func_to_tool_file_result" 9689a96d7823Smrg done > "$output" 9690a96d7823Smrg eval cmd=\"$cmd1\" 9691a96d7823Smrg func_show_eval "$cmd" 'exit $?' 9692a96d7823Smrg output=$save_output 9693a96d7823Smrg libobjs=$save_libobjs 9694a96d7823Smrg skipped_export=false 9695a96d7823Smrg else 9696a96d7823Smrg # The command line is too long to execute in one step. 9697a96d7823Smrg func_verbose "using reloadable object file for export list..." 9698a96d7823Smrg skipped_export=: 9699a96d7823Smrg # Break out early, otherwise skipped_export may be 9700a96d7823Smrg # set to false by a later but shorter cmd. 9701a96d7823Smrg break 9702a96d7823Smrg fi 9703a96d7823Smrg done 9704fd60135fSmrg IFS=$save_ifs 9705fd60135fSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9706a96d7823Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9707a96d7823Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9708a96d7823Smrg fi 9709a96d7823Smrg fi 9710a96d7823Smrg fi 9711a96d7823Smrg 9712a96d7823Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9713fd60135fSmrg tmp_export_symbols=$export_symbols 9714fd60135fSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9715a96d7823Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9716a96d7823Smrg fi 9717a96d7823Smrg 9718fd60135fSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9719a96d7823Smrg # The given exports_symbols file has to be filtered, so filter it. 9720fd60135fSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9721a96d7823Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9722fd60135fSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 9723a96d7823Smrg # though. Also, the filter scales superlinearly with the number of 9724a96d7823Smrg # global variables. join(1) would be nice here, but unfortunately 9725a96d7823Smrg # isn't a blessed tool. 9726a96d7823Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9727a96d7823Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9728a96d7823Smrg export_symbols=$output_objdir/$libname.def 9729a96d7823Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9730a96d7823Smrg fi 9731a96d7823Smrg 9732a96d7823Smrg tmp_deplibs= 9733a96d7823Smrg for test_deplib in $deplibs; do 9734a96d7823Smrg case " $convenience " in 9735a96d7823Smrg *" $test_deplib "*) ;; 9736a96d7823Smrg *) 9737a96d7823Smrg func_append tmp_deplibs " $test_deplib" 9738a96d7823Smrg ;; 9739a96d7823Smrg esac 9740a96d7823Smrg done 9741fd60135fSmrg deplibs=$tmp_deplibs 9742a96d7823Smrg 9743a96d7823Smrg if test -n "$convenience"; then 9744a96d7823Smrg if test -n "$whole_archive_flag_spec" && 9745fd60135fSmrg test yes = "$compiler_needs_object" && 9746a96d7823Smrg test -z "$libobjs"; then 9747a96d7823Smrg # extract the archives, so we have objects to list. 9748a96d7823Smrg # TODO: could optimize this to just extract one archive. 9749a96d7823Smrg whole_archive_flag_spec= 9750a96d7823Smrg fi 9751a96d7823Smrg if test -n "$whole_archive_flag_spec"; then 9752a96d7823Smrg save_libobjs=$libobjs 9753a96d7823Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9754a96d7823Smrg test "X$libobjs" = "X " && libobjs= 9755a96d7823Smrg else 9756fd60135fSmrg gentop=$output_objdir/${outputname}x 9757a96d7823Smrg func_append generated " $gentop" 9758a96d7823Smrg 9759a96d7823Smrg func_extract_archives $gentop $convenience 9760a96d7823Smrg func_append libobjs " $func_extract_archives_result" 9761a96d7823Smrg test "X$libobjs" = "X " && libobjs= 9762a96d7823Smrg fi 9763a96d7823Smrg fi 9764a96d7823Smrg 9765fd60135fSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9766a96d7823Smrg eval flag=\"$thread_safe_flag_spec\" 9767a96d7823Smrg func_append linker_flags " $flag" 9768a96d7823Smrg fi 9769a96d7823Smrg 9770a96d7823Smrg # Make a backup of the uninstalled library when relinking 9771fd60135fSmrg if test relink = "$opt_mode"; then 9772a96d7823Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9773a96d7823Smrg fi 9774a96d7823Smrg 9775a96d7823Smrg # Do each of the archive commands. 9776fd60135fSmrg if test yes = "$module" && test -n "$module_cmds"; then 9777a96d7823Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9778a96d7823Smrg eval test_cmds=\"$module_expsym_cmds\" 9779a96d7823Smrg cmds=$module_expsym_cmds 9780a96d7823Smrg else 9781a96d7823Smrg eval test_cmds=\"$module_cmds\" 9782a96d7823Smrg cmds=$module_cmds 9783a96d7823Smrg fi 9784a96d7823Smrg else 9785a96d7823Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9786a96d7823Smrg eval test_cmds=\"$archive_expsym_cmds\" 9787a96d7823Smrg cmds=$archive_expsym_cmds 9788a96d7823Smrg else 9789a96d7823Smrg eval test_cmds=\"$archive_cmds\" 9790a96d7823Smrg cmds=$archive_cmds 9791a96d7823Smrg fi 9792a96d7823Smrg fi 9793a96d7823Smrg 9794fd60135fSmrg if test : != "$skipped_export" && 9795a96d7823Smrg func_len " $test_cmds" && 9796a96d7823Smrg len=$func_len_result && 9797a96d7823Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9798a96d7823Smrg : 9799a96d7823Smrg else 9800a96d7823Smrg # The command line is too long to link in one step, link piecewise 9801a96d7823Smrg # or, if using GNU ld and skipped_export is not :, use a linker 9802a96d7823Smrg # script. 9803a96d7823Smrg 9804a96d7823Smrg # Save the value of $output and $libobjs because we want to 9805a96d7823Smrg # use them later. If we have whole_archive_flag_spec, we 9806a96d7823Smrg # want to use save_libobjs as it was before 9807a96d7823Smrg # whole_archive_flag_spec was expanded, because we can't 9808a96d7823Smrg # assume the linker understands whole_archive_flag_spec. 9809a96d7823Smrg # This may have to be revisited, in case too many 9810a96d7823Smrg # convenience libraries get linked in and end up exceeding 9811a96d7823Smrg # the spec. 9812a96d7823Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9813a96d7823Smrg save_libobjs=$libobjs 9814a96d7823Smrg fi 9815a96d7823Smrg save_output=$output 9816a96d7823Smrg func_basename "$output" 9817a96d7823Smrg output_la=$func_basename_result 9818a96d7823Smrg 9819a96d7823Smrg # Clear the reloadable object creation command queue and 9820a96d7823Smrg # initialize k to one. 9821a96d7823Smrg test_cmds= 9822a96d7823Smrg concat_cmds= 9823a96d7823Smrg objlist= 9824a96d7823Smrg last_robj= 9825a96d7823Smrg k=1 9826a96d7823Smrg 9827fd60135fSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 9828fd60135fSmrg output=$output_objdir/$output_la.lnkscript 9829a96d7823Smrg func_verbose "creating GNU ld script: $output" 9830a96d7823Smrg echo 'INPUT (' > $output 9831a96d7823Smrg for obj in $save_libobjs 9832a96d7823Smrg do 9833a96d7823Smrg func_to_tool_file "$obj" 9834a96d7823Smrg $ECHO "$func_to_tool_file_result" >> $output 9835a96d7823Smrg done 9836a96d7823Smrg echo ')' >> $output 9837a96d7823Smrg func_append delfiles " $output" 9838a96d7823Smrg func_to_tool_file "$output" 9839a96d7823Smrg output=$func_to_tool_file_result 9840fd60135fSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 9841fd60135fSmrg output=$output_objdir/$output_la.lnk 9842a96d7823Smrg func_verbose "creating linker input file list: $output" 9843a96d7823Smrg : > $output 9844a96d7823Smrg set x $save_libobjs 9845a96d7823Smrg shift 9846a96d7823Smrg firstobj= 9847fd60135fSmrg if test yes = "$compiler_needs_object"; then 9848a96d7823Smrg firstobj="$1 " 9849a96d7823Smrg shift 9850a96d7823Smrg fi 9851a96d7823Smrg for obj 9852a96d7823Smrg do 9853a96d7823Smrg func_to_tool_file "$obj" 9854a96d7823Smrg $ECHO "$func_to_tool_file_result" >> $output 9855a96d7823Smrg done 9856a96d7823Smrg func_append delfiles " $output" 9857a96d7823Smrg func_to_tool_file "$output" 9858a96d7823Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9859a96d7823Smrg else 9860a96d7823Smrg if test -n "$save_libobjs"; then 9861a96d7823Smrg func_verbose "creating reloadable object files..." 9862fd60135fSmrg output=$output_objdir/$output_la-$k.$objext 9863a96d7823Smrg eval test_cmds=\"$reload_cmds\" 9864a96d7823Smrg func_len " $test_cmds" 9865a96d7823Smrg len0=$func_len_result 9866a96d7823Smrg len=$len0 9867a96d7823Smrg 9868a96d7823Smrg # Loop over the list of objects to be linked. 9869a96d7823Smrg for obj in $save_libobjs 9870a96d7823Smrg do 9871a96d7823Smrg func_len " $obj" 9872a96d7823Smrg func_arith $len + $func_len_result 9873a96d7823Smrg len=$func_arith_result 9874fd60135fSmrg if test -z "$objlist" || 9875a96d7823Smrg test "$len" -lt "$max_cmd_len"; then 9876a96d7823Smrg func_append objlist " $obj" 9877a96d7823Smrg else 9878a96d7823Smrg # The command $test_cmds is almost too long, add a 9879a96d7823Smrg # command to the queue. 9880fd60135fSmrg if test 1 -eq "$k"; then 9881a96d7823Smrg # The first file doesn't have a previous command to add. 9882a96d7823Smrg reload_objs=$objlist 9883a96d7823Smrg eval concat_cmds=\"$reload_cmds\" 9884a96d7823Smrg else 9885a96d7823Smrg # All subsequent reloadable object files will link in 9886a96d7823Smrg # the last one created. 9887a96d7823Smrg reload_objs="$objlist $last_robj" 9888a96d7823Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9889a96d7823Smrg fi 9890fd60135fSmrg last_robj=$output_objdir/$output_la-$k.$objext 9891a96d7823Smrg func_arith $k + 1 9892a96d7823Smrg k=$func_arith_result 9893fd60135fSmrg output=$output_objdir/$output_la-$k.$objext 9894a96d7823Smrg objlist=" $obj" 9895a96d7823Smrg func_len " $last_robj" 9896a96d7823Smrg func_arith $len0 + $func_len_result 9897a96d7823Smrg len=$func_arith_result 9898a96d7823Smrg fi 9899a96d7823Smrg done 9900a96d7823Smrg # Handle the remaining objects by creating one last 9901a96d7823Smrg # reloadable object file. All subsequent reloadable object 9902a96d7823Smrg # files will link in the last one created. 9903a96d7823Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9904a96d7823Smrg reload_objs="$objlist $last_robj" 9905fd60135fSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 9906a96d7823Smrg if test -n "$last_robj"; then 9907fd60135fSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9908a96d7823Smrg fi 9909a96d7823Smrg func_append delfiles " $output" 9910a96d7823Smrg 9911a96d7823Smrg else 9912a96d7823Smrg output= 9913a96d7823Smrg fi 9914a96d7823Smrg 9915fd60135fSmrg ${skipped_export-false} && { 9916fd60135fSmrg func_verbose "generating symbol list for '$libname.la'" 9917fd60135fSmrg export_symbols=$output_objdir/$libname.exp 9918a96d7823Smrg $opt_dry_run || $RM $export_symbols 9919a96d7823Smrg libobjs=$output 9920a96d7823Smrg # Append the command to create the export file. 9921a96d7823Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9922a96d7823Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 9923a96d7823Smrg if test -n "$last_robj"; then 9924a96d7823Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9925a96d7823Smrg fi 9926fd60135fSmrg } 9927a96d7823Smrg 9928a96d7823Smrg test -n "$save_libobjs" && 9929a96d7823Smrg func_verbose "creating a temporary reloadable object file: $output" 9930a96d7823Smrg 9931a96d7823Smrg # Loop through the commands generated above and execute them. 9932fd60135fSmrg save_ifs=$IFS; IFS='~' 9933a96d7823Smrg for cmd in $concat_cmds; do 9934fd60135fSmrg IFS=$save_ifs 9935fd60135fSmrg $opt_quiet || { 9936a96d7823Smrg func_quote_for_expand "$cmd" 9937a96d7823Smrg eval "func_echo $func_quote_for_expand_result" 9938a96d7823Smrg } 9939a96d7823Smrg $opt_dry_run || eval "$cmd" || { 9940a96d7823Smrg lt_exit=$? 9941a96d7823Smrg 9942a96d7823Smrg # Restore the uninstalled library and exit 9943fd60135fSmrg if test relink = "$opt_mode"; then 9944a96d7823Smrg ( cd "$output_objdir" && \ 9945a96d7823Smrg $RM "${realname}T" && \ 9946a96d7823Smrg $MV "${realname}U" "$realname" ) 9947a96d7823Smrg fi 9948a96d7823Smrg 9949a96d7823Smrg exit $lt_exit 9950a96d7823Smrg } 9951a96d7823Smrg done 9952fd60135fSmrg IFS=$save_ifs 9953a96d7823Smrg 9954a96d7823Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 9955a96d7823Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9956a96d7823Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9957a96d7823Smrg fi 9958a96d7823Smrg fi 9959a96d7823Smrg 9960fd60135fSmrg ${skipped_export-false} && { 9961a96d7823Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9962fd60135fSmrg tmp_export_symbols=$export_symbols 9963fd60135fSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9964a96d7823Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9965a96d7823Smrg fi 9966a96d7823Smrg 9967a96d7823Smrg if test -n "$orig_export_symbols"; then 9968a96d7823Smrg # The given exports_symbols file has to be filtered, so filter it. 9969fd60135fSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9970a96d7823Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9971fd60135fSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 9972a96d7823Smrg # though. Also, the filter scales superlinearly with the number of 9973a96d7823Smrg # global variables. join(1) would be nice here, but unfortunately 9974a96d7823Smrg # isn't a blessed tool. 9975a96d7823Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9976a96d7823Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9977a96d7823Smrg export_symbols=$output_objdir/$libname.def 9978a96d7823Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9979a96d7823Smrg fi 9980fd60135fSmrg } 9981a96d7823Smrg 9982a96d7823Smrg libobjs=$output 9983a96d7823Smrg # Restore the value of output. 9984a96d7823Smrg output=$save_output 9985a96d7823Smrg 9986a96d7823Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 9987a96d7823Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9988a96d7823Smrg test "X$libobjs" = "X " && libobjs= 9989a96d7823Smrg fi 9990a96d7823Smrg # Expand the library linking commands again to reset the 9991a96d7823Smrg # value of $libobjs for piecewise linking. 9992a96d7823Smrg 9993a96d7823Smrg # Do each of the archive commands. 9994fd60135fSmrg if test yes = "$module" && test -n "$module_cmds"; then 9995a96d7823Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9996a96d7823Smrg cmds=$module_expsym_cmds 9997a96d7823Smrg else 9998a96d7823Smrg cmds=$module_cmds 9999a96d7823Smrg fi 10000a96d7823Smrg else 10001a96d7823Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10002a96d7823Smrg cmds=$archive_expsym_cmds 10003a96d7823Smrg else 10004a96d7823Smrg cmds=$archive_cmds 10005a96d7823Smrg fi 10006a96d7823Smrg fi 10007a96d7823Smrg fi 10008a96d7823Smrg 10009a96d7823Smrg if test -n "$delfiles"; then 10010a96d7823Smrg # Append the command to remove temporary files to $cmds. 10011a96d7823Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10012a96d7823Smrg fi 10013a96d7823Smrg 10014a96d7823Smrg # Add any objects from preloaded convenience libraries 10015a96d7823Smrg if test -n "$dlprefiles"; then 10016fd60135fSmrg gentop=$output_objdir/${outputname}x 10017a96d7823Smrg func_append generated " $gentop" 10018a96d7823Smrg 10019a96d7823Smrg func_extract_archives $gentop $dlprefiles 10020a96d7823Smrg func_append libobjs " $func_extract_archives_result" 10021a96d7823Smrg test "X$libobjs" = "X " && libobjs= 10022a96d7823Smrg fi 10023a96d7823Smrg 10024fd60135fSmrg save_ifs=$IFS; IFS='~' 10025a96d7823Smrg for cmd in $cmds; do 10026fd60135fSmrg IFS=$sp$nl 10027a96d7823Smrg eval cmd=\"$cmd\" 10028fd60135fSmrg IFS=$save_ifs 10029fd60135fSmrg $opt_quiet || { 10030a96d7823Smrg func_quote_for_expand "$cmd" 10031a96d7823Smrg eval "func_echo $func_quote_for_expand_result" 10032a96d7823Smrg } 10033a96d7823Smrg $opt_dry_run || eval "$cmd" || { 10034a96d7823Smrg lt_exit=$? 10035a96d7823Smrg 10036a96d7823Smrg # Restore the uninstalled library and exit 10037fd60135fSmrg if test relink = "$opt_mode"; then 10038a96d7823Smrg ( cd "$output_objdir" && \ 10039a96d7823Smrg $RM "${realname}T" && \ 10040a96d7823Smrg $MV "${realname}U" "$realname" ) 10041a96d7823Smrg fi 10042a96d7823Smrg 10043a96d7823Smrg exit $lt_exit 10044a96d7823Smrg } 10045a96d7823Smrg done 10046fd60135fSmrg IFS=$save_ifs 10047a96d7823Smrg 10048a96d7823Smrg # Restore the uninstalled library and exit 10049fd60135fSmrg if test relink = "$opt_mode"; then 10050a96d7823Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10051a96d7823Smrg 10052a96d7823Smrg if test -n "$convenience"; then 10053a96d7823Smrg if test -z "$whole_archive_flag_spec"; then 10054a96d7823Smrg func_show_eval '${RM}r "$gentop"' 10055a96d7823Smrg fi 10056a96d7823Smrg fi 10057a96d7823Smrg 10058a96d7823Smrg exit $EXIT_SUCCESS 10059a96d7823Smrg fi 10060a96d7823Smrg 10061a96d7823Smrg # Create links to the real library. 10062a96d7823Smrg for linkname in $linknames; do 10063a96d7823Smrg if test "$realname" != "$linkname"; then 10064a96d7823Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10065a96d7823Smrg fi 10066a96d7823Smrg done 10067a96d7823Smrg 10068a96d7823Smrg # If -module or -export-dynamic was specified, set the dlname. 10069fd60135fSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 10070a96d7823Smrg # On all known operating systems, these are identical. 10071fd60135fSmrg dlname=$soname 10072a96d7823Smrg fi 10073a96d7823Smrg fi 10074a96d7823Smrg ;; 10075a96d7823Smrg 10076a96d7823Smrg obj) 10077fd60135fSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10078fd60135fSmrg func_warning "'-dlopen' is ignored for objects" 10079a96d7823Smrg fi 10080a96d7823Smrg 10081a96d7823Smrg case " $deplibs" in 10082a96d7823Smrg *\ -l* | *\ -L*) 10083fd60135fSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 10084a96d7823Smrg esac 10085a96d7823Smrg 10086a96d7823Smrg test -n "$rpath" && \ 10087fd60135fSmrg func_warning "'-rpath' is ignored for objects" 10088a96d7823Smrg 10089a96d7823Smrg test -n "$xrpath" && \ 10090fd60135fSmrg func_warning "'-R' is ignored for objects" 10091a96d7823Smrg 10092a96d7823Smrg test -n "$vinfo" && \ 10093fd60135fSmrg func_warning "'-version-info' is ignored for objects" 10094a96d7823Smrg 10095a96d7823Smrg test -n "$release" && \ 10096fd60135fSmrg func_warning "'-release' is ignored for objects" 10097a96d7823Smrg 10098a96d7823Smrg case $output in 10099a96d7823Smrg *.lo) 10100a96d7823Smrg test -n "$objs$old_deplibs" && \ 10101fd60135fSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10102a96d7823Smrg 10103a96d7823Smrg libobj=$output 10104a96d7823Smrg func_lo2o "$libobj" 10105a96d7823Smrg obj=$func_lo2o_result 10106a96d7823Smrg ;; 10107a96d7823Smrg *) 10108a96d7823Smrg libobj= 10109fd60135fSmrg obj=$output 10110a96d7823Smrg ;; 10111a96d7823Smrg esac 10112a96d7823Smrg 10113a96d7823Smrg # Delete the old objects. 10114a96d7823Smrg $opt_dry_run || $RM $obj $libobj 10115a96d7823Smrg 10116a96d7823Smrg # Objects from convenience libraries. This assumes 10117a96d7823Smrg # single-version convenience libraries. Whenever we create 10118a96d7823Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10119a96d7823Smrg # the extraction. 10120a96d7823Smrg reload_conv_objs= 10121a96d7823Smrg gentop= 10122fd60135fSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 10123fd60135fSmrg # whole_archive_flag_spec and hope we can get by with turning comma 10124fd60135fSmrg # into space. 10125fd60135fSmrg case $reload_cmds in 10126fd60135fSmrg *\$LD[\ \$]*) wl= ;; 10127fd60135fSmrg esac 10128a96d7823Smrg if test -n "$convenience"; then 10129a96d7823Smrg if test -n "$whole_archive_flag_spec"; then 10130a96d7823Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10131fd60135fSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10132fd60135fSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10133a96d7823Smrg else 10134fd60135fSmrg gentop=$output_objdir/${obj}x 10135a96d7823Smrg func_append generated " $gentop" 10136a96d7823Smrg 10137a96d7823Smrg func_extract_archives $gentop $convenience 10138a96d7823Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10139a96d7823Smrg fi 10140a96d7823Smrg fi 10141a96d7823Smrg 10142a96d7823Smrg # If we're not building shared, we need to use non_pic_objs 10143fd60135fSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10144a96d7823Smrg 10145a96d7823Smrg # Create the old-style object. 10146fd60135fSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10147a96d7823Smrg 10148fd60135fSmrg output=$obj 10149a96d7823Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10150a96d7823Smrg 10151a96d7823Smrg # Exit if we aren't doing a library object file. 10152a96d7823Smrg if test -z "$libobj"; then 10153a96d7823Smrg if test -n "$gentop"; then 10154a96d7823Smrg func_show_eval '${RM}r "$gentop"' 10155a96d7823Smrg fi 10156a96d7823Smrg 10157a96d7823Smrg exit $EXIT_SUCCESS 10158a96d7823Smrg fi 10159a96d7823Smrg 10160fd60135fSmrg test yes = "$build_libtool_libs" || { 10161a96d7823Smrg if test -n "$gentop"; then 10162a96d7823Smrg func_show_eval '${RM}r "$gentop"' 10163a96d7823Smrg fi 10164a96d7823Smrg 10165a96d7823Smrg # Create an invalid libtool object if no PIC, so that we don't 10166a96d7823Smrg # accidentally link it into a program. 10167a96d7823Smrg # $show "echo timestamp > $libobj" 10168a96d7823Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10169a96d7823Smrg exit $EXIT_SUCCESS 10170fd60135fSmrg } 10171a96d7823Smrg 10172fd60135fSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10173a96d7823Smrg # Only do commands if we really have different PIC objects. 10174a96d7823Smrg reload_objs="$libobjs $reload_conv_objs" 10175fd60135fSmrg output=$libobj 10176a96d7823Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10177a96d7823Smrg fi 10178a96d7823Smrg 10179a96d7823Smrg if test -n "$gentop"; then 10180a96d7823Smrg func_show_eval '${RM}r "$gentop"' 10181a96d7823Smrg fi 10182a96d7823Smrg 10183a96d7823Smrg exit $EXIT_SUCCESS 10184a96d7823Smrg ;; 10185a96d7823Smrg 10186a96d7823Smrg prog) 10187a96d7823Smrg case $host in 10188a96d7823Smrg *cygwin*) func_stripname '' '.exe' "$output" 10189a96d7823Smrg output=$func_stripname_result.exe;; 10190a96d7823Smrg esac 10191a96d7823Smrg test -n "$vinfo" && \ 10192fd60135fSmrg func_warning "'-version-info' is ignored for programs" 10193a96d7823Smrg 10194a96d7823Smrg test -n "$release" && \ 10195fd60135fSmrg func_warning "'-release' is ignored for programs" 10196a96d7823Smrg 10197fd60135fSmrg $preload \ 10198fd60135fSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10199fd60135fSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10200a96d7823Smrg 10201a96d7823Smrg case $host in 10202a96d7823Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10203a96d7823Smrg # On Rhapsody replace the C library is the System framework 10204a96d7823Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10205a96d7823Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10206a96d7823Smrg ;; 10207a96d7823Smrg esac 10208a96d7823Smrg 10209a96d7823Smrg case $host in 10210a96d7823Smrg *-*-darwin*) 10211a96d7823Smrg # Don't allow lazy linking, it breaks C++ global constructors 10212a96d7823Smrg # But is supposedly fixed on 10.4 or later (yay!). 10213fd60135fSmrg if test CXX = "$tagname"; then 10214a96d7823Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10215a96d7823Smrg 10.[0123]) 10216fd60135fSmrg func_append compile_command " $wl-bind_at_load" 10217fd60135fSmrg func_append finalize_command " $wl-bind_at_load" 10218a96d7823Smrg ;; 10219a96d7823Smrg esac 10220a96d7823Smrg fi 10221a96d7823Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10222a96d7823Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10223a96d7823Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10224a96d7823Smrg ;; 10225a96d7823Smrg esac 10226a96d7823Smrg 10227a96d7823Smrg 10228a96d7823Smrg # move library search paths that coincide with paths to not yet 10229a96d7823Smrg # installed libraries to the beginning of the library search list 10230a96d7823Smrg new_libs= 10231a96d7823Smrg for path in $notinst_path; do 10232a96d7823Smrg case " $new_libs " in 10233a96d7823Smrg *" -L$path/$objdir "*) ;; 10234a96d7823Smrg *) 10235a96d7823Smrg case " $compile_deplibs " in 10236a96d7823Smrg *" -L$path/$objdir "*) 10237a96d7823Smrg func_append new_libs " -L$path/$objdir" ;; 10238a96d7823Smrg esac 10239a96d7823Smrg ;; 10240a96d7823Smrg esac 10241a96d7823Smrg done 10242a96d7823Smrg for deplib in $compile_deplibs; do 10243a96d7823Smrg case $deplib in 10244a96d7823Smrg -L*) 10245a96d7823Smrg case " $new_libs " in 10246a96d7823Smrg *" $deplib "*) ;; 10247a96d7823Smrg *) func_append new_libs " $deplib" ;; 10248a96d7823Smrg esac 10249a96d7823Smrg ;; 10250a96d7823Smrg *) func_append new_libs " $deplib" ;; 10251a96d7823Smrg esac 10252a96d7823Smrg done 10253fd60135fSmrg compile_deplibs=$new_libs 10254a96d7823Smrg 10255a96d7823Smrg 10256a96d7823Smrg func_append compile_command " $compile_deplibs" 10257a96d7823Smrg func_append finalize_command " $finalize_deplibs" 10258a96d7823Smrg 10259a96d7823Smrg if test -n "$rpath$xrpath"; then 10260a96d7823Smrg # If the user specified any rpath flags, then add them. 10261a96d7823Smrg for libdir in $rpath $xrpath; do 10262a96d7823Smrg # This is the magic to use -rpath. 10263a96d7823Smrg case "$finalize_rpath " in 10264a96d7823Smrg *" $libdir "*) ;; 10265a96d7823Smrg *) func_append finalize_rpath " $libdir" ;; 10266a96d7823Smrg esac 10267a96d7823Smrg done 10268a96d7823Smrg fi 10269a96d7823Smrg 10270a96d7823Smrg # Now hardcode the library paths 10271a96d7823Smrg rpath= 10272a96d7823Smrg hardcode_libdirs= 10273a96d7823Smrg for libdir in $compile_rpath $finalize_rpath; do 10274a96d7823Smrg if test -n "$hardcode_libdir_flag_spec"; then 10275a96d7823Smrg if test -n "$hardcode_libdir_separator"; then 10276a96d7823Smrg if test -z "$hardcode_libdirs"; then 10277fd60135fSmrg hardcode_libdirs=$libdir 10278a96d7823Smrg else 10279a96d7823Smrg # Just accumulate the unique libdirs. 10280a96d7823Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10281a96d7823Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10282a96d7823Smrg ;; 10283a96d7823Smrg *) 10284a96d7823Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10285a96d7823Smrg ;; 10286a96d7823Smrg esac 10287a96d7823Smrg fi 10288a96d7823Smrg else 10289a96d7823Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10290a96d7823Smrg func_append rpath " $flag" 10291a96d7823Smrg fi 10292a96d7823Smrg elif test -n "$runpath_var"; then 10293a96d7823Smrg case "$perm_rpath " in 10294a96d7823Smrg *" $libdir "*) ;; 10295a96d7823Smrg *) func_append perm_rpath " $libdir" ;; 10296a96d7823Smrg esac 10297a96d7823Smrg fi 10298a96d7823Smrg case $host in 10299a96d7823Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10300fd60135fSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10301a96d7823Smrg case :$dllsearchpath: in 10302a96d7823Smrg *":$libdir:"*) ;; 10303a96d7823Smrg ::) dllsearchpath=$libdir;; 10304a96d7823Smrg *) func_append dllsearchpath ":$libdir";; 10305a96d7823Smrg esac 10306a96d7823Smrg case :$dllsearchpath: in 10307a96d7823Smrg *":$testbindir:"*) ;; 10308a96d7823Smrg ::) dllsearchpath=$testbindir;; 10309a96d7823Smrg *) func_append dllsearchpath ":$testbindir";; 10310a96d7823Smrg esac 10311a96d7823Smrg ;; 10312a96d7823Smrg esac 10313a96d7823Smrg done 10314a96d7823Smrg # Substitute the hardcoded libdirs into the rpath. 10315a96d7823Smrg if test -n "$hardcode_libdir_separator" && 10316a96d7823Smrg test -n "$hardcode_libdirs"; then 10317fd60135fSmrg libdir=$hardcode_libdirs 10318a96d7823Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10319a96d7823Smrg fi 10320fd60135fSmrg compile_rpath=$rpath 10321a96d7823Smrg 10322a96d7823Smrg rpath= 10323a96d7823Smrg hardcode_libdirs= 10324a96d7823Smrg for libdir in $finalize_rpath; do 10325a96d7823Smrg if test -n "$hardcode_libdir_flag_spec"; then 10326a96d7823Smrg if test -n "$hardcode_libdir_separator"; then 10327a96d7823Smrg if test -z "$hardcode_libdirs"; then 10328fd60135fSmrg hardcode_libdirs=$libdir 10329a96d7823Smrg else 10330a96d7823Smrg # Just accumulate the unique libdirs. 10331a96d7823Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10332a96d7823Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10333a96d7823Smrg ;; 10334a96d7823Smrg *) 10335a96d7823Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10336a96d7823Smrg ;; 10337a96d7823Smrg esac 10338a96d7823Smrg fi 10339a96d7823Smrg else 10340a96d7823Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10341a96d7823Smrg func_append rpath " $flag" 10342a96d7823Smrg fi 10343a96d7823Smrg elif test -n "$runpath_var"; then 10344a96d7823Smrg case "$finalize_perm_rpath " in 10345a96d7823Smrg *" $libdir "*) ;; 10346a96d7823Smrg *) func_append finalize_perm_rpath " $libdir" ;; 10347a96d7823Smrg esac 10348a96d7823Smrg fi 10349a96d7823Smrg done 10350a96d7823Smrg # Substitute the hardcoded libdirs into the rpath. 10351a96d7823Smrg if test -n "$hardcode_libdir_separator" && 10352a96d7823Smrg test -n "$hardcode_libdirs"; then 10353fd60135fSmrg libdir=$hardcode_libdirs 10354a96d7823Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10355a96d7823Smrg fi 10356fd60135fSmrg finalize_rpath=$rpath 10357a96d7823Smrg 10358fd60135fSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10359a96d7823Smrg # Transform all the library objects into standard objects. 10360a96d7823Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10361a96d7823Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10362a96d7823Smrg fi 10363a96d7823Smrg 10364fd60135fSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10365a96d7823Smrg 10366a96d7823Smrg # template prelinking step 10367a96d7823Smrg if test -n "$prelink_cmds"; then 10368a96d7823Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10369a96d7823Smrg fi 10370a96d7823Smrg 10371fd60135fSmrg wrappers_required=: 10372a96d7823Smrg case $host in 10373a96d7823Smrg *cegcc* | *mingw32ce*) 10374a96d7823Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10375fd60135fSmrg wrappers_required=false 10376a96d7823Smrg ;; 10377a96d7823Smrg *cygwin* | *mingw* ) 10378fd60135fSmrg test yes = "$build_libtool_libs" || wrappers_required=false 10379a96d7823Smrg ;; 10380a96d7823Smrg *) 10381fd60135fSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10382fd60135fSmrg wrappers_required=false 10383a96d7823Smrg fi 10384a96d7823Smrg ;; 10385a96d7823Smrg esac 10386fd60135fSmrg $wrappers_required || { 10387a96d7823Smrg # Replace the output file specification. 10388a96d7823Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10389fd60135fSmrg link_command=$compile_command$compile_rpath 10390a96d7823Smrg 10391a96d7823Smrg # We have no uninstalled library dependencies, so finalize right now. 10392a96d7823Smrg exit_status=0 10393a96d7823Smrg func_show_eval "$link_command" 'exit_status=$?' 10394a96d7823Smrg 10395a96d7823Smrg if test -n "$postlink_cmds"; then 10396a96d7823Smrg func_to_tool_file "$output" 10397a96d7823Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10398a96d7823Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10399a96d7823Smrg fi 10400a96d7823Smrg 10401a96d7823Smrg # Delete the generated files. 10402fd60135fSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 10403fd60135fSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10404a96d7823Smrg fi 10405a96d7823Smrg 10406a96d7823Smrg exit $exit_status 10407fd60135fSmrg } 10408a96d7823Smrg 10409a96d7823Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10410a96d7823Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10411a96d7823Smrg fi 10412a96d7823Smrg if test -n "$finalize_shlibpath"; then 10413a96d7823Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10414a96d7823Smrg fi 10415a96d7823Smrg 10416a96d7823Smrg compile_var= 10417a96d7823Smrg finalize_var= 10418a96d7823Smrg if test -n "$runpath_var"; then 10419a96d7823Smrg if test -n "$perm_rpath"; then 10420a96d7823Smrg # We should set the runpath_var. 10421a96d7823Smrg rpath= 10422a96d7823Smrg for dir in $perm_rpath; do 10423a96d7823Smrg func_append rpath "$dir:" 10424a96d7823Smrg done 10425a96d7823Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10426a96d7823Smrg fi 10427a96d7823Smrg if test -n "$finalize_perm_rpath"; then 10428a96d7823Smrg # We should set the runpath_var. 10429a96d7823Smrg rpath= 10430a96d7823Smrg for dir in $finalize_perm_rpath; do 10431a96d7823Smrg func_append rpath "$dir:" 10432a96d7823Smrg done 10433a96d7823Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10434a96d7823Smrg fi 10435a96d7823Smrg fi 10436a96d7823Smrg 10437fd60135fSmrg if test yes = "$no_install"; then 10438a96d7823Smrg # We don't need to create a wrapper script. 10439fd60135fSmrg link_command=$compile_var$compile_command$compile_rpath 10440a96d7823Smrg # Replace the output file specification. 10441a96d7823Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10442a96d7823Smrg # Delete the old output file. 10443a96d7823Smrg $opt_dry_run || $RM $output 10444a96d7823Smrg # Link the executable and exit 10445a96d7823Smrg func_show_eval "$link_command" 'exit $?' 10446a96d7823Smrg 10447a96d7823Smrg if test -n "$postlink_cmds"; then 10448a96d7823Smrg func_to_tool_file "$output" 10449a96d7823Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10450a96d7823Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10451a96d7823Smrg fi 10452a96d7823Smrg 10453a96d7823Smrg exit $EXIT_SUCCESS 10454a96d7823Smrg fi 10455a96d7823Smrg 10456fd60135fSmrg case $hardcode_action,$fast_install in 10457fd60135fSmrg relink,*) 10458fd60135fSmrg # Fast installation is not supported 10459fd60135fSmrg link_command=$compile_var$compile_command$compile_rpath 10460fd60135fSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10461a96d7823Smrg 10462fd60135fSmrg func_warning "this platform does not like uninstalled shared libraries" 10463fd60135fSmrg func_warning "'$output' will be relinked during installation" 10464fd60135fSmrg ;; 10465fd60135fSmrg *,yes) 10466fd60135fSmrg link_command=$finalize_var$compile_command$finalize_rpath 10467fd60135fSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10468fd60135fSmrg ;; 10469fd60135fSmrg *,no) 10470fd60135fSmrg link_command=$compile_var$compile_command$compile_rpath 10471fd60135fSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10472fd60135fSmrg ;; 10473fd60135fSmrg *,needless) 10474fd60135fSmrg link_command=$finalize_var$compile_command$finalize_rpath 10475fd60135fSmrg relink_command= 10476fd60135fSmrg ;; 10477fd60135fSmrg esac 10478a96d7823Smrg 10479a96d7823Smrg # Replace the output file specification. 10480a96d7823Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10481a96d7823Smrg 10482a96d7823Smrg # Delete the old output files. 10483a96d7823Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10484a96d7823Smrg 10485a96d7823Smrg func_show_eval "$link_command" 'exit $?' 10486a96d7823Smrg 10487a96d7823Smrg if test -n "$postlink_cmds"; then 10488a96d7823Smrg func_to_tool_file "$output_objdir/$outputname" 10489a96d7823Smrg 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'` 10490a96d7823Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10491a96d7823Smrg fi 10492a96d7823Smrg 10493a96d7823Smrg # Now create the wrapper script. 10494a96d7823Smrg func_verbose "creating $output" 10495a96d7823Smrg 10496a96d7823Smrg # Quote the relink command for shipping. 10497a96d7823Smrg if test -n "$relink_command"; then 10498a96d7823Smrg # Preserve any variables that may affect compiler behavior 10499a96d7823Smrg for var in $variables_saved_for_relink; do 10500a96d7823Smrg if eval test -z \"\${$var+set}\"; then 10501a96d7823Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10502a96d7823Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10503a96d7823Smrg relink_command="$var=; export $var; $relink_command" 10504a96d7823Smrg else 10505a96d7823Smrg func_quote_for_eval "$var_value" 10506a96d7823Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10507a96d7823Smrg fi 10508a96d7823Smrg done 10509a96d7823Smrg relink_command="(cd `pwd`; $relink_command)" 10510a96d7823Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10511a96d7823Smrg fi 10512a96d7823Smrg 10513a96d7823Smrg # Only actually do things if not in dry run mode. 10514a96d7823Smrg $opt_dry_run || { 10515a96d7823Smrg # win32 will think the script is a binary if it has 10516a96d7823Smrg # a .exe suffix, so we strip it off here. 10517a96d7823Smrg case $output in 10518a96d7823Smrg *.exe) func_stripname '' '.exe' "$output" 10519a96d7823Smrg output=$func_stripname_result ;; 10520a96d7823Smrg esac 10521a96d7823Smrg # test for cygwin because mv fails w/o .exe extensions 10522a96d7823Smrg case $host in 10523a96d7823Smrg *cygwin*) 10524a96d7823Smrg exeext=.exe 10525a96d7823Smrg func_stripname '' '.exe' "$outputname" 10526a96d7823Smrg outputname=$func_stripname_result ;; 10527a96d7823Smrg *) exeext= ;; 10528a96d7823Smrg esac 10529a96d7823Smrg case $host in 10530a96d7823Smrg *cygwin* | *mingw* ) 10531a96d7823Smrg func_dirname_and_basename "$output" "" "." 10532a96d7823Smrg output_name=$func_basename_result 10533a96d7823Smrg output_path=$func_dirname_result 10534fd60135fSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10535fd60135fSmrg cwrapper=$output_path/$output_name.exe 10536a96d7823Smrg $RM $cwrappersource $cwrapper 10537a96d7823Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10538a96d7823Smrg 10539a96d7823Smrg func_emit_cwrapperexe_src > $cwrappersource 10540a96d7823Smrg 10541a96d7823Smrg # The wrapper executable is built using the $host compiler, 10542a96d7823Smrg # because it contains $host paths and files. If cross- 10543a96d7823Smrg # compiling, it, like the target executable, must be 10544a96d7823Smrg # executed on the $host or under an emulation environment. 10545a96d7823Smrg $opt_dry_run || { 10546a96d7823Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10547a96d7823Smrg $STRIP $cwrapper 10548a96d7823Smrg } 10549a96d7823Smrg 10550a96d7823Smrg # Now, create the wrapper script for func_source use: 10551a96d7823Smrg func_ltwrapper_scriptname $cwrapper 10552a96d7823Smrg $RM $func_ltwrapper_scriptname_result 10553a96d7823Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10554a96d7823Smrg $opt_dry_run || { 10555a96d7823Smrg # note: this script will not be executed, so do not chmod. 10556fd60135fSmrg if test "x$build" = "x$host"; then 10557a96d7823Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10558a96d7823Smrg else 10559a96d7823Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10560a96d7823Smrg fi 10561a96d7823Smrg } 10562a96d7823Smrg ;; 10563a96d7823Smrg * ) 10564a96d7823Smrg $RM $output 10565a96d7823Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10566a96d7823Smrg 10567a96d7823Smrg func_emit_wrapper no > $output 10568a96d7823Smrg chmod +x $output 10569a96d7823Smrg ;; 10570a96d7823Smrg esac 10571a96d7823Smrg } 10572a96d7823Smrg exit $EXIT_SUCCESS 10573a96d7823Smrg ;; 10574a96d7823Smrg esac 10575a96d7823Smrg 10576a96d7823Smrg # See if we need to build an old-fashioned archive. 10577a96d7823Smrg for oldlib in $oldlibs; do 10578a96d7823Smrg 10579fd60135fSmrg case $build_libtool_libs in 10580fd60135fSmrg convenience) 10581fd60135fSmrg oldobjs="$libobjs_save $symfileobj" 10582fd60135fSmrg addlibs=$convenience 10583a96d7823Smrg build_libtool_libs=no 10584fd60135fSmrg ;; 10585fd60135fSmrg module) 10586fd60135fSmrg oldobjs=$libobjs_save 10587fd60135fSmrg addlibs=$old_convenience 10588fd60135fSmrg build_libtool_libs=no 10589fd60135fSmrg ;; 10590fd60135fSmrg *) 10591a96d7823Smrg oldobjs="$old_deplibs $non_pic_objects" 10592fd60135fSmrg $preload && test -f "$symfileobj" \ 10593fd60135fSmrg && func_append oldobjs " $symfileobj" 10594fd60135fSmrg addlibs=$old_convenience 10595fd60135fSmrg ;; 10596fd60135fSmrg esac 10597a96d7823Smrg 10598a96d7823Smrg if test -n "$addlibs"; then 10599fd60135fSmrg gentop=$output_objdir/${outputname}x 10600a96d7823Smrg func_append generated " $gentop" 10601a96d7823Smrg 10602a96d7823Smrg func_extract_archives $gentop $addlibs 10603a96d7823Smrg func_append oldobjs " $func_extract_archives_result" 10604a96d7823Smrg fi 10605a96d7823Smrg 10606a96d7823Smrg # Do each command in the archive commands. 10607fd60135fSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10608a96d7823Smrg cmds=$old_archive_from_new_cmds 10609a96d7823Smrg else 10610a96d7823Smrg 10611a96d7823Smrg # Add any objects from preloaded convenience libraries 10612a96d7823Smrg if test -n "$dlprefiles"; then 10613fd60135fSmrg gentop=$output_objdir/${outputname}x 10614a96d7823Smrg func_append generated " $gentop" 10615a96d7823Smrg 10616a96d7823Smrg func_extract_archives $gentop $dlprefiles 10617a96d7823Smrg func_append oldobjs " $func_extract_archives_result" 10618a96d7823Smrg fi 10619a96d7823Smrg 10620a96d7823Smrg # POSIX demands no paths to be encoded in archives. We have 10621a96d7823Smrg # to avoid creating archives with duplicate basenames if we 10622a96d7823Smrg # might have to extract them afterwards, e.g., when creating a 10623a96d7823Smrg # static archive out of a convenience library, or when linking 10624a96d7823Smrg # the entirety of a libtool archive into another (currently 10625a96d7823Smrg # not supported by libtool). 10626a96d7823Smrg if (for obj in $oldobjs 10627a96d7823Smrg do 10628a96d7823Smrg func_basename "$obj" 10629a96d7823Smrg $ECHO "$func_basename_result" 10630a96d7823Smrg done | sort | sort -uc >/dev/null 2>&1); then 10631a96d7823Smrg : 10632a96d7823Smrg else 10633a96d7823Smrg echo "copying selected object files to avoid basename conflicts..." 10634fd60135fSmrg gentop=$output_objdir/${outputname}x 10635a96d7823Smrg func_append generated " $gentop" 10636a96d7823Smrg func_mkdir_p "$gentop" 10637a96d7823Smrg save_oldobjs=$oldobjs 10638a96d7823Smrg oldobjs= 10639a96d7823Smrg counter=1 10640a96d7823Smrg for obj in $save_oldobjs 10641a96d7823Smrg do 10642a96d7823Smrg func_basename "$obj" 10643fd60135fSmrg objbase=$func_basename_result 10644a96d7823Smrg case " $oldobjs " in 10645a96d7823Smrg " ") oldobjs=$obj ;; 10646a96d7823Smrg *[\ /]"$objbase "*) 10647a96d7823Smrg while :; do 10648a96d7823Smrg # Make sure we don't pick an alternate name that also 10649a96d7823Smrg # overlaps. 10650a96d7823Smrg newobj=lt$counter-$objbase 10651a96d7823Smrg func_arith $counter + 1 10652a96d7823Smrg counter=$func_arith_result 10653a96d7823Smrg case " $oldobjs " in 10654a96d7823Smrg *[\ /]"$newobj "*) ;; 10655a96d7823Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10656a96d7823Smrg esac 10657a96d7823Smrg done 10658a96d7823Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10659a96d7823Smrg func_append oldobjs " $gentop/$newobj" 10660a96d7823Smrg ;; 10661a96d7823Smrg *) func_append oldobjs " $obj" ;; 10662a96d7823Smrg esac 10663a96d7823Smrg done 10664a96d7823Smrg fi 10665a96d7823Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10666a96d7823Smrg tool_oldlib=$func_to_tool_file_result 10667a96d7823Smrg eval cmds=\"$old_archive_cmds\" 10668a96d7823Smrg 10669a96d7823Smrg func_len " $cmds" 10670a96d7823Smrg len=$func_len_result 10671a96d7823Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10672a96d7823Smrg cmds=$old_archive_cmds 10673a96d7823Smrg elif test -n "$archiver_list_spec"; then 10674a96d7823Smrg func_verbose "using command file archive linking..." 10675a96d7823Smrg for obj in $oldobjs 10676a96d7823Smrg do 10677a96d7823Smrg func_to_tool_file "$obj" 10678a96d7823Smrg $ECHO "$func_to_tool_file_result" 10679a96d7823Smrg done > $output_objdir/$libname.libcmd 10680a96d7823Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 10681a96d7823Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10682a96d7823Smrg cmds=$old_archive_cmds 10683a96d7823Smrg else 10684a96d7823Smrg # the command line is too long to link in one step, link in parts 10685a96d7823Smrg func_verbose "using piecewise archive linking..." 10686a96d7823Smrg save_RANLIB=$RANLIB 10687a96d7823Smrg RANLIB=: 10688a96d7823Smrg objlist= 10689a96d7823Smrg concat_cmds= 10690a96d7823Smrg save_oldobjs=$oldobjs 10691a96d7823Smrg oldobjs= 10692a96d7823Smrg # Is there a better way of finding the last object in the list? 10693a96d7823Smrg for obj in $save_oldobjs 10694a96d7823Smrg do 10695a96d7823Smrg last_oldobj=$obj 10696a96d7823Smrg done 10697a96d7823Smrg eval test_cmds=\"$old_archive_cmds\" 10698a96d7823Smrg func_len " $test_cmds" 10699a96d7823Smrg len0=$func_len_result 10700a96d7823Smrg len=$len0 10701a96d7823Smrg for obj in $save_oldobjs 10702a96d7823Smrg do 10703a96d7823Smrg func_len " $obj" 10704a96d7823Smrg func_arith $len + $func_len_result 10705a96d7823Smrg len=$func_arith_result 10706a96d7823Smrg func_append objlist " $obj" 10707a96d7823Smrg if test "$len" -lt "$max_cmd_len"; then 10708a96d7823Smrg : 10709a96d7823Smrg else 10710a96d7823Smrg # the above command should be used before it gets too long 10711a96d7823Smrg oldobjs=$objlist 10712fd60135fSmrg if test "$obj" = "$last_oldobj"; then 10713a96d7823Smrg RANLIB=$save_RANLIB 10714a96d7823Smrg fi 10715a96d7823Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10716fd60135fSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10717a96d7823Smrg objlist= 10718a96d7823Smrg len=$len0 10719a96d7823Smrg fi 10720a96d7823Smrg done 10721a96d7823Smrg RANLIB=$save_RANLIB 10722a96d7823Smrg oldobjs=$objlist 10723fd60135fSmrg if test -z "$oldobjs"; then 10724a96d7823Smrg eval cmds=\"\$concat_cmds\" 10725a96d7823Smrg else 10726a96d7823Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10727a96d7823Smrg fi 10728a96d7823Smrg fi 10729a96d7823Smrg fi 10730a96d7823Smrg func_execute_cmds "$cmds" 'exit $?' 10731a96d7823Smrg done 10732a96d7823Smrg 10733a96d7823Smrg test -n "$generated" && \ 10734a96d7823Smrg func_show_eval "${RM}r$generated" 10735a96d7823Smrg 10736a96d7823Smrg # Now create the libtool archive. 10737a96d7823Smrg case $output in 10738a96d7823Smrg *.la) 10739a96d7823Smrg old_library= 10740fd60135fSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 10741a96d7823Smrg func_verbose "creating $output" 10742a96d7823Smrg 10743a96d7823Smrg # Preserve any variables that may affect compiler behavior 10744a96d7823Smrg for var in $variables_saved_for_relink; do 10745a96d7823Smrg if eval test -z \"\${$var+set}\"; then 10746a96d7823Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10747a96d7823Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10748a96d7823Smrg relink_command="$var=; export $var; $relink_command" 10749a96d7823Smrg else 10750a96d7823Smrg func_quote_for_eval "$var_value" 10751a96d7823Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10752a96d7823Smrg fi 10753a96d7823Smrg done 10754a96d7823Smrg # Quote the link command for shipping. 10755fd60135fSmrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 10756a96d7823Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10757fd60135fSmrg if test yes = "$hardcode_automatic"; then 10758a96d7823Smrg relink_command= 10759a96d7823Smrg fi 10760a96d7823Smrg 10761a96d7823Smrg # Only create the output if not a dry run. 10762a96d7823Smrg $opt_dry_run || { 10763a96d7823Smrg for installed in no yes; do 10764fd60135fSmrg if test yes = "$installed"; then 10765a96d7823Smrg if test -z "$install_libdir"; then 10766a96d7823Smrg break 10767a96d7823Smrg fi 10768fd60135fSmrg output=$output_objdir/${outputname}i 10769a96d7823Smrg # Replace all uninstalled libtool libraries with the installed ones 10770a96d7823Smrg newdependency_libs= 10771a96d7823Smrg for deplib in $dependency_libs; do 10772a96d7823Smrg case $deplib in 10773a96d7823Smrg *.la) 10774a96d7823Smrg func_basename "$deplib" 10775fd60135fSmrg name=$func_basename_result 10776a96d7823Smrg func_resolve_sysroot "$deplib" 10777fd60135fSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10778a96d7823Smrg test -z "$libdir" && \ 10779fd60135fSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 10780a96d7823Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 10781a96d7823Smrg ;; 10782a96d7823Smrg -L*) 10783a96d7823Smrg func_stripname -L '' "$deplib" 10784a96d7823Smrg func_replace_sysroot "$func_stripname_result" 10785a96d7823Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 10786a96d7823Smrg ;; 10787a96d7823Smrg -R*) 10788a96d7823Smrg func_stripname -R '' "$deplib" 10789a96d7823Smrg func_replace_sysroot "$func_stripname_result" 10790a96d7823Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 10791a96d7823Smrg ;; 10792a96d7823Smrg *) func_append newdependency_libs " $deplib" ;; 10793a96d7823Smrg esac 10794a96d7823Smrg done 10795fd60135fSmrg dependency_libs=$newdependency_libs 10796a96d7823Smrg newdlfiles= 10797a96d7823Smrg 10798a96d7823Smrg for lib in $dlfiles; do 10799a96d7823Smrg case $lib in 10800a96d7823Smrg *.la) 10801a96d7823Smrg func_basename "$lib" 10802fd60135fSmrg name=$func_basename_result 10803fd60135fSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10804a96d7823Smrg test -z "$libdir" && \ 10805fd60135fSmrg func_fatal_error "'$lib' is not a valid libtool archive" 10806a96d7823Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10807a96d7823Smrg ;; 10808a96d7823Smrg *) func_append newdlfiles " $lib" ;; 10809a96d7823Smrg esac 10810a96d7823Smrg done 10811fd60135fSmrg dlfiles=$newdlfiles 10812a96d7823Smrg newdlprefiles= 10813a96d7823Smrg for lib in $dlprefiles; do 10814a96d7823Smrg case $lib in 10815a96d7823Smrg *.la) 10816a96d7823Smrg # Only pass preopened files to the pseudo-archive (for 10817a96d7823Smrg # eventual linking with the app. that links it) if we 10818a96d7823Smrg # didn't already link the preopened objects directly into 10819a96d7823Smrg # the library: 10820a96d7823Smrg func_basename "$lib" 10821fd60135fSmrg name=$func_basename_result 10822fd60135fSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10823a96d7823Smrg test -z "$libdir" && \ 10824fd60135fSmrg func_fatal_error "'$lib' is not a valid libtool archive" 10825a96d7823Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10826a96d7823Smrg ;; 10827a96d7823Smrg esac 10828a96d7823Smrg done 10829fd60135fSmrg dlprefiles=$newdlprefiles 10830a96d7823Smrg else 10831a96d7823Smrg newdlfiles= 10832a96d7823Smrg for lib in $dlfiles; do 10833a96d7823Smrg case $lib in 10834fd60135fSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10835a96d7823Smrg *) abs=`pwd`"/$lib" ;; 10836a96d7823Smrg esac 10837a96d7823Smrg func_append newdlfiles " $abs" 10838a96d7823Smrg done 10839fd60135fSmrg dlfiles=$newdlfiles 10840a96d7823Smrg newdlprefiles= 10841a96d7823Smrg for lib in $dlprefiles; do 10842a96d7823Smrg case $lib in 10843fd60135fSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10844a96d7823Smrg *) abs=`pwd`"/$lib" ;; 10845a96d7823Smrg esac 10846a96d7823Smrg func_append newdlprefiles " $abs" 10847a96d7823Smrg done 10848fd60135fSmrg dlprefiles=$newdlprefiles 10849a96d7823Smrg fi 10850a96d7823Smrg $RM $output 10851a96d7823Smrg # place dlname in correct position for cygwin 10852a96d7823Smrg # In fact, it would be nice if we could use this code for all target 10853a96d7823Smrg # systems that can't hard-code library paths into their executables 10854a96d7823Smrg # and that have no shared library path variable independent of PATH, 10855a96d7823Smrg # but it turns out we can't easily determine that from inspecting 10856a96d7823Smrg # libtool variables, so we have to hard-code the OSs to which it 10857a96d7823Smrg # applies here; at the moment, that means platforms that use the PE 10858a96d7823Smrg # object format with DLL files. See the long comment at the top of 10859a96d7823Smrg # tests/bindir.at for full details. 10860a96d7823Smrg tdlname=$dlname 10861a96d7823Smrg case $host,$output,$installed,$module,$dlname in 10862a96d7823Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 10863a96d7823Smrg # If a -bindir argument was supplied, place the dll there. 10864fd60135fSmrg if test -n "$bindir"; then 10865a96d7823Smrg func_relative_path "$install_libdir" "$bindir" 10866fd60135fSmrg tdlname=$func_relative_path_result/$dlname 10867a96d7823Smrg else 10868a96d7823Smrg # Otherwise fall back on heuristic. 10869a96d7823Smrg tdlname=../bin/$dlname 10870a96d7823Smrg fi 10871a96d7823Smrg ;; 10872a96d7823Smrg esac 10873a96d7823Smrg $ECHO > $output "\ 10874a96d7823Smrg# $outputname - a libtool library file 10875fd60135fSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10876a96d7823Smrg# 10877a96d7823Smrg# Please DO NOT delete this file! 10878a96d7823Smrg# It is necessary for linking the library. 10879a96d7823Smrg 10880a96d7823Smrg# The name that we can dlopen(3). 10881a96d7823Smrgdlname='$tdlname' 10882a96d7823Smrg 10883a96d7823Smrg# Names of this library. 10884a96d7823Smrglibrary_names='$library_names' 10885a96d7823Smrg 10886a96d7823Smrg# The name of the static archive. 10887a96d7823Smrgold_library='$old_library' 10888a96d7823Smrg 10889fd60135fSmrg# Linker flags that cannot go in dependency_libs. 10890a96d7823Smrginherited_linker_flags='$new_inherited_linker_flags' 10891a96d7823Smrg 10892a96d7823Smrg# Libraries that this one depends upon. 10893a96d7823Smrgdependency_libs='$dependency_libs' 10894a96d7823Smrg 10895a96d7823Smrg# Names of additional weak libraries provided by this library 10896a96d7823Smrgweak_library_names='$weak_libs' 10897a96d7823Smrg 10898a96d7823Smrg# Version information for $libname. 10899a96d7823Smrgcurrent=$current 10900a96d7823Smrgage=$age 10901a96d7823Smrgrevision=$revision 10902a96d7823Smrg 10903a96d7823Smrg# Is this an already installed library? 10904a96d7823Smrginstalled=$installed 10905a96d7823Smrg 10906a96d7823Smrg# Should we warn about portability when linking against -modules? 10907a96d7823Smrgshouldnotlink=$module 10908a96d7823Smrg 10909a96d7823Smrg# Files to dlopen/dlpreopen 10910a96d7823Smrgdlopen='$dlfiles' 10911a96d7823Smrgdlpreopen='$dlprefiles' 10912a96d7823Smrg 10913a96d7823Smrg# Directory that this library needs to be installed in: 10914a96d7823Smrglibdir='$install_libdir'" 10915fd60135fSmrg if test no,yes = "$installed,$need_relink"; then 10916a96d7823Smrg $ECHO >> $output "\ 10917a96d7823Smrgrelink_command=\"$relink_command\"" 10918a96d7823Smrg fi 10919a96d7823Smrg done 10920a96d7823Smrg } 10921a96d7823Smrg 10922a96d7823Smrg # Do a symbolic link so that the libtool archive can be found in 10923a96d7823Smrg # LD_LIBRARY_PATH before the program is installed. 10924a96d7823Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 10925a96d7823Smrg ;; 10926a96d7823Smrg esac 10927a96d7823Smrg exit $EXIT_SUCCESS 10928a96d7823Smrg} 10929a96d7823Smrg 10930fd60135fSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 10931fd60135fSmrg func_mode_link ${1+"$@"} 10932fd60135fSmrgfi 10933a96d7823Smrg 10934a96d7823Smrg 10935a96d7823Smrg# func_mode_uninstall arg... 10936a96d7823Smrgfunc_mode_uninstall () 10937a96d7823Smrg{ 10938fd60135fSmrg $debug_cmd 10939fd60135fSmrg 10940fd60135fSmrg RM=$nonopt 10941a96d7823Smrg files= 10942fd60135fSmrg rmforce=false 10943a96d7823Smrg exit_status=0 10944a96d7823Smrg 10945a96d7823Smrg # This variable tells wrapper scripts just to set variables rather 10946a96d7823Smrg # than running their programs. 10947fd60135fSmrg libtool_install_magic=$magic 10948a96d7823Smrg 10949a96d7823Smrg for arg 10950a96d7823Smrg do 10951a96d7823Smrg case $arg in 10952fd60135fSmrg -f) func_append RM " $arg"; rmforce=: ;; 10953a96d7823Smrg -*) func_append RM " $arg" ;; 10954a96d7823Smrg *) func_append files " $arg" ;; 10955a96d7823Smrg esac 10956a96d7823Smrg done 10957a96d7823Smrg 10958a96d7823Smrg test -z "$RM" && \ 10959a96d7823Smrg func_fatal_help "you must specify an RM program" 10960a96d7823Smrg 10961a96d7823Smrg rmdirs= 10962a96d7823Smrg 10963a96d7823Smrg for file in $files; do 10964a96d7823Smrg func_dirname "$file" "" "." 10965fd60135fSmrg dir=$func_dirname_result 10966fd60135fSmrg if test . = "$dir"; then 10967fd60135fSmrg odir=$objdir 10968a96d7823Smrg else 10969fd60135fSmrg odir=$dir/$objdir 10970a96d7823Smrg fi 10971a96d7823Smrg func_basename "$file" 10972fd60135fSmrg name=$func_basename_result 10973fd60135fSmrg test uninstall = "$opt_mode" && odir=$dir 10974a96d7823Smrg 10975a96d7823Smrg # Remember odir for removal later, being careful to avoid duplicates 10976fd60135fSmrg if test clean = "$opt_mode"; then 10977a96d7823Smrg case " $rmdirs " in 10978a96d7823Smrg *" $odir "*) ;; 10979a96d7823Smrg *) func_append rmdirs " $odir" ;; 10980a96d7823Smrg esac 10981a96d7823Smrg fi 10982a96d7823Smrg 10983a96d7823Smrg # Don't error if the file doesn't exist and rm -f was used. 10984a96d7823Smrg if { test -L "$file"; } >/dev/null 2>&1 || 10985a96d7823Smrg { test -h "$file"; } >/dev/null 2>&1 || 10986a96d7823Smrg test -f "$file"; then 10987a96d7823Smrg : 10988a96d7823Smrg elif test -d "$file"; then 10989a96d7823Smrg exit_status=1 10990a96d7823Smrg continue 10991fd60135fSmrg elif $rmforce; then 10992a96d7823Smrg continue 10993a96d7823Smrg fi 10994a96d7823Smrg 10995fd60135fSmrg rmfiles=$file 10996a96d7823Smrg 10997a96d7823Smrg case $name in 10998a96d7823Smrg *.la) 10999a96d7823Smrg # Possibly a libtool archive, so verify it. 11000a96d7823Smrg if func_lalib_p "$file"; then 11001a96d7823Smrg func_source $dir/$name 11002a96d7823Smrg 11003a96d7823Smrg # Delete the libtool libraries and symlinks. 11004a96d7823Smrg for n in $library_names; do 11005a96d7823Smrg func_append rmfiles " $odir/$n" 11006a96d7823Smrg done 11007a96d7823Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11008a96d7823Smrg 11009fd60135fSmrg case $opt_mode in 11010a96d7823Smrg clean) 11011a96d7823Smrg case " $library_names " in 11012a96d7823Smrg *" $dlname "*) ;; 11013a96d7823Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11014a96d7823Smrg esac 11015a96d7823Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11016a96d7823Smrg ;; 11017a96d7823Smrg uninstall) 11018a96d7823Smrg if test -n "$library_names"; then 11019a96d7823Smrg # Do each command in the postuninstall commands. 11020fd60135fSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11021a96d7823Smrg fi 11022a96d7823Smrg 11023a96d7823Smrg if test -n "$old_library"; then 11024a96d7823Smrg # Do each command in the old_postuninstall commands. 11025fd60135fSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11026a96d7823Smrg fi 11027a96d7823Smrg # FIXME: should reinstall the best remaining shared library. 11028a96d7823Smrg ;; 11029a96d7823Smrg esac 11030a96d7823Smrg fi 11031a96d7823Smrg ;; 11032a96d7823Smrg 11033a96d7823Smrg *.lo) 11034a96d7823Smrg # Possibly a libtool object, so verify it. 11035a96d7823Smrg if func_lalib_p "$file"; then 11036a96d7823Smrg 11037a96d7823Smrg # Read the .lo file 11038a96d7823Smrg func_source $dir/$name 11039a96d7823Smrg 11040a96d7823Smrg # Add PIC object to the list of files to remove. 11041fd60135fSmrg if test -n "$pic_object" && test none != "$pic_object"; then 11042a96d7823Smrg func_append rmfiles " $dir/$pic_object" 11043a96d7823Smrg fi 11044a96d7823Smrg 11045a96d7823Smrg # Add non-PIC object to the list of files to remove. 11046fd60135fSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11047a96d7823Smrg func_append rmfiles " $dir/$non_pic_object" 11048a96d7823Smrg fi 11049a96d7823Smrg fi 11050a96d7823Smrg ;; 11051a96d7823Smrg 11052a96d7823Smrg *) 11053fd60135fSmrg if test clean = "$opt_mode"; then 11054a96d7823Smrg noexename=$name 11055a96d7823Smrg case $file in 11056a96d7823Smrg *.exe) 11057a96d7823Smrg func_stripname '' '.exe' "$file" 11058a96d7823Smrg file=$func_stripname_result 11059a96d7823Smrg func_stripname '' '.exe' "$name" 11060a96d7823Smrg noexename=$func_stripname_result 11061a96d7823Smrg # $file with .exe has already been added to rmfiles, 11062a96d7823Smrg # add $file without .exe 11063a96d7823Smrg func_append rmfiles " $file" 11064a96d7823Smrg ;; 11065a96d7823Smrg esac 11066a96d7823Smrg # Do a test to see if this is a libtool program. 11067a96d7823Smrg if func_ltwrapper_p "$file"; then 11068a96d7823Smrg if func_ltwrapper_executable_p "$file"; then 11069a96d7823Smrg func_ltwrapper_scriptname "$file" 11070a96d7823Smrg relink_command= 11071a96d7823Smrg func_source $func_ltwrapper_scriptname_result 11072a96d7823Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11073a96d7823Smrg else 11074a96d7823Smrg relink_command= 11075a96d7823Smrg func_source $dir/$noexename 11076a96d7823Smrg fi 11077a96d7823Smrg 11078a96d7823Smrg # note $name still contains .exe if it was in $file originally 11079a96d7823Smrg # as does the version of $file that was added into $rmfiles 11080fd60135fSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11081fd60135fSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 11082a96d7823Smrg func_append rmfiles " $odir/lt-$name" 11083a96d7823Smrg fi 11084fd60135fSmrg if test "X$noexename" != "X$name"; then 11085fd60135fSmrg func_append rmfiles " $odir/lt-$noexename.c" 11086a96d7823Smrg fi 11087a96d7823Smrg fi 11088a96d7823Smrg fi 11089a96d7823Smrg ;; 11090a96d7823Smrg esac 11091a96d7823Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11092a96d7823Smrg done 11093a96d7823Smrg 11094fd60135fSmrg # Try to remove the $objdir's in the directories where we deleted files 11095a96d7823Smrg for dir in $rmdirs; do 11096a96d7823Smrg if test -d "$dir"; then 11097a96d7823Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11098a96d7823Smrg fi 11099a96d7823Smrg done 11100a96d7823Smrg 11101a96d7823Smrg exit $exit_status 11102a96d7823Smrg} 11103a96d7823Smrg 11104fd60135fSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11105fd60135fSmrg func_mode_uninstall ${1+"$@"} 11106fd60135fSmrgfi 11107a96d7823Smrg 11108a96d7823Smrgtest -z "$opt_mode" && { 11109fd60135fSmrg help=$generic_help 11110a96d7823Smrg func_fatal_help "you must specify a MODE" 11111a96d7823Smrg} 11112a96d7823Smrg 11113a96d7823Smrgtest -z "$exec_cmd" && \ 11114fd60135fSmrg func_fatal_help "invalid operation mode '$opt_mode'" 11115a96d7823Smrg 11116a96d7823Smrgif test -n "$exec_cmd"; then 11117a96d7823Smrg eval exec "$exec_cmd" 11118a96d7823Smrg exit $EXIT_FAILURE 11119a96d7823Smrgfi 11120a96d7823Smrg 11121a96d7823Smrgexit $exit_status 11122a96d7823Smrg 11123a96d7823Smrg 11124a96d7823Smrg# The TAGs below are defined such that we never get into a situation 11125fd60135fSmrg# where we disable both kinds of libraries. Given conflicting 11126a96d7823Smrg# choices, we go for a static library, that is the most portable, 11127a96d7823Smrg# since we can't tell whether shared libraries were disabled because 11128a96d7823Smrg# the user asked for that or because the platform doesn't support 11129a96d7823Smrg# them. This is particularly important on AIX, because we don't 11130a96d7823Smrg# support having both static and shared libraries enabled at the same 11131a96d7823Smrg# time on that platform, so we default to a shared-only configuration. 11132a96d7823Smrg# If a disable-shared tag is given, we'll fallback to a static-only 11133a96d7823Smrg# configuration. But we'll never go from static-only to shared-only. 11134a96d7823Smrg 11135a96d7823Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11136a96d7823Smrgbuild_libtool_libs=no 11137a96d7823Smrgbuild_old_libs=yes 11138a96d7823Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 11139a96d7823Smrg 11140a96d7823Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11141a96d7823Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11142a96d7823Smrg# ### END LIBTOOL TAG CONFIG: disable-static 11143a96d7823Smrg 11144a96d7823Smrg# Local Variables: 11145a96d7823Smrg# mode:shell-script 11146a96d7823Smrg# sh-indentation:2 11147a96d7823Smrg# End: 11148