1603fc0a3Smrg#! /bin/sh 2603fc0a3Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3603fc0a3Smrg## by inline-source v2014-01-03.01 4603fc0a3Smrg 5603fc0a3Smrg# libtool (GNU libtool) 2.4.6 6603fc0a3Smrg# Provide generalized library-building support services. 7603fc0a3Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8603fc0a3Smrg 9603fc0a3Smrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 10603fc0a3Smrg# This is free software; see the source for copying conditions. There is NO 11603fc0a3Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12603fc0a3Smrg 13603fc0a3Smrg# GNU Libtool is free software; you can redistribute it and/or modify 14603fc0a3Smrg# it under the terms of the GNU General Public License as published by 15603fc0a3Smrg# the Free Software Foundation; either version 2 of the License, or 16603fc0a3Smrg# (at your option) any later version. 17603fc0a3Smrg# 18603fc0a3Smrg# As a special exception to the GNU General Public License, 19603fc0a3Smrg# if you distribute this file as part of a program or library that 20603fc0a3Smrg# is built using GNU Libtool, you may include this file under the 21603fc0a3Smrg# same distribution terms that you use for the rest of that program. 22603fc0a3Smrg# 23603fc0a3Smrg# GNU Libtool is distributed in the hope that it will be useful, but 24603fc0a3Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25603fc0a3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26603fc0a3Smrg# General Public License for more details. 27603fc0a3Smrg# 28603fc0a3Smrg# You should have received a copy of the GNU General Public License 29603fc0a3Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30603fc0a3Smrg 31603fc0a3Smrg 32603fc0a3SmrgPROGRAM=libtool 33603fc0a3SmrgPACKAGE=libtool 34603fc0a3SmrgVERSION=2.4.6 35603fc0a3Smrgpackage_revision=2.4.6 36603fc0a3Smrg 37603fc0a3Smrg 38603fc0a3Smrg## ------ ## 39603fc0a3Smrg## Usage. ## 40603fc0a3Smrg## ------ ## 41603fc0a3Smrg 42603fc0a3Smrg# Run './libtool --help' for help with using this script from the 43603fc0a3Smrg# command line. 44603fc0a3Smrg 45603fc0a3Smrg 46603fc0a3Smrg## ------------------------------- ## 47603fc0a3Smrg## User overridable command paths. ## 48603fc0a3Smrg## ------------------------------- ## 49603fc0a3Smrg 50603fc0a3Smrg# After configure completes, it has a better idea of some of the 51603fc0a3Smrg# shell tools we need than the defaults used by the functions shared 52603fc0a3Smrg# with bootstrap, so set those here where they can still be over- 53603fc0a3Smrg# ridden by the user, but otherwise take precedence. 54603fc0a3Smrg 55603fc0a3Smrg: ${AUTOCONF="autoconf"} 56603fc0a3Smrg: ${AUTOMAKE="automake"} 57603fc0a3Smrg 58603fc0a3Smrg 59603fc0a3Smrg## -------------------------- ## 60603fc0a3Smrg## Source external libraries. ## 61603fc0a3Smrg## -------------------------- ## 62603fc0a3Smrg 63603fc0a3Smrg# Much of our low-level functionality needs to be sourced from external 64603fc0a3Smrg# libraries, which are installed to $pkgauxdir. 65603fc0a3Smrg 66603fc0a3Smrg# Set a version string for this script. 67603fc0a3Smrgscriptversion=2015-01-20.17; # UTC 68603fc0a3Smrg 69603fc0a3Smrg# General shell script boiler plate, and helper functions. 70603fc0a3Smrg# Written by Gary V. Vaughan, 2004 71603fc0a3Smrg 72603fc0a3Smrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 73603fc0a3Smrg# This is free software; see the source for copying conditions. There is NO 74603fc0a3Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 75603fc0a3Smrg 76603fc0a3Smrg# This program is free software; you can redistribute it and/or modify 77603fc0a3Smrg# it under the terms of the GNU General Public License as published by 78603fc0a3Smrg# the Free Software Foundation; either version 3 of the License, or 79603fc0a3Smrg# (at your option) any later version. 80603fc0a3Smrg 81603fc0a3Smrg# As a special exception to the GNU General Public License, if you distribute 82603fc0a3Smrg# this file as part of a program or library that is built using GNU Libtool, 83603fc0a3Smrg# you may include this file under the same distribution terms that you use 84603fc0a3Smrg# for the rest of that program. 85603fc0a3Smrg 86603fc0a3Smrg# This program is distributed in the hope that it will be useful, 87603fc0a3Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 88603fc0a3Smrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 89603fc0a3Smrg# General Public License for more details. 90603fc0a3Smrg 91603fc0a3Smrg# You should have received a copy of the GNU General Public License 92603fc0a3Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 93603fc0a3Smrg 94603fc0a3Smrg# Please report bugs or propose patches to gary@gnu.org. 95603fc0a3Smrg 96603fc0a3Smrg 97603fc0a3Smrg## ------ ## 98603fc0a3Smrg## Usage. ## 99603fc0a3Smrg## ------ ## 100603fc0a3Smrg 101603fc0a3Smrg# Evaluate this file near the top of your script to gain access to 102603fc0a3Smrg# the functions and variables defined here: 103603fc0a3Smrg# 104603fc0a3Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 105603fc0a3Smrg# 106603fc0a3Smrg# If you need to override any of the default environment variable 107603fc0a3Smrg# settings, do that before evaluating this file. 108603fc0a3Smrg 109603fc0a3Smrg 110603fc0a3Smrg## -------------------- ## 111603fc0a3Smrg## Shell normalisation. ## 112603fc0a3Smrg## -------------------- ## 113603fc0a3Smrg 114603fc0a3Smrg# Some shells need a little help to be as Bourne compatible as possible. 115603fc0a3Smrg# Before doing anything else, make sure all that help has been provided! 116603fc0a3Smrg 117603fc0a3SmrgDUALCASE=1; export DUALCASE # for MKS sh 118603fc0a3Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 119603fc0a3Smrg emulate sh 120603fc0a3Smrg NULLCMD=: 121603fc0a3Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 122603fc0a3Smrg # is contrary to our usage. Disable this feature. 123603fc0a3Smrg alias -g '${1+"$@"}'='"$@"' 124603fc0a3Smrg setopt NO_GLOB_SUBST 125603fc0a3Smrgelse 126603fc0a3Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 127603fc0a3Smrgfi 128603fc0a3Smrg 129603fc0a3Smrg# NLS nuisances: We save the old values in case they are required later. 130603fc0a3Smrg_G_user_locale= 131603fc0a3Smrg_G_safe_locale= 132603fc0a3Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 133603fc0a3Smrgdo 134603fc0a3Smrg eval "if test set = \"\${$_G_var+set}\"; then 135603fc0a3Smrg save_$_G_var=\$$_G_var 136603fc0a3Smrg $_G_var=C 137603fc0a3Smrg export $_G_var 138603fc0a3Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 139603fc0a3Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 140603fc0a3Smrg fi" 141603fc0a3Smrgdone 142603fc0a3Smrg 143603fc0a3Smrg# CDPATH. 144603fc0a3Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 145603fc0a3Smrg 146603fc0a3Smrg# Make sure IFS has a sensible default 147603fc0a3Smrgsp=' ' 148603fc0a3Smrgnl=' 149603fc0a3Smrg' 150603fc0a3SmrgIFS="$sp $nl" 151603fc0a3Smrg 152603fc0a3Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 153603fc0a3Smrgif test "${PATH_SEPARATOR+set}" != set; then 154603fc0a3Smrg PATH_SEPARATOR=: 155603fc0a3Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 156603fc0a3Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 157603fc0a3Smrg PATH_SEPARATOR=';' 158603fc0a3Smrg } 159603fc0a3Smrgfi 160603fc0a3Smrg 161603fc0a3Smrg 162603fc0a3Smrg 163603fc0a3Smrg## ------------------------- ## 164603fc0a3Smrg## Locate command utilities. ## 165603fc0a3Smrg## ------------------------- ## 166603fc0a3Smrg 167603fc0a3Smrg 168603fc0a3Smrg# func_executable_p FILE 169603fc0a3Smrg# ---------------------- 170603fc0a3Smrg# Check that FILE is an executable regular file. 171603fc0a3Smrgfunc_executable_p () 172603fc0a3Smrg{ 173603fc0a3Smrg test -f "$1" && test -x "$1" 174603fc0a3Smrg} 175603fc0a3Smrg 176603fc0a3Smrg 177603fc0a3Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 178603fc0a3Smrg# -------------------------------------------- 179603fc0a3Smrg# Search for either a program that responds to --version with output 180603fc0a3Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 181603fc0a3Smrg# trying all the directories in PATH with each of the elements of 182603fc0a3Smrg# PROGS_LIST. 183603fc0a3Smrg# 184603fc0a3Smrg# CHECK_FUNC should accept the path to a candidate program, and 185603fc0a3Smrg# set $func_check_prog_result if it truncates its output less than 186603fc0a3Smrg# $_G_path_prog_max characters. 187603fc0a3Smrgfunc_path_progs () 188603fc0a3Smrg{ 189603fc0a3Smrg _G_progs_list=$1 190603fc0a3Smrg _G_check_func=$2 191603fc0a3Smrg _G_PATH=${3-"$PATH"} 192603fc0a3Smrg 193603fc0a3Smrg _G_path_prog_max=0 194603fc0a3Smrg _G_path_prog_found=false 195603fc0a3Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 196603fc0a3Smrg for _G_dir in $_G_PATH; do 197603fc0a3Smrg IFS=$_G_save_IFS 198603fc0a3Smrg test -z "$_G_dir" && _G_dir=. 199603fc0a3Smrg for _G_prog_name in $_G_progs_list; do 200603fc0a3Smrg for _exeext in '' .EXE; do 201603fc0a3Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 202603fc0a3Smrg func_executable_p "$_G_path_prog" || continue 203603fc0a3Smrg case `"$_G_path_prog" --version 2>&1` in 204603fc0a3Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 205603fc0a3Smrg *) $_G_check_func $_G_path_prog 206603fc0a3Smrg func_path_progs_result=$func_check_prog_result 207603fc0a3Smrg ;; 208603fc0a3Smrg esac 209603fc0a3Smrg $_G_path_prog_found && break 3 210603fc0a3Smrg done 211603fc0a3Smrg done 212603fc0a3Smrg done 213603fc0a3Smrg IFS=$_G_save_IFS 214603fc0a3Smrg test -z "$func_path_progs_result" && { 215603fc0a3Smrg echo "no acceptable sed could be found in \$PATH" >&2 216603fc0a3Smrg exit 1 217603fc0a3Smrg } 218603fc0a3Smrg} 219603fc0a3Smrg 220603fc0a3Smrg 221603fc0a3Smrg# We want to be able to use the functions in this file before configure 222603fc0a3Smrg# has figured out where the best binaries are kept, which means we have 223603fc0a3Smrg# to search for them ourselves - except when the results are already set 224603fc0a3Smrg# where we skip the searches. 225603fc0a3Smrg 226603fc0a3Smrg# Unless the user overrides by setting SED, search the path for either GNU 227603fc0a3Smrg# sed, or the sed that truncates its output the least. 228603fc0a3Smrgtest -z "$SED" && { 229603fc0a3Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 230603fc0a3Smrg for _G_i in 1 2 3 4 5 6 7; do 231603fc0a3Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 232603fc0a3Smrg done 233603fc0a3Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 234603fc0a3Smrg _G_sed_script= 235603fc0a3Smrg 236603fc0a3Smrg func_check_prog_sed () 237603fc0a3Smrg { 238603fc0a3Smrg _G_path_prog=$1 239603fc0a3Smrg 240603fc0a3Smrg _G_count=0 241603fc0a3Smrg printf 0123456789 >conftest.in 242603fc0a3Smrg while : 243603fc0a3Smrg do 244603fc0a3Smrg cat conftest.in conftest.in >conftest.tmp 245603fc0a3Smrg mv conftest.tmp conftest.in 246603fc0a3Smrg cp conftest.in conftest.nl 247603fc0a3Smrg echo '' >> conftest.nl 248603fc0a3Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 249603fc0a3Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 250603fc0a3Smrg _G_count=`expr $_G_count + 1` 251603fc0a3Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 252603fc0a3Smrg # Best one so far, save it but keep looking for a better one 253603fc0a3Smrg func_check_prog_result=$_G_path_prog 254603fc0a3Smrg _G_path_prog_max=$_G_count 255603fc0a3Smrg fi 256603fc0a3Smrg # 10*(2^10) chars as input seems more than enough 257603fc0a3Smrg test 10 -lt "$_G_count" && break 258603fc0a3Smrg done 259603fc0a3Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 260603fc0a3Smrg } 261603fc0a3Smrg 262603fc0a3Smrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 263603fc0a3Smrg rm -f conftest.sed 264603fc0a3Smrg SED=$func_path_progs_result 265603fc0a3Smrg} 266603fc0a3Smrg 267603fc0a3Smrg 268603fc0a3Smrg# Unless the user overrides by setting GREP, search the path for either GNU 269603fc0a3Smrg# grep, or the grep that truncates its output the least. 270603fc0a3Smrgtest -z "$GREP" && { 271603fc0a3Smrg func_check_prog_grep () 272603fc0a3Smrg { 273603fc0a3Smrg _G_path_prog=$1 274603fc0a3Smrg 275603fc0a3Smrg _G_count=0 276603fc0a3Smrg _G_path_prog_max=0 277603fc0a3Smrg printf 0123456789 >conftest.in 278603fc0a3Smrg while : 279603fc0a3Smrg do 280603fc0a3Smrg cat conftest.in conftest.in >conftest.tmp 281603fc0a3Smrg mv conftest.tmp conftest.in 282603fc0a3Smrg cp conftest.in conftest.nl 283603fc0a3Smrg echo 'GREP' >> conftest.nl 284603fc0a3Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 285603fc0a3Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 286603fc0a3Smrg _G_count=`expr $_G_count + 1` 287603fc0a3Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 288603fc0a3Smrg # Best one so far, save it but keep looking for a better one 289603fc0a3Smrg func_check_prog_result=$_G_path_prog 290603fc0a3Smrg _G_path_prog_max=$_G_count 291603fc0a3Smrg fi 292603fc0a3Smrg # 10*(2^10) chars as input seems more than enough 293603fc0a3Smrg test 10 -lt "$_G_count" && break 294603fc0a3Smrg done 295603fc0a3Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 296603fc0a3Smrg } 297603fc0a3Smrg 298603fc0a3Smrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 299603fc0a3Smrg GREP=$func_path_progs_result 300603fc0a3Smrg} 301603fc0a3Smrg 302603fc0a3Smrg 303603fc0a3Smrg## ------------------------------- ## 304603fc0a3Smrg## User overridable command paths. ## 305603fc0a3Smrg## ------------------------------- ## 306603fc0a3Smrg 307603fc0a3Smrg# All uppercase variable names are used for environment variables. These 308603fc0a3Smrg# variables can be overridden by the user before calling a script that 309603fc0a3Smrg# uses them if a suitable command of that name is not already available 310603fc0a3Smrg# in the command search PATH. 311603fc0a3Smrg 312603fc0a3Smrgunset CP 313603fc0a3Smrgunset MV 314603fc0a3Smrgunset RM 315603fc0a3Smrg: ${CP="cp -f"} 316603fc0a3Smrg: ${ECHO="printf %s\n"} 317603fc0a3Smrg: ${EGREP="$GREP -E"} 318603fc0a3Smrg: ${FGREP="$GREP -F"} 319603fc0a3Smrg: ${LN_S="ln -s"} 320603fc0a3Smrg: ${MAKE="make"} 321603fc0a3Smrg: ${MKDIR="mkdir"} 322603fc0a3Smrg: ${MV="mv -f"} 323603fc0a3Smrg: ${RM="rm -f"} 324603fc0a3Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 325603fc0a3Smrg 326603fc0a3Smrg 327603fc0a3Smrg## -------------------- ## 328603fc0a3Smrg## Useful sed snippets. ## 329603fc0a3Smrg## -------------------- ## 330603fc0a3Smrg 331603fc0a3Smrgsed_dirname='s|/[^/]*$||' 332603fc0a3Smrgsed_basename='s|^.*/||' 333603fc0a3Smrg 334603fc0a3Smrg# Sed substitution that helps us do robust quoting. It backslashifies 335603fc0a3Smrg# metacharacters that are still active within double-quoted strings. 336603fc0a3Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 337603fc0a3Smrg 338603fc0a3Smrg# Same as above, but do not quote variable references. 339603fc0a3Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 340603fc0a3Smrg 341603fc0a3Smrg# Sed substitution that turns a string into a regex matching for the 342603fc0a3Smrg# string literally. 343603fc0a3Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 344603fc0a3Smrg 345603fc0a3Smrg# Sed substitution that converts a w32 file name or path 346603fc0a3Smrg# that contains forward slashes, into one that contains 347603fc0a3Smrg# (escaped) backslashes. A very naive implementation. 348603fc0a3Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 349603fc0a3Smrg 350603fc0a3Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 351603fc0a3Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 352603fc0a3Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 353603fc0a3Smrg# expansion. Since each input '\' is now two '\'s, look for any number 354603fc0a3Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 355603fc0a3Smrg_G_bs='\\' 356603fc0a3Smrg_G_bs2='\\\\' 357603fc0a3Smrg_G_bs4='\\\\\\\\' 358603fc0a3Smrg_G_dollar='\$' 359603fc0a3Smrgsed_double_backslash="\ 360603fc0a3Smrg s/$_G_bs4/&\\ 361603fc0a3Smrg/g 362603fc0a3Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 363603fc0a3Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 364603fc0a3Smrg s/\n//g" 365603fc0a3Smrg 366603fc0a3Smrg 367603fc0a3Smrg## ----------------- ## 368603fc0a3Smrg## Global variables. ## 369603fc0a3Smrg## ----------------- ## 370603fc0a3Smrg 371603fc0a3Smrg# Except for the global variables explicitly listed below, the following 372603fc0a3Smrg# functions in the '^func_' namespace, and the '^require_' namespace 373603fc0a3Smrg# variables initialised in the 'Resource management' section, sourcing 374603fc0a3Smrg# this file will not pollute your global namespace with anything 375603fc0a3Smrg# else. There's no portable way to scope variables in Bourne shell 376603fc0a3Smrg# though, so actually running these functions will sometimes place 377603fc0a3Smrg# results into a variable named after the function, and often use 378603fc0a3Smrg# temporary variables in the '^_G_' namespace. If you are careful to 379603fc0a3Smrg# avoid using those namespaces casually in your sourcing script, things 380603fc0a3Smrg# should continue to work as you expect. And, of course, you can freely 381603fc0a3Smrg# overwrite any of the functions or variables defined here before 382603fc0a3Smrg# calling anything to customize them. 383603fc0a3Smrg 384603fc0a3SmrgEXIT_SUCCESS=0 385603fc0a3SmrgEXIT_FAILURE=1 386603fc0a3SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 387603fc0a3SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 388603fc0a3Smrg 389603fc0a3Smrg# Allow overriding, eg assuming that you follow the convention of 390603fc0a3Smrg# putting '$debug_cmd' at the start of all your functions, you can get 391603fc0a3Smrg# bash to show function call trace with: 392603fc0a3Smrg# 393603fc0a3Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 394603fc0a3Smrgdebug_cmd=${debug_cmd-":"} 395603fc0a3Smrgexit_cmd=: 396603fc0a3Smrg 397603fc0a3Smrg# By convention, finish your script with: 398603fc0a3Smrg# 399603fc0a3Smrg# exit $exit_status 400603fc0a3Smrg# 401603fc0a3Smrg# so that you can set exit_status to non-zero if you want to indicate 402603fc0a3Smrg# something went wrong during execution without actually bailing out at 403603fc0a3Smrg# the point of failure. 404603fc0a3Smrgexit_status=$EXIT_SUCCESS 405603fc0a3Smrg 406603fc0a3Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 407603fc0a3Smrg# is ksh but when the shell is invoked as "sh" and the current value of 408603fc0a3Smrg# the _XPG environment variable is not equal to 1 (one), the special 409603fc0a3Smrg# positional parameter $0, within a function call, is the name of the 410603fc0a3Smrg# function. 411603fc0a3Smrgprogpath=$0 412603fc0a3Smrg 413603fc0a3Smrg# The name of this program. 414603fc0a3Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 415603fc0a3Smrg 416603fc0a3Smrg# Make sure we have an absolute progpath for reexecution: 417603fc0a3Smrgcase $progpath in 418603fc0a3Smrg [\\/]*|[A-Za-z]:\\*) ;; 419603fc0a3Smrg *[\\/]*) 420603fc0a3Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 421603fc0a3Smrg progdir=`cd "$progdir" && pwd` 422603fc0a3Smrg progpath=$progdir/$progname 423603fc0a3Smrg ;; 424603fc0a3Smrg *) 425603fc0a3Smrg _G_IFS=$IFS 426603fc0a3Smrg IFS=${PATH_SEPARATOR-:} 427603fc0a3Smrg for progdir in $PATH; do 428603fc0a3Smrg IFS=$_G_IFS 429603fc0a3Smrg test -x "$progdir/$progname" && break 430603fc0a3Smrg done 431603fc0a3Smrg IFS=$_G_IFS 432603fc0a3Smrg test -n "$progdir" || progdir=`pwd` 433603fc0a3Smrg progpath=$progdir/$progname 434603fc0a3Smrg ;; 435603fc0a3Smrgesac 436603fc0a3Smrg 437603fc0a3Smrg 438603fc0a3Smrg## ----------------- ## 439603fc0a3Smrg## Standard options. ## 440603fc0a3Smrg## ----------------- ## 441603fc0a3Smrg 442603fc0a3Smrg# The following options affect the operation of the functions defined 443603fc0a3Smrg# below, and should be set appropriately depending on run-time para- 444603fc0a3Smrg# meters passed on the command line. 445603fc0a3Smrg 446603fc0a3Smrgopt_dry_run=false 447603fc0a3Smrgopt_quiet=false 448603fc0a3Smrgopt_verbose=false 449603fc0a3Smrg 450603fc0a3Smrg# Categories 'all' and 'none' are always available. Append any others 451603fc0a3Smrg# you will pass as the first argument to func_warning from your own 452603fc0a3Smrg# code. 453603fc0a3Smrgwarning_categories= 454603fc0a3Smrg 455603fc0a3Smrg# By default, display warnings according to 'opt_warning_types'. Set 456603fc0a3Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 457603fc0a3Smrg# treat the next displayed warning as a fatal error. 458603fc0a3Smrgwarning_func=func_warn_and_continue 459603fc0a3Smrg 460603fc0a3Smrg# Set to 'all' to display all warnings, 'none' to suppress all 461603fc0a3Smrg# warnings, or a space delimited list of some subset of 462603fc0a3Smrg# 'warning_categories' to display only the listed warnings. 463603fc0a3Smrgopt_warning_types=all 464603fc0a3Smrg 465603fc0a3Smrg 466603fc0a3Smrg## -------------------- ## 467603fc0a3Smrg## Resource management. ## 468603fc0a3Smrg## -------------------- ## 469603fc0a3Smrg 470603fc0a3Smrg# This section contains definitions for functions that each ensure a 471603fc0a3Smrg# particular resource (a file, or a non-empty configuration variable for 472603fc0a3Smrg# example) is available, and if appropriate to extract default values 473603fc0a3Smrg# from pertinent package files. Call them using their associated 474603fc0a3Smrg# 'require_*' variable to ensure that they are executed, at most, once. 475603fc0a3Smrg# 476603fc0a3Smrg# It's entirely deliberate that calling these functions can set 477603fc0a3Smrg# variables that don't obey the namespace limitations obeyed by the rest 478603fc0a3Smrg# of this file, in order that that they be as useful as possible to 479603fc0a3Smrg# callers. 480603fc0a3Smrg 481603fc0a3Smrg 482603fc0a3Smrg# require_term_colors 483603fc0a3Smrg# ------------------- 484603fc0a3Smrg# Allow display of bold text on terminals that support it. 485603fc0a3Smrgrequire_term_colors=func_require_term_colors 486603fc0a3Smrgfunc_require_term_colors () 487603fc0a3Smrg{ 488603fc0a3Smrg $debug_cmd 489603fc0a3Smrg 490603fc0a3Smrg test -t 1 && { 491603fc0a3Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 492603fc0a3Smrg # precedence, because most terminfo databases neglect to describe 493603fc0a3Smrg # whether color sequences are supported. 494603fc0a3Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 495603fc0a3Smrg 496603fc0a3Smrg if test 1 = "$USE_ANSI_COLORS"; then 497603fc0a3Smrg # Standard ANSI escape sequences 498603fc0a3Smrg tc_reset='[0m' 499603fc0a3Smrg tc_bold='[1m'; tc_standout='[7m' 500603fc0a3Smrg tc_red='[31m'; tc_green='[32m' 501603fc0a3Smrg tc_blue='[34m'; tc_cyan='[36m' 502603fc0a3Smrg else 503603fc0a3Smrg # Otherwise trust the terminfo database after all. 504603fc0a3Smrg test -n "`tput sgr0 2>/dev/null`" && { 505603fc0a3Smrg tc_reset=`tput sgr0` 506603fc0a3Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 507603fc0a3Smrg tc_standout=$tc_bold 508603fc0a3Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 509603fc0a3Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 510603fc0a3Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 511603fc0a3Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 512603fc0a3Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 513603fc0a3Smrg } 514603fc0a3Smrg fi 515603fc0a3Smrg } 516603fc0a3Smrg 517603fc0a3Smrg require_term_colors=: 518603fc0a3Smrg} 519603fc0a3Smrg 520603fc0a3Smrg 521603fc0a3Smrg## ----------------- ## 522603fc0a3Smrg## Function library. ## 523603fc0a3Smrg## ----------------- ## 524603fc0a3Smrg 525603fc0a3Smrg# This section contains a variety of useful functions to call in your 526603fc0a3Smrg# scripts. Take note of the portable wrappers for features provided by 527603fc0a3Smrg# some modern shells, which will fall back to slower equivalents on 528603fc0a3Smrg# less featureful shells. 529603fc0a3Smrg 530603fc0a3Smrg 531603fc0a3Smrg# func_append VAR VALUE 532603fc0a3Smrg# --------------------- 533603fc0a3Smrg# Append VALUE onto the existing contents of VAR. 534603fc0a3Smrg 535603fc0a3Smrg # We should try to minimise forks, especially on Windows where they are 536603fc0a3Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 537603fc0a3Smrg # being used: 538603fc0a3Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 539603fc0a3Smrg : ${_G_HAVE_ARITH_OP="yes"} 540603fc0a3Smrg : ${_G_HAVE_XSI_OPS="yes"} 541603fc0a3Smrg # The += operator was introduced in bash 3.1 542603fc0a3Smrg case $BASH_VERSION in 543603fc0a3Smrg [12].* | 3.0 | 3.0*) ;; 544603fc0a3Smrg *) 545603fc0a3Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 546603fc0a3Smrg ;; 547603fc0a3Smrg esac 548603fc0a3Smrg fi 549603fc0a3Smrg 550603fc0a3Smrg # _G_HAVE_PLUSEQ_OP 551603fc0a3Smrg # Can be empty, in which case the shell is probed, "yes" if += is 552603fc0a3Smrg # useable or anything else if it does not work. 553603fc0a3Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 554603fc0a3Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 555603fc0a3Smrg && _G_HAVE_PLUSEQ_OP=yes 556603fc0a3Smrg 557603fc0a3Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 558603fc0a3Smrgthen 559603fc0a3Smrg # This is an XSI compatible shell, allowing a faster implementation... 560603fc0a3Smrg eval 'func_append () 561603fc0a3Smrg { 562603fc0a3Smrg $debug_cmd 563603fc0a3Smrg 564603fc0a3Smrg eval "$1+=\$2" 565603fc0a3Smrg }' 566603fc0a3Smrgelse 567603fc0a3Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 568603fc0a3Smrg func_append () 569603fc0a3Smrg { 570603fc0a3Smrg $debug_cmd 571603fc0a3Smrg 572603fc0a3Smrg eval "$1=\$$1\$2" 573603fc0a3Smrg } 574603fc0a3Smrgfi 575603fc0a3Smrg 576603fc0a3Smrg 577603fc0a3Smrg# func_append_quoted VAR VALUE 578603fc0a3Smrg# ---------------------------- 579603fc0a3Smrg# Quote VALUE and append to the end of shell variable VAR, separated 580603fc0a3Smrg# by a space. 581603fc0a3Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 582603fc0a3Smrg eval 'func_append_quoted () 583603fc0a3Smrg { 584603fc0a3Smrg $debug_cmd 585603fc0a3Smrg 586603fc0a3Smrg func_quote_for_eval "$2" 587603fc0a3Smrg eval "$1+=\\ \$func_quote_for_eval_result" 588603fc0a3Smrg }' 589603fc0a3Smrgelse 590603fc0a3Smrg func_append_quoted () 591603fc0a3Smrg { 592603fc0a3Smrg $debug_cmd 593603fc0a3Smrg 594603fc0a3Smrg func_quote_for_eval "$2" 595603fc0a3Smrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 596603fc0a3Smrg } 597603fc0a3Smrgfi 598603fc0a3Smrg 599603fc0a3Smrg 600603fc0a3Smrg# func_append_uniq VAR VALUE 601603fc0a3Smrg# -------------------------- 602603fc0a3Smrg# Append unique VALUE onto the existing contents of VAR, assuming 603603fc0a3Smrg# entries are delimited by the first character of VALUE. For example: 604603fc0a3Smrg# 605603fc0a3Smrg# func_append_uniq options " --another-option option-argument" 606603fc0a3Smrg# 607603fc0a3Smrg# will only append to $options if " --another-option option-argument " 608603fc0a3Smrg# is not already present somewhere in $options already (note spaces at 609603fc0a3Smrg# each end implied by leading space in second argument). 610603fc0a3Smrgfunc_append_uniq () 611603fc0a3Smrg{ 612603fc0a3Smrg $debug_cmd 613603fc0a3Smrg 614603fc0a3Smrg eval _G_current_value='`$ECHO $'$1'`' 615603fc0a3Smrg _G_delim=`expr "$2" : '\(.\)'` 616603fc0a3Smrg 617603fc0a3Smrg case $_G_delim$_G_current_value$_G_delim in 618603fc0a3Smrg *"$2$_G_delim"*) ;; 619603fc0a3Smrg *) func_append "$@" ;; 620603fc0a3Smrg esac 621603fc0a3Smrg} 622603fc0a3Smrg 623603fc0a3Smrg 624603fc0a3Smrg# func_arith TERM... 625603fc0a3Smrg# ------------------ 626603fc0a3Smrg# Set func_arith_result to the result of evaluating TERMs. 627603fc0a3Smrg test -z "$_G_HAVE_ARITH_OP" \ 628603fc0a3Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 629603fc0a3Smrg && _G_HAVE_ARITH_OP=yes 630603fc0a3Smrg 631603fc0a3Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 632603fc0a3Smrg eval 'func_arith () 633603fc0a3Smrg { 634603fc0a3Smrg $debug_cmd 635603fc0a3Smrg 636603fc0a3Smrg func_arith_result=$(( $* )) 637603fc0a3Smrg }' 638603fc0a3Smrgelse 639603fc0a3Smrg func_arith () 640603fc0a3Smrg { 641603fc0a3Smrg $debug_cmd 642603fc0a3Smrg 643603fc0a3Smrg func_arith_result=`expr "$@"` 644603fc0a3Smrg } 645603fc0a3Smrgfi 646603fc0a3Smrg 647603fc0a3Smrg 648603fc0a3Smrg# func_basename FILE 649603fc0a3Smrg# ------------------ 650603fc0a3Smrg# Set func_basename_result to FILE with everything up to and including 651603fc0a3Smrg# the last / stripped. 652603fc0a3Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 653603fc0a3Smrg # If this shell supports suffix pattern removal, then use it to avoid 654603fc0a3Smrg # forking. Hide the definitions single quotes in case the shell chokes 655603fc0a3Smrg # on unsupported syntax... 656603fc0a3Smrg _b='func_basename_result=${1##*/}' 657603fc0a3Smrg _d='case $1 in 658603fc0a3Smrg */*) func_dirname_result=${1%/*}$2 ;; 659603fc0a3Smrg * ) func_dirname_result=$3 ;; 660603fc0a3Smrg esac' 661603fc0a3Smrg 662603fc0a3Smrgelse 663603fc0a3Smrg # ...otherwise fall back to using sed. 664603fc0a3Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 665603fc0a3Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 666603fc0a3Smrg if test "X$func_dirname_result" = "X$1"; then 667603fc0a3Smrg func_dirname_result=$3 668603fc0a3Smrg else 669603fc0a3Smrg func_append func_dirname_result "$2" 670603fc0a3Smrg fi' 671603fc0a3Smrgfi 672603fc0a3Smrg 673603fc0a3Smrgeval 'func_basename () 674603fc0a3Smrg{ 675603fc0a3Smrg $debug_cmd 676603fc0a3Smrg 677603fc0a3Smrg '"$_b"' 678603fc0a3Smrg}' 679603fc0a3Smrg 680603fc0a3Smrg 681603fc0a3Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 682603fc0a3Smrg# ------------------------------------------- 683603fc0a3Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 684603fc0a3Smrg# otherwise set result to NONDIR_REPLACEMENT. 685603fc0a3Smrgeval 'func_dirname () 686603fc0a3Smrg{ 687603fc0a3Smrg $debug_cmd 688603fc0a3Smrg 689603fc0a3Smrg '"$_d"' 690603fc0a3Smrg}' 691603fc0a3Smrg 692603fc0a3Smrg 693603fc0a3Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 694603fc0a3Smrg# -------------------------------------------------------- 695603fc0a3Smrg# Perform func_basename and func_dirname in a single function 696603fc0a3Smrg# call: 697603fc0a3Smrg# dirname: Compute the dirname of FILE. If nonempty, 698603fc0a3Smrg# add APPEND to the result, otherwise set result 699603fc0a3Smrg# to NONDIR_REPLACEMENT. 700603fc0a3Smrg# value returned in "$func_dirname_result" 701603fc0a3Smrg# basename: Compute filename of FILE. 702603fc0a3Smrg# value retuned in "$func_basename_result" 703603fc0a3Smrg# For efficiency, we do not delegate to the functions above but instead 704603fc0a3Smrg# duplicate the functionality here. 705603fc0a3Smrgeval 'func_dirname_and_basename () 706603fc0a3Smrg{ 707603fc0a3Smrg $debug_cmd 708603fc0a3Smrg 709603fc0a3Smrg '"$_b"' 710603fc0a3Smrg '"$_d"' 711603fc0a3Smrg}' 712603fc0a3Smrg 713603fc0a3Smrg 714603fc0a3Smrg# func_echo ARG... 715603fc0a3Smrg# ---------------- 716603fc0a3Smrg# Echo program name prefixed message. 717603fc0a3Smrgfunc_echo () 718603fc0a3Smrg{ 719603fc0a3Smrg $debug_cmd 720603fc0a3Smrg 721603fc0a3Smrg _G_message=$* 722603fc0a3Smrg 723603fc0a3Smrg func_echo_IFS=$IFS 724603fc0a3Smrg IFS=$nl 725603fc0a3Smrg for _G_line in $_G_message; do 726603fc0a3Smrg IFS=$func_echo_IFS 727603fc0a3Smrg $ECHO "$progname: $_G_line" 728603fc0a3Smrg done 729603fc0a3Smrg IFS=$func_echo_IFS 730603fc0a3Smrg} 731603fc0a3Smrg 732603fc0a3Smrg 733603fc0a3Smrg# func_echo_all ARG... 734603fc0a3Smrg# -------------------- 735603fc0a3Smrg# Invoke $ECHO with all args, space-separated. 736603fc0a3Smrgfunc_echo_all () 737603fc0a3Smrg{ 738603fc0a3Smrg $ECHO "$*" 739603fc0a3Smrg} 740603fc0a3Smrg 741603fc0a3Smrg 742603fc0a3Smrg# func_echo_infix_1 INFIX ARG... 743603fc0a3Smrg# ------------------------------ 744603fc0a3Smrg# Echo program name, followed by INFIX on the first line, with any 745603fc0a3Smrg# additional lines not showing INFIX. 746603fc0a3Smrgfunc_echo_infix_1 () 747603fc0a3Smrg{ 748603fc0a3Smrg $debug_cmd 749603fc0a3Smrg 750603fc0a3Smrg $require_term_colors 751603fc0a3Smrg 752603fc0a3Smrg _G_infix=$1; shift 753603fc0a3Smrg _G_indent=$_G_infix 754603fc0a3Smrg _G_prefix="$progname: $_G_infix: " 755603fc0a3Smrg _G_message=$* 756603fc0a3Smrg 757603fc0a3Smrg # Strip color escape sequences before counting printable length 758603fc0a3Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 759603fc0a3Smrg do 760603fc0a3Smrg test -n "$_G_tc" && { 761603fc0a3Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 762603fc0a3Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 763603fc0a3Smrg } 764603fc0a3Smrg done 765603fc0a3Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 766603fc0a3Smrg 767603fc0a3Smrg func_echo_infix_1_IFS=$IFS 768603fc0a3Smrg IFS=$nl 769603fc0a3Smrg for _G_line in $_G_message; do 770603fc0a3Smrg IFS=$func_echo_infix_1_IFS 771603fc0a3Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 772603fc0a3Smrg _G_prefix=$_G_indent 773603fc0a3Smrg done 774603fc0a3Smrg IFS=$func_echo_infix_1_IFS 775603fc0a3Smrg} 776603fc0a3Smrg 777603fc0a3Smrg 778603fc0a3Smrg# func_error ARG... 779603fc0a3Smrg# ----------------- 780603fc0a3Smrg# Echo program name prefixed message to standard error. 781603fc0a3Smrgfunc_error () 782603fc0a3Smrg{ 783603fc0a3Smrg $debug_cmd 784603fc0a3Smrg 785603fc0a3Smrg $require_term_colors 786603fc0a3Smrg 787603fc0a3Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 788603fc0a3Smrg} 789603fc0a3Smrg 790603fc0a3Smrg 791603fc0a3Smrg# func_fatal_error ARG... 792603fc0a3Smrg# ----------------------- 793603fc0a3Smrg# Echo program name prefixed message to standard error, and exit. 794603fc0a3Smrgfunc_fatal_error () 795603fc0a3Smrg{ 796603fc0a3Smrg $debug_cmd 797603fc0a3Smrg 798603fc0a3Smrg func_error "$*" 799603fc0a3Smrg exit $EXIT_FAILURE 800603fc0a3Smrg} 801603fc0a3Smrg 802603fc0a3Smrg 803603fc0a3Smrg# func_grep EXPRESSION FILENAME 804603fc0a3Smrg# ----------------------------- 805603fc0a3Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 806603fc0a3Smrgfunc_grep () 807603fc0a3Smrg{ 808603fc0a3Smrg $debug_cmd 809603fc0a3Smrg 810603fc0a3Smrg $GREP "$1" "$2" >/dev/null 2>&1 811603fc0a3Smrg} 812603fc0a3Smrg 813603fc0a3Smrg 814603fc0a3Smrg# func_len STRING 815603fc0a3Smrg# --------------- 816603fc0a3Smrg# Set func_len_result to the length of STRING. STRING may not 817603fc0a3Smrg# start with a hyphen. 818603fc0a3Smrg test -z "$_G_HAVE_XSI_OPS" \ 819603fc0a3Smrg && (eval 'x=a/b/c; 820603fc0a3Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 821603fc0a3Smrg && _G_HAVE_XSI_OPS=yes 822603fc0a3Smrg 823603fc0a3Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 824603fc0a3Smrg eval 'func_len () 825603fc0a3Smrg { 826603fc0a3Smrg $debug_cmd 827603fc0a3Smrg 828603fc0a3Smrg func_len_result=${#1} 829603fc0a3Smrg }' 830603fc0a3Smrgelse 831603fc0a3Smrg func_len () 832603fc0a3Smrg { 833603fc0a3Smrg $debug_cmd 834603fc0a3Smrg 835603fc0a3Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 836603fc0a3Smrg } 837603fc0a3Smrgfi 838603fc0a3Smrg 839603fc0a3Smrg 840603fc0a3Smrg# func_mkdir_p DIRECTORY-PATH 841603fc0a3Smrg# --------------------------- 842603fc0a3Smrg# Make sure the entire path to DIRECTORY-PATH is available. 843603fc0a3Smrgfunc_mkdir_p () 844603fc0a3Smrg{ 845603fc0a3Smrg $debug_cmd 846603fc0a3Smrg 847603fc0a3Smrg _G_directory_path=$1 848603fc0a3Smrg _G_dir_list= 849603fc0a3Smrg 850603fc0a3Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 851603fc0a3Smrg 852603fc0a3Smrg # Protect directory names starting with '-' 853603fc0a3Smrg case $_G_directory_path in 854603fc0a3Smrg -*) _G_directory_path=./$_G_directory_path ;; 855603fc0a3Smrg esac 856603fc0a3Smrg 857603fc0a3Smrg # While some portion of DIR does not yet exist... 858603fc0a3Smrg while test ! -d "$_G_directory_path"; do 859603fc0a3Smrg # ...make a list in topmost first order. Use a colon delimited 860603fc0a3Smrg # list incase some portion of path contains whitespace. 861603fc0a3Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 862603fc0a3Smrg 863603fc0a3Smrg # If the last portion added has no slash in it, the list is done 864603fc0a3Smrg case $_G_directory_path in */*) ;; *) break ;; esac 865603fc0a3Smrg 866603fc0a3Smrg # ...otherwise throw away the child directory and loop 867603fc0a3Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 868603fc0a3Smrg done 869603fc0a3Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 870603fc0a3Smrg 871603fc0a3Smrg func_mkdir_p_IFS=$IFS; IFS=: 872603fc0a3Smrg for _G_dir in $_G_dir_list; do 873603fc0a3Smrg IFS=$func_mkdir_p_IFS 874603fc0a3Smrg # mkdir can fail with a 'File exist' error if two processes 875603fc0a3Smrg # try to create one of the directories concurrently. Don't 876603fc0a3Smrg # stop in that case! 877603fc0a3Smrg $MKDIR "$_G_dir" 2>/dev/null || : 878603fc0a3Smrg done 879603fc0a3Smrg IFS=$func_mkdir_p_IFS 880603fc0a3Smrg 881603fc0a3Smrg # Bail out if we (or some other process) failed to create a directory. 882603fc0a3Smrg test -d "$_G_directory_path" || \ 883603fc0a3Smrg func_fatal_error "Failed to create '$1'" 884603fc0a3Smrg fi 885603fc0a3Smrg} 886603fc0a3Smrg 887603fc0a3Smrg 888603fc0a3Smrg# func_mktempdir [BASENAME] 889603fc0a3Smrg# ------------------------- 890603fc0a3Smrg# Make a temporary directory that won't clash with other running 891603fc0a3Smrg# libtool processes, and avoids race conditions if possible. If 892603fc0a3Smrg# given, BASENAME is the basename for that directory. 893603fc0a3Smrgfunc_mktempdir () 894603fc0a3Smrg{ 895603fc0a3Smrg $debug_cmd 896603fc0a3Smrg 897603fc0a3Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 898603fc0a3Smrg 899603fc0a3Smrg if test : = "$opt_dry_run"; then 900603fc0a3Smrg # Return a directory name, but don't create it in dry-run mode 901603fc0a3Smrg _G_tmpdir=$_G_template-$$ 902603fc0a3Smrg else 903603fc0a3Smrg 904603fc0a3Smrg # If mktemp works, use that first and foremost 905603fc0a3Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 906603fc0a3Smrg 907603fc0a3Smrg if test ! -d "$_G_tmpdir"; then 908603fc0a3Smrg # Failing that, at least try and use $RANDOM to avoid a race 909603fc0a3Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 910603fc0a3Smrg 911603fc0a3Smrg func_mktempdir_umask=`umask` 912603fc0a3Smrg umask 0077 913603fc0a3Smrg $MKDIR "$_G_tmpdir" 914603fc0a3Smrg umask $func_mktempdir_umask 915603fc0a3Smrg fi 916603fc0a3Smrg 917603fc0a3Smrg # If we're not in dry-run mode, bomb out on failure 918603fc0a3Smrg test -d "$_G_tmpdir" || \ 919603fc0a3Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 920603fc0a3Smrg fi 921603fc0a3Smrg 922603fc0a3Smrg $ECHO "$_G_tmpdir" 923603fc0a3Smrg} 924603fc0a3Smrg 925603fc0a3Smrg 926603fc0a3Smrg# func_normal_abspath PATH 927603fc0a3Smrg# ------------------------ 928603fc0a3Smrg# Remove doubled-up and trailing slashes, "." path components, 929603fc0a3Smrg# and cancel out any ".." path components in PATH after making 930603fc0a3Smrg# it an absolute path. 931603fc0a3Smrgfunc_normal_abspath () 932603fc0a3Smrg{ 933603fc0a3Smrg $debug_cmd 934603fc0a3Smrg 935603fc0a3Smrg # These SED scripts presuppose an absolute path with a trailing slash. 936603fc0a3Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 937603fc0a3Smrg _G_pathcdr='s|^/[^/]*||' 938603fc0a3Smrg _G_removedotparts=':dotsl 939603fc0a3Smrg s|/\./|/|g 940603fc0a3Smrg t dotsl 941603fc0a3Smrg s|/\.$|/|' 942603fc0a3Smrg _G_collapseslashes='s|/\{1,\}|/|g' 943603fc0a3Smrg _G_finalslash='s|/*$|/|' 944603fc0a3Smrg 945603fc0a3Smrg # Start from root dir and reassemble the path. 946603fc0a3Smrg func_normal_abspath_result= 947603fc0a3Smrg func_normal_abspath_tpath=$1 948603fc0a3Smrg func_normal_abspath_altnamespace= 949603fc0a3Smrg case $func_normal_abspath_tpath in 950603fc0a3Smrg "") 951603fc0a3Smrg # Empty path, that just means $cwd. 952603fc0a3Smrg func_stripname '' '/' "`pwd`" 953603fc0a3Smrg func_normal_abspath_result=$func_stripname_result 954603fc0a3Smrg return 955603fc0a3Smrg ;; 956603fc0a3Smrg # The next three entries are used to spot a run of precisely 957603fc0a3Smrg # two leading slashes without using negated character classes; 958603fc0a3Smrg # we take advantage of case's first-match behaviour. 959603fc0a3Smrg ///*) 960603fc0a3Smrg # Unusual form of absolute path, do nothing. 961603fc0a3Smrg ;; 962603fc0a3Smrg //*) 963603fc0a3Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 964603fc0a3Smrg # and for example Cygwin uses it to access remote file shares 965603fc0a3Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 966603fc0a3Smrg func_normal_abspath_altnamespace=/ 967603fc0a3Smrg ;; 968603fc0a3Smrg /*) 969603fc0a3Smrg # Absolute path, do nothing. 970603fc0a3Smrg ;; 971603fc0a3Smrg *) 972603fc0a3Smrg # Relative path, prepend $cwd. 973603fc0a3Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 974603fc0a3Smrg ;; 975603fc0a3Smrg esac 976603fc0a3Smrg 977603fc0a3Smrg # Cancel out all the simple stuff to save iterations. We also want 978603fc0a3Smrg # the path to end with a slash for ease of parsing, so make sure 979603fc0a3Smrg # there is one (and only one) here. 980603fc0a3Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 981603fc0a3Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 982603fc0a3Smrg while :; do 983603fc0a3Smrg # Processed it all yet? 984603fc0a3Smrg if test / = "$func_normal_abspath_tpath"; then 985603fc0a3Smrg # If we ascended to the root using ".." the result may be empty now. 986603fc0a3Smrg if test -z "$func_normal_abspath_result"; then 987603fc0a3Smrg func_normal_abspath_result=/ 988603fc0a3Smrg fi 989603fc0a3Smrg break 990603fc0a3Smrg fi 991603fc0a3Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 992603fc0a3Smrg -e "$_G_pathcar"` 993603fc0a3Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 994603fc0a3Smrg -e "$_G_pathcdr"` 995603fc0a3Smrg # Figure out what to do with it 996603fc0a3Smrg case $func_normal_abspath_tcomponent in 997603fc0a3Smrg "") 998603fc0a3Smrg # Trailing empty path component, ignore it. 999603fc0a3Smrg ;; 1000603fc0a3Smrg ..) 1001603fc0a3Smrg # Parent dir; strip last assembled component from result. 1002603fc0a3Smrg func_dirname "$func_normal_abspath_result" 1003603fc0a3Smrg func_normal_abspath_result=$func_dirname_result 1004603fc0a3Smrg ;; 1005603fc0a3Smrg *) 1006603fc0a3Smrg # Actual path component, append it. 1007603fc0a3Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1008603fc0a3Smrg ;; 1009603fc0a3Smrg esac 1010603fc0a3Smrg done 1011603fc0a3Smrg # Restore leading double-slash if one was found on entry. 1012603fc0a3Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1013603fc0a3Smrg} 1014603fc0a3Smrg 1015603fc0a3Smrg 1016603fc0a3Smrg# func_notquiet ARG... 1017603fc0a3Smrg# -------------------- 1018603fc0a3Smrg# Echo program name prefixed message only when not in quiet mode. 1019603fc0a3Smrgfunc_notquiet () 1020603fc0a3Smrg{ 1021603fc0a3Smrg $debug_cmd 1022603fc0a3Smrg 1023603fc0a3Smrg $opt_quiet || func_echo ${1+"$@"} 1024603fc0a3Smrg 1025603fc0a3Smrg # A bug in bash halts the script if the last line of a function 1026603fc0a3Smrg # fails when set -e is in force, so we need another command to 1027603fc0a3Smrg # work around that: 1028603fc0a3Smrg : 1029603fc0a3Smrg} 1030603fc0a3Smrg 1031603fc0a3Smrg 1032603fc0a3Smrg# func_relative_path SRCDIR DSTDIR 1033603fc0a3Smrg# -------------------------------- 1034603fc0a3Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1035603fc0a3Smrgfunc_relative_path () 1036603fc0a3Smrg{ 1037603fc0a3Smrg $debug_cmd 1038603fc0a3Smrg 1039603fc0a3Smrg func_relative_path_result= 1040603fc0a3Smrg func_normal_abspath "$1" 1041603fc0a3Smrg func_relative_path_tlibdir=$func_normal_abspath_result 1042603fc0a3Smrg func_normal_abspath "$2" 1043603fc0a3Smrg func_relative_path_tbindir=$func_normal_abspath_result 1044603fc0a3Smrg 1045603fc0a3Smrg # Ascend the tree starting from libdir 1046603fc0a3Smrg while :; do 1047603fc0a3Smrg # check if we have found a prefix of bindir 1048603fc0a3Smrg case $func_relative_path_tbindir in 1049603fc0a3Smrg $func_relative_path_tlibdir) 1050603fc0a3Smrg # found an exact match 1051603fc0a3Smrg func_relative_path_tcancelled= 1052603fc0a3Smrg break 1053603fc0a3Smrg ;; 1054603fc0a3Smrg $func_relative_path_tlibdir*) 1055603fc0a3Smrg # found a matching prefix 1056603fc0a3Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1057603fc0a3Smrg func_relative_path_tcancelled=$func_stripname_result 1058603fc0a3Smrg if test -z "$func_relative_path_result"; then 1059603fc0a3Smrg func_relative_path_result=. 1060603fc0a3Smrg fi 1061603fc0a3Smrg break 1062603fc0a3Smrg ;; 1063603fc0a3Smrg *) 1064603fc0a3Smrg func_dirname $func_relative_path_tlibdir 1065603fc0a3Smrg func_relative_path_tlibdir=$func_dirname_result 1066603fc0a3Smrg if test -z "$func_relative_path_tlibdir"; then 1067603fc0a3Smrg # Have to descend all the way to the root! 1068603fc0a3Smrg func_relative_path_result=../$func_relative_path_result 1069603fc0a3Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 1070603fc0a3Smrg break 1071603fc0a3Smrg fi 1072603fc0a3Smrg func_relative_path_result=../$func_relative_path_result 1073603fc0a3Smrg ;; 1074603fc0a3Smrg esac 1075603fc0a3Smrg done 1076603fc0a3Smrg 1077603fc0a3Smrg # Now calculate path; take care to avoid doubling-up slashes. 1078603fc0a3Smrg func_stripname '' '/' "$func_relative_path_result" 1079603fc0a3Smrg func_relative_path_result=$func_stripname_result 1080603fc0a3Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1081603fc0a3Smrg if test -n "$func_stripname_result"; then 1082603fc0a3Smrg func_append func_relative_path_result "/$func_stripname_result" 1083603fc0a3Smrg fi 1084603fc0a3Smrg 1085603fc0a3Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 1086603fc0a3Smrg if test -n "$func_relative_path_result"; then 1087603fc0a3Smrg func_stripname './' '' "$func_relative_path_result" 1088603fc0a3Smrg func_relative_path_result=$func_stripname_result 1089603fc0a3Smrg fi 1090603fc0a3Smrg 1091603fc0a3Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 1092603fc0a3Smrg 1093603fc0a3Smrg : 1094603fc0a3Smrg} 1095603fc0a3Smrg 1096603fc0a3Smrg 1097603fc0a3Smrg# func_quote_for_eval ARG... 1098603fc0a3Smrg# -------------------------- 1099603fc0a3Smrg# Aesthetically quote ARGs to be evaled later. 1100603fc0a3Smrg# This function returns two values: 1101603fc0a3Smrg# i) func_quote_for_eval_result 1102603fc0a3Smrg# double-quoted, suitable for a subsequent eval 1103603fc0a3Smrg# ii) func_quote_for_eval_unquoted_result 1104603fc0a3Smrg# has all characters that are still active within double 1105603fc0a3Smrg# quotes backslashified. 1106603fc0a3Smrgfunc_quote_for_eval () 1107603fc0a3Smrg{ 1108603fc0a3Smrg $debug_cmd 1109603fc0a3Smrg 1110603fc0a3Smrg func_quote_for_eval_unquoted_result= 1111603fc0a3Smrg func_quote_for_eval_result= 1112603fc0a3Smrg while test 0 -lt $#; do 1113603fc0a3Smrg case $1 in 1114603fc0a3Smrg *[\\\`\"\$]*) 1115603fc0a3Smrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 1116603fc0a3Smrg *) 1117603fc0a3Smrg _G_unquoted_arg=$1 ;; 1118603fc0a3Smrg esac 1119603fc0a3Smrg if test -n "$func_quote_for_eval_unquoted_result"; then 1120603fc0a3Smrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 1121603fc0a3Smrg else 1122603fc0a3Smrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 1123603fc0a3Smrg fi 1124603fc0a3Smrg 1125603fc0a3Smrg case $_G_unquoted_arg in 1126603fc0a3Smrg # Double-quote args containing shell metacharacters to delay 1127603fc0a3Smrg # word splitting, command substitution and variable expansion 1128603fc0a3Smrg # for a subsequent eval. 1129603fc0a3Smrg # Many Bourne shells cannot handle close brackets correctly 1130603fc0a3Smrg # in scan sets, so we specify it separately. 1131603fc0a3Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1132603fc0a3Smrg _G_quoted_arg=\"$_G_unquoted_arg\" 1133603fc0a3Smrg ;; 1134603fc0a3Smrg *) 1135603fc0a3Smrg _G_quoted_arg=$_G_unquoted_arg 1136603fc0a3Smrg ;; 1137603fc0a3Smrg esac 1138603fc0a3Smrg 1139603fc0a3Smrg if test -n "$func_quote_for_eval_result"; then 1140603fc0a3Smrg func_append func_quote_for_eval_result " $_G_quoted_arg" 1141603fc0a3Smrg else 1142603fc0a3Smrg func_append func_quote_for_eval_result "$_G_quoted_arg" 1143603fc0a3Smrg fi 1144603fc0a3Smrg shift 1145603fc0a3Smrg done 1146603fc0a3Smrg} 1147603fc0a3Smrg 1148603fc0a3Smrg 1149603fc0a3Smrg# func_quote_for_expand ARG 1150603fc0a3Smrg# ------------------------- 1151603fc0a3Smrg# Aesthetically quote ARG to be evaled later; same as above, 1152603fc0a3Smrg# but do not quote variable references. 1153603fc0a3Smrgfunc_quote_for_expand () 1154603fc0a3Smrg{ 1155603fc0a3Smrg $debug_cmd 1156603fc0a3Smrg 1157603fc0a3Smrg case $1 in 1158603fc0a3Smrg *[\\\`\"]*) 1159603fc0a3Smrg _G_arg=`$ECHO "$1" | $SED \ 1160603fc0a3Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 1161603fc0a3Smrg *) 1162603fc0a3Smrg _G_arg=$1 ;; 1163603fc0a3Smrg esac 1164603fc0a3Smrg 1165603fc0a3Smrg case $_G_arg in 1166603fc0a3Smrg # Double-quote args containing shell metacharacters to delay 1167603fc0a3Smrg # word splitting and command substitution for a subsequent eval. 1168603fc0a3Smrg # Many Bourne shells cannot handle close brackets correctly 1169603fc0a3Smrg # in scan sets, so we specify it separately. 1170603fc0a3Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1171603fc0a3Smrg _G_arg=\"$_G_arg\" 1172603fc0a3Smrg ;; 1173603fc0a3Smrg esac 1174603fc0a3Smrg 1175603fc0a3Smrg func_quote_for_expand_result=$_G_arg 1176603fc0a3Smrg} 1177603fc0a3Smrg 1178603fc0a3Smrg 1179603fc0a3Smrg# func_stripname PREFIX SUFFIX NAME 1180603fc0a3Smrg# --------------------------------- 1181603fc0a3Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1182603fc0a3Smrg# PREFIX and SUFFIX must not contain globbing or regex special 1183603fc0a3Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 1184603fc0a3Smrg# dot (in which case that matches only a dot). 1185603fc0a3Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 1186603fc0a3Smrg eval 'func_stripname () 1187603fc0a3Smrg { 1188603fc0a3Smrg $debug_cmd 1189603fc0a3Smrg 1190603fc0a3Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1191603fc0a3Smrg # positional parameters, so assign one to ordinary variable first. 1192603fc0a3Smrg func_stripname_result=$3 1193603fc0a3Smrg func_stripname_result=${func_stripname_result#"$1"} 1194603fc0a3Smrg func_stripname_result=${func_stripname_result%"$2"} 1195603fc0a3Smrg }' 1196603fc0a3Smrgelse 1197603fc0a3Smrg func_stripname () 1198603fc0a3Smrg { 1199603fc0a3Smrg $debug_cmd 1200603fc0a3Smrg 1201603fc0a3Smrg case $2 in 1202603fc0a3Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1203603fc0a3Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1204603fc0a3Smrg esac 1205603fc0a3Smrg } 1206603fc0a3Smrgfi 1207603fc0a3Smrg 1208603fc0a3Smrg 1209603fc0a3Smrg# func_show_eval CMD [FAIL_EXP] 1210603fc0a3Smrg# ----------------------------- 1211603fc0a3Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1212603fc0a3Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1213603fc0a3Smrg# is given, then evaluate it. 1214603fc0a3Smrgfunc_show_eval () 1215603fc0a3Smrg{ 1216603fc0a3Smrg $debug_cmd 1217603fc0a3Smrg 1218603fc0a3Smrg _G_cmd=$1 1219603fc0a3Smrg _G_fail_exp=${2-':'} 1220603fc0a3Smrg 1221603fc0a3Smrg func_quote_for_expand "$_G_cmd" 1222603fc0a3Smrg eval "func_notquiet $func_quote_for_expand_result" 1223603fc0a3Smrg 1224603fc0a3Smrg $opt_dry_run || { 1225603fc0a3Smrg eval "$_G_cmd" 1226603fc0a3Smrg _G_status=$? 1227603fc0a3Smrg if test 0 -ne "$_G_status"; then 1228603fc0a3Smrg eval "(exit $_G_status); $_G_fail_exp" 1229603fc0a3Smrg fi 1230603fc0a3Smrg } 1231603fc0a3Smrg} 1232603fc0a3Smrg 1233603fc0a3Smrg 1234603fc0a3Smrg# func_show_eval_locale CMD [FAIL_EXP] 1235603fc0a3Smrg# ------------------------------------ 1236603fc0a3Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1237603fc0a3Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1238603fc0a3Smrg# is given, then evaluate it. Use the saved locale for evaluation. 1239603fc0a3Smrgfunc_show_eval_locale () 1240603fc0a3Smrg{ 1241603fc0a3Smrg $debug_cmd 1242603fc0a3Smrg 1243603fc0a3Smrg _G_cmd=$1 1244603fc0a3Smrg _G_fail_exp=${2-':'} 1245603fc0a3Smrg 1246603fc0a3Smrg $opt_quiet || { 1247603fc0a3Smrg func_quote_for_expand "$_G_cmd" 1248603fc0a3Smrg eval "func_echo $func_quote_for_expand_result" 1249603fc0a3Smrg } 1250603fc0a3Smrg 1251603fc0a3Smrg $opt_dry_run || { 1252603fc0a3Smrg eval "$_G_user_locale 1253603fc0a3Smrg $_G_cmd" 1254603fc0a3Smrg _G_status=$? 1255603fc0a3Smrg eval "$_G_safe_locale" 1256603fc0a3Smrg if test 0 -ne "$_G_status"; then 1257603fc0a3Smrg eval "(exit $_G_status); $_G_fail_exp" 1258603fc0a3Smrg fi 1259603fc0a3Smrg } 1260603fc0a3Smrg} 1261603fc0a3Smrg 1262603fc0a3Smrg 1263603fc0a3Smrg# func_tr_sh 1264603fc0a3Smrg# ---------- 1265603fc0a3Smrg# Turn $1 into a string suitable for a shell variable name. 1266603fc0a3Smrg# Result is stored in $func_tr_sh_result. All characters 1267603fc0a3Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1268603fc0a3Smrg# if $1 begins with a digit, a '_' is prepended as well. 1269603fc0a3Smrgfunc_tr_sh () 1270603fc0a3Smrg{ 1271603fc0a3Smrg $debug_cmd 1272603fc0a3Smrg 1273603fc0a3Smrg case $1 in 1274603fc0a3Smrg [0-9]* | *[!a-zA-Z0-9_]*) 1275603fc0a3Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1276603fc0a3Smrg ;; 1277603fc0a3Smrg * ) 1278603fc0a3Smrg func_tr_sh_result=$1 1279603fc0a3Smrg ;; 1280603fc0a3Smrg esac 1281603fc0a3Smrg} 1282603fc0a3Smrg 1283603fc0a3Smrg 1284603fc0a3Smrg# func_verbose ARG... 1285603fc0a3Smrg# ------------------- 1286603fc0a3Smrg# Echo program name prefixed message in verbose mode only. 1287603fc0a3Smrgfunc_verbose () 1288603fc0a3Smrg{ 1289603fc0a3Smrg $debug_cmd 1290603fc0a3Smrg 1291603fc0a3Smrg $opt_verbose && func_echo "$*" 1292603fc0a3Smrg 1293603fc0a3Smrg : 1294603fc0a3Smrg} 1295603fc0a3Smrg 1296603fc0a3Smrg 1297603fc0a3Smrg# func_warn_and_continue ARG... 1298603fc0a3Smrg# ----------------------------- 1299603fc0a3Smrg# Echo program name prefixed warning message to standard error. 1300603fc0a3Smrgfunc_warn_and_continue () 1301603fc0a3Smrg{ 1302603fc0a3Smrg $debug_cmd 1303603fc0a3Smrg 1304603fc0a3Smrg $require_term_colors 1305603fc0a3Smrg 1306603fc0a3Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1307603fc0a3Smrg} 1308603fc0a3Smrg 1309603fc0a3Smrg 1310603fc0a3Smrg# func_warning CATEGORY ARG... 1311603fc0a3Smrg# ---------------------------- 1312603fc0a3Smrg# Echo program name prefixed warning message to standard error. Warning 1313603fc0a3Smrg# messages can be filtered according to CATEGORY, where this function 1314603fc0a3Smrg# elides messages where CATEGORY is not listed in the global variable 1315603fc0a3Smrg# 'opt_warning_types'. 1316603fc0a3Smrgfunc_warning () 1317603fc0a3Smrg{ 1318603fc0a3Smrg $debug_cmd 1319603fc0a3Smrg 1320603fc0a3Smrg # CATEGORY must be in the warning_categories list! 1321603fc0a3Smrg case " $warning_categories " in 1322603fc0a3Smrg *" $1 "*) ;; 1323603fc0a3Smrg *) func_internal_error "invalid warning category '$1'" ;; 1324603fc0a3Smrg esac 1325603fc0a3Smrg 1326603fc0a3Smrg _G_category=$1 1327603fc0a3Smrg shift 1328603fc0a3Smrg 1329603fc0a3Smrg case " $opt_warning_types " in 1330603fc0a3Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1331603fc0a3Smrg esac 1332603fc0a3Smrg} 1333603fc0a3Smrg 1334603fc0a3Smrg 1335603fc0a3Smrg# func_sort_ver VER1 VER2 1336603fc0a3Smrg# ----------------------- 1337603fc0a3Smrg# 'sort -V' is not generally available. 1338603fc0a3Smrg# Note this deviates from the version comparison in automake 1339603fc0a3Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1340603fc0a3Smrg# but this should suffice as we won't be specifying old 1341603fc0a3Smrg# version formats or redundant trailing .0 in bootstrap.conf. 1342603fc0a3Smrg# If we did want full compatibility then we should probably 1343603fc0a3Smrg# use m4_version_compare from autoconf. 1344603fc0a3Smrgfunc_sort_ver () 1345603fc0a3Smrg{ 1346603fc0a3Smrg $debug_cmd 1347603fc0a3Smrg 1348603fc0a3Smrg printf '%s\n%s\n' "$1" "$2" \ 1349603fc0a3Smrg | 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 1350603fc0a3Smrg} 1351603fc0a3Smrg 1352603fc0a3Smrg# func_lt_ver PREV CURR 1353603fc0a3Smrg# --------------------- 1354603fc0a3Smrg# Return true if PREV and CURR are in the correct order according to 1355603fc0a3Smrg# func_sort_ver, otherwise false. Use it like this: 1356603fc0a3Smrg# 1357603fc0a3Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1358603fc0a3Smrgfunc_lt_ver () 1359603fc0a3Smrg{ 1360603fc0a3Smrg $debug_cmd 1361603fc0a3Smrg 1362603fc0a3Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1363603fc0a3Smrg} 1364603fc0a3Smrg 1365603fc0a3Smrg 1366603fc0a3Smrg# Local variables: 1367603fc0a3Smrg# mode: shell-script 1368603fc0a3Smrg# sh-indentation: 2 1369603fc0a3Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 1370603fc0a3Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1371603fc0a3Smrg# time-stamp-time-zone: "UTC" 1372603fc0a3Smrg# End: 1373603fc0a3Smrg#! /bin/sh 1374603fc0a3Smrg 1375603fc0a3Smrg# Set a version string for this script. 1376603fc0a3Smrgscriptversion=2014-01-07.03; # UTC 1377603fc0a3Smrg 1378603fc0a3Smrg# A portable, pluggable option parser for Bourne shell. 1379603fc0a3Smrg# Written by Gary V. Vaughan, 2010 1380603fc0a3Smrg 1381603fc0a3Smrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 1382603fc0a3Smrg# This is free software; see the source for copying conditions. There is NO 1383603fc0a3Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1384603fc0a3Smrg 1385603fc0a3Smrg# This program is free software: you can redistribute it and/or modify 1386603fc0a3Smrg# it under the terms of the GNU General Public License as published by 1387603fc0a3Smrg# the Free Software Foundation, either version 3 of the License, or 1388603fc0a3Smrg# (at your option) any later version. 1389603fc0a3Smrg 1390603fc0a3Smrg# This program is distributed in the hope that it will be useful, 1391603fc0a3Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1392603fc0a3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1393603fc0a3Smrg# GNU General Public License for more details. 1394603fc0a3Smrg 1395603fc0a3Smrg# You should have received a copy of the GNU General Public License 1396603fc0a3Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 1397603fc0a3Smrg 1398603fc0a3Smrg# Please report bugs or propose patches to gary@gnu.org. 1399603fc0a3Smrg 1400603fc0a3Smrg 1401603fc0a3Smrg## ------ ## 1402603fc0a3Smrg## Usage. ## 1403603fc0a3Smrg## ------ ## 1404603fc0a3Smrg 1405603fc0a3Smrg# This file is a library for parsing options in your shell scripts along 1406603fc0a3Smrg# with assorted other useful supporting features that you can make use 1407603fc0a3Smrg# of too. 1408603fc0a3Smrg# 1409603fc0a3Smrg# For the simplest scripts you might need only: 1410603fc0a3Smrg# 1411603fc0a3Smrg# #!/bin/sh 1412603fc0a3Smrg# . relative/path/to/funclib.sh 1413603fc0a3Smrg# . relative/path/to/options-parser 1414603fc0a3Smrg# scriptversion=1.0 1415603fc0a3Smrg# func_options ${1+"$@"} 1416603fc0a3Smrg# eval set dummy "$func_options_result"; shift 1417603fc0a3Smrg# ...rest of your script... 1418603fc0a3Smrg# 1419603fc0a3Smrg# In order for the '--version' option to work, you will need to have a 1420603fc0a3Smrg# suitably formatted comment like the one at the top of this file 1421603fc0a3Smrg# starting with '# Written by ' and ending with '# warranty; '. 1422603fc0a3Smrg# 1423603fc0a3Smrg# For '-h' and '--help' to work, you will also need a one line 1424603fc0a3Smrg# description of your script's purpose in a comment directly above the 1425603fc0a3Smrg# '# Written by ' line, like the one at the top of this file. 1426603fc0a3Smrg# 1427603fc0a3Smrg# The default options also support '--debug', which will turn on shell 1428603fc0a3Smrg# execution tracing (see the comment above debug_cmd below for another 1429603fc0a3Smrg# use), and '--verbose' and the func_verbose function to allow your script 1430603fc0a3Smrg# to display verbose messages only when your user has specified 1431603fc0a3Smrg# '--verbose'. 1432603fc0a3Smrg# 1433603fc0a3Smrg# After sourcing this file, you can plug processing for additional 1434603fc0a3Smrg# options by amending the variables from the 'Configuration' section 1435603fc0a3Smrg# below, and following the instructions in the 'Option parsing' 1436603fc0a3Smrg# section further down. 1437603fc0a3Smrg 1438603fc0a3Smrg## -------------- ## 1439603fc0a3Smrg## Configuration. ## 1440603fc0a3Smrg## -------------- ## 1441603fc0a3Smrg 1442603fc0a3Smrg# You should override these variables in your script after sourcing this 1443603fc0a3Smrg# file so that they reflect the customisations you have added to the 1444603fc0a3Smrg# option parser. 1445603fc0a3Smrg 1446603fc0a3Smrg# The usage line for option parsing errors and the start of '-h' and 1447603fc0a3Smrg# '--help' output messages. You can embed shell variables for delayed 1448603fc0a3Smrg# expansion at the time the message is displayed, but you will need to 1449603fc0a3Smrg# quote other shell meta-characters carefully to prevent them being 1450603fc0a3Smrg# expanded when the contents are evaled. 1451603fc0a3Smrgusage='$progpath [OPTION]...' 1452603fc0a3Smrg 1453603fc0a3Smrg# Short help message in response to '-h' and '--help'. Add to this or 1454603fc0a3Smrg# override it after sourcing this library to reflect the full set of 1455603fc0a3Smrg# options your script accepts. 1456603fc0a3Smrgusage_message="\ 1457603fc0a3Smrg --debug enable verbose shell tracing 1458603fc0a3Smrg -W, --warnings=CATEGORY 1459603fc0a3Smrg report the warnings falling in CATEGORY [all] 1460603fc0a3Smrg -v, --verbose verbosely report processing 1461603fc0a3Smrg --version print version information and exit 1462603fc0a3Smrg -h, --help print short or long help message and exit 1463603fc0a3Smrg" 1464603fc0a3Smrg 1465603fc0a3Smrg# Additional text appended to 'usage_message' in response to '--help'. 1466603fc0a3Smrglong_help_message=" 1467603fc0a3SmrgWarning categories include: 1468603fc0a3Smrg 'all' show all warnings 1469603fc0a3Smrg 'none' turn off all the warnings 1470603fc0a3Smrg 'error' warnings are treated as fatal errors" 1471603fc0a3Smrg 1472603fc0a3Smrg# Help message printed before fatal option parsing errors. 1473603fc0a3Smrgfatal_help="Try '\$progname --help' for more information." 1474603fc0a3Smrg 1475603fc0a3Smrg 1476603fc0a3Smrg 1477603fc0a3Smrg## ------------------------- ## 1478603fc0a3Smrg## Hook function management. ## 1479603fc0a3Smrg## ------------------------- ## 1480603fc0a3Smrg 1481603fc0a3Smrg# This section contains functions for adding, removing, and running hooks 1482603fc0a3Smrg# to the main code. A hook is just a named list of of function, that can 1483603fc0a3Smrg# be run in order later on. 1484603fc0a3Smrg 1485603fc0a3Smrg# func_hookable FUNC_NAME 1486603fc0a3Smrg# ----------------------- 1487603fc0a3Smrg# Declare that FUNC_NAME will run hooks added with 1488603fc0a3Smrg# 'func_add_hook FUNC_NAME ...'. 1489603fc0a3Smrgfunc_hookable () 1490603fc0a3Smrg{ 1491603fc0a3Smrg $debug_cmd 1492603fc0a3Smrg 1493603fc0a3Smrg func_append hookable_fns " $1" 1494603fc0a3Smrg} 1495603fc0a3Smrg 1496603fc0a3Smrg 1497603fc0a3Smrg# func_add_hook FUNC_NAME HOOK_FUNC 1498603fc0a3Smrg# --------------------------------- 1499603fc0a3Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1500603fc0a3Smrg# first have been declared "hookable" by a call to 'func_hookable'. 1501603fc0a3Smrgfunc_add_hook () 1502603fc0a3Smrg{ 1503603fc0a3Smrg $debug_cmd 1504603fc0a3Smrg 1505603fc0a3Smrg case " $hookable_fns " in 1506603fc0a3Smrg *" $1 "*) ;; 1507603fc0a3Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1508603fc0a3Smrg esac 1509603fc0a3Smrg 1510603fc0a3Smrg eval func_append ${1}_hooks '" $2"' 1511603fc0a3Smrg} 1512603fc0a3Smrg 1513603fc0a3Smrg 1514603fc0a3Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 1515603fc0a3Smrg# ------------------------------------ 1516603fc0a3Smrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 1517603fc0a3Smrgfunc_remove_hook () 1518603fc0a3Smrg{ 1519603fc0a3Smrg $debug_cmd 1520603fc0a3Smrg 1521603fc0a3Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1522603fc0a3Smrg} 1523603fc0a3Smrg 1524603fc0a3Smrg 1525603fc0a3Smrg# func_run_hooks FUNC_NAME [ARG]... 1526603fc0a3Smrg# --------------------------------- 1527603fc0a3Smrg# Run all hook functions registered to FUNC_NAME. 1528603fc0a3Smrg# It is assumed that the list of hook functions contains nothing more 1529603fc0a3Smrg# than a whitespace-delimited list of legal shell function names, and 1530603fc0a3Smrg# no effort is wasted trying to catch shell meta-characters or preserve 1531603fc0a3Smrg# whitespace. 1532603fc0a3Smrgfunc_run_hooks () 1533603fc0a3Smrg{ 1534603fc0a3Smrg $debug_cmd 1535603fc0a3Smrg 1536603fc0a3Smrg case " $hookable_fns " in 1537603fc0a3Smrg *" $1 "*) ;; 1538603fc0a3Smrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 1539603fc0a3Smrg esac 1540603fc0a3Smrg 1541603fc0a3Smrg eval _G_hook_fns=\$$1_hooks; shift 1542603fc0a3Smrg 1543603fc0a3Smrg for _G_hook in $_G_hook_fns; do 1544603fc0a3Smrg eval $_G_hook '"$@"' 1545603fc0a3Smrg 1546603fc0a3Smrg # store returned options list back into positional 1547603fc0a3Smrg # parameters for next 'cmd' execution. 1548603fc0a3Smrg eval _G_hook_result=\$${_G_hook}_result 1549603fc0a3Smrg eval set dummy "$_G_hook_result"; shift 1550603fc0a3Smrg done 1551603fc0a3Smrg 1552603fc0a3Smrg func_quote_for_eval ${1+"$@"} 1553603fc0a3Smrg func_run_hooks_result=$func_quote_for_eval_result 1554603fc0a3Smrg} 1555603fc0a3Smrg 1556603fc0a3Smrg 1557603fc0a3Smrg 1558603fc0a3Smrg## --------------- ## 1559603fc0a3Smrg## Option parsing. ## 1560603fc0a3Smrg## --------------- ## 1561603fc0a3Smrg 1562603fc0a3Smrg# In order to add your own option parsing hooks, you must accept the 1563603fc0a3Smrg# full positional parameter list in your hook function, remove any 1564603fc0a3Smrg# options that you action, and then pass back the remaining unprocessed 1565603fc0a3Smrg# options in '<hooked_function_name>_result', escaped suitably for 1566603fc0a3Smrg# 'eval'. Like this: 1567603fc0a3Smrg# 1568603fc0a3Smrg# my_options_prep () 1569603fc0a3Smrg# { 1570603fc0a3Smrg# $debug_cmd 1571603fc0a3Smrg# 1572603fc0a3Smrg# # Extend the existing usage message. 1573603fc0a3Smrg# usage_message=$usage_message' 1574603fc0a3Smrg# -s, --silent don'\''t print informational messages 1575603fc0a3Smrg# ' 1576603fc0a3Smrg# 1577603fc0a3Smrg# func_quote_for_eval ${1+"$@"} 1578603fc0a3Smrg# my_options_prep_result=$func_quote_for_eval_result 1579603fc0a3Smrg# } 1580603fc0a3Smrg# func_add_hook func_options_prep my_options_prep 1581603fc0a3Smrg# 1582603fc0a3Smrg# 1583603fc0a3Smrg# my_silent_option () 1584603fc0a3Smrg# { 1585603fc0a3Smrg# $debug_cmd 1586603fc0a3Smrg# 1587603fc0a3Smrg# # Note that for efficiency, we parse as many options as we can 1588603fc0a3Smrg# # recognise in a loop before passing the remainder back to the 1589603fc0a3Smrg# # caller on the first unrecognised argument we encounter. 1590603fc0a3Smrg# while test $# -gt 0; do 1591603fc0a3Smrg# opt=$1; shift 1592603fc0a3Smrg# case $opt in 1593603fc0a3Smrg# --silent|-s) opt_silent=: ;; 1594603fc0a3Smrg# # Separate non-argument short options: 1595603fc0a3Smrg# -s*) func_split_short_opt "$_G_opt" 1596603fc0a3Smrg# set dummy "$func_split_short_opt_name" \ 1597603fc0a3Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 1598603fc0a3Smrg# shift 1599603fc0a3Smrg# ;; 1600603fc0a3Smrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 1601603fc0a3Smrg# esac 1602603fc0a3Smrg# done 1603603fc0a3Smrg# 1604603fc0a3Smrg# func_quote_for_eval ${1+"$@"} 1605603fc0a3Smrg# my_silent_option_result=$func_quote_for_eval_result 1606603fc0a3Smrg# } 1607603fc0a3Smrg# func_add_hook func_parse_options my_silent_option 1608603fc0a3Smrg# 1609603fc0a3Smrg# 1610603fc0a3Smrg# my_option_validation () 1611603fc0a3Smrg# { 1612603fc0a3Smrg# $debug_cmd 1613603fc0a3Smrg# 1614603fc0a3Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 1615603fc0a3Smrg# '--silent' and '--verbose' options are mutually exclusive." 1616603fc0a3Smrg# 1617603fc0a3Smrg# func_quote_for_eval ${1+"$@"} 1618603fc0a3Smrg# my_option_validation_result=$func_quote_for_eval_result 1619603fc0a3Smrg# } 1620603fc0a3Smrg# func_add_hook func_validate_options my_option_validation 1621603fc0a3Smrg# 1622603fc0a3Smrg# You'll alse need to manually amend $usage_message to reflect the extra 1623603fc0a3Smrg# options you parse. It's preferable to append if you can, so that 1624603fc0a3Smrg# multiple option parsing hooks can be added safely. 1625603fc0a3Smrg 1626603fc0a3Smrg 1627603fc0a3Smrg# func_options [ARG]... 1628603fc0a3Smrg# --------------------- 1629603fc0a3Smrg# All the functions called inside func_options are hookable. See the 1630603fc0a3Smrg# individual implementations for details. 1631603fc0a3Smrgfunc_hookable func_options 1632603fc0a3Smrgfunc_options () 1633603fc0a3Smrg{ 1634603fc0a3Smrg $debug_cmd 1635603fc0a3Smrg 1636603fc0a3Smrg func_options_prep ${1+"$@"} 1637603fc0a3Smrg eval func_parse_options \ 1638603fc0a3Smrg ${func_options_prep_result+"$func_options_prep_result"} 1639603fc0a3Smrg eval func_validate_options \ 1640603fc0a3Smrg ${func_parse_options_result+"$func_parse_options_result"} 1641603fc0a3Smrg 1642603fc0a3Smrg eval func_run_hooks func_options \ 1643603fc0a3Smrg ${func_validate_options_result+"$func_validate_options_result"} 1644603fc0a3Smrg 1645603fc0a3Smrg # save modified positional parameters for caller 1646603fc0a3Smrg func_options_result=$func_run_hooks_result 1647603fc0a3Smrg} 1648603fc0a3Smrg 1649603fc0a3Smrg 1650603fc0a3Smrg# func_options_prep [ARG]... 1651603fc0a3Smrg# -------------------------- 1652603fc0a3Smrg# All initialisations required before starting the option parse loop. 1653603fc0a3Smrg# Note that when calling hook functions, we pass through the list of 1654603fc0a3Smrg# positional parameters. If a hook function modifies that list, and 1655603fc0a3Smrg# needs to propogate that back to rest of this script, then the complete 1656603fc0a3Smrg# modified list must be put in 'func_run_hooks_result' before 1657603fc0a3Smrg# returning. 1658603fc0a3Smrgfunc_hookable func_options_prep 1659603fc0a3Smrgfunc_options_prep () 1660603fc0a3Smrg{ 1661603fc0a3Smrg $debug_cmd 1662603fc0a3Smrg 1663603fc0a3Smrg # Option defaults: 1664603fc0a3Smrg opt_verbose=false 1665603fc0a3Smrg opt_warning_types= 1666603fc0a3Smrg 1667603fc0a3Smrg func_run_hooks func_options_prep ${1+"$@"} 1668603fc0a3Smrg 1669603fc0a3Smrg # save modified positional parameters for caller 1670603fc0a3Smrg func_options_prep_result=$func_run_hooks_result 1671603fc0a3Smrg} 1672603fc0a3Smrg 1673603fc0a3Smrg 1674603fc0a3Smrg# func_parse_options [ARG]... 1675603fc0a3Smrg# --------------------------- 1676603fc0a3Smrg# The main option parsing loop. 1677603fc0a3Smrgfunc_hookable func_parse_options 1678603fc0a3Smrgfunc_parse_options () 1679603fc0a3Smrg{ 1680603fc0a3Smrg $debug_cmd 1681603fc0a3Smrg 1682603fc0a3Smrg func_parse_options_result= 1683603fc0a3Smrg 1684603fc0a3Smrg # this just eases exit handling 1685603fc0a3Smrg while test $# -gt 0; do 1686603fc0a3Smrg # Defer to hook functions for initial option parsing, so they 1687603fc0a3Smrg # get priority in the event of reusing an option name. 1688603fc0a3Smrg func_run_hooks func_parse_options ${1+"$@"} 1689603fc0a3Smrg 1690603fc0a3Smrg # Adjust func_parse_options positional parameters to match 1691603fc0a3Smrg eval set dummy "$func_run_hooks_result"; shift 1692603fc0a3Smrg 1693603fc0a3Smrg # Break out of the loop if we already parsed every option. 1694603fc0a3Smrg test $# -gt 0 || break 1695603fc0a3Smrg 1696603fc0a3Smrg _G_opt=$1 1697603fc0a3Smrg shift 1698603fc0a3Smrg case $_G_opt in 1699603fc0a3Smrg --debug|-x) debug_cmd='set -x' 1700603fc0a3Smrg func_echo "enabling shell trace mode" 1701603fc0a3Smrg $debug_cmd 1702603fc0a3Smrg ;; 1703603fc0a3Smrg 1704603fc0a3Smrg --no-warnings|--no-warning|--no-warn) 1705603fc0a3Smrg set dummy --warnings none ${1+"$@"} 1706603fc0a3Smrg shift 1707603fc0a3Smrg ;; 1708603fc0a3Smrg 1709603fc0a3Smrg --warnings|--warning|-W) 1710603fc0a3Smrg test $# = 0 && func_missing_arg $_G_opt && break 1711603fc0a3Smrg case " $warning_categories $1" in 1712603fc0a3Smrg *" $1 "*) 1713603fc0a3Smrg # trailing space prevents matching last $1 above 1714603fc0a3Smrg func_append_uniq opt_warning_types " $1" 1715603fc0a3Smrg ;; 1716603fc0a3Smrg *all) 1717603fc0a3Smrg opt_warning_types=$warning_categories 1718603fc0a3Smrg ;; 1719603fc0a3Smrg *none) 1720603fc0a3Smrg opt_warning_types=none 1721603fc0a3Smrg warning_func=: 1722603fc0a3Smrg ;; 1723603fc0a3Smrg *error) 1724603fc0a3Smrg opt_warning_types=$warning_categories 1725603fc0a3Smrg warning_func=func_fatal_error 1726603fc0a3Smrg ;; 1727603fc0a3Smrg *) 1728603fc0a3Smrg func_fatal_error \ 1729603fc0a3Smrg "unsupported warning category: '$1'" 1730603fc0a3Smrg ;; 1731603fc0a3Smrg esac 1732603fc0a3Smrg shift 1733603fc0a3Smrg ;; 1734603fc0a3Smrg 1735603fc0a3Smrg --verbose|-v) opt_verbose=: ;; 1736603fc0a3Smrg --version) func_version ;; 1737603fc0a3Smrg -\?|-h) func_usage ;; 1738603fc0a3Smrg --help) func_help ;; 1739603fc0a3Smrg 1740603fc0a3Smrg # Separate optargs to long options (plugins may need this): 1741603fc0a3Smrg --*=*) func_split_equals "$_G_opt" 1742603fc0a3Smrg set dummy "$func_split_equals_lhs" \ 1743603fc0a3Smrg "$func_split_equals_rhs" ${1+"$@"} 1744603fc0a3Smrg shift 1745603fc0a3Smrg ;; 1746603fc0a3Smrg 1747603fc0a3Smrg # Separate optargs to short options: 1748603fc0a3Smrg -W*) 1749603fc0a3Smrg func_split_short_opt "$_G_opt" 1750603fc0a3Smrg set dummy "$func_split_short_opt_name" \ 1751603fc0a3Smrg "$func_split_short_opt_arg" ${1+"$@"} 1752603fc0a3Smrg shift 1753603fc0a3Smrg ;; 1754603fc0a3Smrg 1755603fc0a3Smrg # Separate non-argument short options: 1756603fc0a3Smrg -\?*|-h*|-v*|-x*) 1757603fc0a3Smrg func_split_short_opt "$_G_opt" 1758603fc0a3Smrg set dummy "$func_split_short_opt_name" \ 1759603fc0a3Smrg "-$func_split_short_opt_arg" ${1+"$@"} 1760603fc0a3Smrg shift 1761603fc0a3Smrg ;; 1762603fc0a3Smrg 1763603fc0a3Smrg --) break ;; 1764603fc0a3Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1765603fc0a3Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1766603fc0a3Smrg esac 1767603fc0a3Smrg done 1768603fc0a3Smrg 1769603fc0a3Smrg # save modified positional parameters for caller 1770603fc0a3Smrg func_quote_for_eval ${1+"$@"} 1771603fc0a3Smrg func_parse_options_result=$func_quote_for_eval_result 1772603fc0a3Smrg} 1773603fc0a3Smrg 1774603fc0a3Smrg 1775603fc0a3Smrg# func_validate_options [ARG]... 1776603fc0a3Smrg# ------------------------------ 1777603fc0a3Smrg# Perform any sanity checks on option settings and/or unconsumed 1778603fc0a3Smrg# arguments. 1779603fc0a3Smrgfunc_hookable func_validate_options 1780603fc0a3Smrgfunc_validate_options () 1781603fc0a3Smrg{ 1782603fc0a3Smrg $debug_cmd 1783603fc0a3Smrg 1784603fc0a3Smrg # Display all warnings if -W was not given. 1785603fc0a3Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1786603fc0a3Smrg 1787603fc0a3Smrg func_run_hooks func_validate_options ${1+"$@"} 1788603fc0a3Smrg 1789603fc0a3Smrg # Bail if the options were screwed! 1790603fc0a3Smrg $exit_cmd $EXIT_FAILURE 1791603fc0a3Smrg 1792603fc0a3Smrg # save modified positional parameters for caller 1793603fc0a3Smrg func_validate_options_result=$func_run_hooks_result 1794603fc0a3Smrg} 1795603fc0a3Smrg 1796603fc0a3Smrg 1797603fc0a3Smrg 1798603fc0a3Smrg## ----------------- ## 1799603fc0a3Smrg## Helper functions. ## 1800603fc0a3Smrg## ----------------- ## 1801603fc0a3Smrg 1802603fc0a3Smrg# This section contains the helper functions used by the rest of the 1803603fc0a3Smrg# hookable option parser framework in ascii-betical order. 1804603fc0a3Smrg 1805603fc0a3Smrg 1806603fc0a3Smrg# func_fatal_help ARG... 1807603fc0a3Smrg# ---------------------- 1808603fc0a3Smrg# Echo program name prefixed message to standard error, followed by 1809603fc0a3Smrg# a help hint, and exit. 1810603fc0a3Smrgfunc_fatal_help () 1811603fc0a3Smrg{ 1812603fc0a3Smrg $debug_cmd 1813603fc0a3Smrg 1814603fc0a3Smrg eval \$ECHO \""Usage: $usage"\" 1815603fc0a3Smrg eval \$ECHO \""$fatal_help"\" 1816603fc0a3Smrg func_error ${1+"$@"} 1817603fc0a3Smrg exit $EXIT_FAILURE 1818603fc0a3Smrg} 1819603fc0a3Smrg 1820603fc0a3Smrg 1821603fc0a3Smrg# func_help 1822603fc0a3Smrg# --------- 1823603fc0a3Smrg# Echo long help message to standard output and exit. 1824603fc0a3Smrgfunc_help () 1825603fc0a3Smrg{ 1826603fc0a3Smrg $debug_cmd 1827603fc0a3Smrg 1828603fc0a3Smrg func_usage_message 1829603fc0a3Smrg $ECHO "$long_help_message" 1830603fc0a3Smrg exit 0 1831603fc0a3Smrg} 1832603fc0a3Smrg 1833603fc0a3Smrg 1834603fc0a3Smrg# func_missing_arg ARGNAME 1835603fc0a3Smrg# ------------------------ 1836603fc0a3Smrg# Echo program name prefixed message to standard error and set global 1837603fc0a3Smrg# exit_cmd. 1838603fc0a3Smrgfunc_missing_arg () 1839603fc0a3Smrg{ 1840603fc0a3Smrg $debug_cmd 1841603fc0a3Smrg 1842603fc0a3Smrg func_error "Missing argument for '$1'." 1843603fc0a3Smrg exit_cmd=exit 1844603fc0a3Smrg} 1845603fc0a3Smrg 1846603fc0a3Smrg 1847603fc0a3Smrg# func_split_equals STRING 1848603fc0a3Smrg# ------------------------ 1849603fc0a3Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 1850603fc0a3Smrg# splitting STRING at the '=' sign. 1851603fc0a3Smrgtest -z "$_G_HAVE_XSI_OPS" \ 1852603fc0a3Smrg && (eval 'x=a/b/c; 1853603fc0a3Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 1854603fc0a3Smrg && _G_HAVE_XSI_OPS=yes 1855603fc0a3Smrg 1856603fc0a3Smrgif test yes = "$_G_HAVE_XSI_OPS" 1857603fc0a3Smrgthen 1858603fc0a3Smrg # This is an XSI compatible shell, allowing a faster implementation... 1859603fc0a3Smrg eval 'func_split_equals () 1860603fc0a3Smrg { 1861603fc0a3Smrg $debug_cmd 1862603fc0a3Smrg 1863603fc0a3Smrg func_split_equals_lhs=${1%%=*} 1864603fc0a3Smrg func_split_equals_rhs=${1#*=} 1865603fc0a3Smrg test "x$func_split_equals_lhs" = "x$1" \ 1866603fc0a3Smrg && func_split_equals_rhs= 1867603fc0a3Smrg }' 1868603fc0a3Smrgelse 1869603fc0a3Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 1870603fc0a3Smrg func_split_equals () 1871603fc0a3Smrg { 1872603fc0a3Smrg $debug_cmd 1873603fc0a3Smrg 1874603fc0a3Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 1875603fc0a3Smrg func_split_equals_rhs= 1876603fc0a3Smrg test "x$func_split_equals_lhs" = "x$1" \ 1877603fc0a3Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 1878603fc0a3Smrg } 1879603fc0a3Smrgfi #func_split_equals 1880603fc0a3Smrg 1881603fc0a3Smrg 1882603fc0a3Smrg# func_split_short_opt SHORTOPT 1883603fc0a3Smrg# ----------------------------- 1884603fc0a3Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 1885603fc0a3Smrg# variables after splitting SHORTOPT after the 2nd character. 1886603fc0a3Smrgif test yes = "$_G_HAVE_XSI_OPS" 1887603fc0a3Smrgthen 1888603fc0a3Smrg # This is an XSI compatible shell, allowing a faster implementation... 1889603fc0a3Smrg eval 'func_split_short_opt () 1890603fc0a3Smrg { 1891603fc0a3Smrg $debug_cmd 1892603fc0a3Smrg 1893603fc0a3Smrg func_split_short_opt_arg=${1#??} 1894603fc0a3Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 1895603fc0a3Smrg }' 1896603fc0a3Smrgelse 1897603fc0a3Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 1898603fc0a3Smrg func_split_short_opt () 1899603fc0a3Smrg { 1900603fc0a3Smrg $debug_cmd 1901603fc0a3Smrg 1902603fc0a3Smrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 1903603fc0a3Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 1904603fc0a3Smrg } 1905603fc0a3Smrgfi #func_split_short_opt 1906603fc0a3Smrg 1907603fc0a3Smrg 1908603fc0a3Smrg# func_usage 1909603fc0a3Smrg# ---------- 1910603fc0a3Smrg# Echo short help message to standard output and exit. 1911603fc0a3Smrgfunc_usage () 1912603fc0a3Smrg{ 1913603fc0a3Smrg $debug_cmd 1914603fc0a3Smrg 1915603fc0a3Smrg func_usage_message 1916603fc0a3Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 1917603fc0a3Smrg exit 0 1918603fc0a3Smrg} 1919603fc0a3Smrg 1920603fc0a3Smrg 1921603fc0a3Smrg# func_usage_message 1922603fc0a3Smrg# ------------------ 1923603fc0a3Smrg# Echo short help message to standard output. 1924603fc0a3Smrgfunc_usage_message () 1925603fc0a3Smrg{ 1926603fc0a3Smrg $debug_cmd 1927603fc0a3Smrg 1928603fc0a3Smrg eval \$ECHO \""Usage: $usage"\" 1929603fc0a3Smrg echo 1930603fc0a3Smrg $SED -n 's|^# || 1931603fc0a3Smrg /^Written by/{ 1932603fc0a3Smrg x;p;x 1933603fc0a3Smrg } 1934603fc0a3Smrg h 1935603fc0a3Smrg /^Written by/q' < "$progpath" 1936603fc0a3Smrg echo 1937603fc0a3Smrg eval \$ECHO \""$usage_message"\" 1938603fc0a3Smrg} 1939603fc0a3Smrg 1940603fc0a3Smrg 1941603fc0a3Smrg# func_version 1942603fc0a3Smrg# ------------ 1943603fc0a3Smrg# Echo version message to standard output and exit. 1944603fc0a3Smrgfunc_version () 1945603fc0a3Smrg{ 1946603fc0a3Smrg $debug_cmd 1947603fc0a3Smrg 1948603fc0a3Smrg printf '%s\n' "$progname $scriptversion" 1949603fc0a3Smrg $SED -n ' 1950603fc0a3Smrg /(C)/!b go 1951603fc0a3Smrg :more 1952603fc0a3Smrg /\./!{ 1953603fc0a3Smrg N 1954603fc0a3Smrg s|\n# | | 1955603fc0a3Smrg b more 1956603fc0a3Smrg } 1957603fc0a3Smrg :go 1958603fc0a3Smrg /^# Written by /,/# warranty; / { 1959603fc0a3Smrg s|^# || 1960603fc0a3Smrg s|^# *$|| 1961603fc0a3Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 1962603fc0a3Smrg p 1963603fc0a3Smrg } 1964603fc0a3Smrg /^# Written by / { 1965603fc0a3Smrg s|^# || 1966603fc0a3Smrg p 1967603fc0a3Smrg } 1968603fc0a3Smrg /^warranty; /q' < "$progpath" 1969603fc0a3Smrg 1970603fc0a3Smrg exit $? 1971603fc0a3Smrg} 1972603fc0a3Smrg 1973603fc0a3Smrg 1974603fc0a3Smrg# Local variables: 1975603fc0a3Smrg# mode: shell-script 1976603fc0a3Smrg# sh-indentation: 2 1977603fc0a3Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 1978603fc0a3Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1979603fc0a3Smrg# time-stamp-time-zone: "UTC" 1980603fc0a3Smrg# End: 1981603fc0a3Smrg 1982603fc0a3Smrg# Set a version string. 1983603fc0a3Smrgscriptversion='(GNU libtool) 2.4.6' 1984603fc0a3Smrg 1985603fc0a3Smrg 1986603fc0a3Smrg# func_echo ARG... 1987603fc0a3Smrg# ---------------- 1988603fc0a3Smrg# Libtool also displays the current mode in messages, so override 1989603fc0a3Smrg# funclib.sh func_echo with this custom definition. 1990603fc0a3Smrgfunc_echo () 1991603fc0a3Smrg{ 1992603fc0a3Smrg $debug_cmd 1993603fc0a3Smrg 1994603fc0a3Smrg _G_message=$* 1995603fc0a3Smrg 1996603fc0a3Smrg func_echo_IFS=$IFS 1997603fc0a3Smrg IFS=$nl 1998603fc0a3Smrg for _G_line in $_G_message; do 1999603fc0a3Smrg IFS=$func_echo_IFS 2000603fc0a3Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 2001603fc0a3Smrg done 2002603fc0a3Smrg IFS=$func_echo_IFS 2003603fc0a3Smrg} 2004603fc0a3Smrg 2005603fc0a3Smrg 2006603fc0a3Smrg# func_warning ARG... 2007603fc0a3Smrg# ------------------- 2008603fc0a3Smrg# Libtool warnings are not categorized, so override funclib.sh 2009603fc0a3Smrg# func_warning with this simpler definition. 2010603fc0a3Smrgfunc_warning () 2011603fc0a3Smrg{ 2012603fc0a3Smrg $debug_cmd 2013603fc0a3Smrg 2014603fc0a3Smrg $warning_func ${1+"$@"} 2015603fc0a3Smrg} 2016603fc0a3Smrg 2017603fc0a3Smrg 2018603fc0a3Smrg## ---------------- ## 2019603fc0a3Smrg## Options parsing. ## 2020603fc0a3Smrg## ---------------- ## 2021603fc0a3Smrg 2022603fc0a3Smrg# Hook in the functions to make sure our own options are parsed during 2023603fc0a3Smrg# the option parsing loop. 2024603fc0a3Smrg 2025603fc0a3Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 2026603fc0a3Smrg 2027603fc0a3Smrg# Short help message in response to '-h'. 2028603fc0a3Smrgusage_message="Options: 2029603fc0a3Smrg --config show all configuration variables 2030603fc0a3Smrg --debug enable verbose shell tracing 2031603fc0a3Smrg -n, --dry-run display commands without modifying any files 2032603fc0a3Smrg --features display basic configuration information and exit 2033603fc0a3Smrg --mode=MODE use operation mode MODE 2034603fc0a3Smrg --no-warnings equivalent to '-Wnone' 2035603fc0a3Smrg --preserve-dup-deps don't remove duplicate dependency libraries 2036603fc0a3Smrg --quiet, --silent don't print informational messages 2037603fc0a3Smrg --tag=TAG use configuration variables from tag TAG 2038603fc0a3Smrg -v, --verbose print more informational messages than default 2039603fc0a3Smrg --version print version information 2040603fc0a3Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2041603fc0a3Smrg -h, --help, --help-all print short, long, or detailed help message 2042603fc0a3Smrg" 2043603fc0a3Smrg 2044603fc0a3Smrg# Additional text appended to 'usage_message' in response to '--help'. 2045603fc0a3Smrgfunc_help () 2046603fc0a3Smrg{ 2047603fc0a3Smrg $debug_cmd 2048603fc0a3Smrg 2049603fc0a3Smrg func_usage_message 2050603fc0a3Smrg $ECHO "$long_help_message 2051603fc0a3Smrg 2052603fc0a3SmrgMODE must be one of the following: 2053603fc0a3Smrg 2054603fc0a3Smrg clean remove files from the build directory 2055603fc0a3Smrg compile compile a source file into a libtool object 2056603fc0a3Smrg execute automatically set library path, then run a program 2057603fc0a3Smrg finish complete the installation of libtool libraries 2058603fc0a3Smrg install install libraries or executables 2059603fc0a3Smrg link create a library or an executable 2060603fc0a3Smrg uninstall remove libraries from an installed directory 2061603fc0a3Smrg 2062603fc0a3SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2063603fc0a3Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2064603fc0a3SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2065603fc0a3Smrg 2066603fc0a3SmrgWhen reporting a bug, please describe a test case to reproduce it and 2067603fc0a3Smrginclude the following information: 2068603fc0a3Smrg 2069603fc0a3Smrg host-triplet: $host 2070603fc0a3Smrg shell: $SHELL 2071603fc0a3Smrg compiler: $LTCC 2072603fc0a3Smrg compiler flags: $LTCFLAGS 2073603fc0a3Smrg linker: $LD (gnu? $with_gnu_ld) 2074603fc0a3Smrg version: $progname (GNU libtool) 2.4.6 2075603fc0a3Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2076603fc0a3Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2077603fc0a3Smrg 2078603fc0a3SmrgReport bugs to <bug-libtool@gnu.org>. 2079603fc0a3SmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>. 2080603fc0a3SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2081603fc0a3Smrg exit 0 2082603fc0a3Smrg} 2083603fc0a3Smrg 2084603fc0a3Smrg 2085603fc0a3Smrg# func_lo2o OBJECT-NAME 2086603fc0a3Smrg# --------------------- 2087603fc0a3Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2088603fc0a3Smrg# object suffix. 2089603fc0a3Smrg 2090603fc0a3Smrglo2o=s/\\.lo\$/.$objext/ 2091603fc0a3Smrgo2lo=s/\\.$objext\$/.lo/ 2092603fc0a3Smrg 2093603fc0a3Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 2094603fc0a3Smrg eval 'func_lo2o () 2095603fc0a3Smrg { 2096603fc0a3Smrg case $1 in 2097603fc0a3Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2098603fc0a3Smrg * ) func_lo2o_result=$1 ;; 2099603fc0a3Smrg esac 2100603fc0a3Smrg }' 2101603fc0a3Smrg 2102603fc0a3Smrg # func_xform LIBOBJ-OR-SOURCE 2103603fc0a3Smrg # --------------------------- 2104603fc0a3Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2105603fc0a3Smrg # suffix to a '.lo' libtool-object suffix. 2106603fc0a3Smrg eval 'func_xform () 2107603fc0a3Smrg { 2108603fc0a3Smrg func_xform_result=${1%.*}.lo 2109603fc0a3Smrg }' 2110603fc0a3Smrgelse 2111603fc0a3Smrg # ...otherwise fall back to using sed. 2112603fc0a3Smrg func_lo2o () 2113603fc0a3Smrg { 2114603fc0a3Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2115603fc0a3Smrg } 2116603fc0a3Smrg 2117603fc0a3Smrg func_xform () 2118603fc0a3Smrg { 2119603fc0a3Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2120603fc0a3Smrg } 2121603fc0a3Smrgfi 2122603fc0a3Smrg 2123603fc0a3Smrg 2124603fc0a3Smrg# func_fatal_configuration ARG... 2125603fc0a3Smrg# ------------------------------- 2126603fc0a3Smrg# Echo program name prefixed message to standard error, followed by 2127603fc0a3Smrg# a configuration failure hint, and exit. 2128603fc0a3Smrgfunc_fatal_configuration () 2129603fc0a3Smrg{ 2130603fc0a3Smrg func__fatal_error ${1+"$@"} \ 2131603fc0a3Smrg "See the $PACKAGE documentation for more information." \ 2132603fc0a3Smrg "Fatal configuration error." 2133603fc0a3Smrg} 2134603fc0a3Smrg 2135603fc0a3Smrg 2136603fc0a3Smrg# func_config 2137603fc0a3Smrg# ----------- 2138603fc0a3Smrg# Display the configuration for all the tags in this script. 2139603fc0a3Smrgfunc_config () 2140603fc0a3Smrg{ 2141603fc0a3Smrg re_begincf='^# ### BEGIN LIBTOOL' 2142603fc0a3Smrg re_endcf='^# ### END LIBTOOL' 2143603fc0a3Smrg 2144603fc0a3Smrg # Default configuration. 2145603fc0a3Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2146603fc0a3Smrg 2147603fc0a3Smrg # Now print the configurations for the tags. 2148603fc0a3Smrg for tagname in $taglist; do 2149603fc0a3Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2150603fc0a3Smrg done 2151603fc0a3Smrg 2152603fc0a3Smrg exit $? 2153603fc0a3Smrg} 2154603fc0a3Smrg 2155603fc0a3Smrg 2156603fc0a3Smrg# func_features 2157603fc0a3Smrg# ------------- 2158603fc0a3Smrg# Display the features supported by this script. 2159603fc0a3Smrgfunc_features () 2160603fc0a3Smrg{ 2161603fc0a3Smrg echo "host: $host" 2162603fc0a3Smrg if test yes = "$build_libtool_libs"; then 2163603fc0a3Smrg echo "enable shared libraries" 2164603fc0a3Smrg else 2165603fc0a3Smrg echo "disable shared libraries" 2166603fc0a3Smrg fi 2167603fc0a3Smrg if test yes = "$build_old_libs"; then 2168603fc0a3Smrg echo "enable static libraries" 2169603fc0a3Smrg else 2170603fc0a3Smrg echo "disable static libraries" 2171603fc0a3Smrg fi 2172603fc0a3Smrg 2173603fc0a3Smrg exit $? 2174603fc0a3Smrg} 2175603fc0a3Smrg 2176603fc0a3Smrg 2177603fc0a3Smrg# func_enable_tag TAGNAME 2178603fc0a3Smrg# ----------------------- 2179603fc0a3Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2180603fc0a3Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2181603fc0a3Smrg# variable here. 2182603fc0a3Smrgfunc_enable_tag () 2183603fc0a3Smrg{ 2184603fc0a3Smrg # Global variable: 2185603fc0a3Smrg tagname=$1 2186603fc0a3Smrg 2187603fc0a3Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2188603fc0a3Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2189603fc0a3Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2190603fc0a3Smrg 2191603fc0a3Smrg # Validate tagname. 2192603fc0a3Smrg case $tagname in 2193603fc0a3Smrg *[!-_A-Za-z0-9,/]*) 2194603fc0a3Smrg func_fatal_error "invalid tag name: $tagname" 2195603fc0a3Smrg ;; 2196603fc0a3Smrg esac 2197603fc0a3Smrg 2198603fc0a3Smrg # Don't test for the "default" C tag, as we know it's 2199603fc0a3Smrg # there but not specially marked. 2200603fc0a3Smrg case $tagname in 2201603fc0a3Smrg CC) ;; 2202603fc0a3Smrg *) 2203603fc0a3Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2204603fc0a3Smrg taglist="$taglist $tagname" 2205603fc0a3Smrg 2206603fc0a3Smrg # Evaluate the configuration. Be careful to quote the path 2207603fc0a3Smrg # and the sed script, to avoid splitting on whitespace, but 2208603fc0a3Smrg # also don't use non-portable quotes within backquotes within 2209603fc0a3Smrg # quotes we have to do it in 2 steps: 2210603fc0a3Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2211603fc0a3Smrg eval "$extractedcf" 2212603fc0a3Smrg else 2213603fc0a3Smrg func_error "ignoring unknown tag $tagname" 2214603fc0a3Smrg fi 2215603fc0a3Smrg ;; 2216603fc0a3Smrg esac 2217603fc0a3Smrg} 2218603fc0a3Smrg 2219603fc0a3Smrg 2220603fc0a3Smrg# func_check_version_match 2221603fc0a3Smrg# ------------------------ 2222603fc0a3Smrg# Ensure that we are using m4 macros, and libtool script from the same 2223603fc0a3Smrg# release of libtool. 2224603fc0a3Smrgfunc_check_version_match () 2225603fc0a3Smrg{ 2226603fc0a3Smrg if test "$package_revision" != "$macro_revision"; then 2227603fc0a3Smrg if test "$VERSION" != "$macro_version"; then 2228603fc0a3Smrg if test -z "$macro_version"; then 2229603fc0a3Smrg cat >&2 <<_LT_EOF 2230603fc0a3Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2231603fc0a3Smrg$progname: definition of this LT_INIT comes from an older release. 2232603fc0a3Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2233603fc0a3Smrg$progname: and run autoconf again. 2234603fc0a3Smrg_LT_EOF 2235603fc0a3Smrg else 2236603fc0a3Smrg cat >&2 <<_LT_EOF 2237603fc0a3Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2238603fc0a3Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2239603fc0a3Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2240603fc0a3Smrg$progname: and run autoconf again. 2241603fc0a3Smrg_LT_EOF 2242603fc0a3Smrg fi 2243603fc0a3Smrg else 2244603fc0a3Smrg cat >&2 <<_LT_EOF 2245603fc0a3Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2246603fc0a3Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2247603fc0a3Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2248603fc0a3Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 2249603fc0a3Smrg_LT_EOF 2250603fc0a3Smrg fi 2251603fc0a3Smrg 2252603fc0a3Smrg exit $EXIT_MISMATCH 2253603fc0a3Smrg fi 2254603fc0a3Smrg} 2255603fc0a3Smrg 2256603fc0a3Smrg 2257603fc0a3Smrg# libtool_options_prep [ARG]... 2258603fc0a3Smrg# ----------------------------- 2259603fc0a3Smrg# Preparation for options parsed by libtool. 2260603fc0a3Smrglibtool_options_prep () 2261603fc0a3Smrg{ 2262603fc0a3Smrg $debug_mode 2263603fc0a3Smrg 2264603fc0a3Smrg # Option defaults: 2265603fc0a3Smrg opt_config=false 2266603fc0a3Smrg opt_dlopen= 2267603fc0a3Smrg opt_dry_run=false 2268603fc0a3Smrg opt_help=false 2269603fc0a3Smrg opt_mode= 2270603fc0a3Smrg opt_preserve_dup_deps=false 2271603fc0a3Smrg opt_quiet=false 2272603fc0a3Smrg 2273603fc0a3Smrg nonopt= 2274603fc0a3Smrg preserve_args= 2275603fc0a3Smrg 2276603fc0a3Smrg # Shorthand for --mode=foo, only valid as the first argument 2277603fc0a3Smrg case $1 in 2278603fc0a3Smrg clean|clea|cle|cl) 2279603fc0a3Smrg shift; set dummy --mode clean ${1+"$@"}; shift 2280603fc0a3Smrg ;; 2281603fc0a3Smrg compile|compil|compi|comp|com|co|c) 2282603fc0a3Smrg shift; set dummy --mode compile ${1+"$@"}; shift 2283603fc0a3Smrg ;; 2284603fc0a3Smrg execute|execut|execu|exec|exe|ex|e) 2285603fc0a3Smrg shift; set dummy --mode execute ${1+"$@"}; shift 2286603fc0a3Smrg ;; 2287603fc0a3Smrg finish|finis|fini|fin|fi|f) 2288603fc0a3Smrg shift; set dummy --mode finish ${1+"$@"}; shift 2289603fc0a3Smrg ;; 2290603fc0a3Smrg install|instal|insta|inst|ins|in|i) 2291603fc0a3Smrg shift; set dummy --mode install ${1+"$@"}; shift 2292603fc0a3Smrg ;; 2293603fc0a3Smrg link|lin|li|l) 2294603fc0a3Smrg shift; set dummy --mode link ${1+"$@"}; shift 2295603fc0a3Smrg ;; 2296603fc0a3Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2297603fc0a3Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2298603fc0a3Smrg ;; 2299603fc0a3Smrg esac 2300603fc0a3Smrg 2301603fc0a3Smrg # Pass back the list of options. 2302603fc0a3Smrg func_quote_for_eval ${1+"$@"} 2303603fc0a3Smrg libtool_options_prep_result=$func_quote_for_eval_result 2304603fc0a3Smrg} 2305603fc0a3Smrgfunc_add_hook func_options_prep libtool_options_prep 2306603fc0a3Smrg 2307603fc0a3Smrg 2308603fc0a3Smrg# libtool_parse_options [ARG]... 2309603fc0a3Smrg# --------------------------------- 2310603fc0a3Smrg# Provide handling for libtool specific options. 2311603fc0a3Smrglibtool_parse_options () 2312603fc0a3Smrg{ 2313603fc0a3Smrg $debug_cmd 2314603fc0a3Smrg 2315603fc0a3Smrg # Perform our own loop to consume as many options as possible in 2316603fc0a3Smrg # each iteration. 2317603fc0a3Smrg while test $# -gt 0; do 2318603fc0a3Smrg _G_opt=$1 2319603fc0a3Smrg shift 2320603fc0a3Smrg case $_G_opt in 2321603fc0a3Smrg --dry-run|--dryrun|-n) 2322603fc0a3Smrg opt_dry_run=: 2323603fc0a3Smrg ;; 2324603fc0a3Smrg 2325603fc0a3Smrg --config) func_config ;; 2326603fc0a3Smrg 2327603fc0a3Smrg --dlopen|-dlopen) 2328603fc0a3Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 2329603fc0a3Smrg}$1" 2330603fc0a3Smrg shift 2331603fc0a3Smrg ;; 2332603fc0a3Smrg 2333603fc0a3Smrg --preserve-dup-deps) 2334603fc0a3Smrg opt_preserve_dup_deps=: ;; 2335603fc0a3Smrg 2336603fc0a3Smrg --features) func_features ;; 2337603fc0a3Smrg 2338603fc0a3Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2339603fc0a3Smrg 2340603fc0a3Smrg --help) opt_help=: ;; 2341603fc0a3Smrg 2342603fc0a3Smrg --help-all) opt_help=': help-all' ;; 2343603fc0a3Smrg 2344603fc0a3Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2345603fc0a3Smrg opt_mode=$1 2346603fc0a3Smrg case $1 in 2347603fc0a3Smrg # Valid mode arguments: 2348603fc0a3Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2349603fc0a3Smrg 2350603fc0a3Smrg # Catch anything else as an error 2351603fc0a3Smrg *) func_error "invalid argument for $_G_opt" 2352603fc0a3Smrg exit_cmd=exit 2353603fc0a3Smrg break 2354603fc0a3Smrg ;; 2355603fc0a3Smrg esac 2356603fc0a3Smrg shift 2357603fc0a3Smrg ;; 2358603fc0a3Smrg 2359603fc0a3Smrg --no-silent|--no-quiet) 2360603fc0a3Smrg opt_quiet=false 2361603fc0a3Smrg func_append preserve_args " $_G_opt" 2362603fc0a3Smrg ;; 2363603fc0a3Smrg 2364603fc0a3Smrg --no-warnings|--no-warning|--no-warn) 2365603fc0a3Smrg opt_warning=false 2366603fc0a3Smrg func_append preserve_args " $_G_opt" 2367603fc0a3Smrg ;; 2368603fc0a3Smrg 2369603fc0a3Smrg --no-verbose) 2370603fc0a3Smrg opt_verbose=false 2371603fc0a3Smrg func_append preserve_args " $_G_opt" 2372603fc0a3Smrg ;; 2373603fc0a3Smrg 2374603fc0a3Smrg --silent|--quiet) 2375603fc0a3Smrg opt_quiet=: 2376603fc0a3Smrg opt_verbose=false 2377603fc0a3Smrg func_append preserve_args " $_G_opt" 2378603fc0a3Smrg ;; 2379603fc0a3Smrg 2380603fc0a3Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2381603fc0a3Smrg opt_tag=$1 2382603fc0a3Smrg func_append preserve_args " $_G_opt $1" 2383603fc0a3Smrg func_enable_tag "$1" 2384603fc0a3Smrg shift 2385603fc0a3Smrg ;; 2386603fc0a3Smrg 2387603fc0a3Smrg --verbose|-v) opt_quiet=false 2388603fc0a3Smrg opt_verbose=: 2389603fc0a3Smrg func_append preserve_args " $_G_opt" 2390603fc0a3Smrg ;; 2391603fc0a3Smrg 2392603fc0a3Smrg # An option not handled by this hook function: 2393603fc0a3Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 2394603fc0a3Smrg esac 2395603fc0a3Smrg done 2396603fc0a3Smrg 2397603fc0a3Smrg 2398603fc0a3Smrg # save modified positional parameters for caller 2399603fc0a3Smrg func_quote_for_eval ${1+"$@"} 2400603fc0a3Smrg libtool_parse_options_result=$func_quote_for_eval_result 2401603fc0a3Smrg} 2402603fc0a3Smrgfunc_add_hook func_parse_options libtool_parse_options 2403603fc0a3Smrg 2404603fc0a3Smrg 2405603fc0a3Smrg 2406603fc0a3Smrg# libtool_validate_options [ARG]... 2407603fc0a3Smrg# --------------------------------- 2408603fc0a3Smrg# Perform any sanity checks on option settings and/or unconsumed 2409603fc0a3Smrg# arguments. 2410603fc0a3Smrglibtool_validate_options () 2411603fc0a3Smrg{ 2412603fc0a3Smrg # save first non-option argument 2413603fc0a3Smrg if test 0 -lt $#; then 2414603fc0a3Smrg nonopt=$1 2415603fc0a3Smrg shift 2416603fc0a3Smrg fi 2417603fc0a3Smrg 2418603fc0a3Smrg # preserve --debug 2419603fc0a3Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2420603fc0a3Smrg 2421603fc0a3Smrg case $host in 2422603fc0a3Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2423603fc0a3Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2424603fc0a3Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2425603fc0a3Smrg # don't eliminate duplications in $postdeps and $predeps 2426603fc0a3Smrg opt_duplicate_compiler_generated_deps=: 2427603fc0a3Smrg ;; 2428603fc0a3Smrg *) 2429603fc0a3Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2430603fc0a3Smrg ;; 2431603fc0a3Smrg esac 2432603fc0a3Smrg 2433603fc0a3Smrg $opt_help || { 2434603fc0a3Smrg # Sanity checks first: 2435603fc0a3Smrg func_check_version_match 2436603fc0a3Smrg 2437603fc0a3Smrg test yes != "$build_libtool_libs" \ 2438603fc0a3Smrg && test yes != "$build_old_libs" \ 2439603fc0a3Smrg && func_fatal_configuration "not configured to build any kind of library" 2440603fc0a3Smrg 2441603fc0a3Smrg # Darwin sucks 2442603fc0a3Smrg eval std_shrext=\"$shrext_cmds\" 2443603fc0a3Smrg 2444603fc0a3Smrg # Only execute mode is allowed to have -dlopen flags. 2445603fc0a3Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2446603fc0a3Smrg func_error "unrecognized option '-dlopen'" 2447603fc0a3Smrg $ECHO "$help" 1>&2 2448603fc0a3Smrg exit $EXIT_FAILURE 2449603fc0a3Smrg fi 2450603fc0a3Smrg 2451603fc0a3Smrg # Change the help message to a mode-specific one. 2452603fc0a3Smrg generic_help=$help 2453603fc0a3Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 2454603fc0a3Smrg } 2455603fc0a3Smrg 2456603fc0a3Smrg # Pass back the unparsed argument list 2457603fc0a3Smrg func_quote_for_eval ${1+"$@"} 2458603fc0a3Smrg libtool_validate_options_result=$func_quote_for_eval_result 2459603fc0a3Smrg} 2460603fc0a3Smrgfunc_add_hook func_validate_options libtool_validate_options 2461603fc0a3Smrg 2462603fc0a3Smrg 2463603fc0a3Smrg# Process options as early as possible so that --help and --version 2464603fc0a3Smrg# can return quickly. 2465603fc0a3Smrgfunc_options ${1+"$@"} 2466603fc0a3Smrgeval set dummy "$func_options_result"; shift 2467603fc0a3Smrg 2468603fc0a3Smrg 2469603fc0a3Smrg 2470603fc0a3Smrg## ----------- ## 2471603fc0a3Smrg## Main. ## 2472603fc0a3Smrg## ----------- ## 2473603fc0a3Smrg 2474603fc0a3Smrgmagic='%%%MAGIC variable%%%' 2475603fc0a3Smrgmagic_exe='%%%MAGIC EXE variable%%%' 2476603fc0a3Smrg 2477603fc0a3Smrg# Global variables. 2478603fc0a3Smrgextracted_archives= 2479603fc0a3Smrgextracted_serial=0 2480603fc0a3Smrg 2481603fc0a3Smrg# If this variable is set in any of the actions, the command in it 2482603fc0a3Smrg# will be execed at the end. This prevents here-documents from being 2483603fc0a3Smrg# left over by shells. 2484603fc0a3Smrgexec_cmd= 2485603fc0a3Smrg 2486603fc0a3Smrg 2487603fc0a3Smrg# A function that is used when there is no print builtin or printf. 2488603fc0a3Smrgfunc_fallback_echo () 2489603fc0a3Smrg{ 2490603fc0a3Smrg eval 'cat <<_LTECHO_EOF 2491603fc0a3Smrg$1 2492603fc0a3Smrg_LTECHO_EOF' 2493603fc0a3Smrg} 2494603fc0a3Smrg 2495603fc0a3Smrg# func_generated_by_libtool 2496603fc0a3Smrg# True iff stdin has been generated by Libtool. This function is only 2497603fc0a3Smrg# a basic sanity check; it will hardly flush out determined imposters. 2498603fc0a3Smrgfunc_generated_by_libtool_p () 2499603fc0a3Smrg{ 2500603fc0a3Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2501603fc0a3Smrg} 2502603fc0a3Smrg 2503603fc0a3Smrg# func_lalib_p file 2504603fc0a3Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2505603fc0a3Smrg# This function is only a basic sanity check; it will hardly flush out 2506603fc0a3Smrg# determined imposters. 2507603fc0a3Smrgfunc_lalib_p () 2508603fc0a3Smrg{ 2509603fc0a3Smrg test -f "$1" && 2510603fc0a3Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2511603fc0a3Smrg} 2512603fc0a3Smrg 2513603fc0a3Smrg# func_lalib_unsafe_p file 2514603fc0a3Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2515603fc0a3Smrg# This function implements the same check as func_lalib_p without 2516603fc0a3Smrg# resorting to external programs. To this end, it redirects stdin and 2517603fc0a3Smrg# closes it afterwards, without saving the original file descriptor. 2518603fc0a3Smrg# As a safety measure, use it only where a negative result would be 2519603fc0a3Smrg# fatal anyway. Works if 'file' does not exist. 2520603fc0a3Smrgfunc_lalib_unsafe_p () 2521603fc0a3Smrg{ 2522603fc0a3Smrg lalib_p=no 2523603fc0a3Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2524603fc0a3Smrg for lalib_p_l in 1 2 3 4 2525603fc0a3Smrg do 2526603fc0a3Smrg read lalib_p_line 2527603fc0a3Smrg case $lalib_p_line in 2528603fc0a3Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2529603fc0a3Smrg esac 2530603fc0a3Smrg done 2531603fc0a3Smrg exec 0<&5 5<&- 2532603fc0a3Smrg fi 2533603fc0a3Smrg test yes = "$lalib_p" 2534603fc0a3Smrg} 2535603fc0a3Smrg 2536603fc0a3Smrg# func_ltwrapper_script_p file 2537603fc0a3Smrg# True iff FILE is a libtool wrapper script 2538603fc0a3Smrg# This function is only a basic sanity check; it will hardly flush out 2539603fc0a3Smrg# determined imposters. 2540603fc0a3Smrgfunc_ltwrapper_script_p () 2541603fc0a3Smrg{ 2542603fc0a3Smrg test -f "$1" && 2543603fc0a3Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2544603fc0a3Smrg} 2545603fc0a3Smrg 2546603fc0a3Smrg# func_ltwrapper_executable_p file 2547603fc0a3Smrg# True iff FILE is a libtool wrapper executable 2548603fc0a3Smrg# This function is only a basic sanity check; it will hardly flush out 2549603fc0a3Smrg# determined imposters. 2550603fc0a3Smrgfunc_ltwrapper_executable_p () 2551603fc0a3Smrg{ 2552603fc0a3Smrg func_ltwrapper_exec_suffix= 2553603fc0a3Smrg case $1 in 2554603fc0a3Smrg *.exe) ;; 2555603fc0a3Smrg *) func_ltwrapper_exec_suffix=.exe ;; 2556603fc0a3Smrg esac 2557603fc0a3Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2558603fc0a3Smrg} 2559603fc0a3Smrg 2560603fc0a3Smrg# func_ltwrapper_scriptname file 2561603fc0a3Smrg# Assumes file is an ltwrapper_executable 2562603fc0a3Smrg# uses $file to determine the appropriate filename for a 2563603fc0a3Smrg# temporary ltwrapper_script. 2564603fc0a3Smrgfunc_ltwrapper_scriptname () 2565603fc0a3Smrg{ 2566603fc0a3Smrg func_dirname_and_basename "$1" "" "." 2567603fc0a3Smrg func_stripname '' '.exe' "$func_basename_result" 2568603fc0a3Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2569603fc0a3Smrg} 2570603fc0a3Smrg 2571603fc0a3Smrg# func_ltwrapper_p file 2572603fc0a3Smrg# True iff FILE is a libtool wrapper script or wrapper executable 2573603fc0a3Smrg# This function is only a basic sanity check; it will hardly flush out 2574603fc0a3Smrg# determined imposters. 2575603fc0a3Smrgfunc_ltwrapper_p () 2576603fc0a3Smrg{ 2577603fc0a3Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2578603fc0a3Smrg} 2579603fc0a3Smrg 2580603fc0a3Smrg 2581603fc0a3Smrg# func_execute_cmds commands fail_cmd 2582603fc0a3Smrg# Execute tilde-delimited COMMANDS. 2583603fc0a3Smrg# If FAIL_CMD is given, eval that upon failure. 2584603fc0a3Smrg# FAIL_CMD may read-access the current command in variable CMD! 2585603fc0a3Smrgfunc_execute_cmds () 2586603fc0a3Smrg{ 2587603fc0a3Smrg $debug_cmd 2588603fc0a3Smrg 2589603fc0a3Smrg save_ifs=$IFS; IFS='~' 2590603fc0a3Smrg for cmd in $1; do 2591603fc0a3Smrg IFS=$sp$nl 2592603fc0a3Smrg eval cmd=\"$cmd\" 2593603fc0a3Smrg IFS=$save_ifs 2594603fc0a3Smrg func_show_eval "$cmd" "${2-:}" 2595603fc0a3Smrg done 2596603fc0a3Smrg IFS=$save_ifs 2597603fc0a3Smrg} 2598603fc0a3Smrg 2599603fc0a3Smrg 2600603fc0a3Smrg# func_source file 2601603fc0a3Smrg# Source FILE, adding directory component if necessary. 2602603fc0a3Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 2603603fc0a3Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2604603fc0a3Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2605603fc0a3Smrg# 'FILE.' does not work on cygwin managed mounts. 2606603fc0a3Smrgfunc_source () 2607603fc0a3Smrg{ 2608603fc0a3Smrg $debug_cmd 2609603fc0a3Smrg 2610603fc0a3Smrg case $1 in 2611603fc0a3Smrg */* | *\\*) . "$1" ;; 2612603fc0a3Smrg *) . "./$1" ;; 2613603fc0a3Smrg esac 2614603fc0a3Smrg} 2615603fc0a3Smrg 2616603fc0a3Smrg 2617603fc0a3Smrg# func_resolve_sysroot PATH 2618603fc0a3Smrg# Replace a leading = in PATH with a sysroot. Store the result into 2619603fc0a3Smrg# func_resolve_sysroot_result 2620603fc0a3Smrgfunc_resolve_sysroot () 2621603fc0a3Smrg{ 2622603fc0a3Smrg func_resolve_sysroot_result=$1 2623603fc0a3Smrg case $func_resolve_sysroot_result in 2624603fc0a3Smrg =*) 2625603fc0a3Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 2626603fc0a3Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2627603fc0a3Smrg ;; 2628603fc0a3Smrg esac 2629603fc0a3Smrg} 2630603fc0a3Smrg 2631603fc0a3Smrg# func_replace_sysroot PATH 2632603fc0a3Smrg# If PATH begins with the sysroot, replace it with = and 2633603fc0a3Smrg# store the result into func_replace_sysroot_result. 2634603fc0a3Smrgfunc_replace_sysroot () 2635603fc0a3Smrg{ 2636603fc0a3Smrg case $lt_sysroot:$1 in 2637603fc0a3Smrg ?*:"$lt_sysroot"*) 2638603fc0a3Smrg func_stripname "$lt_sysroot" '' "$1" 2639603fc0a3Smrg func_replace_sysroot_result='='$func_stripname_result 2640603fc0a3Smrg ;; 2641603fc0a3Smrg *) 2642603fc0a3Smrg # Including no sysroot. 2643603fc0a3Smrg func_replace_sysroot_result=$1 2644603fc0a3Smrg ;; 2645603fc0a3Smrg esac 2646603fc0a3Smrg} 2647603fc0a3Smrg 2648603fc0a3Smrg# func_infer_tag arg 2649603fc0a3Smrg# Infer tagged configuration to use if any are available and 2650603fc0a3Smrg# if one wasn't chosen via the "--tag" command line option. 2651603fc0a3Smrg# Only attempt this if the compiler in the base compile 2652603fc0a3Smrg# command doesn't match the default compiler. 2653603fc0a3Smrg# arg is usually of the form 'gcc ...' 2654603fc0a3Smrgfunc_infer_tag () 2655603fc0a3Smrg{ 2656603fc0a3Smrg $debug_cmd 2657603fc0a3Smrg 2658603fc0a3Smrg if test -n "$available_tags" && test -z "$tagname"; then 2659603fc0a3Smrg CC_quoted= 2660603fc0a3Smrg for arg in $CC; do 2661603fc0a3Smrg func_append_quoted CC_quoted "$arg" 2662603fc0a3Smrg done 2663603fc0a3Smrg CC_expanded=`func_echo_all $CC` 2664603fc0a3Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2665603fc0a3Smrg case $@ in 2666603fc0a3Smrg # Blanks in the command may have been stripped by the calling shell, 2667603fc0a3Smrg # but not from the CC environment variable when configure was run. 2668603fc0a3Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2669603fc0a3Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2670603fc0a3Smrg # Blanks at the start of $base_compile will cause this to fail 2671603fc0a3Smrg # if we don't check for them as well. 2672603fc0a3Smrg *) 2673603fc0a3Smrg for z in $available_tags; do 2674603fc0a3Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2675603fc0a3Smrg # Evaluate the configuration. 2676603fc0a3Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2677603fc0a3Smrg CC_quoted= 2678603fc0a3Smrg for arg in $CC; do 2679603fc0a3Smrg # Double-quote args containing other shell metacharacters. 2680603fc0a3Smrg func_append_quoted CC_quoted "$arg" 2681603fc0a3Smrg done 2682603fc0a3Smrg CC_expanded=`func_echo_all $CC` 2683603fc0a3Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2684603fc0a3Smrg case "$@ " in 2685603fc0a3Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2686603fc0a3Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2687603fc0a3Smrg # The compiler in the base compile command matches 2688603fc0a3Smrg # the one in the tagged configuration. 2689603fc0a3Smrg # Assume this is the tagged configuration we want. 2690603fc0a3Smrg tagname=$z 2691603fc0a3Smrg break 2692603fc0a3Smrg ;; 2693603fc0a3Smrg esac 2694603fc0a3Smrg fi 2695603fc0a3Smrg done 2696603fc0a3Smrg # If $tagname still isn't set, then no tagged configuration 2697603fc0a3Smrg # was found and let the user know that the "--tag" command 2698603fc0a3Smrg # line option must be used. 2699603fc0a3Smrg if test -z "$tagname"; then 2700603fc0a3Smrg func_echo "unable to infer tagged configuration" 2701603fc0a3Smrg func_fatal_error "specify a tag with '--tag'" 2702603fc0a3Smrg# else 2703603fc0a3Smrg# func_verbose "using $tagname tagged configuration" 2704603fc0a3Smrg fi 2705603fc0a3Smrg ;; 2706603fc0a3Smrg esac 2707603fc0a3Smrg fi 2708603fc0a3Smrg} 2709603fc0a3Smrg 2710603fc0a3Smrg 2711603fc0a3Smrg 2712603fc0a3Smrg# func_write_libtool_object output_name pic_name nonpic_name 2713603fc0a3Smrg# Create a libtool object file (analogous to a ".la" file), 2714603fc0a3Smrg# but don't create it if we're doing a dry run. 2715603fc0a3Smrgfunc_write_libtool_object () 2716603fc0a3Smrg{ 2717603fc0a3Smrg write_libobj=$1 2718603fc0a3Smrg if test yes = "$build_libtool_libs"; then 2719603fc0a3Smrg write_lobj=\'$2\' 2720603fc0a3Smrg else 2721603fc0a3Smrg write_lobj=none 2722603fc0a3Smrg fi 2723603fc0a3Smrg 2724603fc0a3Smrg if test yes = "$build_old_libs"; then 2725603fc0a3Smrg write_oldobj=\'$3\' 2726603fc0a3Smrg else 2727603fc0a3Smrg write_oldobj=none 2728603fc0a3Smrg fi 2729603fc0a3Smrg 2730603fc0a3Smrg $opt_dry_run || { 2731603fc0a3Smrg cat >${write_libobj}T <<EOF 2732603fc0a3Smrg# $write_libobj - a libtool object file 2733603fc0a3Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2734603fc0a3Smrg# 2735603fc0a3Smrg# Please DO NOT delete this file! 2736603fc0a3Smrg# It is necessary for linking the library. 2737603fc0a3Smrg 2738603fc0a3Smrg# Name of the PIC object. 2739603fc0a3Smrgpic_object=$write_lobj 2740603fc0a3Smrg 2741603fc0a3Smrg# Name of the non-PIC object 2742603fc0a3Smrgnon_pic_object=$write_oldobj 2743603fc0a3Smrg 2744603fc0a3SmrgEOF 2745603fc0a3Smrg $MV "${write_libobj}T" "$write_libobj" 2746603fc0a3Smrg } 2747603fc0a3Smrg} 2748603fc0a3Smrg 2749603fc0a3Smrg 2750603fc0a3Smrg################################################## 2751603fc0a3Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2752603fc0a3Smrg################################################## 2753603fc0a3Smrg 2754603fc0a3Smrg# func_convert_core_file_wine_to_w32 ARG 2755603fc0a3Smrg# Helper function used by file name conversion functions when $build is *nix, 2756603fc0a3Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2757603fc0a3Smrg# correctly configured wine environment available, with the winepath program 2758603fc0a3Smrg# in $build's $PATH. 2759603fc0a3Smrg# 2760603fc0a3Smrg# ARG is the $build file name to be converted to w32 format. 2761603fc0a3Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 2762603fc0a3Smrg# be empty on error (or when ARG is empty) 2763603fc0a3Smrgfunc_convert_core_file_wine_to_w32 () 2764603fc0a3Smrg{ 2765603fc0a3Smrg $debug_cmd 2766603fc0a3Smrg 2767603fc0a3Smrg func_convert_core_file_wine_to_w32_result=$1 2768603fc0a3Smrg if test -n "$1"; then 2769603fc0a3Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 2770603fc0a3Smrg # are forced to check the contents of stdout. On the other hand, if the 2771603fc0a3Smrg # command is not found, the shell will set an exit code of 127 and print 2772603fc0a3Smrg # *an error message* to stdout. So we must check for both error code of 2773603fc0a3Smrg # zero AND non-empty stdout, which explains the odd construction: 2774603fc0a3Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 2775603fc0a3Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 2776603fc0a3Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 2777603fc0a3Smrg $SED -e "$sed_naive_backslashify"` 2778603fc0a3Smrg else 2779603fc0a3Smrg func_convert_core_file_wine_to_w32_result= 2780603fc0a3Smrg fi 2781603fc0a3Smrg fi 2782603fc0a3Smrg} 2783603fc0a3Smrg# end: func_convert_core_file_wine_to_w32 2784603fc0a3Smrg 2785603fc0a3Smrg 2786603fc0a3Smrg# func_convert_core_path_wine_to_w32 ARG 2787603fc0a3Smrg# Helper function used by path conversion functions when $build is *nix, and 2788603fc0a3Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 2789603fc0a3Smrg# configured wine environment available, with the winepath program in $build's 2790603fc0a3Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 2791603fc0a3Smrg# 2792603fc0a3Smrg# ARG is path to be converted from $build format to win32. 2793603fc0a3Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 2794603fc0a3Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 2795603fc0a3Smrg# are convertible, then the result may be empty. 2796603fc0a3Smrgfunc_convert_core_path_wine_to_w32 () 2797603fc0a3Smrg{ 2798603fc0a3Smrg $debug_cmd 2799603fc0a3Smrg 2800603fc0a3Smrg # unfortunately, winepath doesn't convert paths, only file names 2801603fc0a3Smrg func_convert_core_path_wine_to_w32_result= 2802603fc0a3Smrg if test -n "$1"; then 2803603fc0a3Smrg oldIFS=$IFS 2804603fc0a3Smrg IFS=: 2805603fc0a3Smrg for func_convert_core_path_wine_to_w32_f in $1; do 2806603fc0a3Smrg IFS=$oldIFS 2807603fc0a3Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 2808603fc0a3Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 2809603fc0a3Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 2810603fc0a3Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 2811603fc0a3Smrg else 2812603fc0a3Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 2813603fc0a3Smrg fi 2814603fc0a3Smrg fi 2815603fc0a3Smrg done 2816603fc0a3Smrg IFS=$oldIFS 2817603fc0a3Smrg fi 2818603fc0a3Smrg} 2819603fc0a3Smrg# end: func_convert_core_path_wine_to_w32 2820603fc0a3Smrg 2821603fc0a3Smrg 2822603fc0a3Smrg# func_cygpath ARGS... 2823603fc0a3Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 2824603fc0a3Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 2825603fc0a3Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 2826603fc0a3Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 2827603fc0a3Smrg# file name or path is assumed to be in w32 format, as previously converted 2828603fc0a3Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 2829603fc0a3Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 2830603fc0a3Smrg# Cygwin format). Returns an empty string on error. 2831603fc0a3Smrg# 2832603fc0a3Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 2833603fc0a3Smrg# be converted. 2834603fc0a3Smrg# 2835603fc0a3Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 2836603fc0a3Smrg# environment variable; do not put it in $PATH. 2837603fc0a3Smrgfunc_cygpath () 2838603fc0a3Smrg{ 2839603fc0a3Smrg $debug_cmd 2840603fc0a3Smrg 2841603fc0a3Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 2842603fc0a3Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 2843603fc0a3Smrg if test "$?" -ne 0; then 2844603fc0a3Smrg # on failure, ensure result is empty 2845603fc0a3Smrg func_cygpath_result= 2846603fc0a3Smrg fi 2847603fc0a3Smrg else 2848603fc0a3Smrg func_cygpath_result= 2849603fc0a3Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 2850603fc0a3Smrg fi 2851603fc0a3Smrg} 2852603fc0a3Smrg#end: func_cygpath 2853603fc0a3Smrg 2854603fc0a3Smrg 2855603fc0a3Smrg# func_convert_core_msys_to_w32 ARG 2856603fc0a3Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 2857603fc0a3Smrg# result in func_convert_core_msys_to_w32_result. 2858603fc0a3Smrgfunc_convert_core_msys_to_w32 () 2859603fc0a3Smrg{ 2860603fc0a3Smrg $debug_cmd 2861603fc0a3Smrg 2862603fc0a3Smrg # awkward: cmd appends spaces to result 2863603fc0a3Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 2864603fc0a3Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 2865603fc0a3Smrg} 2866603fc0a3Smrg#end: func_convert_core_msys_to_w32 2867603fc0a3Smrg 2868603fc0a3Smrg 2869603fc0a3Smrg# func_convert_file_check ARG1 ARG2 2870603fc0a3Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 2871603fc0a3Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 2872603fc0a3Smrg# func_to_host_file_result to ARG1). 2873603fc0a3Smrgfunc_convert_file_check () 2874603fc0a3Smrg{ 2875603fc0a3Smrg $debug_cmd 2876603fc0a3Smrg 2877603fc0a3Smrg if test -z "$2" && test -n "$1"; then 2878603fc0a3Smrg func_error "Could not determine host file name corresponding to" 2879603fc0a3Smrg func_error " '$1'" 2880603fc0a3Smrg func_error "Continuing, but uninstalled executables may not work." 2881603fc0a3Smrg # Fallback: 2882603fc0a3Smrg func_to_host_file_result=$1 2883603fc0a3Smrg fi 2884603fc0a3Smrg} 2885603fc0a3Smrg# end func_convert_file_check 2886603fc0a3Smrg 2887603fc0a3Smrg 2888603fc0a3Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 2889603fc0a3Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 2890603fc0a3Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 2891603fc0a3Smrg# func_to_host_file_result to a simplistic fallback value (see below). 2892603fc0a3Smrgfunc_convert_path_check () 2893603fc0a3Smrg{ 2894603fc0a3Smrg $debug_cmd 2895603fc0a3Smrg 2896603fc0a3Smrg if test -z "$4" && test -n "$3"; then 2897603fc0a3Smrg func_error "Could not determine the host path corresponding to" 2898603fc0a3Smrg func_error " '$3'" 2899603fc0a3Smrg func_error "Continuing, but uninstalled executables may not work." 2900603fc0a3Smrg # Fallback. This is a deliberately simplistic "conversion" and 2901603fc0a3Smrg # should not be "improved". See libtool.info. 2902603fc0a3Smrg if test "x$1" != "x$2"; then 2903603fc0a3Smrg lt_replace_pathsep_chars="s|$1|$2|g" 2904603fc0a3Smrg func_to_host_path_result=`echo "$3" | 2905603fc0a3Smrg $SED -e "$lt_replace_pathsep_chars"` 2906603fc0a3Smrg else 2907603fc0a3Smrg func_to_host_path_result=$3 2908603fc0a3Smrg fi 2909603fc0a3Smrg fi 2910603fc0a3Smrg} 2911603fc0a3Smrg# end func_convert_path_check 2912603fc0a3Smrg 2913603fc0a3Smrg 2914603fc0a3Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 2915603fc0a3Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 2916603fc0a3Smrg# and appending REPL if ORIG matches BACKPAT. 2917603fc0a3Smrgfunc_convert_path_front_back_pathsep () 2918603fc0a3Smrg{ 2919603fc0a3Smrg $debug_cmd 2920603fc0a3Smrg 2921603fc0a3Smrg case $4 in 2922603fc0a3Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 2923603fc0a3Smrg ;; 2924603fc0a3Smrg esac 2925603fc0a3Smrg case $4 in 2926603fc0a3Smrg $2 ) func_append func_to_host_path_result "$3" 2927603fc0a3Smrg ;; 2928603fc0a3Smrg esac 2929603fc0a3Smrg} 2930603fc0a3Smrg# end func_convert_path_front_back_pathsep 2931603fc0a3Smrg 2932603fc0a3Smrg 2933603fc0a3Smrg################################################## 2934603fc0a3Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 2935603fc0a3Smrg################################################## 2936603fc0a3Smrg# invoked via '$to_host_file_cmd ARG' 2937603fc0a3Smrg# 2938603fc0a3Smrg# In each case, ARG is the path to be converted from $build to $host format. 2939603fc0a3Smrg# Result will be available in $func_to_host_file_result. 2940603fc0a3Smrg 2941603fc0a3Smrg 2942603fc0a3Smrg# func_to_host_file ARG 2943603fc0a3Smrg# Converts the file name ARG from $build format to $host format. Return result 2944603fc0a3Smrg# in func_to_host_file_result. 2945603fc0a3Smrgfunc_to_host_file () 2946603fc0a3Smrg{ 2947603fc0a3Smrg $debug_cmd 2948603fc0a3Smrg 2949603fc0a3Smrg $to_host_file_cmd "$1" 2950603fc0a3Smrg} 2951603fc0a3Smrg# end func_to_host_file 2952603fc0a3Smrg 2953603fc0a3Smrg 2954603fc0a3Smrg# func_to_tool_file ARG LAZY 2955603fc0a3Smrg# converts the file name ARG from $build format to toolchain format. Return 2956603fc0a3Smrg# result in func_to_tool_file_result. If the conversion in use is listed 2957603fc0a3Smrg# in (the comma separated) LAZY, no conversion takes place. 2958603fc0a3Smrgfunc_to_tool_file () 2959603fc0a3Smrg{ 2960603fc0a3Smrg $debug_cmd 2961603fc0a3Smrg 2962603fc0a3Smrg case ,$2, in 2963603fc0a3Smrg *,"$to_tool_file_cmd",*) 2964603fc0a3Smrg func_to_tool_file_result=$1 2965603fc0a3Smrg ;; 2966603fc0a3Smrg *) 2967603fc0a3Smrg $to_tool_file_cmd "$1" 2968603fc0a3Smrg func_to_tool_file_result=$func_to_host_file_result 2969603fc0a3Smrg ;; 2970603fc0a3Smrg esac 2971603fc0a3Smrg} 2972603fc0a3Smrg# end func_to_tool_file 2973603fc0a3Smrg 2974603fc0a3Smrg 2975603fc0a3Smrg# func_convert_file_noop ARG 2976603fc0a3Smrg# Copy ARG to func_to_host_file_result. 2977603fc0a3Smrgfunc_convert_file_noop () 2978603fc0a3Smrg{ 2979603fc0a3Smrg func_to_host_file_result=$1 2980603fc0a3Smrg} 2981603fc0a3Smrg# end func_convert_file_noop 2982603fc0a3Smrg 2983603fc0a3Smrg 2984603fc0a3Smrg# func_convert_file_msys_to_w32 ARG 2985603fc0a3Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 2986603fc0a3Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 2987603fc0a3Smrg# func_to_host_file_result. 2988603fc0a3Smrgfunc_convert_file_msys_to_w32 () 2989603fc0a3Smrg{ 2990603fc0a3Smrg $debug_cmd 2991603fc0a3Smrg 2992603fc0a3Smrg func_to_host_file_result=$1 2993603fc0a3Smrg if test -n "$1"; then 2994603fc0a3Smrg func_convert_core_msys_to_w32 "$1" 2995603fc0a3Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 2996603fc0a3Smrg fi 2997603fc0a3Smrg func_convert_file_check "$1" "$func_to_host_file_result" 2998603fc0a3Smrg} 2999603fc0a3Smrg# end func_convert_file_msys_to_w32 3000603fc0a3Smrg 3001603fc0a3Smrg 3002603fc0a3Smrg# func_convert_file_cygwin_to_w32 ARG 3003603fc0a3Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3004603fc0a3Smrg# func_to_host_file_result. 3005603fc0a3Smrgfunc_convert_file_cygwin_to_w32 () 3006603fc0a3Smrg{ 3007603fc0a3Smrg $debug_cmd 3008603fc0a3Smrg 3009603fc0a3Smrg func_to_host_file_result=$1 3010603fc0a3Smrg if test -n "$1"; then 3011603fc0a3Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3012603fc0a3Smrg # LT_CYGPATH in this case. 3013603fc0a3Smrg func_to_host_file_result=`cygpath -m "$1"` 3014603fc0a3Smrg fi 3015603fc0a3Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3016603fc0a3Smrg} 3017603fc0a3Smrg# end func_convert_file_cygwin_to_w32 3018603fc0a3Smrg 3019603fc0a3Smrg 3020603fc0a3Smrg# func_convert_file_nix_to_w32 ARG 3021603fc0a3Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3022603fc0a3Smrg# and a working winepath. Returns result in func_to_host_file_result. 3023603fc0a3Smrgfunc_convert_file_nix_to_w32 () 3024603fc0a3Smrg{ 3025603fc0a3Smrg $debug_cmd 3026603fc0a3Smrg 3027603fc0a3Smrg func_to_host_file_result=$1 3028603fc0a3Smrg if test -n "$1"; then 3029603fc0a3Smrg func_convert_core_file_wine_to_w32 "$1" 3030603fc0a3Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3031603fc0a3Smrg fi 3032603fc0a3Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3033603fc0a3Smrg} 3034603fc0a3Smrg# end func_convert_file_nix_to_w32 3035603fc0a3Smrg 3036603fc0a3Smrg 3037603fc0a3Smrg# func_convert_file_msys_to_cygwin ARG 3038603fc0a3Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3039603fc0a3Smrg# Returns result in func_to_host_file_result. 3040603fc0a3Smrgfunc_convert_file_msys_to_cygwin () 3041603fc0a3Smrg{ 3042603fc0a3Smrg $debug_cmd 3043603fc0a3Smrg 3044603fc0a3Smrg func_to_host_file_result=$1 3045603fc0a3Smrg if test -n "$1"; then 3046603fc0a3Smrg func_convert_core_msys_to_w32 "$1" 3047603fc0a3Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3048603fc0a3Smrg func_to_host_file_result=$func_cygpath_result 3049603fc0a3Smrg fi 3050603fc0a3Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3051603fc0a3Smrg} 3052603fc0a3Smrg# end func_convert_file_msys_to_cygwin 3053603fc0a3Smrg 3054603fc0a3Smrg 3055603fc0a3Smrg# func_convert_file_nix_to_cygwin ARG 3056603fc0a3Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3057603fc0a3Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3058603fc0a3Smrg# in func_to_host_file_result. 3059603fc0a3Smrgfunc_convert_file_nix_to_cygwin () 3060603fc0a3Smrg{ 3061603fc0a3Smrg $debug_cmd 3062603fc0a3Smrg 3063603fc0a3Smrg func_to_host_file_result=$1 3064603fc0a3Smrg if test -n "$1"; then 3065603fc0a3Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3066603fc0a3Smrg func_convert_core_file_wine_to_w32 "$1" 3067603fc0a3Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3068603fc0a3Smrg func_to_host_file_result=$func_cygpath_result 3069603fc0a3Smrg fi 3070603fc0a3Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3071603fc0a3Smrg} 3072603fc0a3Smrg# end func_convert_file_nix_to_cygwin 3073603fc0a3Smrg 3074603fc0a3Smrg 3075603fc0a3Smrg############################################# 3076603fc0a3Smrg# $build to $host PATH CONVERSION FUNCTIONS # 3077603fc0a3Smrg############################################# 3078603fc0a3Smrg# invoked via '$to_host_path_cmd ARG' 3079603fc0a3Smrg# 3080603fc0a3Smrg# In each case, ARG is the path to be converted from $build to $host format. 3081603fc0a3Smrg# The result will be available in $func_to_host_path_result. 3082603fc0a3Smrg# 3083603fc0a3Smrg# Path separators are also converted from $build format to $host format. If 3084603fc0a3Smrg# ARG begins or ends with a path separator character, it is preserved (but 3085603fc0a3Smrg# converted to $host format) on output. 3086603fc0a3Smrg# 3087603fc0a3Smrg# All path conversion functions are named using the following convention: 3088603fc0a3Smrg# file name conversion function : func_convert_file_X_to_Y () 3089603fc0a3Smrg# path conversion function : func_convert_path_X_to_Y () 3090603fc0a3Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3091603fc0a3Smrg# same. If conversion functions are added for new $build/$host combinations, 3092603fc0a3Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3093603fc0a3Smrg# will break. 3094603fc0a3Smrg 3095603fc0a3Smrg 3096603fc0a3Smrg# func_init_to_host_path_cmd 3097603fc0a3Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3098603fc0a3Smrg# appropriate value, based on the value of $to_host_file_cmd. 3099603fc0a3Smrgto_host_path_cmd= 3100603fc0a3Smrgfunc_init_to_host_path_cmd () 3101603fc0a3Smrg{ 3102603fc0a3Smrg $debug_cmd 3103603fc0a3Smrg 3104603fc0a3Smrg if test -z "$to_host_path_cmd"; then 3105603fc0a3Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3106603fc0a3Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 3107603fc0a3Smrg fi 3108603fc0a3Smrg} 3109603fc0a3Smrg 3110603fc0a3Smrg 3111603fc0a3Smrg# func_to_host_path ARG 3112603fc0a3Smrg# Converts the path ARG from $build format to $host format. Return result 3113603fc0a3Smrg# in func_to_host_path_result. 3114603fc0a3Smrgfunc_to_host_path () 3115603fc0a3Smrg{ 3116603fc0a3Smrg $debug_cmd 3117603fc0a3Smrg 3118603fc0a3Smrg func_init_to_host_path_cmd 3119603fc0a3Smrg $to_host_path_cmd "$1" 3120603fc0a3Smrg} 3121603fc0a3Smrg# end func_to_host_path 3122603fc0a3Smrg 3123603fc0a3Smrg 3124603fc0a3Smrg# func_convert_path_noop ARG 3125603fc0a3Smrg# Copy ARG to func_to_host_path_result. 3126603fc0a3Smrgfunc_convert_path_noop () 3127603fc0a3Smrg{ 3128603fc0a3Smrg func_to_host_path_result=$1 3129603fc0a3Smrg} 3130603fc0a3Smrg# end func_convert_path_noop 3131603fc0a3Smrg 3132603fc0a3Smrg 3133603fc0a3Smrg# func_convert_path_msys_to_w32 ARG 3134603fc0a3Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3135603fc0a3Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3136603fc0a3Smrg# func_to_host_path_result. 3137603fc0a3Smrgfunc_convert_path_msys_to_w32 () 3138603fc0a3Smrg{ 3139603fc0a3Smrg $debug_cmd 3140603fc0a3Smrg 3141603fc0a3Smrg func_to_host_path_result=$1 3142603fc0a3Smrg if test -n "$1"; then 3143603fc0a3Smrg # Remove leading and trailing path separator characters from ARG. MSYS 3144603fc0a3Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3145603fc0a3Smrg # and winepath ignores them completely. 3146603fc0a3Smrg func_stripname : : "$1" 3147603fc0a3Smrg func_to_host_path_tmp1=$func_stripname_result 3148603fc0a3Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3149603fc0a3Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3150603fc0a3Smrg func_convert_path_check : ";" \ 3151603fc0a3Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3152603fc0a3Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3153603fc0a3Smrg fi 3154603fc0a3Smrg} 3155603fc0a3Smrg# end func_convert_path_msys_to_w32 3156603fc0a3Smrg 3157603fc0a3Smrg 3158603fc0a3Smrg# func_convert_path_cygwin_to_w32 ARG 3159603fc0a3Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 3160603fc0a3Smrg# func_to_host_file_result. 3161603fc0a3Smrgfunc_convert_path_cygwin_to_w32 () 3162603fc0a3Smrg{ 3163603fc0a3Smrg $debug_cmd 3164603fc0a3Smrg 3165603fc0a3Smrg func_to_host_path_result=$1 3166603fc0a3Smrg if test -n "$1"; then 3167603fc0a3Smrg # See func_convert_path_msys_to_w32: 3168603fc0a3Smrg func_stripname : : "$1" 3169603fc0a3Smrg func_to_host_path_tmp1=$func_stripname_result 3170603fc0a3Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3171603fc0a3Smrg func_convert_path_check : ";" \ 3172603fc0a3Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3173603fc0a3Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3174603fc0a3Smrg fi 3175603fc0a3Smrg} 3176603fc0a3Smrg# end func_convert_path_cygwin_to_w32 3177603fc0a3Smrg 3178603fc0a3Smrg 3179603fc0a3Smrg# func_convert_path_nix_to_w32 ARG 3180603fc0a3Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3181603fc0a3Smrg# a working winepath. Returns result in func_to_host_file_result. 3182603fc0a3Smrgfunc_convert_path_nix_to_w32 () 3183603fc0a3Smrg{ 3184603fc0a3Smrg $debug_cmd 3185603fc0a3Smrg 3186603fc0a3Smrg func_to_host_path_result=$1 3187603fc0a3Smrg if test -n "$1"; then 3188603fc0a3Smrg # See func_convert_path_msys_to_w32: 3189603fc0a3Smrg func_stripname : : "$1" 3190603fc0a3Smrg func_to_host_path_tmp1=$func_stripname_result 3191603fc0a3Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3192603fc0a3Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3193603fc0a3Smrg func_convert_path_check : ";" \ 3194603fc0a3Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3195603fc0a3Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3196603fc0a3Smrg fi 3197603fc0a3Smrg} 3198603fc0a3Smrg# end func_convert_path_nix_to_w32 3199603fc0a3Smrg 3200603fc0a3Smrg 3201603fc0a3Smrg# func_convert_path_msys_to_cygwin ARG 3202603fc0a3Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3203603fc0a3Smrg# Returns result in func_to_host_file_result. 3204603fc0a3Smrgfunc_convert_path_msys_to_cygwin () 3205603fc0a3Smrg{ 3206603fc0a3Smrg $debug_cmd 3207603fc0a3Smrg 3208603fc0a3Smrg func_to_host_path_result=$1 3209603fc0a3Smrg if test -n "$1"; then 3210603fc0a3Smrg # See func_convert_path_msys_to_w32: 3211603fc0a3Smrg func_stripname : : "$1" 3212603fc0a3Smrg func_to_host_path_tmp1=$func_stripname_result 3213603fc0a3Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3214603fc0a3Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3215603fc0a3Smrg func_to_host_path_result=$func_cygpath_result 3216603fc0a3Smrg func_convert_path_check : : \ 3217603fc0a3Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3218603fc0a3Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3219603fc0a3Smrg fi 3220603fc0a3Smrg} 3221603fc0a3Smrg# end func_convert_path_msys_to_cygwin 3222603fc0a3Smrg 3223603fc0a3Smrg 3224603fc0a3Smrg# func_convert_path_nix_to_cygwin ARG 3225603fc0a3Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3226603fc0a3Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3227603fc0a3Smrg# func_to_host_file_result. 3228603fc0a3Smrgfunc_convert_path_nix_to_cygwin () 3229603fc0a3Smrg{ 3230603fc0a3Smrg $debug_cmd 3231603fc0a3Smrg 3232603fc0a3Smrg func_to_host_path_result=$1 3233603fc0a3Smrg if test -n "$1"; then 3234603fc0a3Smrg # Remove leading and trailing path separator characters from 3235603fc0a3Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 3236603fc0a3Smrg # into '.;' and ';.', and winepath ignores them completely. 3237603fc0a3Smrg func_stripname : : "$1" 3238603fc0a3Smrg func_to_host_path_tmp1=$func_stripname_result 3239603fc0a3Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3240603fc0a3Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3241603fc0a3Smrg func_to_host_path_result=$func_cygpath_result 3242603fc0a3Smrg func_convert_path_check : : \ 3243603fc0a3Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3244603fc0a3Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3245603fc0a3Smrg fi 3246603fc0a3Smrg} 3247603fc0a3Smrg# end func_convert_path_nix_to_cygwin 3248603fc0a3Smrg 3249603fc0a3Smrg 3250603fc0a3Smrg# func_dll_def_p FILE 3251603fc0a3Smrg# True iff FILE is a Windows DLL '.def' file. 3252603fc0a3Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3253603fc0a3Smrgfunc_dll_def_p () 3254603fc0a3Smrg{ 3255603fc0a3Smrg $debug_cmd 3256603fc0a3Smrg 3257603fc0a3Smrg func_dll_def_p_tmp=`$SED -n \ 3258603fc0a3Smrg -e 's/^[ ]*//' \ 3259603fc0a3Smrg -e '/^\(;.*\)*$/d' \ 3260603fc0a3Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3261603fc0a3Smrg -e q \ 3262603fc0a3Smrg "$1"` 3263603fc0a3Smrg test DEF = "$func_dll_def_p_tmp" 3264603fc0a3Smrg} 3265603fc0a3Smrg 3266603fc0a3Smrg 3267603fc0a3Smrg# func_mode_compile arg... 3268603fc0a3Smrgfunc_mode_compile () 3269603fc0a3Smrg{ 3270603fc0a3Smrg $debug_cmd 3271603fc0a3Smrg 3272603fc0a3Smrg # Get the compilation command and the source file. 3273603fc0a3Smrg base_compile= 3274603fc0a3Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3275603fc0a3Smrg suppress_opt=yes 3276603fc0a3Smrg suppress_output= 3277603fc0a3Smrg arg_mode=normal 3278603fc0a3Smrg libobj= 3279603fc0a3Smrg later= 3280603fc0a3Smrg pie_flag= 3281603fc0a3Smrg 3282603fc0a3Smrg for arg 3283603fc0a3Smrg do 3284603fc0a3Smrg case $arg_mode in 3285603fc0a3Smrg arg ) 3286603fc0a3Smrg # do not "continue". Instead, add this to base_compile 3287603fc0a3Smrg lastarg=$arg 3288603fc0a3Smrg arg_mode=normal 3289603fc0a3Smrg ;; 3290603fc0a3Smrg 3291603fc0a3Smrg target ) 3292603fc0a3Smrg libobj=$arg 3293603fc0a3Smrg arg_mode=normal 3294603fc0a3Smrg continue 3295603fc0a3Smrg ;; 3296603fc0a3Smrg 3297603fc0a3Smrg normal ) 3298603fc0a3Smrg # Accept any command-line options. 3299603fc0a3Smrg case $arg in 3300603fc0a3Smrg -o) 3301603fc0a3Smrg test -n "$libobj" && \ 3302603fc0a3Smrg func_fatal_error "you cannot specify '-o' more than once" 3303603fc0a3Smrg arg_mode=target 3304603fc0a3Smrg continue 3305603fc0a3Smrg ;; 3306603fc0a3Smrg 3307603fc0a3Smrg -pie | -fpie | -fPIE) 3308603fc0a3Smrg func_append pie_flag " $arg" 3309603fc0a3Smrg continue 3310603fc0a3Smrg ;; 3311603fc0a3Smrg 3312603fc0a3Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 3313603fc0a3Smrg func_append later " $arg" 3314603fc0a3Smrg continue 3315603fc0a3Smrg ;; 3316603fc0a3Smrg 3317603fc0a3Smrg -no-suppress) 3318603fc0a3Smrg suppress_opt=no 3319603fc0a3Smrg continue 3320603fc0a3Smrg ;; 3321603fc0a3Smrg 3322603fc0a3Smrg -Xcompiler) 3323603fc0a3Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 3324603fc0a3Smrg continue # The current "srcfile" will either be retained or 3325603fc0a3Smrg ;; # replaced later. I would guess that would be a bug. 3326603fc0a3Smrg 3327603fc0a3Smrg -Wc,*) 3328603fc0a3Smrg func_stripname '-Wc,' '' "$arg" 3329603fc0a3Smrg args=$func_stripname_result 3330603fc0a3Smrg lastarg= 3331603fc0a3Smrg save_ifs=$IFS; IFS=, 3332603fc0a3Smrg for arg in $args; do 3333603fc0a3Smrg IFS=$save_ifs 3334603fc0a3Smrg func_append_quoted lastarg "$arg" 3335603fc0a3Smrg done 3336603fc0a3Smrg IFS=$save_ifs 3337603fc0a3Smrg func_stripname ' ' '' "$lastarg" 3338603fc0a3Smrg lastarg=$func_stripname_result 3339603fc0a3Smrg 3340603fc0a3Smrg # Add the arguments to base_compile. 3341603fc0a3Smrg func_append base_compile " $lastarg" 3342603fc0a3Smrg continue 3343603fc0a3Smrg ;; 3344603fc0a3Smrg 3345603fc0a3Smrg *) 3346603fc0a3Smrg # Accept the current argument as the source file. 3347603fc0a3Smrg # The previous "srcfile" becomes the current argument. 3348603fc0a3Smrg # 3349603fc0a3Smrg lastarg=$srcfile 3350603fc0a3Smrg srcfile=$arg 3351603fc0a3Smrg ;; 3352603fc0a3Smrg esac # case $arg 3353603fc0a3Smrg ;; 3354603fc0a3Smrg esac # case $arg_mode 3355603fc0a3Smrg 3356603fc0a3Smrg # Aesthetically quote the previous argument. 3357603fc0a3Smrg func_append_quoted base_compile "$lastarg" 3358603fc0a3Smrg done # for arg 3359603fc0a3Smrg 3360603fc0a3Smrg case $arg_mode in 3361603fc0a3Smrg arg) 3362603fc0a3Smrg func_fatal_error "you must specify an argument for -Xcompile" 3363603fc0a3Smrg ;; 3364603fc0a3Smrg target) 3365603fc0a3Smrg func_fatal_error "you must specify a target with '-o'" 3366603fc0a3Smrg ;; 3367603fc0a3Smrg *) 3368603fc0a3Smrg # Get the name of the library object. 3369603fc0a3Smrg test -z "$libobj" && { 3370603fc0a3Smrg func_basename "$srcfile" 3371603fc0a3Smrg libobj=$func_basename_result 3372603fc0a3Smrg } 3373603fc0a3Smrg ;; 3374603fc0a3Smrg esac 3375603fc0a3Smrg 3376603fc0a3Smrg # Recognize several different file suffixes. 3377603fc0a3Smrg # If the user specifies -o file.o, it is replaced with file.lo 3378603fc0a3Smrg case $libobj in 3379603fc0a3Smrg *.[cCFSifmso] | \ 3380603fc0a3Smrg *.ada | *.adb | *.ads | *.asm | \ 3381603fc0a3Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3382603fc0a3Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3383603fc0a3Smrg func_xform "$libobj" 3384603fc0a3Smrg libobj=$func_xform_result 3385603fc0a3Smrg ;; 3386603fc0a3Smrg esac 3387603fc0a3Smrg 3388603fc0a3Smrg case $libobj in 3389603fc0a3Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3390603fc0a3Smrg *) 3391603fc0a3Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 3392603fc0a3Smrg ;; 3393603fc0a3Smrg esac 3394603fc0a3Smrg 3395603fc0a3Smrg func_infer_tag $base_compile 3396603fc0a3Smrg 3397603fc0a3Smrg for arg in $later; do 3398603fc0a3Smrg case $arg in 3399603fc0a3Smrg -shared) 3400603fc0a3Smrg test yes = "$build_libtool_libs" \ 3401603fc0a3Smrg || func_fatal_configuration "cannot build a shared library" 3402603fc0a3Smrg build_old_libs=no 3403603fc0a3Smrg continue 3404603fc0a3Smrg ;; 3405603fc0a3Smrg 3406603fc0a3Smrg -static) 3407603fc0a3Smrg build_libtool_libs=no 3408603fc0a3Smrg build_old_libs=yes 3409603fc0a3Smrg continue 3410603fc0a3Smrg ;; 3411603fc0a3Smrg 3412603fc0a3Smrg -prefer-pic) 3413603fc0a3Smrg pic_mode=yes 3414603fc0a3Smrg continue 3415603fc0a3Smrg ;; 3416603fc0a3Smrg 3417603fc0a3Smrg -prefer-non-pic) 3418603fc0a3Smrg pic_mode=no 3419603fc0a3Smrg continue 3420603fc0a3Smrg ;; 3421603fc0a3Smrg esac 3422603fc0a3Smrg done 3423603fc0a3Smrg 3424603fc0a3Smrg func_quote_for_eval "$libobj" 3425603fc0a3Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 3426603fc0a3Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3427603fc0a3Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3428603fc0a3Smrg func_dirname_and_basename "$obj" "/" "" 3429603fc0a3Smrg objname=$func_basename_result 3430603fc0a3Smrg xdir=$func_dirname_result 3431603fc0a3Smrg lobj=$xdir$objdir/$objname 3432603fc0a3Smrg 3433603fc0a3Smrg test -z "$base_compile" && \ 3434603fc0a3Smrg func_fatal_help "you must specify a compilation command" 3435603fc0a3Smrg 3436603fc0a3Smrg # Delete any leftover library objects. 3437603fc0a3Smrg if test yes = "$build_old_libs"; then 3438603fc0a3Smrg removelist="$obj $lobj $libobj ${libobj}T" 3439603fc0a3Smrg else 3440603fc0a3Smrg removelist="$lobj $libobj ${libobj}T" 3441603fc0a3Smrg fi 3442603fc0a3Smrg 3443603fc0a3Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 3444603fc0a3Smrg case $host_os in 3445603fc0a3Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3446603fc0a3Smrg pic_mode=default 3447603fc0a3Smrg ;; 3448603fc0a3Smrg esac 3449603fc0a3Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3450603fc0a3Smrg # non-PIC code in shared libraries is not supported 3451603fc0a3Smrg pic_mode=default 3452603fc0a3Smrg fi 3453603fc0a3Smrg 3454603fc0a3Smrg # Calculate the filename of the output object if compiler does 3455603fc0a3Smrg # not support -o with -c 3456603fc0a3Smrg if test no = "$compiler_c_o"; then 3457603fc0a3Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3458603fc0a3Smrg lockfile=$output_obj.lock 3459603fc0a3Smrg else 3460603fc0a3Smrg output_obj= 3461603fc0a3Smrg need_locks=no 3462603fc0a3Smrg lockfile= 3463603fc0a3Smrg fi 3464603fc0a3Smrg 3465603fc0a3Smrg # Lock this critical section if it is needed 3466603fc0a3Smrg # We use this script file to make the link, it avoids creating a new file 3467603fc0a3Smrg if test yes = "$need_locks"; then 3468603fc0a3Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3469603fc0a3Smrg func_echo "Waiting for $lockfile to be removed" 3470603fc0a3Smrg sleep 2 3471603fc0a3Smrg done 3472603fc0a3Smrg elif test warn = "$need_locks"; then 3473603fc0a3Smrg if test -f "$lockfile"; then 3474603fc0a3Smrg $ECHO "\ 3475603fc0a3Smrg*** ERROR, $lockfile exists and contains: 3476603fc0a3Smrg`cat $lockfile 2>/dev/null` 3477603fc0a3Smrg 3478603fc0a3SmrgThis indicates that another process is trying to use the same 3479603fc0a3Smrgtemporary object file, and libtool could not work around it because 3480603fc0a3Smrgyour compiler does not support '-c' and '-o' together. If you 3481603fc0a3Smrgrepeat this compilation, it may succeed, by chance, but you had better 3482603fc0a3Smrgavoid parallel builds (make -j) in this platform, or get a better 3483603fc0a3Smrgcompiler." 3484603fc0a3Smrg 3485603fc0a3Smrg $opt_dry_run || $RM $removelist 3486603fc0a3Smrg exit $EXIT_FAILURE 3487603fc0a3Smrg fi 3488603fc0a3Smrg func_append removelist " $output_obj" 3489603fc0a3Smrg $ECHO "$srcfile" > "$lockfile" 3490603fc0a3Smrg fi 3491603fc0a3Smrg 3492603fc0a3Smrg $opt_dry_run || $RM $removelist 3493603fc0a3Smrg func_append removelist " $lockfile" 3494603fc0a3Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3495603fc0a3Smrg 3496603fc0a3Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3497603fc0a3Smrg srcfile=$func_to_tool_file_result 3498603fc0a3Smrg func_quote_for_eval "$srcfile" 3499603fc0a3Smrg qsrcfile=$func_quote_for_eval_result 3500603fc0a3Smrg 3501603fc0a3Smrg # Only build a PIC object if we are building libtool libraries. 3502603fc0a3Smrg if test yes = "$build_libtool_libs"; then 3503603fc0a3Smrg # Without this assignment, base_compile gets emptied. 3504603fc0a3Smrg fbsd_hideous_sh_bug=$base_compile 3505603fc0a3Smrg 3506603fc0a3Smrg if test no != "$pic_mode"; then 3507603fc0a3Smrg command="$base_compile $qsrcfile $pic_flag" 3508603fc0a3Smrg else 3509603fc0a3Smrg # Don't build PIC code 3510603fc0a3Smrg command="$base_compile $qsrcfile" 3511603fc0a3Smrg fi 3512603fc0a3Smrg 3513603fc0a3Smrg func_mkdir_p "$xdir$objdir" 3514603fc0a3Smrg 3515603fc0a3Smrg if test -z "$output_obj"; then 3516603fc0a3Smrg # Place PIC objects in $objdir 3517603fc0a3Smrg func_append command " -o $lobj" 3518603fc0a3Smrg fi 3519603fc0a3Smrg 3520603fc0a3Smrg func_show_eval_locale "$command" \ 3521603fc0a3Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3522603fc0a3Smrg 3523603fc0a3Smrg if test warn = "$need_locks" && 3524603fc0a3Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3525603fc0a3Smrg $ECHO "\ 3526603fc0a3Smrg*** ERROR, $lockfile contains: 3527603fc0a3Smrg`cat $lockfile 2>/dev/null` 3528603fc0a3Smrg 3529603fc0a3Smrgbut it should contain: 3530603fc0a3Smrg$srcfile 3531603fc0a3Smrg 3532603fc0a3SmrgThis indicates that another process is trying to use the same 3533603fc0a3Smrgtemporary object file, and libtool could not work around it because 3534603fc0a3Smrgyour compiler does not support '-c' and '-o' together. If you 3535603fc0a3Smrgrepeat this compilation, it may succeed, by chance, but you had better 3536603fc0a3Smrgavoid parallel builds (make -j) in this platform, or get a better 3537603fc0a3Smrgcompiler." 3538603fc0a3Smrg 3539603fc0a3Smrg $opt_dry_run || $RM $removelist 3540603fc0a3Smrg exit $EXIT_FAILURE 3541603fc0a3Smrg fi 3542603fc0a3Smrg 3543603fc0a3Smrg # Just move the object if needed, then go on to compile the next one 3544603fc0a3Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3545603fc0a3Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3546603fc0a3Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3547603fc0a3Smrg fi 3548603fc0a3Smrg 3549603fc0a3Smrg # Allow error messages only from the first compilation. 3550603fc0a3Smrg if test yes = "$suppress_opt"; then 3551603fc0a3Smrg suppress_output=' >/dev/null 2>&1' 3552603fc0a3Smrg fi 3553603fc0a3Smrg fi 3554603fc0a3Smrg 3555603fc0a3Smrg # Only build a position-dependent object if we build old libraries. 3556603fc0a3Smrg if test yes = "$build_old_libs"; then 3557603fc0a3Smrg if test yes != "$pic_mode"; then 3558603fc0a3Smrg # Don't build PIC code 3559603fc0a3Smrg command="$base_compile $qsrcfile$pie_flag" 3560603fc0a3Smrg else 3561603fc0a3Smrg command="$base_compile $qsrcfile $pic_flag" 3562603fc0a3Smrg fi 3563603fc0a3Smrg if test yes = "$compiler_c_o"; then 3564603fc0a3Smrg func_append command " -o $obj" 3565603fc0a3Smrg fi 3566603fc0a3Smrg 3567603fc0a3Smrg # Suppress compiler output if we already did a PIC compilation. 3568603fc0a3Smrg func_append command "$suppress_output" 3569603fc0a3Smrg func_show_eval_locale "$command" \ 3570603fc0a3Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3571603fc0a3Smrg 3572603fc0a3Smrg if test warn = "$need_locks" && 3573603fc0a3Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3574603fc0a3Smrg $ECHO "\ 3575603fc0a3Smrg*** ERROR, $lockfile contains: 3576603fc0a3Smrg`cat $lockfile 2>/dev/null` 3577603fc0a3Smrg 3578603fc0a3Smrgbut it should contain: 3579603fc0a3Smrg$srcfile 3580603fc0a3Smrg 3581603fc0a3SmrgThis indicates that another process is trying to use the same 3582603fc0a3Smrgtemporary object file, and libtool could not work around it because 3583603fc0a3Smrgyour compiler does not support '-c' and '-o' together. If you 3584603fc0a3Smrgrepeat this compilation, it may succeed, by chance, but you had better 3585603fc0a3Smrgavoid parallel builds (make -j) in this platform, or get a better 3586603fc0a3Smrgcompiler." 3587603fc0a3Smrg 3588603fc0a3Smrg $opt_dry_run || $RM $removelist 3589603fc0a3Smrg exit $EXIT_FAILURE 3590603fc0a3Smrg fi 3591603fc0a3Smrg 3592603fc0a3Smrg # Just move the object if needed 3593603fc0a3Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3594603fc0a3Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 3595603fc0a3Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3596603fc0a3Smrg fi 3597603fc0a3Smrg fi 3598603fc0a3Smrg 3599603fc0a3Smrg $opt_dry_run || { 3600603fc0a3Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3601603fc0a3Smrg 3602603fc0a3Smrg # Unlock the critical section if it was locked 3603603fc0a3Smrg if test no != "$need_locks"; then 3604603fc0a3Smrg removelist=$lockfile 3605603fc0a3Smrg $RM "$lockfile" 3606603fc0a3Smrg fi 3607603fc0a3Smrg } 3608603fc0a3Smrg 3609603fc0a3Smrg exit $EXIT_SUCCESS 3610603fc0a3Smrg} 3611603fc0a3Smrg 3612603fc0a3Smrg$opt_help || { 3613603fc0a3Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3614603fc0a3Smrg} 3615603fc0a3Smrg 3616603fc0a3Smrgfunc_mode_help () 3617603fc0a3Smrg{ 3618603fc0a3Smrg # We need to display help for each of the modes. 3619603fc0a3Smrg case $opt_mode in 3620603fc0a3Smrg "") 3621603fc0a3Smrg # Generic help is extracted from the usage comments 3622603fc0a3Smrg # at the start of this file. 3623603fc0a3Smrg func_help 3624603fc0a3Smrg ;; 3625603fc0a3Smrg 3626603fc0a3Smrg clean) 3627603fc0a3Smrg $ECHO \ 3628603fc0a3Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3629603fc0a3Smrg 3630603fc0a3SmrgRemove files from the build directory. 3631603fc0a3Smrg 3632603fc0a3SmrgRM is the name of the program to use to delete files associated with each FILE 3633603fc0a3Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3634603fc0a3Smrgto RM. 3635603fc0a3Smrg 3636603fc0a3SmrgIf FILE is a libtool library, object or program, all the files associated 3637603fc0a3Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3638603fc0a3Smrg ;; 3639603fc0a3Smrg 3640603fc0a3Smrg compile) 3641603fc0a3Smrg $ECHO \ 3642603fc0a3Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3643603fc0a3Smrg 3644603fc0a3SmrgCompile a source file into a libtool library object. 3645603fc0a3Smrg 3646603fc0a3SmrgThis mode accepts the following additional options: 3647603fc0a3Smrg 3648603fc0a3Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3649603fc0a3Smrg -no-suppress do not suppress compiler output for multiple passes 3650603fc0a3Smrg -prefer-pic try to build PIC objects only 3651603fc0a3Smrg -prefer-non-pic try to build non-PIC objects only 3652603fc0a3Smrg -shared do not build a '.o' file suitable for static linking 3653603fc0a3Smrg -static only build a '.o' file suitable for static linking 3654603fc0a3Smrg -Wc,FLAG pass FLAG directly to the compiler 3655603fc0a3Smrg 3656603fc0a3SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3657603fc0a3Smrgfrom the given SOURCEFILE. 3658603fc0a3Smrg 3659603fc0a3SmrgThe output file name is determined by removing the directory component from 3660603fc0a3SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 3661603fc0a3Smrglibrary object suffix, '.lo'." 3662603fc0a3Smrg ;; 3663603fc0a3Smrg 3664603fc0a3Smrg execute) 3665603fc0a3Smrg $ECHO \ 3666603fc0a3Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3667603fc0a3Smrg 3668603fc0a3SmrgAutomatically set library path, then run a program. 3669603fc0a3Smrg 3670603fc0a3SmrgThis mode accepts the following additional options: 3671603fc0a3Smrg 3672603fc0a3Smrg -dlopen FILE add the directory containing FILE to the library path 3673603fc0a3Smrg 3674603fc0a3SmrgThis mode sets the library path environment variable according to '-dlopen' 3675603fc0a3Smrgflags. 3676603fc0a3Smrg 3677603fc0a3SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3678603fc0a3Smrginto their corresponding uninstalled binary, and any of their required library 3679603fc0a3Smrgdirectories are added to the library path. 3680603fc0a3Smrg 3681603fc0a3SmrgThen, COMMAND is executed, with ARGS as arguments." 3682603fc0a3Smrg ;; 3683603fc0a3Smrg 3684603fc0a3Smrg finish) 3685603fc0a3Smrg $ECHO \ 3686603fc0a3Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3687603fc0a3Smrg 3688603fc0a3SmrgComplete the installation of libtool libraries. 3689603fc0a3Smrg 3690603fc0a3SmrgEach LIBDIR is a directory that contains libtool libraries. 3691603fc0a3Smrg 3692603fc0a3SmrgThe commands that this mode executes may require superuser privileges. Use 3693603fc0a3Smrgthe '--dry-run' option if you just want to see what would be executed." 3694603fc0a3Smrg ;; 3695603fc0a3Smrg 3696603fc0a3Smrg install) 3697603fc0a3Smrg $ECHO \ 3698603fc0a3Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3699603fc0a3Smrg 3700603fc0a3SmrgInstall executables or libraries. 3701603fc0a3Smrg 3702603fc0a3SmrgINSTALL-COMMAND is the installation command. The first component should be 3703603fc0a3Smrgeither the 'install' or 'cp' program. 3704603fc0a3Smrg 3705603fc0a3SmrgThe following components of INSTALL-COMMAND are treated specially: 3706603fc0a3Smrg 3707603fc0a3Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3708603fc0a3Smrg 3709603fc0a3SmrgThe rest of the components are interpreted as arguments to that command (only 3710603fc0a3SmrgBSD-compatible install options are recognized)." 3711603fc0a3Smrg ;; 3712603fc0a3Smrg 3713603fc0a3Smrg link) 3714603fc0a3Smrg $ECHO \ 3715603fc0a3Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3716603fc0a3Smrg 3717603fc0a3SmrgLink object files or libraries together to form another library, or to 3718603fc0a3Smrgcreate an executable program. 3719603fc0a3Smrg 3720603fc0a3SmrgLINK-COMMAND is a command using the C compiler that you would use to create 3721603fc0a3Smrga program from several object files. 3722603fc0a3Smrg 3723603fc0a3SmrgThe following components of LINK-COMMAND are treated specially: 3724603fc0a3Smrg 3725603fc0a3Smrg -all-static do not do any dynamic linking at all 3726603fc0a3Smrg -avoid-version do not add a version suffix if possible 3727603fc0a3Smrg -bindir BINDIR specify path to binaries directory (for systems where 3728603fc0a3Smrg libraries must be found in the PATH setting at runtime) 3729603fc0a3Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3730603fc0a3Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3731603fc0a3Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3732603fc0a3Smrg -export-symbols SYMFILE 3733603fc0a3Smrg try to export only the symbols listed in SYMFILE 3734603fc0a3Smrg -export-symbols-regex REGEX 3735603fc0a3Smrg try to export only the symbols matching REGEX 3736603fc0a3Smrg -LLIBDIR search LIBDIR for required installed libraries 3737603fc0a3Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 3738603fc0a3Smrg -module build a library that can dlopened 3739603fc0a3Smrg -no-fast-install disable the fast-install mode 3740603fc0a3Smrg -no-install link a not-installable executable 3741603fc0a3Smrg -no-undefined declare that a library does not refer to external symbols 3742603fc0a3Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3743603fc0a3Smrg -objectlist FILE use a list of object files found in FILE to specify objects 3744603fc0a3Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3745603fc0a3Smrg -precious-files-regex REGEX 3746603fc0a3Smrg don't remove output files matching REGEX 3747603fc0a3Smrg -release RELEASE specify package release information 3748603fc0a3Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 3749603fc0a3Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3750603fc0a3Smrg -shared only do dynamic linking of libtool libraries 3751603fc0a3Smrg -shrext SUFFIX override the standard shared library file extension 3752603fc0a3Smrg -static do not do any dynamic linking of uninstalled libtool libraries 3753603fc0a3Smrg -static-libtool-libs 3754603fc0a3Smrg do not do any dynamic linking of libtool libraries 3755603fc0a3Smrg -version-info CURRENT[:REVISION[:AGE]] 3756603fc0a3Smrg specify library version info [each variable defaults to 0] 3757603fc0a3Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 3758603fc0a3Smrg -Wc,FLAG 3759603fc0a3Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 3760603fc0a3Smrg -Wl,FLAG 3761603fc0a3Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 3762603fc0a3Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3763603fc0a3Smrg 3764603fc0a3SmrgAll other options (arguments beginning with '-') are ignored. 3765603fc0a3Smrg 3766603fc0a3SmrgEvery other argument is treated as a filename. Files ending in '.la' are 3767603fc0a3Smrgtreated as uninstalled libtool libraries, other files are standard or library 3768603fc0a3Smrgobject files. 3769603fc0a3Smrg 3770603fc0a3SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 3771603fc0a3Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 3772603fc0a3Smrgrequired, except when creating a convenience library. 3773603fc0a3Smrg 3774603fc0a3SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 3775603fc0a3Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 3776603fc0a3Smrg 3777603fc0a3SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3778603fc0a3Smrgis created, otherwise an executable program is created." 3779603fc0a3Smrg ;; 3780603fc0a3Smrg 3781603fc0a3Smrg uninstall) 3782603fc0a3Smrg $ECHO \ 3783603fc0a3Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3784603fc0a3Smrg 3785603fc0a3SmrgRemove libraries from an installation directory. 3786603fc0a3Smrg 3787603fc0a3SmrgRM is the name of the program to use to delete files associated with each FILE 3788603fc0a3Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3789603fc0a3Smrgto RM. 3790603fc0a3Smrg 3791603fc0a3SmrgIf FILE is a libtool library, all the files associated with it are deleted. 3792603fc0a3SmrgOtherwise, only FILE itself is deleted using RM." 3793603fc0a3Smrg ;; 3794603fc0a3Smrg 3795603fc0a3Smrg *) 3796603fc0a3Smrg func_fatal_help "invalid operation mode '$opt_mode'" 3797603fc0a3Smrg ;; 3798603fc0a3Smrg esac 3799603fc0a3Smrg 3800603fc0a3Smrg echo 3801603fc0a3Smrg $ECHO "Try '$progname --help' for more information about other modes." 3802603fc0a3Smrg} 3803603fc0a3Smrg 3804603fc0a3Smrg# Now that we've collected a possible --mode arg, show help if necessary 3805603fc0a3Smrgif $opt_help; then 3806603fc0a3Smrg if test : = "$opt_help"; then 3807603fc0a3Smrg func_mode_help 3808603fc0a3Smrg else 3809603fc0a3Smrg { 3810603fc0a3Smrg func_help noexit 3811603fc0a3Smrg for opt_mode in compile link execute install finish uninstall clean; do 3812603fc0a3Smrg func_mode_help 3813603fc0a3Smrg done 3814603fc0a3Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 3815603fc0a3Smrg { 3816603fc0a3Smrg func_help noexit 3817603fc0a3Smrg for opt_mode in compile link execute install finish uninstall clean; do 3818603fc0a3Smrg echo 3819603fc0a3Smrg func_mode_help 3820603fc0a3Smrg done 3821603fc0a3Smrg } | 3822603fc0a3Smrg $SED '1d 3823603fc0a3Smrg /^When reporting/,/^Report/{ 3824603fc0a3Smrg H 3825603fc0a3Smrg d 3826603fc0a3Smrg } 3827603fc0a3Smrg $x 3828603fc0a3Smrg /information about other modes/d 3829603fc0a3Smrg /more detailed .*MODE/d 3830603fc0a3Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 3831603fc0a3Smrg fi 3832603fc0a3Smrg exit $? 3833603fc0a3Smrgfi 3834603fc0a3Smrg 3835603fc0a3Smrg 3836603fc0a3Smrg# func_mode_execute arg... 3837603fc0a3Smrgfunc_mode_execute () 3838603fc0a3Smrg{ 3839603fc0a3Smrg $debug_cmd 3840603fc0a3Smrg 3841603fc0a3Smrg # The first argument is the command name. 3842603fc0a3Smrg cmd=$nonopt 3843603fc0a3Smrg test -z "$cmd" && \ 3844603fc0a3Smrg func_fatal_help "you must specify a COMMAND" 3845603fc0a3Smrg 3846603fc0a3Smrg # Handle -dlopen flags immediately. 3847603fc0a3Smrg for file in $opt_dlopen; do 3848603fc0a3Smrg test -f "$file" \ 3849603fc0a3Smrg || func_fatal_help "'$file' is not a file" 3850603fc0a3Smrg 3851603fc0a3Smrg dir= 3852603fc0a3Smrg case $file in 3853603fc0a3Smrg *.la) 3854603fc0a3Smrg func_resolve_sysroot "$file" 3855603fc0a3Smrg file=$func_resolve_sysroot_result 3856603fc0a3Smrg 3857603fc0a3Smrg # Check to see that this really is a libtool archive. 3858603fc0a3Smrg func_lalib_unsafe_p "$file" \ 3859603fc0a3Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 3860603fc0a3Smrg 3861603fc0a3Smrg # Read the libtool library. 3862603fc0a3Smrg dlname= 3863603fc0a3Smrg library_names= 3864603fc0a3Smrg func_source "$file" 3865603fc0a3Smrg 3866603fc0a3Smrg # Skip this library if it cannot be dlopened. 3867603fc0a3Smrg if test -z "$dlname"; then 3868603fc0a3Smrg # Warn if it was a shared library. 3869603fc0a3Smrg test -n "$library_names" && \ 3870603fc0a3Smrg func_warning "'$file' was not linked with '-export-dynamic'" 3871603fc0a3Smrg continue 3872603fc0a3Smrg fi 3873603fc0a3Smrg 3874603fc0a3Smrg func_dirname "$file" "" "." 3875603fc0a3Smrg dir=$func_dirname_result 3876603fc0a3Smrg 3877603fc0a3Smrg if test -f "$dir/$objdir/$dlname"; then 3878603fc0a3Smrg func_append dir "/$objdir" 3879603fc0a3Smrg else 3880603fc0a3Smrg if test ! -f "$dir/$dlname"; then 3881603fc0a3Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3882603fc0a3Smrg fi 3883603fc0a3Smrg fi 3884603fc0a3Smrg ;; 3885603fc0a3Smrg 3886603fc0a3Smrg *.lo) 3887603fc0a3Smrg # Just add the directory containing the .lo file. 3888603fc0a3Smrg func_dirname "$file" "" "." 3889603fc0a3Smrg dir=$func_dirname_result 3890603fc0a3Smrg ;; 3891603fc0a3Smrg 3892603fc0a3Smrg *) 3893603fc0a3Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3894603fc0a3Smrg continue 3895603fc0a3Smrg ;; 3896603fc0a3Smrg esac 3897603fc0a3Smrg 3898603fc0a3Smrg # Get the absolute pathname. 3899603fc0a3Smrg absdir=`cd "$dir" && pwd` 3900603fc0a3Smrg test -n "$absdir" && dir=$absdir 3901603fc0a3Smrg 3902603fc0a3Smrg # Now add the directory to shlibpath_var. 3903603fc0a3Smrg if eval "test -z \"\$$shlibpath_var\""; then 3904603fc0a3Smrg eval "$shlibpath_var=\"\$dir\"" 3905603fc0a3Smrg else 3906603fc0a3Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3907603fc0a3Smrg fi 3908603fc0a3Smrg done 3909603fc0a3Smrg 3910603fc0a3Smrg # This variable tells wrapper scripts just to set shlibpath_var 3911603fc0a3Smrg # rather than running their programs. 3912603fc0a3Smrg libtool_execute_magic=$magic 3913603fc0a3Smrg 3914603fc0a3Smrg # Check if any of the arguments is a wrapper script. 3915603fc0a3Smrg args= 3916603fc0a3Smrg for file 3917603fc0a3Smrg do 3918603fc0a3Smrg case $file in 3919603fc0a3Smrg -* | *.la | *.lo ) ;; 3920603fc0a3Smrg *) 3921603fc0a3Smrg # Do a test to see if this is really a libtool program. 3922603fc0a3Smrg if func_ltwrapper_script_p "$file"; then 3923603fc0a3Smrg func_source "$file" 3924603fc0a3Smrg # Transform arg to wrapped name. 3925603fc0a3Smrg file=$progdir/$program 3926603fc0a3Smrg elif func_ltwrapper_executable_p "$file"; then 3927603fc0a3Smrg func_ltwrapper_scriptname "$file" 3928603fc0a3Smrg func_source "$func_ltwrapper_scriptname_result" 3929603fc0a3Smrg # Transform arg to wrapped name. 3930603fc0a3Smrg file=$progdir/$program 3931603fc0a3Smrg fi 3932603fc0a3Smrg ;; 3933603fc0a3Smrg esac 3934603fc0a3Smrg # Quote arguments (to preserve shell metacharacters). 3935603fc0a3Smrg func_append_quoted args "$file" 3936603fc0a3Smrg done 3937603fc0a3Smrg 3938603fc0a3Smrg if $opt_dry_run; then 3939603fc0a3Smrg # Display what would be done. 3940603fc0a3Smrg if test -n "$shlibpath_var"; then 3941603fc0a3Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 3942603fc0a3Smrg echo "export $shlibpath_var" 3943603fc0a3Smrg fi 3944603fc0a3Smrg $ECHO "$cmd$args" 3945603fc0a3Smrg exit $EXIT_SUCCESS 3946603fc0a3Smrg else 3947603fc0a3Smrg if test -n "$shlibpath_var"; then 3948603fc0a3Smrg # Export the shlibpath_var. 3949603fc0a3Smrg eval "export $shlibpath_var" 3950603fc0a3Smrg fi 3951603fc0a3Smrg 3952603fc0a3Smrg # Restore saved environment variables 3953603fc0a3Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 3954603fc0a3Smrg do 3955603fc0a3Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 3956603fc0a3Smrg $lt_var=\$save_$lt_var; export $lt_var 3957603fc0a3Smrg else 3958603fc0a3Smrg $lt_unset $lt_var 3959603fc0a3Smrg fi" 3960603fc0a3Smrg done 3961603fc0a3Smrg 3962603fc0a3Smrg # Now prepare to actually exec the command. 3963603fc0a3Smrg exec_cmd=\$cmd$args 3964603fc0a3Smrg fi 3965603fc0a3Smrg} 3966603fc0a3Smrg 3967603fc0a3Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 3968603fc0a3Smrg 3969603fc0a3Smrg 3970603fc0a3Smrg# func_mode_finish arg... 3971603fc0a3Smrgfunc_mode_finish () 3972603fc0a3Smrg{ 3973603fc0a3Smrg $debug_cmd 3974603fc0a3Smrg 3975603fc0a3Smrg libs= 3976603fc0a3Smrg libdirs= 3977603fc0a3Smrg admincmds= 3978603fc0a3Smrg 3979603fc0a3Smrg for opt in "$nonopt" ${1+"$@"} 3980603fc0a3Smrg do 3981603fc0a3Smrg if test -d "$opt"; then 3982603fc0a3Smrg func_append libdirs " $opt" 3983603fc0a3Smrg 3984603fc0a3Smrg elif test -f "$opt"; then 3985603fc0a3Smrg if func_lalib_unsafe_p "$opt"; then 3986603fc0a3Smrg func_append libs " $opt" 3987603fc0a3Smrg else 3988603fc0a3Smrg func_warning "'$opt' is not a valid libtool archive" 3989603fc0a3Smrg fi 3990603fc0a3Smrg 3991603fc0a3Smrg else 3992603fc0a3Smrg func_fatal_error "invalid argument '$opt'" 3993603fc0a3Smrg fi 3994603fc0a3Smrg done 3995603fc0a3Smrg 3996603fc0a3Smrg if test -n "$libs"; then 3997603fc0a3Smrg if test -n "$lt_sysroot"; then 3998603fc0a3Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 3999603fc0a3Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4000603fc0a3Smrg else 4001603fc0a3Smrg sysroot_cmd= 4002603fc0a3Smrg fi 4003603fc0a3Smrg 4004603fc0a3Smrg # Remove sysroot references 4005603fc0a3Smrg if $opt_dry_run; then 4006603fc0a3Smrg for lib in $libs; do 4007603fc0a3Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4008603fc0a3Smrg done 4009603fc0a3Smrg else 4010603fc0a3Smrg tmpdir=`func_mktempdir` 4011603fc0a3Smrg for lib in $libs; do 4012603fc0a3Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4013603fc0a3Smrg > $tmpdir/tmp-la 4014603fc0a3Smrg mv -f $tmpdir/tmp-la $lib 4015603fc0a3Smrg done 4016603fc0a3Smrg ${RM}r "$tmpdir" 4017603fc0a3Smrg fi 4018603fc0a3Smrg fi 4019603fc0a3Smrg 4020603fc0a3Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4021603fc0a3Smrg for libdir in $libdirs; do 4022603fc0a3Smrg if test -n "$finish_cmds"; then 4023603fc0a3Smrg # Do each command in the finish commands. 4024603fc0a3Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4025603fc0a3Smrg'"$cmd"'"' 4026603fc0a3Smrg fi 4027603fc0a3Smrg if test -n "$finish_eval"; then 4028603fc0a3Smrg # Do the single finish_eval. 4029603fc0a3Smrg eval cmds=\"$finish_eval\" 4030603fc0a3Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4031603fc0a3Smrg $cmds" 4032603fc0a3Smrg fi 4033603fc0a3Smrg done 4034603fc0a3Smrg fi 4035603fc0a3Smrg 4036603fc0a3Smrg # Exit here if they wanted silent mode. 4037603fc0a3Smrg $opt_quiet && exit $EXIT_SUCCESS 4038603fc0a3Smrg 4039603fc0a3Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4040603fc0a3Smrg echo "----------------------------------------------------------------------" 4041603fc0a3Smrg echo "Libraries have been installed in:" 4042603fc0a3Smrg for libdir in $libdirs; do 4043603fc0a3Smrg $ECHO " $libdir" 4044603fc0a3Smrg done 4045603fc0a3Smrg echo 4046603fc0a3Smrg echo "If you ever happen to want to link against installed libraries" 4047603fc0a3Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4048603fc0a3Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4049603fc0a3Smrg echo "flag during linking and do at least one of the following:" 4050603fc0a3Smrg if test -n "$shlibpath_var"; then 4051603fc0a3Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4052603fc0a3Smrg echo " during execution" 4053603fc0a3Smrg fi 4054603fc0a3Smrg if test -n "$runpath_var"; then 4055603fc0a3Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4056603fc0a3Smrg echo " during linking" 4057603fc0a3Smrg fi 4058603fc0a3Smrg if test -n "$hardcode_libdir_flag_spec"; then 4059603fc0a3Smrg libdir=LIBDIR 4060603fc0a3Smrg eval flag=\"$hardcode_libdir_flag_spec\" 4061603fc0a3Smrg 4062603fc0a3Smrg $ECHO " - use the '$flag' linker flag" 4063603fc0a3Smrg fi 4064603fc0a3Smrg if test -n "$admincmds"; then 4065603fc0a3Smrg $ECHO " - have your system administrator run these commands:$admincmds" 4066603fc0a3Smrg fi 4067603fc0a3Smrg if test -f /etc/ld.so.conf; then 4068603fc0a3Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4069603fc0a3Smrg fi 4070603fc0a3Smrg echo 4071603fc0a3Smrg 4072603fc0a3Smrg echo "See any operating system documentation about shared libraries for" 4073603fc0a3Smrg case $host in 4074603fc0a3Smrg solaris2.[6789]|solaris2.1[0-9]) 4075603fc0a3Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4076603fc0a3Smrg echo "pages." 4077603fc0a3Smrg ;; 4078603fc0a3Smrg *) 4079603fc0a3Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4080603fc0a3Smrg ;; 4081603fc0a3Smrg esac 4082603fc0a3Smrg echo "----------------------------------------------------------------------" 4083603fc0a3Smrg fi 4084603fc0a3Smrg exit $EXIT_SUCCESS 4085603fc0a3Smrg} 4086603fc0a3Smrg 4087603fc0a3Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4088603fc0a3Smrg 4089603fc0a3Smrg 4090603fc0a3Smrg# func_mode_install arg... 4091603fc0a3Smrgfunc_mode_install () 4092603fc0a3Smrg{ 4093603fc0a3Smrg $debug_cmd 4094603fc0a3Smrg 4095603fc0a3Smrg # There may be an optional sh(1) argument at the beginning of 4096603fc0a3Smrg # install_prog (especially on Windows NT). 4097603fc0a3Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4098603fc0a3Smrg # Allow the use of GNU shtool's install command. 4099603fc0a3Smrg case $nonopt in *shtool*) :;; *) false;; esac 4100603fc0a3Smrg then 4101603fc0a3Smrg # Aesthetically quote it. 4102603fc0a3Smrg func_quote_for_eval "$nonopt" 4103603fc0a3Smrg install_prog="$func_quote_for_eval_result " 4104603fc0a3Smrg arg=$1 4105603fc0a3Smrg shift 4106603fc0a3Smrg else 4107603fc0a3Smrg install_prog= 4108603fc0a3Smrg arg=$nonopt 4109603fc0a3Smrg fi 4110603fc0a3Smrg 4111603fc0a3Smrg # The real first argument should be the name of the installation program. 4112603fc0a3Smrg # Aesthetically quote it. 4113603fc0a3Smrg func_quote_for_eval "$arg" 4114603fc0a3Smrg func_append install_prog "$func_quote_for_eval_result" 4115603fc0a3Smrg install_shared_prog=$install_prog 4116603fc0a3Smrg case " $install_prog " in 4117603fc0a3Smrg *[\\\ /]cp\ *) install_cp=: ;; 4118603fc0a3Smrg *) install_cp=false ;; 4119603fc0a3Smrg esac 4120603fc0a3Smrg 4121603fc0a3Smrg # We need to accept at least all the BSD install flags. 4122603fc0a3Smrg dest= 4123603fc0a3Smrg files= 4124603fc0a3Smrg opts= 4125603fc0a3Smrg prev= 4126603fc0a3Smrg install_type= 4127603fc0a3Smrg isdir=false 4128603fc0a3Smrg stripme= 4129603fc0a3Smrg no_mode=: 4130603fc0a3Smrg for arg 4131603fc0a3Smrg do 4132603fc0a3Smrg arg2= 4133603fc0a3Smrg if test -n "$dest"; then 4134603fc0a3Smrg func_append files " $dest" 4135603fc0a3Smrg dest=$arg 4136603fc0a3Smrg continue 4137603fc0a3Smrg fi 4138603fc0a3Smrg 4139603fc0a3Smrg case $arg in 4140603fc0a3Smrg -d) isdir=: ;; 4141603fc0a3Smrg -f) 4142603fc0a3Smrg if $install_cp; then :; else 4143603fc0a3Smrg prev=$arg 4144603fc0a3Smrg fi 4145603fc0a3Smrg ;; 4146603fc0a3Smrg -g | -m | -o) 4147603fc0a3Smrg prev=$arg 4148603fc0a3Smrg ;; 4149603fc0a3Smrg -s) 4150603fc0a3Smrg stripme=" -s" 4151603fc0a3Smrg continue 4152603fc0a3Smrg ;; 4153603fc0a3Smrg -*) 4154603fc0a3Smrg ;; 4155603fc0a3Smrg *) 4156603fc0a3Smrg # If the previous option needed an argument, then skip it. 4157603fc0a3Smrg if test -n "$prev"; then 4158603fc0a3Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4159603fc0a3Smrg arg2=$install_override_mode 4160603fc0a3Smrg no_mode=false 4161603fc0a3Smrg fi 4162603fc0a3Smrg prev= 4163603fc0a3Smrg else 4164603fc0a3Smrg dest=$arg 4165603fc0a3Smrg continue 4166603fc0a3Smrg fi 4167603fc0a3Smrg ;; 4168603fc0a3Smrg esac 4169603fc0a3Smrg 4170603fc0a3Smrg # Aesthetically quote the argument. 4171603fc0a3Smrg func_quote_for_eval "$arg" 4172603fc0a3Smrg func_append install_prog " $func_quote_for_eval_result" 4173603fc0a3Smrg if test -n "$arg2"; then 4174603fc0a3Smrg func_quote_for_eval "$arg2" 4175603fc0a3Smrg fi 4176603fc0a3Smrg func_append install_shared_prog " $func_quote_for_eval_result" 4177603fc0a3Smrg done 4178603fc0a3Smrg 4179603fc0a3Smrg test -z "$install_prog" && \ 4180603fc0a3Smrg func_fatal_help "you must specify an install program" 4181603fc0a3Smrg 4182603fc0a3Smrg test -n "$prev" && \ 4183603fc0a3Smrg func_fatal_help "the '$prev' option requires an argument" 4184603fc0a3Smrg 4185603fc0a3Smrg if test -n "$install_override_mode" && $no_mode; then 4186603fc0a3Smrg if $install_cp; then :; else 4187603fc0a3Smrg func_quote_for_eval "$install_override_mode" 4188603fc0a3Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 4189603fc0a3Smrg fi 4190603fc0a3Smrg fi 4191603fc0a3Smrg 4192603fc0a3Smrg if test -z "$files"; then 4193603fc0a3Smrg if test -z "$dest"; then 4194603fc0a3Smrg func_fatal_help "no file or destination specified" 4195603fc0a3Smrg else 4196603fc0a3Smrg func_fatal_help "you must specify a destination" 4197603fc0a3Smrg fi 4198603fc0a3Smrg fi 4199603fc0a3Smrg 4200603fc0a3Smrg # Strip any trailing slash from the destination. 4201603fc0a3Smrg func_stripname '' '/' "$dest" 4202603fc0a3Smrg dest=$func_stripname_result 4203603fc0a3Smrg 4204603fc0a3Smrg # Check to see that the destination is a directory. 4205603fc0a3Smrg test -d "$dest" && isdir=: 4206603fc0a3Smrg if $isdir; then 4207603fc0a3Smrg destdir=$dest 4208603fc0a3Smrg destname= 4209603fc0a3Smrg else 4210603fc0a3Smrg func_dirname_and_basename "$dest" "" "." 4211603fc0a3Smrg destdir=$func_dirname_result 4212603fc0a3Smrg destname=$func_basename_result 4213603fc0a3Smrg 4214603fc0a3Smrg # Not a directory, so check to see that there is only one file specified. 4215603fc0a3Smrg set dummy $files; shift 4216603fc0a3Smrg test "$#" -gt 1 && \ 4217603fc0a3Smrg func_fatal_help "'$dest' is not a directory" 4218603fc0a3Smrg fi 4219603fc0a3Smrg case $destdir in 4220603fc0a3Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4221603fc0a3Smrg *) 4222603fc0a3Smrg for file in $files; do 4223603fc0a3Smrg case $file in 4224603fc0a3Smrg *.lo) ;; 4225603fc0a3Smrg *) 4226603fc0a3Smrg func_fatal_help "'$destdir' must be an absolute directory name" 4227603fc0a3Smrg ;; 4228603fc0a3Smrg esac 4229603fc0a3Smrg done 4230603fc0a3Smrg ;; 4231603fc0a3Smrg esac 4232603fc0a3Smrg 4233603fc0a3Smrg # This variable tells wrapper scripts just to set variables rather 4234603fc0a3Smrg # than running their programs. 4235603fc0a3Smrg libtool_install_magic=$magic 4236603fc0a3Smrg 4237603fc0a3Smrg staticlibs= 4238603fc0a3Smrg future_libdirs= 4239603fc0a3Smrg current_libdirs= 4240603fc0a3Smrg for file in $files; do 4241603fc0a3Smrg 4242603fc0a3Smrg # Do each installation. 4243603fc0a3Smrg case $file in 4244603fc0a3Smrg *.$libext) 4245603fc0a3Smrg # Do the static libraries later. 4246603fc0a3Smrg func_append staticlibs " $file" 4247603fc0a3Smrg ;; 4248603fc0a3Smrg 4249603fc0a3Smrg *.la) 4250603fc0a3Smrg func_resolve_sysroot "$file" 4251603fc0a3Smrg file=$func_resolve_sysroot_result 4252603fc0a3Smrg 4253603fc0a3Smrg # Check to see that this really is a libtool archive. 4254603fc0a3Smrg func_lalib_unsafe_p "$file" \ 4255603fc0a3Smrg || func_fatal_help "'$file' is not a valid libtool archive" 4256603fc0a3Smrg 4257603fc0a3Smrg library_names= 4258603fc0a3Smrg old_library= 4259603fc0a3Smrg relink_command= 4260603fc0a3Smrg func_source "$file" 4261603fc0a3Smrg 4262603fc0a3Smrg # Add the libdir to current_libdirs if it is the destination. 4263603fc0a3Smrg if test "X$destdir" = "X$libdir"; then 4264603fc0a3Smrg case "$current_libdirs " in 4265603fc0a3Smrg *" $libdir "*) ;; 4266603fc0a3Smrg *) func_append current_libdirs " $libdir" ;; 4267603fc0a3Smrg esac 4268603fc0a3Smrg else 4269603fc0a3Smrg # Note the libdir as a future libdir. 4270603fc0a3Smrg case "$future_libdirs " in 4271603fc0a3Smrg *" $libdir "*) ;; 4272603fc0a3Smrg *) func_append future_libdirs " $libdir" ;; 4273603fc0a3Smrg esac 4274603fc0a3Smrg fi 4275603fc0a3Smrg 4276603fc0a3Smrg func_dirname "$file" "/" "" 4277603fc0a3Smrg dir=$func_dirname_result 4278603fc0a3Smrg func_append dir "$objdir" 4279603fc0a3Smrg 4280603fc0a3Smrg if test -n "$relink_command"; then 4281603fc0a3Smrg # Determine the prefix the user has applied to our future dir. 4282603fc0a3Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4283603fc0a3Smrg 4284603fc0a3Smrg # Don't allow the user to place us outside of our expected 4285603fc0a3Smrg # location b/c this prevents finding dependent libraries that 4286603fc0a3Smrg # are installed to the same prefix. 4287603fc0a3Smrg # At present, this check doesn't affect windows .dll's that 4288603fc0a3Smrg # are installed into $libdir/../bin (currently, that works fine) 4289603fc0a3Smrg # but it's something to keep an eye on. 4290603fc0a3Smrg test "$inst_prefix_dir" = "$destdir" && \ 4291603fc0a3Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4292603fc0a3Smrg 4293603fc0a3Smrg if test -n "$inst_prefix_dir"; then 4294603fc0a3Smrg # Stick the inst_prefix_dir data into the link command. 4295603fc0a3Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4296603fc0a3Smrg else 4297603fc0a3Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4298603fc0a3Smrg fi 4299603fc0a3Smrg 4300603fc0a3Smrg func_warning "relinking '$file'" 4301603fc0a3Smrg func_show_eval "$relink_command" \ 4302603fc0a3Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4303603fc0a3Smrg fi 4304603fc0a3Smrg 4305603fc0a3Smrg # See the names of the shared library. 4306603fc0a3Smrg set dummy $library_names; shift 4307603fc0a3Smrg if test -n "$1"; then 4308603fc0a3Smrg realname=$1 4309603fc0a3Smrg shift 4310603fc0a3Smrg 4311603fc0a3Smrg srcname=$realname 4312603fc0a3Smrg test -n "$relink_command" && srcname=${realname}T 4313603fc0a3Smrg 4314603fc0a3Smrg # Install the shared library and build the symlinks. 4315603fc0a3Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4316603fc0a3Smrg 'exit $?' 4317603fc0a3Smrg tstripme=$stripme 4318603fc0a3Smrg case $host_os in 4319603fc0a3Smrg cygwin* | mingw* | pw32* | cegcc*) 4320603fc0a3Smrg case $realname in 4321603fc0a3Smrg *.dll.a) 4322603fc0a3Smrg tstripme= 4323603fc0a3Smrg ;; 4324603fc0a3Smrg esac 4325603fc0a3Smrg ;; 4326603fc0a3Smrg os2*) 4327603fc0a3Smrg case $realname in 4328603fc0a3Smrg *_dll.a) 4329603fc0a3Smrg tstripme= 4330603fc0a3Smrg ;; 4331603fc0a3Smrg esac 4332603fc0a3Smrg ;; 4333603fc0a3Smrg esac 4334603fc0a3Smrg if test -n "$tstripme" && test -n "$striplib"; then 4335603fc0a3Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4336603fc0a3Smrg fi 4337603fc0a3Smrg 4338603fc0a3Smrg if test "$#" -gt 0; then 4339603fc0a3Smrg # Delete the old symlinks, and create new ones. 4340603fc0a3Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4341603fc0a3Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4342603fc0a3Smrg # so we also need to try rm && ln -s. 4343603fc0a3Smrg for linkname 4344603fc0a3Smrg do 4345603fc0a3Smrg test "$linkname" != "$realname" \ 4346603fc0a3Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4347603fc0a3Smrg done 4348603fc0a3Smrg fi 4349603fc0a3Smrg 4350603fc0a3Smrg # Do each command in the postinstall commands. 4351603fc0a3Smrg lib=$destdir/$realname 4352603fc0a3Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4353603fc0a3Smrg fi 4354603fc0a3Smrg 4355603fc0a3Smrg # Install the pseudo-library for information purposes. 4356603fc0a3Smrg func_basename "$file" 4357603fc0a3Smrg name=$func_basename_result 4358603fc0a3Smrg instname=$dir/${name}i 4359603fc0a3Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4360603fc0a3Smrg 4361603fc0a3Smrg # Maybe install the static library, too. 4362603fc0a3Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4363603fc0a3Smrg ;; 4364603fc0a3Smrg 4365603fc0a3Smrg *.lo) 4366603fc0a3Smrg # Install (i.e. copy) a libtool object. 4367603fc0a3Smrg 4368603fc0a3Smrg # Figure out destination file name, if it wasn't already specified. 4369603fc0a3Smrg if test -n "$destname"; then 4370603fc0a3Smrg destfile=$destdir/$destname 4371603fc0a3Smrg else 4372603fc0a3Smrg func_basename "$file" 4373603fc0a3Smrg destfile=$func_basename_result 4374603fc0a3Smrg destfile=$destdir/$destfile 4375603fc0a3Smrg fi 4376603fc0a3Smrg 4377603fc0a3Smrg # Deduce the name of the destination old-style object file. 4378603fc0a3Smrg case $destfile in 4379603fc0a3Smrg *.lo) 4380603fc0a3Smrg func_lo2o "$destfile" 4381603fc0a3Smrg staticdest=$func_lo2o_result 4382603fc0a3Smrg ;; 4383603fc0a3Smrg *.$objext) 4384603fc0a3Smrg staticdest=$destfile 4385603fc0a3Smrg destfile= 4386603fc0a3Smrg ;; 4387603fc0a3Smrg *) 4388603fc0a3Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4389603fc0a3Smrg ;; 4390603fc0a3Smrg esac 4391603fc0a3Smrg 4392603fc0a3Smrg # Install the libtool object if requested. 4393603fc0a3Smrg test -n "$destfile" && \ 4394603fc0a3Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4395603fc0a3Smrg 4396603fc0a3Smrg # Install the old object if enabled. 4397603fc0a3Smrg if test yes = "$build_old_libs"; then 4398603fc0a3Smrg # Deduce the name of the old-style object file. 4399603fc0a3Smrg func_lo2o "$file" 4400603fc0a3Smrg staticobj=$func_lo2o_result 4401603fc0a3Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4402603fc0a3Smrg fi 4403603fc0a3Smrg exit $EXIT_SUCCESS 4404603fc0a3Smrg ;; 4405603fc0a3Smrg 4406603fc0a3Smrg *) 4407603fc0a3Smrg # Figure out destination file name, if it wasn't already specified. 4408603fc0a3Smrg if test -n "$destname"; then 4409603fc0a3Smrg destfile=$destdir/$destname 4410603fc0a3Smrg else 4411603fc0a3Smrg func_basename "$file" 4412603fc0a3Smrg destfile=$func_basename_result 4413603fc0a3Smrg destfile=$destdir/$destfile 4414603fc0a3Smrg fi 4415603fc0a3Smrg 4416603fc0a3Smrg # If the file is missing, and there is a .exe on the end, strip it 4417603fc0a3Smrg # because it is most likely a libtool script we actually want to 4418603fc0a3Smrg # install 4419603fc0a3Smrg stripped_ext= 4420603fc0a3Smrg case $file in 4421603fc0a3Smrg *.exe) 4422603fc0a3Smrg if test ! -f "$file"; then 4423603fc0a3Smrg func_stripname '' '.exe' "$file" 4424603fc0a3Smrg file=$func_stripname_result 4425603fc0a3Smrg stripped_ext=.exe 4426603fc0a3Smrg fi 4427603fc0a3Smrg ;; 4428603fc0a3Smrg esac 4429603fc0a3Smrg 4430603fc0a3Smrg # Do a test to see if this is really a libtool program. 4431603fc0a3Smrg case $host in 4432603fc0a3Smrg *cygwin* | *mingw*) 4433603fc0a3Smrg if func_ltwrapper_executable_p "$file"; then 4434603fc0a3Smrg func_ltwrapper_scriptname "$file" 4435603fc0a3Smrg wrapper=$func_ltwrapper_scriptname_result 4436603fc0a3Smrg else 4437603fc0a3Smrg func_stripname '' '.exe' "$file" 4438603fc0a3Smrg wrapper=$func_stripname_result 4439603fc0a3Smrg fi 4440603fc0a3Smrg ;; 4441603fc0a3Smrg *) 4442603fc0a3Smrg wrapper=$file 4443603fc0a3Smrg ;; 4444603fc0a3Smrg esac 4445603fc0a3Smrg if func_ltwrapper_script_p "$wrapper"; then 4446603fc0a3Smrg notinst_deplibs= 4447603fc0a3Smrg relink_command= 4448603fc0a3Smrg 4449603fc0a3Smrg func_source "$wrapper" 4450603fc0a3Smrg 4451603fc0a3Smrg # Check the variables that should have been set. 4452603fc0a3Smrg test -z "$generated_by_libtool_version" && \ 4453603fc0a3Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4454603fc0a3Smrg 4455603fc0a3Smrg finalize=: 4456603fc0a3Smrg for lib in $notinst_deplibs; do 4457603fc0a3Smrg # Check to see that each library is installed. 4458603fc0a3Smrg libdir= 4459603fc0a3Smrg if test -f "$lib"; then 4460603fc0a3Smrg func_source "$lib" 4461603fc0a3Smrg fi 4462603fc0a3Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4463603fc0a3Smrg if test -n "$libdir" && test ! -f "$libfile"; then 4464603fc0a3Smrg func_warning "'$lib' has not been installed in '$libdir'" 4465603fc0a3Smrg finalize=false 4466603fc0a3Smrg fi 4467603fc0a3Smrg done 4468603fc0a3Smrg 4469603fc0a3Smrg relink_command= 4470603fc0a3Smrg func_source "$wrapper" 4471603fc0a3Smrg 4472603fc0a3Smrg outputname= 4473603fc0a3Smrg if test no = "$fast_install" && test -n "$relink_command"; then 4474603fc0a3Smrg $opt_dry_run || { 4475603fc0a3Smrg if $finalize; then 4476603fc0a3Smrg tmpdir=`func_mktempdir` 4477603fc0a3Smrg func_basename "$file$stripped_ext" 4478603fc0a3Smrg file=$func_basename_result 4479603fc0a3Smrg outputname=$tmpdir/$file 4480603fc0a3Smrg # Replace the output file specification. 4481603fc0a3Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4482603fc0a3Smrg 4483603fc0a3Smrg $opt_quiet || { 4484603fc0a3Smrg func_quote_for_expand "$relink_command" 4485603fc0a3Smrg eval "func_echo $func_quote_for_expand_result" 4486603fc0a3Smrg } 4487603fc0a3Smrg if eval "$relink_command"; then : 4488603fc0a3Smrg else 4489603fc0a3Smrg func_error "error: relink '$file' with the above command before installing it" 4490603fc0a3Smrg $opt_dry_run || ${RM}r "$tmpdir" 4491603fc0a3Smrg continue 4492603fc0a3Smrg fi 4493603fc0a3Smrg file=$outputname 4494603fc0a3Smrg else 4495603fc0a3Smrg func_warning "cannot relink '$file'" 4496603fc0a3Smrg fi 4497603fc0a3Smrg } 4498603fc0a3Smrg else 4499603fc0a3Smrg # Install the binary that we compiled earlier. 4500603fc0a3Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4501603fc0a3Smrg fi 4502603fc0a3Smrg fi 4503603fc0a3Smrg 4504603fc0a3Smrg # remove .exe since cygwin /usr/bin/install will append another 4505603fc0a3Smrg # one anyway 4506603fc0a3Smrg case $install_prog,$host in 4507603fc0a3Smrg */usr/bin/install*,*cygwin*) 4508603fc0a3Smrg case $file:$destfile in 4509603fc0a3Smrg *.exe:*.exe) 4510603fc0a3Smrg # this is ok 4511603fc0a3Smrg ;; 4512603fc0a3Smrg *.exe:*) 4513603fc0a3Smrg destfile=$destfile.exe 4514603fc0a3Smrg ;; 4515603fc0a3Smrg *:*.exe) 4516603fc0a3Smrg func_stripname '' '.exe' "$destfile" 4517603fc0a3Smrg destfile=$func_stripname_result 4518603fc0a3Smrg ;; 4519603fc0a3Smrg esac 4520603fc0a3Smrg ;; 4521603fc0a3Smrg esac 4522603fc0a3Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4523603fc0a3Smrg $opt_dry_run || if test -n "$outputname"; then 4524603fc0a3Smrg ${RM}r "$tmpdir" 4525603fc0a3Smrg fi 4526603fc0a3Smrg ;; 4527603fc0a3Smrg esac 4528603fc0a3Smrg done 4529603fc0a3Smrg 4530603fc0a3Smrg for file in $staticlibs; do 4531603fc0a3Smrg func_basename "$file" 4532603fc0a3Smrg name=$func_basename_result 4533603fc0a3Smrg 4534603fc0a3Smrg # Set up the ranlib parameters. 4535603fc0a3Smrg oldlib=$destdir/$name 4536603fc0a3Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4537603fc0a3Smrg tool_oldlib=$func_to_tool_file_result 4538603fc0a3Smrg 4539603fc0a3Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4540603fc0a3Smrg 4541603fc0a3Smrg if test -n "$stripme" && test -n "$old_striplib"; then 4542603fc0a3Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4543603fc0a3Smrg fi 4544603fc0a3Smrg 4545603fc0a3Smrg # Do each command in the postinstall commands. 4546603fc0a3Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4547603fc0a3Smrg done 4548603fc0a3Smrg 4549603fc0a3Smrg test -n "$future_libdirs" && \ 4550603fc0a3Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 4551603fc0a3Smrg 4552603fc0a3Smrg if test -n "$current_libdirs"; then 4553603fc0a3Smrg # Maybe just do a dry run. 4554603fc0a3Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4555603fc0a3Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4556603fc0a3Smrg else 4557603fc0a3Smrg exit $EXIT_SUCCESS 4558603fc0a3Smrg fi 4559603fc0a3Smrg} 4560603fc0a3Smrg 4561603fc0a3Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4562603fc0a3Smrg 4563603fc0a3Smrg 4564603fc0a3Smrg# func_generate_dlsyms outputname originator pic_p 4565603fc0a3Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4566603fc0a3Smrg# a dlpreopen symbol table. 4567603fc0a3Smrgfunc_generate_dlsyms () 4568603fc0a3Smrg{ 4569603fc0a3Smrg $debug_cmd 4570603fc0a3Smrg 4571603fc0a3Smrg my_outputname=$1 4572603fc0a3Smrg my_originator=$2 4573603fc0a3Smrg my_pic_p=${3-false} 4574603fc0a3Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4575603fc0a3Smrg my_dlsyms= 4576603fc0a3Smrg 4577603fc0a3Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4578603fc0a3Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4579603fc0a3Smrg my_dlsyms=${my_outputname}S.c 4580603fc0a3Smrg else 4581603fc0a3Smrg func_error "not configured to extract global symbols from dlpreopened files" 4582603fc0a3Smrg fi 4583603fc0a3Smrg fi 4584603fc0a3Smrg 4585603fc0a3Smrg if test -n "$my_dlsyms"; then 4586603fc0a3Smrg case $my_dlsyms in 4587603fc0a3Smrg "") ;; 4588603fc0a3Smrg *.c) 4589603fc0a3Smrg # Discover the nlist of each of the dlfiles. 4590603fc0a3Smrg nlist=$output_objdir/$my_outputname.nm 4591603fc0a3Smrg 4592603fc0a3Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4593603fc0a3Smrg 4594603fc0a3Smrg # Parse the name list into a source file. 4595603fc0a3Smrg func_verbose "creating $output_objdir/$my_dlsyms" 4596603fc0a3Smrg 4597603fc0a3Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4598603fc0a3Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4599603fc0a3Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4600603fc0a3Smrg 4601603fc0a3Smrg#ifdef __cplusplus 4602603fc0a3Smrgextern \"C\" { 4603603fc0a3Smrg#endif 4604603fc0a3Smrg 4605603fc0a3Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4606603fc0a3Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4607603fc0a3Smrg#endif 4608603fc0a3Smrg 4609603fc0a3Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4610603fc0a3Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4611603fc0a3Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4612603fc0a3Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4613603fc0a3Smrg# define LT_DLSYM_CONST 4614603fc0a3Smrg#elif defined __osf__ 4615603fc0a3Smrg/* This system does not cope well with relocations in const data. */ 4616603fc0a3Smrg# define LT_DLSYM_CONST 4617603fc0a3Smrg#else 4618603fc0a3Smrg# define LT_DLSYM_CONST const 4619603fc0a3Smrg#endif 4620603fc0a3Smrg 4621603fc0a3Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4622603fc0a3Smrg 4623603fc0a3Smrg/* External symbol declarations for the compiler. */\ 4624603fc0a3Smrg" 4625603fc0a3Smrg 4626603fc0a3Smrg if test yes = "$dlself"; then 4627603fc0a3Smrg func_verbose "generating symbol list for '$output'" 4628603fc0a3Smrg 4629603fc0a3Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4630603fc0a3Smrg 4631603fc0a3Smrg # Add our own program objects to the symbol list. 4632603fc0a3Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4633603fc0a3Smrg for progfile in $progfiles; do 4634603fc0a3Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4635603fc0a3Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4636603fc0a3Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4637603fc0a3Smrg done 4638603fc0a3Smrg 4639603fc0a3Smrg if test -n "$exclude_expsyms"; then 4640603fc0a3Smrg $opt_dry_run || { 4641603fc0a3Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4642603fc0a3Smrg eval '$MV "$nlist"T "$nlist"' 4643603fc0a3Smrg } 4644603fc0a3Smrg fi 4645603fc0a3Smrg 4646603fc0a3Smrg if test -n "$export_symbols_regex"; then 4647603fc0a3Smrg $opt_dry_run || { 4648603fc0a3Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4649603fc0a3Smrg eval '$MV "$nlist"T "$nlist"' 4650603fc0a3Smrg } 4651603fc0a3Smrg fi 4652603fc0a3Smrg 4653603fc0a3Smrg # Prepare the list of exported symbols 4654603fc0a3Smrg if test -z "$export_symbols"; then 4655603fc0a3Smrg export_symbols=$output_objdir/$outputname.exp 4656603fc0a3Smrg $opt_dry_run || { 4657603fc0a3Smrg $RM $export_symbols 4658603fc0a3Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4659603fc0a3Smrg case $host in 4660603fc0a3Smrg *cygwin* | *mingw* | *cegcc* ) 4661603fc0a3Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4662603fc0a3Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4663603fc0a3Smrg ;; 4664603fc0a3Smrg esac 4665603fc0a3Smrg } 4666603fc0a3Smrg else 4667603fc0a3Smrg $opt_dry_run || { 4668603fc0a3Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4669603fc0a3Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4670603fc0a3Smrg eval '$MV "$nlist"T "$nlist"' 4671603fc0a3Smrg case $host in 4672603fc0a3Smrg *cygwin* | *mingw* | *cegcc* ) 4673603fc0a3Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4674603fc0a3Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4675603fc0a3Smrg ;; 4676603fc0a3Smrg esac 4677603fc0a3Smrg } 4678603fc0a3Smrg fi 4679603fc0a3Smrg fi 4680603fc0a3Smrg 4681603fc0a3Smrg for dlprefile in $dlprefiles; do 4682603fc0a3Smrg func_verbose "extracting global C symbols from '$dlprefile'" 4683603fc0a3Smrg func_basename "$dlprefile" 4684603fc0a3Smrg name=$func_basename_result 4685603fc0a3Smrg case $host in 4686603fc0a3Smrg *cygwin* | *mingw* | *cegcc* ) 4687603fc0a3Smrg # if an import library, we need to obtain dlname 4688603fc0a3Smrg if func_win32_import_lib_p "$dlprefile"; then 4689603fc0a3Smrg func_tr_sh "$dlprefile" 4690603fc0a3Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4691603fc0a3Smrg dlprefile_dlbasename= 4692603fc0a3Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4693603fc0a3Smrg # Use subshell, to avoid clobbering current variable values 4694603fc0a3Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4695603fc0a3Smrg if test -n "$dlprefile_dlname"; then 4696603fc0a3Smrg func_basename "$dlprefile_dlname" 4697603fc0a3Smrg dlprefile_dlbasename=$func_basename_result 4698603fc0a3Smrg else 4699603fc0a3Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 4700603fc0a3Smrg $sharedlib_from_linklib_cmd "$dlprefile" 4701603fc0a3Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4702603fc0a3Smrg fi 4703603fc0a3Smrg fi 4704603fc0a3Smrg $opt_dry_run || { 4705603fc0a3Smrg if test -n "$dlprefile_dlbasename"; then 4706603fc0a3Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4707603fc0a3Smrg else 4708603fc0a3Smrg func_warning "Could not compute DLL name from $name" 4709603fc0a3Smrg eval '$ECHO ": $name " >> "$nlist"' 4710603fc0a3Smrg fi 4711603fc0a3Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4712603fc0a3Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4713603fc0a3Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4714603fc0a3Smrg } 4715603fc0a3Smrg else # not an import lib 4716603fc0a3Smrg $opt_dry_run || { 4717603fc0a3Smrg eval '$ECHO ": $name " >> "$nlist"' 4718603fc0a3Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4719603fc0a3Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4720603fc0a3Smrg } 4721603fc0a3Smrg fi 4722603fc0a3Smrg ;; 4723603fc0a3Smrg *) 4724603fc0a3Smrg $opt_dry_run || { 4725603fc0a3Smrg eval '$ECHO ": $name " >> "$nlist"' 4726603fc0a3Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4727603fc0a3Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4728603fc0a3Smrg } 4729603fc0a3Smrg ;; 4730603fc0a3Smrg esac 4731603fc0a3Smrg done 4732603fc0a3Smrg 4733603fc0a3Smrg $opt_dry_run || { 4734603fc0a3Smrg # Make sure we have at least an empty file. 4735603fc0a3Smrg test -f "$nlist" || : > "$nlist" 4736603fc0a3Smrg 4737603fc0a3Smrg if test -n "$exclude_expsyms"; then 4738603fc0a3Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4739603fc0a3Smrg $MV "$nlist"T "$nlist" 4740603fc0a3Smrg fi 4741603fc0a3Smrg 4742603fc0a3Smrg # Try sorting and uniquifying the output. 4743603fc0a3Smrg if $GREP -v "^: " < "$nlist" | 4744603fc0a3Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4745603fc0a3Smrg sort -k 3 4746603fc0a3Smrg else 4747603fc0a3Smrg sort +2 4748603fc0a3Smrg fi | 4749603fc0a3Smrg uniq > "$nlist"S; then 4750603fc0a3Smrg : 4751603fc0a3Smrg else 4752603fc0a3Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 4753603fc0a3Smrg fi 4754603fc0a3Smrg 4755603fc0a3Smrg if test -f "$nlist"S; then 4756603fc0a3Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4757603fc0a3Smrg else 4758603fc0a3Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4759603fc0a3Smrg fi 4760603fc0a3Smrg 4761603fc0a3Smrg func_show_eval '$RM "${nlist}I"' 4762603fc0a3Smrg if test -n "$global_symbol_to_import"; then 4763603fc0a3Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 4764603fc0a3Smrg fi 4765603fc0a3Smrg 4766603fc0a3Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4767603fc0a3Smrg 4768603fc0a3Smrg/* The mapping between symbol names and symbols. */ 4769603fc0a3Smrgtypedef struct { 4770603fc0a3Smrg const char *name; 4771603fc0a3Smrg void *address; 4772603fc0a3Smrg} lt_dlsymlist; 4773603fc0a3Smrgextern LT_DLSYM_CONST lt_dlsymlist 4774603fc0a3Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 4775603fc0a3Smrg" 4776603fc0a3Smrg 4777603fc0a3Smrg if test -s "$nlist"I; then 4778603fc0a3Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4779603fc0a3Smrgstatic void lt_syminit(void) 4780603fc0a3Smrg{ 4781603fc0a3Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 4782603fc0a3Smrg for (; symbol->name; ++symbol) 4783603fc0a3Smrg {" 4784603fc0a3Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 4785603fc0a3Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4786603fc0a3Smrg } 4787603fc0a3Smrg}" 4788603fc0a3Smrg fi 4789603fc0a3Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4790603fc0a3SmrgLT_DLSYM_CONST lt_dlsymlist 4791603fc0a3Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 4792603fc0a3Smrg{ {\"$my_originator\", (void *) 0}," 4793603fc0a3Smrg 4794603fc0a3Smrg if test -s "$nlist"I; then 4795603fc0a3Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4796603fc0a3Smrg {\"@INIT@\", (void *) <_syminit}," 4797603fc0a3Smrg fi 4798603fc0a3Smrg 4799603fc0a3Smrg case $need_lib_prefix in 4800603fc0a3Smrg no) 4801603fc0a3Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4802603fc0a3Smrg ;; 4803603fc0a3Smrg *) 4804603fc0a3Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4805603fc0a3Smrg ;; 4806603fc0a3Smrg esac 4807603fc0a3Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4808603fc0a3Smrg {0, (void *) 0} 4809603fc0a3Smrg}; 4810603fc0a3Smrg 4811603fc0a3Smrg/* This works around a problem in FreeBSD linker */ 4812603fc0a3Smrg#ifdef FREEBSD_WORKAROUND 4813603fc0a3Smrgstatic const void *lt_preloaded_setup() { 4814603fc0a3Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 4815603fc0a3Smrg} 4816603fc0a3Smrg#endif 4817603fc0a3Smrg 4818603fc0a3Smrg#ifdef __cplusplus 4819603fc0a3Smrg} 4820603fc0a3Smrg#endif\ 4821603fc0a3Smrg" 4822603fc0a3Smrg } # !$opt_dry_run 4823603fc0a3Smrg 4824603fc0a3Smrg pic_flag_for_symtable= 4825603fc0a3Smrg case "$compile_command " in 4826603fc0a3Smrg *" -static "*) ;; 4827603fc0a3Smrg *) 4828603fc0a3Smrg case $host in 4829603fc0a3Smrg # compiling the symbol table file with pic_flag works around 4830603fc0a3Smrg # a FreeBSD bug that causes programs to crash when -lm is 4831603fc0a3Smrg # linked before any other PIC object. But we must not use 4832603fc0a3Smrg # pic_flag when linking with -static. The problem exists in 4833603fc0a3Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4834603fc0a3Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4835603fc0a3Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4836603fc0a3Smrg *-*-hpux*) 4837603fc0a3Smrg pic_flag_for_symtable=" $pic_flag" ;; 4838603fc0a3Smrg *) 4839603fc0a3Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4840603fc0a3Smrg ;; 4841603fc0a3Smrg esac 4842603fc0a3Smrg ;; 4843603fc0a3Smrg esac 4844603fc0a3Smrg symtab_cflags= 4845603fc0a3Smrg for arg in $LTCFLAGS; do 4846603fc0a3Smrg case $arg in 4847603fc0a3Smrg -pie | -fpie | -fPIE) ;; 4848603fc0a3Smrg *) func_append symtab_cflags " $arg" ;; 4849603fc0a3Smrg esac 4850603fc0a3Smrg done 4851603fc0a3Smrg 4852603fc0a3Smrg # Now compile the dynamic symbol file. 4853603fc0a3Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4854603fc0a3Smrg 4855603fc0a3Smrg # Clean up the generated files. 4856603fc0a3Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4857603fc0a3Smrg 4858603fc0a3Smrg # Transform the symbol file into the correct name. 4859603fc0a3Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 4860603fc0a3Smrg case $host in 4861603fc0a3Smrg *cygwin* | *mingw* | *cegcc* ) 4862603fc0a3Smrg if test -f "$output_objdir/$my_outputname.def"; then 4863603fc0a3Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4864603fc0a3Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4865603fc0a3Smrg else 4866603fc0a3Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4867603fc0a3Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4868603fc0a3Smrg fi 4869603fc0a3Smrg ;; 4870603fc0a3Smrg *) 4871603fc0a3Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4872603fc0a3Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4873603fc0a3Smrg ;; 4874603fc0a3Smrg esac 4875603fc0a3Smrg ;; 4876603fc0a3Smrg *) 4877603fc0a3Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 4878603fc0a3Smrg ;; 4879603fc0a3Smrg esac 4880603fc0a3Smrg else 4881603fc0a3Smrg # We keep going just in case the user didn't refer to 4882603fc0a3Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4883603fc0a3Smrg # really was required. 4884603fc0a3Smrg 4885603fc0a3Smrg # Nullify the symbol file. 4886603fc0a3Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 4887603fc0a3Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4888603fc0a3Smrg fi 4889603fc0a3Smrg} 4890603fc0a3Smrg 4891603fc0a3Smrg# func_cygming_gnu_implib_p ARG 4892603fc0a3Smrg# This predicate returns with zero status (TRUE) if 4893603fc0a3Smrg# ARG is a GNU/binutils-style import library. Returns 4894603fc0a3Smrg# with nonzero status (FALSE) otherwise. 4895603fc0a3Smrgfunc_cygming_gnu_implib_p () 4896603fc0a3Smrg{ 4897603fc0a3Smrg $debug_cmd 4898603fc0a3Smrg 4899603fc0a3Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4900603fc0a3Smrg 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)$'` 4901603fc0a3Smrg test -n "$func_cygming_gnu_implib_tmp" 4902603fc0a3Smrg} 4903603fc0a3Smrg 4904603fc0a3Smrg# func_cygming_ms_implib_p ARG 4905603fc0a3Smrg# This predicate returns with zero status (TRUE) if 4906603fc0a3Smrg# ARG is an MS-style import library. Returns 4907603fc0a3Smrg# with nonzero status (FALSE) otherwise. 4908603fc0a3Smrgfunc_cygming_ms_implib_p () 4909603fc0a3Smrg{ 4910603fc0a3Smrg $debug_cmd 4911603fc0a3Smrg 4912603fc0a3Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4913603fc0a3Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 4914603fc0a3Smrg test -n "$func_cygming_ms_implib_tmp" 4915603fc0a3Smrg} 4916603fc0a3Smrg 4917603fc0a3Smrg# func_win32_libid arg 4918603fc0a3Smrg# return the library type of file 'arg' 4919603fc0a3Smrg# 4920603fc0a3Smrg# Need a lot of goo to handle *both* DLLs and import libs 4921603fc0a3Smrg# Has to be a shell function in order to 'eat' the argument 4922603fc0a3Smrg# that is supplied when $file_magic_command is called. 4923603fc0a3Smrg# Despite the name, also deal with 64 bit binaries. 4924603fc0a3Smrgfunc_win32_libid () 4925603fc0a3Smrg{ 4926603fc0a3Smrg $debug_cmd 4927603fc0a3Smrg 4928603fc0a3Smrg win32_libid_type=unknown 4929603fc0a3Smrg win32_fileres=`file -L $1 2>/dev/null` 4930603fc0a3Smrg case $win32_fileres in 4931603fc0a3Smrg *ar\ archive\ import\ library*) # definitely import 4932603fc0a3Smrg win32_libid_type="x86 archive import" 4933603fc0a3Smrg ;; 4934603fc0a3Smrg *ar\ archive*) # could be an import, or static 4935603fc0a3Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 4936603fc0a3Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 4937603fc0a3Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 4938603fc0a3Smrg case $nm_interface in 4939603fc0a3Smrg "MS dumpbin") 4940603fc0a3Smrg if func_cygming_ms_implib_p "$1" || 4941603fc0a3Smrg func_cygming_gnu_implib_p "$1" 4942603fc0a3Smrg then 4943603fc0a3Smrg win32_nmres=import 4944603fc0a3Smrg else 4945603fc0a3Smrg win32_nmres= 4946603fc0a3Smrg fi 4947603fc0a3Smrg ;; 4948603fc0a3Smrg *) 4949603fc0a3Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4950603fc0a3Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 4951603fc0a3Smrg $SED -n -e ' 4952603fc0a3Smrg 1,100{ 4953603fc0a3Smrg / I /{ 4954603fc0a3Smrg s|.*|import| 4955603fc0a3Smrg p 4956603fc0a3Smrg q 4957603fc0a3Smrg } 4958603fc0a3Smrg }'` 4959603fc0a3Smrg ;; 4960603fc0a3Smrg esac 4961603fc0a3Smrg case $win32_nmres in 4962603fc0a3Smrg import*) win32_libid_type="x86 archive import";; 4963603fc0a3Smrg *) win32_libid_type="x86 archive static";; 4964603fc0a3Smrg esac 4965603fc0a3Smrg fi 4966603fc0a3Smrg ;; 4967603fc0a3Smrg *DLL*) 4968603fc0a3Smrg win32_libid_type="x86 DLL" 4969603fc0a3Smrg ;; 4970603fc0a3Smrg *executable*) # but shell scripts are "executable" too... 4971603fc0a3Smrg case $win32_fileres in 4972603fc0a3Smrg *MS\ Windows\ PE\ Intel*) 4973603fc0a3Smrg win32_libid_type="x86 DLL" 4974603fc0a3Smrg ;; 4975603fc0a3Smrg esac 4976603fc0a3Smrg ;; 4977603fc0a3Smrg esac 4978603fc0a3Smrg $ECHO "$win32_libid_type" 4979603fc0a3Smrg} 4980603fc0a3Smrg 4981603fc0a3Smrg# func_cygming_dll_for_implib ARG 4982603fc0a3Smrg# 4983603fc0a3Smrg# Platform-specific function to extract the 4984603fc0a3Smrg# name of the DLL associated with the specified 4985603fc0a3Smrg# import library ARG. 4986603fc0a3Smrg# Invoked by eval'ing the libtool variable 4987603fc0a3Smrg# $sharedlib_from_linklib_cmd 4988603fc0a3Smrg# Result is available in the variable 4989603fc0a3Smrg# $sharedlib_from_linklib_result 4990603fc0a3Smrgfunc_cygming_dll_for_implib () 4991603fc0a3Smrg{ 4992603fc0a3Smrg $debug_cmd 4993603fc0a3Smrg 4994603fc0a3Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 4995603fc0a3Smrg} 4996603fc0a3Smrg 4997603fc0a3Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 4998603fc0a3Smrg# 4999603fc0a3Smrg# The is the core of a fallback implementation of a 5000603fc0a3Smrg# platform-specific function to extract the name of the 5001603fc0a3Smrg# DLL associated with the specified import library LIBNAME. 5002603fc0a3Smrg# 5003603fc0a3Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5004603fc0a3Smrg# on the platform and compiler that created the implib. 5005603fc0a3Smrg# 5006603fc0a3Smrg# Echos the name of the DLL associated with the 5007603fc0a3Smrg# specified import library. 5008603fc0a3Smrgfunc_cygming_dll_for_implib_fallback_core () 5009603fc0a3Smrg{ 5010603fc0a3Smrg $debug_cmd 5011603fc0a3Smrg 5012603fc0a3Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5013603fc0a3Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5014603fc0a3Smrg $SED '/^Contents of section '"$match_literal"':/{ 5015603fc0a3Smrg # Place marker at beginning of archive member dllname section 5016603fc0a3Smrg s/.*/====MARK====/ 5017603fc0a3Smrg p 5018603fc0a3Smrg d 5019603fc0a3Smrg } 5020603fc0a3Smrg # These lines can sometimes be longer than 43 characters, but 5021603fc0a3Smrg # are always uninteresting 5022603fc0a3Smrg /:[ ]*file format pe[i]\{,1\}-/d 5023603fc0a3Smrg /^In archive [^:]*:/d 5024603fc0a3Smrg # Ensure marker is printed 5025603fc0a3Smrg /^====MARK====/p 5026603fc0a3Smrg # Remove all lines with less than 43 characters 5027603fc0a3Smrg /^.\{43\}/!d 5028603fc0a3Smrg # From remaining lines, remove first 43 characters 5029603fc0a3Smrg s/^.\{43\}//' | 5030603fc0a3Smrg $SED -n ' 5031603fc0a3Smrg # Join marker and all lines until next marker into a single line 5032603fc0a3Smrg /^====MARK====/ b para 5033603fc0a3Smrg H 5034603fc0a3Smrg $ b para 5035603fc0a3Smrg b 5036603fc0a3Smrg :para 5037603fc0a3Smrg x 5038603fc0a3Smrg s/\n//g 5039603fc0a3Smrg # Remove the marker 5040603fc0a3Smrg s/^====MARK====// 5041603fc0a3Smrg # Remove trailing dots and whitespace 5042603fc0a3Smrg s/[\. \t]*$// 5043603fc0a3Smrg # Print 5044603fc0a3Smrg /./p' | 5045603fc0a3Smrg # we now have a list, one entry per line, of the stringified 5046603fc0a3Smrg # contents of the appropriate section of all members of the 5047603fc0a3Smrg # archive that possess that section. Heuristic: eliminate 5048603fc0a3Smrg # all those that have a first or second character that is 5049603fc0a3Smrg # a '.' (that is, objdump's representation of an unprintable 5050603fc0a3Smrg # character.) This should work for all archives with less than 5051603fc0a3Smrg # 0x302f exports -- but will fail for DLLs whose name actually 5052603fc0a3Smrg # begins with a literal '.' or a single character followed by 5053603fc0a3Smrg # a '.'. 5054603fc0a3Smrg # 5055603fc0a3Smrg # Of those that remain, print the first one. 5056603fc0a3Smrg $SED -e '/^\./d;/^.\./d;q' 5057603fc0a3Smrg} 5058603fc0a3Smrg 5059603fc0a3Smrg# func_cygming_dll_for_implib_fallback ARG 5060603fc0a3Smrg# Platform-specific function to extract the 5061603fc0a3Smrg# name of the DLL associated with the specified 5062603fc0a3Smrg# import library ARG. 5063603fc0a3Smrg# 5064603fc0a3Smrg# This fallback implementation is for use when $DLLTOOL 5065603fc0a3Smrg# does not support the --identify-strict option. 5066603fc0a3Smrg# Invoked by eval'ing the libtool variable 5067603fc0a3Smrg# $sharedlib_from_linklib_cmd 5068603fc0a3Smrg# Result is available in the variable 5069603fc0a3Smrg# $sharedlib_from_linklib_result 5070603fc0a3Smrgfunc_cygming_dll_for_implib_fallback () 5071603fc0a3Smrg{ 5072603fc0a3Smrg $debug_cmd 5073603fc0a3Smrg 5074603fc0a3Smrg if func_cygming_gnu_implib_p "$1"; then 5075603fc0a3Smrg # binutils import library 5076603fc0a3Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5077603fc0a3Smrg elif func_cygming_ms_implib_p "$1"; then 5078603fc0a3Smrg # ms-generated import library 5079603fc0a3Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5080603fc0a3Smrg else 5081603fc0a3Smrg # unknown 5082603fc0a3Smrg sharedlib_from_linklib_result= 5083603fc0a3Smrg fi 5084603fc0a3Smrg} 5085603fc0a3Smrg 5086603fc0a3Smrg 5087603fc0a3Smrg# func_extract_an_archive dir oldlib 5088603fc0a3Smrgfunc_extract_an_archive () 5089603fc0a3Smrg{ 5090603fc0a3Smrg $debug_cmd 5091603fc0a3Smrg 5092603fc0a3Smrg f_ex_an_ar_dir=$1; shift 5093603fc0a3Smrg f_ex_an_ar_oldlib=$1 5094603fc0a3Smrg if test yes = "$lock_old_archive_extraction"; then 5095603fc0a3Smrg lockfile=$f_ex_an_ar_oldlib.lock 5096603fc0a3Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5097603fc0a3Smrg func_echo "Waiting for $lockfile to be removed" 5098603fc0a3Smrg sleep 2 5099603fc0a3Smrg done 5100603fc0a3Smrg fi 5101603fc0a3Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5102603fc0a3Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5103603fc0a3Smrg if test yes = "$lock_old_archive_extraction"; then 5104603fc0a3Smrg $opt_dry_run || rm -f "$lockfile" 5105603fc0a3Smrg fi 5106603fc0a3Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5107603fc0a3Smrg : 5108603fc0a3Smrg else 5109603fc0a3Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5110603fc0a3Smrg fi 5111603fc0a3Smrg} 5112603fc0a3Smrg 5113603fc0a3Smrg 5114603fc0a3Smrg# func_extract_archives gentop oldlib ... 5115603fc0a3Smrgfunc_extract_archives () 5116603fc0a3Smrg{ 5117603fc0a3Smrg $debug_cmd 5118603fc0a3Smrg 5119603fc0a3Smrg my_gentop=$1; shift 5120603fc0a3Smrg my_oldlibs=${1+"$@"} 5121603fc0a3Smrg my_oldobjs= 5122603fc0a3Smrg my_xlib= 5123603fc0a3Smrg my_xabs= 5124603fc0a3Smrg my_xdir= 5125603fc0a3Smrg 5126603fc0a3Smrg for my_xlib in $my_oldlibs; do 5127603fc0a3Smrg # Extract the objects. 5128603fc0a3Smrg case $my_xlib in 5129603fc0a3Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5130603fc0a3Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 5131603fc0a3Smrg esac 5132603fc0a3Smrg func_basename "$my_xlib" 5133603fc0a3Smrg my_xlib=$func_basename_result 5134603fc0a3Smrg my_xlib_u=$my_xlib 5135603fc0a3Smrg while :; do 5136603fc0a3Smrg case " $extracted_archives " in 5137603fc0a3Smrg *" $my_xlib_u "*) 5138603fc0a3Smrg func_arith $extracted_serial + 1 5139603fc0a3Smrg extracted_serial=$func_arith_result 5140603fc0a3Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5141603fc0a3Smrg *) break ;; 5142603fc0a3Smrg esac 5143603fc0a3Smrg done 5144603fc0a3Smrg extracted_archives="$extracted_archives $my_xlib_u" 5145603fc0a3Smrg my_xdir=$my_gentop/$my_xlib_u 5146603fc0a3Smrg 5147603fc0a3Smrg func_mkdir_p "$my_xdir" 5148603fc0a3Smrg 5149603fc0a3Smrg case $host in 5150603fc0a3Smrg *-darwin*) 5151603fc0a3Smrg func_verbose "Extracting $my_xabs" 5152603fc0a3Smrg # Do not bother doing anything if just a dry run 5153603fc0a3Smrg $opt_dry_run || { 5154603fc0a3Smrg darwin_orig_dir=`pwd` 5155603fc0a3Smrg cd $my_xdir || exit $? 5156603fc0a3Smrg darwin_archive=$my_xabs 5157603fc0a3Smrg darwin_curdir=`pwd` 5158603fc0a3Smrg func_basename "$darwin_archive" 5159603fc0a3Smrg darwin_base_archive=$func_basename_result 5160603fc0a3Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5161603fc0a3Smrg if test -n "$darwin_arches"; then 5162603fc0a3Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5163603fc0a3Smrg darwin_arch= 5164603fc0a3Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5165603fc0a3Smrg for darwin_arch in $darwin_arches; do 5166603fc0a3Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5167603fc0a3Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5168603fc0a3Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5169603fc0a3Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5170603fc0a3Smrg cd "$darwin_curdir" 5171603fc0a3Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5172603fc0a3Smrg done # $darwin_arches 5173603fc0a3Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5174603fc0a3Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5175603fc0a3Smrg darwin_file= 5176603fc0a3Smrg darwin_files= 5177603fc0a3Smrg for darwin_file in $darwin_filelist; do 5178603fc0a3Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5179603fc0a3Smrg $LIPO -create -output "$darwin_file" $darwin_files 5180603fc0a3Smrg done # $darwin_filelist 5181603fc0a3Smrg $RM -rf unfat-$$ 5182603fc0a3Smrg cd "$darwin_orig_dir" 5183603fc0a3Smrg else 5184603fc0a3Smrg cd $darwin_orig_dir 5185603fc0a3Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5186603fc0a3Smrg fi # $darwin_arches 5187603fc0a3Smrg } # !$opt_dry_run 5188603fc0a3Smrg ;; 5189603fc0a3Smrg *) 5190603fc0a3Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 5191603fc0a3Smrg ;; 5192603fc0a3Smrg esac 5193603fc0a3Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5194603fc0a3Smrg done 5195603fc0a3Smrg 5196603fc0a3Smrg func_extract_archives_result=$my_oldobjs 5197603fc0a3Smrg} 5198603fc0a3Smrg 5199603fc0a3Smrg 5200603fc0a3Smrg# func_emit_wrapper [arg=no] 5201603fc0a3Smrg# 5202603fc0a3Smrg# Emit a libtool wrapper script on stdout. 5203603fc0a3Smrg# Don't directly open a file because we may want to 5204603fc0a3Smrg# incorporate the script contents within a cygwin/mingw 5205603fc0a3Smrg# wrapper executable. Must ONLY be called from within 5206603fc0a3Smrg# func_mode_link because it depends on a number of variables 5207603fc0a3Smrg# set therein. 5208603fc0a3Smrg# 5209603fc0a3Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5210603fc0a3Smrg# variable will take. If 'yes', then the emitted script 5211603fc0a3Smrg# will assume that the directory where it is stored is 5212603fc0a3Smrg# the $objdir directory. This is a cygwin/mingw-specific 5213603fc0a3Smrg# behavior. 5214603fc0a3Smrgfunc_emit_wrapper () 5215603fc0a3Smrg{ 5216603fc0a3Smrg func_emit_wrapper_arg1=${1-no} 5217603fc0a3Smrg 5218603fc0a3Smrg $ECHO "\ 5219603fc0a3Smrg#! $SHELL 5220603fc0a3Smrg 5221603fc0a3Smrg# $output - temporary wrapper script for $objdir/$outputname 5222603fc0a3Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5223603fc0a3Smrg# 5224603fc0a3Smrg# The $output program cannot be directly executed until all the libtool 5225603fc0a3Smrg# libraries that it depends on are installed. 5226603fc0a3Smrg# 5227603fc0a3Smrg# This wrapper script should never be moved out of the build directory. 5228603fc0a3Smrg# If it is, it will not operate correctly. 5229603fc0a3Smrg 5230603fc0a3Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5231603fc0a3Smrg# metacharacters that are still active within double-quoted strings. 5232603fc0a3Smrgsed_quote_subst='$sed_quote_subst' 5233603fc0a3Smrg 5234603fc0a3Smrg# Be Bourne compatible 5235603fc0a3Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5236603fc0a3Smrg emulate sh 5237603fc0a3Smrg NULLCMD=: 5238603fc0a3Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5239603fc0a3Smrg # is contrary to our usage. Disable this feature. 5240603fc0a3Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5241603fc0a3Smrg setopt NO_GLOB_SUBST 5242603fc0a3Smrgelse 5243603fc0a3Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5244603fc0a3Smrgfi 5245603fc0a3SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5246603fc0a3SmrgDUALCASE=1; export DUALCASE # for MKS sh 5247603fc0a3Smrg 5248603fc0a3Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5249603fc0a3Smrg# if CDPATH is set. 5250603fc0a3Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5251603fc0a3Smrg 5252603fc0a3Smrgrelink_command=\"$relink_command\" 5253603fc0a3Smrg 5254603fc0a3Smrg# This environment variable determines our operation mode. 5255603fc0a3Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5256603fc0a3Smrg # install mode needs the following variables: 5257603fc0a3Smrg generated_by_libtool_version='$macro_version' 5258603fc0a3Smrg notinst_deplibs='$notinst_deplibs' 5259603fc0a3Smrgelse 5260603fc0a3Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5261603fc0a3Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5262603fc0a3Smrg file=\"\$0\"" 5263603fc0a3Smrg 5264603fc0a3Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 5265603fc0a3Smrg $ECHO "\ 5266603fc0a3Smrg 5267603fc0a3Smrg# A function that is used when there is no print builtin or printf. 5268603fc0a3Smrgfunc_fallback_echo () 5269603fc0a3Smrg{ 5270603fc0a3Smrg eval 'cat <<_LTECHO_EOF 5271603fc0a3Smrg\$1 5272603fc0a3Smrg_LTECHO_EOF' 5273603fc0a3Smrg} 5274603fc0a3Smrg ECHO=\"$qECHO\" 5275603fc0a3Smrg fi 5276603fc0a3Smrg 5277603fc0a3Smrg# Very basic option parsing. These options are (a) specific to 5278603fc0a3Smrg# the libtool wrapper, (b) are identical between the wrapper 5279603fc0a3Smrg# /script/ and the wrapper /executable/ that is used only on 5280603fc0a3Smrg# windows platforms, and (c) all begin with the string "--lt-" 5281603fc0a3Smrg# (application programs are unlikely to have options that match 5282603fc0a3Smrg# this pattern). 5283603fc0a3Smrg# 5284603fc0a3Smrg# There are only two supported options: --lt-debug and 5285603fc0a3Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 5286603fc0a3Smrg# 5287603fc0a3Smrg# The first argument to this parsing function should be the 5288603fc0a3Smrg# script's $0 value, followed by "$@". 5289603fc0a3Smrglt_option_debug= 5290603fc0a3Smrgfunc_parse_lt_options () 5291603fc0a3Smrg{ 5292603fc0a3Smrg lt_script_arg0=\$0 5293603fc0a3Smrg shift 5294603fc0a3Smrg for lt_opt 5295603fc0a3Smrg do 5296603fc0a3Smrg case \"\$lt_opt\" in 5297603fc0a3Smrg --lt-debug) lt_option_debug=1 ;; 5298603fc0a3Smrg --lt-dump-script) 5299603fc0a3Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5300603fc0a3Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5301603fc0a3Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5302603fc0a3Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 5303603fc0a3Smrg exit 0 5304603fc0a3Smrg ;; 5305603fc0a3Smrg --lt-*) 5306603fc0a3Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5307603fc0a3Smrg exit 1 5308603fc0a3Smrg ;; 5309603fc0a3Smrg esac 5310603fc0a3Smrg done 5311603fc0a3Smrg 5312603fc0a3Smrg # Print the debug banner immediately: 5313603fc0a3Smrg if test -n \"\$lt_option_debug\"; then 5314603fc0a3Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5315603fc0a3Smrg fi 5316603fc0a3Smrg} 5317603fc0a3Smrg 5318603fc0a3Smrg# Used when --lt-debug. Prints its arguments to stdout 5319603fc0a3Smrg# (redirection is the responsibility of the caller) 5320603fc0a3Smrgfunc_lt_dump_args () 5321603fc0a3Smrg{ 5322603fc0a3Smrg lt_dump_args_N=1; 5323603fc0a3Smrg for lt_arg 5324603fc0a3Smrg do 5325603fc0a3Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5326603fc0a3Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5327603fc0a3Smrg done 5328603fc0a3Smrg} 5329603fc0a3Smrg 5330603fc0a3Smrg# Core function for launching the target application 5331603fc0a3Smrgfunc_exec_program_core () 5332603fc0a3Smrg{ 5333603fc0a3Smrg" 5334603fc0a3Smrg case $host in 5335603fc0a3Smrg # Backslashes separate directories on plain windows 5336603fc0a3Smrg *-*-mingw | *-*-os2* | *-cegcc*) 5337603fc0a3Smrg $ECHO "\ 5338603fc0a3Smrg if test -n \"\$lt_option_debug\"; then 5339603fc0a3Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5340603fc0a3Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5341603fc0a3Smrg fi 5342603fc0a3Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5343603fc0a3Smrg" 5344603fc0a3Smrg ;; 5345603fc0a3Smrg 5346603fc0a3Smrg *) 5347603fc0a3Smrg $ECHO "\ 5348603fc0a3Smrg if test -n \"\$lt_option_debug\"; then 5349603fc0a3Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5350603fc0a3Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5351603fc0a3Smrg fi 5352603fc0a3Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5353603fc0a3Smrg" 5354603fc0a3Smrg ;; 5355603fc0a3Smrg esac 5356603fc0a3Smrg $ECHO "\ 5357603fc0a3Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5358603fc0a3Smrg exit 1 5359603fc0a3Smrg} 5360603fc0a3Smrg 5361603fc0a3Smrg# A function to encapsulate launching the target application 5362603fc0a3Smrg# Strips options in the --lt-* namespace from \$@ and 5363603fc0a3Smrg# launches target application with the remaining arguments. 5364603fc0a3Smrgfunc_exec_program () 5365603fc0a3Smrg{ 5366603fc0a3Smrg case \" \$* \" in 5367603fc0a3Smrg *\\ --lt-*) 5368603fc0a3Smrg for lt_wr_arg 5369603fc0a3Smrg do 5370603fc0a3Smrg case \$lt_wr_arg in 5371603fc0a3Smrg --lt-*) ;; 5372603fc0a3Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5373603fc0a3Smrg esac 5374603fc0a3Smrg shift 5375603fc0a3Smrg done ;; 5376603fc0a3Smrg esac 5377603fc0a3Smrg func_exec_program_core \${1+\"\$@\"} 5378603fc0a3Smrg} 5379603fc0a3Smrg 5380603fc0a3Smrg # Parse options 5381603fc0a3Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5382603fc0a3Smrg 5383603fc0a3Smrg # Find the directory that this script lives in. 5384603fc0a3Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5385603fc0a3Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5386603fc0a3Smrg 5387603fc0a3Smrg # Follow symbolic links until we get to the real thisdir. 5388603fc0a3Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5389603fc0a3Smrg while test -n \"\$file\"; do 5390603fc0a3Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5391603fc0a3Smrg 5392603fc0a3Smrg # If there was a directory component, then change thisdir. 5393603fc0a3Smrg if test \"x\$destdir\" != \"x\$file\"; then 5394603fc0a3Smrg case \"\$destdir\" in 5395603fc0a3Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5396603fc0a3Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5397603fc0a3Smrg esac 5398603fc0a3Smrg fi 5399603fc0a3Smrg 5400603fc0a3Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5401603fc0a3Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5402603fc0a3Smrg done 5403603fc0a3Smrg 5404603fc0a3Smrg # Usually 'no', except on cygwin/mingw when embedded into 5405603fc0a3Smrg # the cwrapper. 5406603fc0a3Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5407603fc0a3Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5408603fc0a3Smrg # special case for '.' 5409603fc0a3Smrg if test \"\$thisdir\" = \".\"; then 5410603fc0a3Smrg thisdir=\`pwd\` 5411603fc0a3Smrg fi 5412603fc0a3Smrg # remove .libs from thisdir 5413603fc0a3Smrg case \"\$thisdir\" in 5414603fc0a3Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5415603fc0a3Smrg $objdir ) thisdir=. ;; 5416603fc0a3Smrg esac 5417603fc0a3Smrg fi 5418603fc0a3Smrg 5419603fc0a3Smrg # Try to get the absolute directory name. 5420603fc0a3Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5421603fc0a3Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5422603fc0a3Smrg" 5423603fc0a3Smrg 5424603fc0a3Smrg if test yes = "$fast_install"; then 5425603fc0a3Smrg $ECHO "\ 5426603fc0a3Smrg program=lt-'$outputname'$exeext 5427603fc0a3Smrg progdir=\"\$thisdir/$objdir\" 5428603fc0a3Smrg 5429603fc0a3Smrg if test ! -f \"\$progdir/\$program\" || 5430603fc0a3Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5431603fc0a3Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5432603fc0a3Smrg 5433603fc0a3Smrg file=\"\$\$-\$program\" 5434603fc0a3Smrg 5435603fc0a3Smrg if test ! -d \"\$progdir\"; then 5436603fc0a3Smrg $MKDIR \"\$progdir\" 5437603fc0a3Smrg else 5438603fc0a3Smrg $RM \"\$progdir/\$file\" 5439603fc0a3Smrg fi" 5440603fc0a3Smrg 5441603fc0a3Smrg $ECHO "\ 5442603fc0a3Smrg 5443603fc0a3Smrg # relink executable if necessary 5444603fc0a3Smrg if test -n \"\$relink_command\"; then 5445603fc0a3Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5446603fc0a3Smrg else 5447603fc0a3Smrg \$ECHO \"\$relink_command_output\" >&2 5448603fc0a3Smrg $RM \"\$progdir/\$file\" 5449603fc0a3Smrg exit 1 5450603fc0a3Smrg fi 5451603fc0a3Smrg fi 5452603fc0a3Smrg 5453603fc0a3Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5454603fc0a3Smrg { $RM \"\$progdir/\$program\"; 5455603fc0a3Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5456603fc0a3Smrg $RM \"\$progdir/\$file\" 5457603fc0a3Smrg fi" 5458603fc0a3Smrg else 5459603fc0a3Smrg $ECHO "\ 5460603fc0a3Smrg program='$outputname' 5461603fc0a3Smrg progdir=\"\$thisdir/$objdir\" 5462603fc0a3Smrg" 5463603fc0a3Smrg fi 5464603fc0a3Smrg 5465603fc0a3Smrg $ECHO "\ 5466603fc0a3Smrg 5467603fc0a3Smrg if test -f \"\$progdir/\$program\"; then" 5468603fc0a3Smrg 5469603fc0a3Smrg # fixup the dll searchpath if we need to. 5470603fc0a3Smrg # 5471603fc0a3Smrg # Fix the DLL searchpath if we need to. Do this before prepending 5472603fc0a3Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 5473603fc0a3Smrg # libraries must come first. 5474603fc0a3Smrg if test -n "$dllsearchpath"; then 5475603fc0a3Smrg $ECHO "\ 5476603fc0a3Smrg # Add the dll search path components to the executable PATH 5477603fc0a3Smrg PATH=$dllsearchpath:\$PATH 5478603fc0a3Smrg" 5479603fc0a3Smrg fi 5480603fc0a3Smrg 5481603fc0a3Smrg # Export our shlibpath_var if we have one. 5482603fc0a3Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5483603fc0a3Smrg $ECHO "\ 5484603fc0a3Smrg # Add our own library path to $shlibpath_var 5485603fc0a3Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5486603fc0a3Smrg 5487603fc0a3Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5488603fc0a3Smrg # The second colon is a workaround for a bug in BeOS R4 sed 5489603fc0a3Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5490603fc0a3Smrg 5491603fc0a3Smrg export $shlibpath_var 5492603fc0a3Smrg" 5493603fc0a3Smrg fi 5494603fc0a3Smrg 5495603fc0a3Smrg $ECHO "\ 5496603fc0a3Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5497603fc0a3Smrg # Run the actual program with our arguments. 5498603fc0a3Smrg func_exec_program \${1+\"\$@\"} 5499603fc0a3Smrg fi 5500603fc0a3Smrg else 5501603fc0a3Smrg # The program doesn't exist. 5502603fc0a3Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5503603fc0a3Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5504603fc0a3Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5505603fc0a3Smrg exit 1 5506603fc0a3Smrg fi 5507603fc0a3Smrgfi\ 5508603fc0a3Smrg" 5509603fc0a3Smrg} 5510603fc0a3Smrg 5511603fc0a3Smrg 5512603fc0a3Smrg# func_emit_cwrapperexe_src 5513603fc0a3Smrg# emit the source code for a wrapper executable on stdout 5514603fc0a3Smrg# Must ONLY be called from within func_mode_link because 5515603fc0a3Smrg# it depends on a number of variable set therein. 5516603fc0a3Smrgfunc_emit_cwrapperexe_src () 5517603fc0a3Smrg{ 5518603fc0a3Smrg cat <<EOF 5519603fc0a3Smrg 5520603fc0a3Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5521603fc0a3Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5522603fc0a3Smrg 5523603fc0a3Smrg The $output program cannot be directly executed until all the libtool 5524603fc0a3Smrg libraries that it depends on are installed. 5525603fc0a3Smrg 5526603fc0a3Smrg This wrapper executable should never be moved out of the build directory. 5527603fc0a3Smrg If it is, it will not operate correctly. 5528603fc0a3Smrg*/ 5529603fc0a3SmrgEOF 5530603fc0a3Smrg cat <<"EOF" 5531603fc0a3Smrg#ifdef _MSC_VER 5532603fc0a3Smrg# define _CRT_SECURE_NO_DEPRECATE 1 5533603fc0a3Smrg#endif 5534603fc0a3Smrg#include <stdio.h> 5535603fc0a3Smrg#include <stdlib.h> 5536603fc0a3Smrg#ifdef _MSC_VER 5537603fc0a3Smrg# include <direct.h> 5538603fc0a3Smrg# include <process.h> 5539603fc0a3Smrg# include <io.h> 5540603fc0a3Smrg#else 5541603fc0a3Smrg# include <unistd.h> 5542603fc0a3Smrg# include <stdint.h> 5543603fc0a3Smrg# ifdef __CYGWIN__ 5544603fc0a3Smrg# include <io.h> 5545603fc0a3Smrg# endif 5546603fc0a3Smrg#endif 5547603fc0a3Smrg#include <malloc.h> 5548603fc0a3Smrg#include <stdarg.h> 5549603fc0a3Smrg#include <assert.h> 5550603fc0a3Smrg#include <string.h> 5551603fc0a3Smrg#include <ctype.h> 5552603fc0a3Smrg#include <errno.h> 5553603fc0a3Smrg#include <fcntl.h> 5554603fc0a3Smrg#include <sys/stat.h> 5555603fc0a3Smrg 5556603fc0a3Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5557603fc0a3Smrg 5558603fc0a3Smrg/* declarations of non-ANSI functions */ 5559603fc0a3Smrg#if defined __MINGW32__ 5560603fc0a3Smrg# ifdef __STRICT_ANSI__ 5561603fc0a3Smrgint _putenv (const char *); 5562603fc0a3Smrg# endif 5563603fc0a3Smrg#elif defined __CYGWIN__ 5564603fc0a3Smrg# ifdef __STRICT_ANSI__ 5565603fc0a3Smrgchar *realpath (const char *, char *); 5566603fc0a3Smrgint putenv (char *); 5567603fc0a3Smrgint setenv (const char *, const char *, int); 5568603fc0a3Smrg# endif 5569603fc0a3Smrg/* #elif defined other_platform || defined ... */ 5570603fc0a3Smrg#endif 5571603fc0a3Smrg 5572603fc0a3Smrg/* portability defines, excluding path handling macros */ 5573603fc0a3Smrg#if defined _MSC_VER 5574603fc0a3Smrg# define setmode _setmode 5575603fc0a3Smrg# define stat _stat 5576603fc0a3Smrg# define chmod _chmod 5577603fc0a3Smrg# define getcwd _getcwd 5578603fc0a3Smrg# define putenv _putenv 5579603fc0a3Smrg# define S_IXUSR _S_IEXEC 5580603fc0a3Smrg#elif defined __MINGW32__ 5581603fc0a3Smrg# define setmode _setmode 5582603fc0a3Smrg# define stat _stat 5583603fc0a3Smrg# define chmod _chmod 5584603fc0a3Smrg# define getcwd _getcwd 5585603fc0a3Smrg# define putenv _putenv 5586603fc0a3Smrg#elif defined __CYGWIN__ 5587603fc0a3Smrg# define HAVE_SETENV 5588603fc0a3Smrg# define FOPEN_WB "wb" 5589603fc0a3Smrg/* #elif defined other platforms ... */ 5590603fc0a3Smrg#endif 5591603fc0a3Smrg 5592603fc0a3Smrg#if defined PATH_MAX 5593603fc0a3Smrg# define LT_PATHMAX PATH_MAX 5594603fc0a3Smrg#elif defined MAXPATHLEN 5595603fc0a3Smrg# define LT_PATHMAX MAXPATHLEN 5596603fc0a3Smrg#else 5597603fc0a3Smrg# define LT_PATHMAX 1024 5598603fc0a3Smrg#endif 5599603fc0a3Smrg 5600603fc0a3Smrg#ifndef S_IXOTH 5601603fc0a3Smrg# define S_IXOTH 0 5602603fc0a3Smrg#endif 5603603fc0a3Smrg#ifndef S_IXGRP 5604603fc0a3Smrg# define S_IXGRP 0 5605603fc0a3Smrg#endif 5606603fc0a3Smrg 5607603fc0a3Smrg/* path handling portability macros */ 5608603fc0a3Smrg#ifndef DIR_SEPARATOR 5609603fc0a3Smrg# define DIR_SEPARATOR '/' 5610603fc0a3Smrg# define PATH_SEPARATOR ':' 5611603fc0a3Smrg#endif 5612603fc0a3Smrg 5613603fc0a3Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5614603fc0a3Smrg defined __OS2__ 5615603fc0a3Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 5616603fc0a3Smrg# define FOPEN_WB "wb" 5617603fc0a3Smrg# ifndef DIR_SEPARATOR_2 5618603fc0a3Smrg# define DIR_SEPARATOR_2 '\\' 5619603fc0a3Smrg# endif 5620603fc0a3Smrg# ifndef PATH_SEPARATOR_2 5621603fc0a3Smrg# define PATH_SEPARATOR_2 ';' 5622603fc0a3Smrg# endif 5623603fc0a3Smrg#endif 5624603fc0a3Smrg 5625603fc0a3Smrg#ifndef DIR_SEPARATOR_2 5626603fc0a3Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5627603fc0a3Smrg#else /* DIR_SEPARATOR_2 */ 5628603fc0a3Smrg# define IS_DIR_SEPARATOR(ch) \ 5629603fc0a3Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5630603fc0a3Smrg#endif /* DIR_SEPARATOR_2 */ 5631603fc0a3Smrg 5632603fc0a3Smrg#ifndef PATH_SEPARATOR_2 5633603fc0a3Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5634603fc0a3Smrg#else /* PATH_SEPARATOR_2 */ 5635603fc0a3Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5636603fc0a3Smrg#endif /* PATH_SEPARATOR_2 */ 5637603fc0a3Smrg 5638603fc0a3Smrg#ifndef FOPEN_WB 5639603fc0a3Smrg# define FOPEN_WB "w" 5640603fc0a3Smrg#endif 5641603fc0a3Smrg#ifndef _O_BINARY 5642603fc0a3Smrg# define _O_BINARY 0 5643603fc0a3Smrg#endif 5644603fc0a3Smrg 5645603fc0a3Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5646603fc0a3Smrg#define XFREE(stale) do { \ 5647603fc0a3Smrg if (stale) { free (stale); stale = 0; } \ 5648603fc0a3Smrg} while (0) 5649603fc0a3Smrg 5650603fc0a3Smrg#if defined LT_DEBUGWRAPPER 5651603fc0a3Smrgstatic int lt_debug = 1; 5652603fc0a3Smrg#else 5653603fc0a3Smrgstatic int lt_debug = 0; 5654603fc0a3Smrg#endif 5655603fc0a3Smrg 5656603fc0a3Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5657603fc0a3Smrg 5658603fc0a3Smrgvoid *xmalloc (size_t num); 5659603fc0a3Smrgchar *xstrdup (const char *string); 5660603fc0a3Smrgconst char *base_name (const char *name); 5661603fc0a3Smrgchar *find_executable (const char *wrapper); 5662603fc0a3Smrgchar *chase_symlinks (const char *pathspec); 5663603fc0a3Smrgint make_executable (const char *path); 5664603fc0a3Smrgint check_executable (const char *path); 5665603fc0a3Smrgchar *strendzap (char *str, const char *pat); 5666603fc0a3Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5667603fc0a3Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5668603fc0a3Smrgstatic const char *nonnull (const char *s); 5669603fc0a3Smrgstatic const char *nonempty (const char *s); 5670603fc0a3Smrgvoid lt_setenv (const char *name, const char *value); 5671603fc0a3Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5672603fc0a3Smrgvoid lt_update_exe_path (const char *name, const char *value); 5673603fc0a3Smrgvoid lt_update_lib_path (const char *name, const char *value); 5674603fc0a3Smrgchar **prepare_spawn (char **argv); 5675603fc0a3Smrgvoid lt_dump_script (FILE *f); 5676603fc0a3SmrgEOF 5677603fc0a3Smrg 5678603fc0a3Smrg cat <<EOF 5679603fc0a3Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5680603fc0a3Smrg# define externally_visible volatile 5681603fc0a3Smrg#else 5682603fc0a3Smrg# define externally_visible __attribute__((externally_visible)) volatile 5683603fc0a3Smrg#endif 5684603fc0a3Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5685603fc0a3Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5686603fc0a3SmrgEOF 5687603fc0a3Smrg 5688603fc0a3Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5689603fc0a3Smrg func_to_host_path "$temp_rpath" 5690603fc0a3Smrg cat <<EOF 5691603fc0a3Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5692603fc0a3SmrgEOF 5693603fc0a3Smrg else 5694603fc0a3Smrg cat <<"EOF" 5695603fc0a3Smrgconst char * LIB_PATH_VALUE = ""; 5696603fc0a3SmrgEOF 5697603fc0a3Smrg fi 5698603fc0a3Smrg 5699603fc0a3Smrg if test -n "$dllsearchpath"; then 5700603fc0a3Smrg func_to_host_path "$dllsearchpath:" 5701603fc0a3Smrg cat <<EOF 5702603fc0a3Smrgconst char * EXE_PATH_VARNAME = "PATH"; 5703603fc0a3Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5704603fc0a3SmrgEOF 5705603fc0a3Smrg else 5706603fc0a3Smrg cat <<"EOF" 5707603fc0a3Smrgconst char * EXE_PATH_VARNAME = ""; 5708603fc0a3Smrgconst char * EXE_PATH_VALUE = ""; 5709603fc0a3SmrgEOF 5710603fc0a3Smrg fi 5711603fc0a3Smrg 5712603fc0a3Smrg if test yes = "$fast_install"; then 5713603fc0a3Smrg cat <<EOF 5714603fc0a3Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5715603fc0a3SmrgEOF 5716603fc0a3Smrg else 5717603fc0a3Smrg cat <<EOF 5718603fc0a3Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5719603fc0a3SmrgEOF 5720603fc0a3Smrg fi 5721603fc0a3Smrg 5722603fc0a3Smrg 5723603fc0a3Smrg cat <<"EOF" 5724603fc0a3Smrg 5725603fc0a3Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5726603fc0a3Smrg 5727603fc0a3Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5728603fc0a3Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5729603fc0a3Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5730603fc0a3Smrg 5731603fc0a3Smrgint 5732603fc0a3Smrgmain (int argc, char *argv[]) 5733603fc0a3Smrg{ 5734603fc0a3Smrg char **newargz; 5735603fc0a3Smrg int newargc; 5736603fc0a3Smrg char *tmp_pathspec; 5737603fc0a3Smrg char *actual_cwrapper_path; 5738603fc0a3Smrg char *actual_cwrapper_name; 5739603fc0a3Smrg char *target_name; 5740603fc0a3Smrg char *lt_argv_zero; 5741603fc0a3Smrg int rval = 127; 5742603fc0a3Smrg 5743603fc0a3Smrg int i; 5744603fc0a3Smrg 5745603fc0a3Smrg program_name = (char *) xstrdup (base_name (argv[0])); 5746603fc0a3Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 5747603fc0a3Smrg 5748603fc0a3Smrg /* very simple arg parsing; don't want to rely on getopt 5749603fc0a3Smrg * also, copy all non cwrapper options to newargz, except 5750603fc0a3Smrg * argz[0], which is handled differently 5751603fc0a3Smrg */ 5752603fc0a3Smrg newargc=0; 5753603fc0a3Smrg for (i = 1; i < argc; i++) 5754603fc0a3Smrg { 5755603fc0a3Smrg if (STREQ (argv[i], dumpscript_opt)) 5756603fc0a3Smrg { 5757603fc0a3SmrgEOF 5758603fc0a3Smrg case $host in 5759603fc0a3Smrg *mingw* | *cygwin* ) 5760603fc0a3Smrg # make stdout use "unix" line endings 5761603fc0a3Smrg echo " setmode(1,_O_BINARY);" 5762603fc0a3Smrg ;; 5763603fc0a3Smrg esac 5764603fc0a3Smrg 5765603fc0a3Smrg cat <<"EOF" 5766603fc0a3Smrg lt_dump_script (stdout); 5767603fc0a3Smrg return 0; 5768603fc0a3Smrg } 5769603fc0a3Smrg if (STREQ (argv[i], debug_opt)) 5770603fc0a3Smrg { 5771603fc0a3Smrg lt_debug = 1; 5772603fc0a3Smrg continue; 5773603fc0a3Smrg } 5774603fc0a3Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 5775603fc0a3Smrg { 5776603fc0a3Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 5777603fc0a3Smrg namespace, but it is not one of the ones we know about and 5778603fc0a3Smrg have already dealt with, above (inluding dump-script), then 5779603fc0a3Smrg report an error. Otherwise, targets might begin to believe 5780603fc0a3Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 5781603fc0a3Smrg namespace. The first time any user complains about this, we'll 5782603fc0a3Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 5783603fc0a3Smrg or a configure.ac-settable value. 5784603fc0a3Smrg */ 5785603fc0a3Smrg lt_fatal (__FILE__, __LINE__, 5786603fc0a3Smrg "unrecognized %s option: '%s'", 5787603fc0a3Smrg ltwrapper_option_prefix, argv[i]); 5788603fc0a3Smrg } 5789603fc0a3Smrg /* otherwise ... */ 5790603fc0a3Smrg newargz[++newargc] = xstrdup (argv[i]); 5791603fc0a3Smrg } 5792603fc0a3Smrg newargz[++newargc] = NULL; 5793603fc0a3Smrg 5794603fc0a3SmrgEOF 5795603fc0a3Smrg cat <<EOF 5796603fc0a3Smrg /* The GNU banner must be the first non-error debug message */ 5797603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 5798603fc0a3SmrgEOF 5799603fc0a3Smrg cat <<"EOF" 5800603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 5801603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 5802603fc0a3Smrg 5803603fc0a3Smrg tmp_pathspec = find_executable (argv[0]); 5804603fc0a3Smrg if (tmp_pathspec == NULL) 5805603fc0a3Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 5806603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, 5807603fc0a3Smrg "(main) found exe (before symlink chase) at: %s\n", 5808603fc0a3Smrg tmp_pathspec); 5809603fc0a3Smrg 5810603fc0a3Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 5811603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, 5812603fc0a3Smrg "(main) found exe (after symlink chase) at: %s\n", 5813603fc0a3Smrg actual_cwrapper_path); 5814603fc0a3Smrg XFREE (tmp_pathspec); 5815603fc0a3Smrg 5816603fc0a3Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5817603fc0a3Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 5818603fc0a3Smrg 5819603fc0a3Smrg /* wrapper name transforms */ 5820603fc0a3Smrg strendzap (actual_cwrapper_name, ".exe"); 5821603fc0a3Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5822603fc0a3Smrg XFREE (actual_cwrapper_name); 5823603fc0a3Smrg actual_cwrapper_name = tmp_pathspec; 5824603fc0a3Smrg tmp_pathspec = 0; 5825603fc0a3Smrg 5826603fc0a3Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 5827603fc0a3Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5828603fc0a3Smrg strendzap (target_name, ".exe"); 5829603fc0a3Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5830603fc0a3Smrg XFREE (target_name); 5831603fc0a3Smrg target_name = tmp_pathspec; 5832603fc0a3Smrg tmp_pathspec = 0; 5833603fc0a3Smrg 5834603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, 5835603fc0a3Smrg "(main) libtool target name: %s\n", 5836603fc0a3Smrg target_name); 5837603fc0a3SmrgEOF 5838603fc0a3Smrg 5839603fc0a3Smrg cat <<EOF 5840603fc0a3Smrg newargz[0] = 5841603fc0a3Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 5842603fc0a3Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5843603fc0a3Smrg strcpy (newargz[0], actual_cwrapper_path); 5844603fc0a3Smrg strcat (newargz[0], "$objdir"); 5845603fc0a3Smrg strcat (newargz[0], "/"); 5846603fc0a3SmrgEOF 5847603fc0a3Smrg 5848603fc0a3Smrg cat <<"EOF" 5849603fc0a3Smrg /* stop here, and copy so we don't have to do this twice */ 5850603fc0a3Smrg tmp_pathspec = xstrdup (newargz[0]); 5851603fc0a3Smrg 5852603fc0a3Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5853603fc0a3Smrg strcat (newargz[0], actual_cwrapper_name); 5854603fc0a3Smrg 5855603fc0a3Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 5856603fc0a3Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5857603fc0a3Smrg XFREE (tmp_pathspec); 5858603fc0a3Smrg tmp_pathspec = NULL; 5859603fc0a3SmrgEOF 5860603fc0a3Smrg 5861603fc0a3Smrg case $host_os in 5862603fc0a3Smrg mingw*) 5863603fc0a3Smrg cat <<"EOF" 5864603fc0a3Smrg { 5865603fc0a3Smrg char* p; 5866603fc0a3Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 5867603fc0a3Smrg { 5868603fc0a3Smrg *p = '/'; 5869603fc0a3Smrg } 5870603fc0a3Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5871603fc0a3Smrg { 5872603fc0a3Smrg *p = '/'; 5873603fc0a3Smrg } 5874603fc0a3Smrg } 5875603fc0a3SmrgEOF 5876603fc0a3Smrg ;; 5877603fc0a3Smrg esac 5878603fc0a3Smrg 5879603fc0a3Smrg cat <<"EOF" 5880603fc0a3Smrg XFREE (target_name); 5881603fc0a3Smrg XFREE (actual_cwrapper_path); 5882603fc0a3Smrg XFREE (actual_cwrapper_name); 5883603fc0a3Smrg 5884603fc0a3Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5885603fc0a3Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 5886603fc0a3Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 5887603fc0a3Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 5888603fc0a3Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 5889603fc0a3Smrg libraries must come first. */ 5890603fc0a3Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 5891603fc0a3Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 5892603fc0a3Smrg 5893603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 5894603fc0a3Smrg nonnull (lt_argv_zero)); 5895603fc0a3Smrg for (i = 0; i < newargc; i++) 5896603fc0a3Smrg { 5897603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 5898603fc0a3Smrg i, nonnull (newargz[i])); 5899603fc0a3Smrg } 5900603fc0a3Smrg 5901603fc0a3SmrgEOF 5902603fc0a3Smrg 5903603fc0a3Smrg case $host_os in 5904603fc0a3Smrg mingw*) 5905603fc0a3Smrg cat <<"EOF" 5906603fc0a3Smrg /* execv doesn't actually work on mingw as expected on unix */ 5907603fc0a3Smrg newargz = prepare_spawn (newargz); 5908603fc0a3Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5909603fc0a3Smrg if (rval == -1) 5910603fc0a3Smrg { 5911603fc0a3Smrg /* failed to start process */ 5912603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, 5913603fc0a3Smrg "(main) failed to launch target \"%s\": %s\n", 5914603fc0a3Smrg lt_argv_zero, nonnull (strerror (errno))); 5915603fc0a3Smrg return 127; 5916603fc0a3Smrg } 5917603fc0a3Smrg return rval; 5918603fc0a3SmrgEOF 5919603fc0a3Smrg ;; 5920603fc0a3Smrg *) 5921603fc0a3Smrg cat <<"EOF" 5922603fc0a3Smrg execv (lt_argv_zero, newargz); 5923603fc0a3Smrg return rval; /* =127, but avoids unused variable warning */ 5924603fc0a3SmrgEOF 5925603fc0a3Smrg ;; 5926603fc0a3Smrg esac 5927603fc0a3Smrg 5928603fc0a3Smrg cat <<"EOF" 5929603fc0a3Smrg} 5930603fc0a3Smrg 5931603fc0a3Smrgvoid * 5932603fc0a3Smrgxmalloc (size_t num) 5933603fc0a3Smrg{ 5934603fc0a3Smrg void *p = (void *) malloc (num); 5935603fc0a3Smrg if (!p) 5936603fc0a3Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5937603fc0a3Smrg 5938603fc0a3Smrg return p; 5939603fc0a3Smrg} 5940603fc0a3Smrg 5941603fc0a3Smrgchar * 5942603fc0a3Smrgxstrdup (const char *string) 5943603fc0a3Smrg{ 5944603fc0a3Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 5945603fc0a3Smrg string) : NULL; 5946603fc0a3Smrg} 5947603fc0a3Smrg 5948603fc0a3Smrgconst char * 5949603fc0a3Smrgbase_name (const char *name) 5950603fc0a3Smrg{ 5951603fc0a3Smrg const char *base; 5952603fc0a3Smrg 5953603fc0a3Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 5954603fc0a3Smrg /* Skip over the disk name in MSDOS pathnames. */ 5955603fc0a3Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 5956603fc0a3Smrg name += 2; 5957603fc0a3Smrg#endif 5958603fc0a3Smrg 5959603fc0a3Smrg for (base = name; *name; name++) 5960603fc0a3Smrg if (IS_DIR_SEPARATOR (*name)) 5961603fc0a3Smrg base = name + 1; 5962603fc0a3Smrg return base; 5963603fc0a3Smrg} 5964603fc0a3Smrg 5965603fc0a3Smrgint 5966603fc0a3Smrgcheck_executable (const char *path) 5967603fc0a3Smrg{ 5968603fc0a3Smrg struct stat st; 5969603fc0a3Smrg 5970603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 5971603fc0a3Smrg nonempty (path)); 5972603fc0a3Smrg if ((!path) || (!*path)) 5973603fc0a3Smrg return 0; 5974603fc0a3Smrg 5975603fc0a3Smrg if ((stat (path, &st) >= 0) 5976603fc0a3Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 5977603fc0a3Smrg return 1; 5978603fc0a3Smrg else 5979603fc0a3Smrg return 0; 5980603fc0a3Smrg} 5981603fc0a3Smrg 5982603fc0a3Smrgint 5983603fc0a3Smrgmake_executable (const char *path) 5984603fc0a3Smrg{ 5985603fc0a3Smrg int rval = 0; 5986603fc0a3Smrg struct stat st; 5987603fc0a3Smrg 5988603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 5989603fc0a3Smrg nonempty (path)); 5990603fc0a3Smrg if ((!path) || (!*path)) 5991603fc0a3Smrg return 0; 5992603fc0a3Smrg 5993603fc0a3Smrg if (stat (path, &st) >= 0) 5994603fc0a3Smrg { 5995603fc0a3Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 5996603fc0a3Smrg } 5997603fc0a3Smrg return rval; 5998603fc0a3Smrg} 5999603fc0a3Smrg 6000603fc0a3Smrg/* Searches for the full path of the wrapper. Returns 6001603fc0a3Smrg newly allocated full path name if found, NULL otherwise 6002603fc0a3Smrg Does not chase symlinks, even on platforms that support them. 6003603fc0a3Smrg*/ 6004603fc0a3Smrgchar * 6005603fc0a3Smrgfind_executable (const char *wrapper) 6006603fc0a3Smrg{ 6007603fc0a3Smrg int has_slash = 0; 6008603fc0a3Smrg const char *p; 6009603fc0a3Smrg const char *p_next; 6010603fc0a3Smrg /* static buffer for getcwd */ 6011603fc0a3Smrg char tmp[LT_PATHMAX + 1]; 6012603fc0a3Smrg size_t tmp_len; 6013603fc0a3Smrg char *concat_name; 6014603fc0a3Smrg 6015603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6016603fc0a3Smrg nonempty (wrapper)); 6017603fc0a3Smrg 6018603fc0a3Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 6019603fc0a3Smrg return NULL; 6020603fc0a3Smrg 6021603fc0a3Smrg /* Absolute path? */ 6022603fc0a3Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6023603fc0a3Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6024603fc0a3Smrg { 6025603fc0a3Smrg concat_name = xstrdup (wrapper); 6026603fc0a3Smrg if (check_executable (concat_name)) 6027603fc0a3Smrg return concat_name; 6028603fc0a3Smrg XFREE (concat_name); 6029603fc0a3Smrg } 6030603fc0a3Smrg else 6031603fc0a3Smrg { 6032603fc0a3Smrg#endif 6033603fc0a3Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 6034603fc0a3Smrg { 6035603fc0a3Smrg concat_name = xstrdup (wrapper); 6036603fc0a3Smrg if (check_executable (concat_name)) 6037603fc0a3Smrg return concat_name; 6038603fc0a3Smrg XFREE (concat_name); 6039603fc0a3Smrg } 6040603fc0a3Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6041603fc0a3Smrg } 6042603fc0a3Smrg#endif 6043603fc0a3Smrg 6044603fc0a3Smrg for (p = wrapper; *p; p++) 6045603fc0a3Smrg if (*p == '/') 6046603fc0a3Smrg { 6047603fc0a3Smrg has_slash = 1; 6048603fc0a3Smrg break; 6049603fc0a3Smrg } 6050603fc0a3Smrg if (!has_slash) 6051603fc0a3Smrg { 6052603fc0a3Smrg /* no slashes; search PATH */ 6053603fc0a3Smrg const char *path = getenv ("PATH"); 6054603fc0a3Smrg if (path != NULL) 6055603fc0a3Smrg { 6056603fc0a3Smrg for (p = path; *p; p = p_next) 6057603fc0a3Smrg { 6058603fc0a3Smrg const char *q; 6059603fc0a3Smrg size_t p_len; 6060603fc0a3Smrg for (q = p; *q; q++) 6061603fc0a3Smrg if (IS_PATH_SEPARATOR (*q)) 6062603fc0a3Smrg break; 6063603fc0a3Smrg p_len = (size_t) (q - p); 6064603fc0a3Smrg p_next = (*q == '\0' ? q : q + 1); 6065603fc0a3Smrg if (p_len == 0) 6066603fc0a3Smrg { 6067603fc0a3Smrg /* empty path: current directory */ 6068603fc0a3Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6069603fc0a3Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6070603fc0a3Smrg nonnull (strerror (errno))); 6071603fc0a3Smrg tmp_len = strlen (tmp); 6072603fc0a3Smrg concat_name = 6073603fc0a3Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6074603fc0a3Smrg memcpy (concat_name, tmp, tmp_len); 6075603fc0a3Smrg concat_name[tmp_len] = '/'; 6076603fc0a3Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6077603fc0a3Smrg } 6078603fc0a3Smrg else 6079603fc0a3Smrg { 6080603fc0a3Smrg concat_name = 6081603fc0a3Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6082603fc0a3Smrg memcpy (concat_name, p, p_len); 6083603fc0a3Smrg concat_name[p_len] = '/'; 6084603fc0a3Smrg strcpy (concat_name + p_len + 1, wrapper); 6085603fc0a3Smrg } 6086603fc0a3Smrg if (check_executable (concat_name)) 6087603fc0a3Smrg return concat_name; 6088603fc0a3Smrg XFREE (concat_name); 6089603fc0a3Smrg } 6090603fc0a3Smrg } 6091603fc0a3Smrg /* not found in PATH; assume curdir */ 6092603fc0a3Smrg } 6093603fc0a3Smrg /* Relative path | not found in path: prepend cwd */ 6094603fc0a3Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6095603fc0a3Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6096603fc0a3Smrg nonnull (strerror (errno))); 6097603fc0a3Smrg tmp_len = strlen (tmp); 6098603fc0a3Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6099603fc0a3Smrg memcpy (concat_name, tmp, tmp_len); 6100603fc0a3Smrg concat_name[tmp_len] = '/'; 6101603fc0a3Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6102603fc0a3Smrg 6103603fc0a3Smrg if (check_executable (concat_name)) 6104603fc0a3Smrg return concat_name; 6105603fc0a3Smrg XFREE (concat_name); 6106603fc0a3Smrg return NULL; 6107603fc0a3Smrg} 6108603fc0a3Smrg 6109603fc0a3Smrgchar * 6110603fc0a3Smrgchase_symlinks (const char *pathspec) 6111603fc0a3Smrg{ 6112603fc0a3Smrg#ifndef S_ISLNK 6113603fc0a3Smrg return xstrdup (pathspec); 6114603fc0a3Smrg#else 6115603fc0a3Smrg char buf[LT_PATHMAX]; 6116603fc0a3Smrg struct stat s; 6117603fc0a3Smrg char *tmp_pathspec = xstrdup (pathspec); 6118603fc0a3Smrg char *p; 6119603fc0a3Smrg int has_symlinks = 0; 6120603fc0a3Smrg while (strlen (tmp_pathspec) && !has_symlinks) 6121603fc0a3Smrg { 6122603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, 6123603fc0a3Smrg "checking path component for symlinks: %s\n", 6124603fc0a3Smrg tmp_pathspec); 6125603fc0a3Smrg if (lstat (tmp_pathspec, &s) == 0) 6126603fc0a3Smrg { 6127603fc0a3Smrg if (S_ISLNK (s.st_mode) != 0) 6128603fc0a3Smrg { 6129603fc0a3Smrg has_symlinks = 1; 6130603fc0a3Smrg break; 6131603fc0a3Smrg } 6132603fc0a3Smrg 6133603fc0a3Smrg /* search backwards for last DIR_SEPARATOR */ 6134603fc0a3Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6135603fc0a3Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6136603fc0a3Smrg p--; 6137603fc0a3Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6138603fc0a3Smrg { 6139603fc0a3Smrg /* no more DIR_SEPARATORS left */ 6140603fc0a3Smrg break; 6141603fc0a3Smrg } 6142603fc0a3Smrg *p = '\0'; 6143603fc0a3Smrg } 6144603fc0a3Smrg else 6145603fc0a3Smrg { 6146603fc0a3Smrg lt_fatal (__FILE__, __LINE__, 6147603fc0a3Smrg "error accessing file \"%s\": %s", 6148603fc0a3Smrg tmp_pathspec, nonnull (strerror (errno))); 6149603fc0a3Smrg } 6150603fc0a3Smrg } 6151603fc0a3Smrg XFREE (tmp_pathspec); 6152603fc0a3Smrg 6153603fc0a3Smrg if (!has_symlinks) 6154603fc0a3Smrg { 6155603fc0a3Smrg return xstrdup (pathspec); 6156603fc0a3Smrg } 6157603fc0a3Smrg 6158603fc0a3Smrg tmp_pathspec = realpath (pathspec, buf); 6159603fc0a3Smrg if (tmp_pathspec == 0) 6160603fc0a3Smrg { 6161603fc0a3Smrg lt_fatal (__FILE__, __LINE__, 6162603fc0a3Smrg "could not follow symlinks for %s", pathspec); 6163603fc0a3Smrg } 6164603fc0a3Smrg return xstrdup (tmp_pathspec); 6165603fc0a3Smrg#endif 6166603fc0a3Smrg} 6167603fc0a3Smrg 6168603fc0a3Smrgchar * 6169603fc0a3Smrgstrendzap (char *str, const char *pat) 6170603fc0a3Smrg{ 6171603fc0a3Smrg size_t len, patlen; 6172603fc0a3Smrg 6173603fc0a3Smrg assert (str != NULL); 6174603fc0a3Smrg assert (pat != NULL); 6175603fc0a3Smrg 6176603fc0a3Smrg len = strlen (str); 6177603fc0a3Smrg patlen = strlen (pat); 6178603fc0a3Smrg 6179603fc0a3Smrg if (patlen <= len) 6180603fc0a3Smrg { 6181603fc0a3Smrg str += len - patlen; 6182603fc0a3Smrg if (STREQ (str, pat)) 6183603fc0a3Smrg *str = '\0'; 6184603fc0a3Smrg } 6185603fc0a3Smrg return str; 6186603fc0a3Smrg} 6187603fc0a3Smrg 6188603fc0a3Smrgvoid 6189603fc0a3Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6190603fc0a3Smrg{ 6191603fc0a3Smrg va_list args; 6192603fc0a3Smrg if (lt_debug) 6193603fc0a3Smrg { 6194603fc0a3Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6195603fc0a3Smrg va_start (args, fmt); 6196603fc0a3Smrg (void) vfprintf (stderr, fmt, args); 6197603fc0a3Smrg va_end (args); 6198603fc0a3Smrg } 6199603fc0a3Smrg} 6200603fc0a3Smrg 6201603fc0a3Smrgstatic void 6202603fc0a3Smrglt_error_core (int exit_status, const char *file, 6203603fc0a3Smrg int line, const char *mode, 6204603fc0a3Smrg const char *message, va_list ap) 6205603fc0a3Smrg{ 6206603fc0a3Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6207603fc0a3Smrg vfprintf (stderr, message, ap); 6208603fc0a3Smrg fprintf (stderr, ".\n"); 6209603fc0a3Smrg 6210603fc0a3Smrg if (exit_status >= 0) 6211603fc0a3Smrg exit (exit_status); 6212603fc0a3Smrg} 6213603fc0a3Smrg 6214603fc0a3Smrgvoid 6215603fc0a3Smrglt_fatal (const char *file, int line, const char *message, ...) 6216603fc0a3Smrg{ 6217603fc0a3Smrg va_list ap; 6218603fc0a3Smrg va_start (ap, message); 6219603fc0a3Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6220603fc0a3Smrg va_end (ap); 6221603fc0a3Smrg} 6222603fc0a3Smrg 6223603fc0a3Smrgstatic const char * 6224603fc0a3Smrgnonnull (const char *s) 6225603fc0a3Smrg{ 6226603fc0a3Smrg return s ? s : "(null)"; 6227603fc0a3Smrg} 6228603fc0a3Smrg 6229603fc0a3Smrgstatic const char * 6230603fc0a3Smrgnonempty (const char *s) 6231603fc0a3Smrg{ 6232603fc0a3Smrg return (s && !*s) ? "(empty)" : nonnull (s); 6233603fc0a3Smrg} 6234603fc0a3Smrg 6235603fc0a3Smrgvoid 6236603fc0a3Smrglt_setenv (const char *name, const char *value) 6237603fc0a3Smrg{ 6238603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, 6239603fc0a3Smrg "(lt_setenv) setting '%s' to '%s'\n", 6240603fc0a3Smrg nonnull (name), nonnull (value)); 6241603fc0a3Smrg { 6242603fc0a3Smrg#ifdef HAVE_SETENV 6243603fc0a3Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 6244603fc0a3Smrg char *str = xstrdup (value); 6245603fc0a3Smrg setenv (name, str, 1); 6246603fc0a3Smrg#else 6247603fc0a3Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6248603fc0a3Smrg char *str = XMALLOC (char, len); 6249603fc0a3Smrg sprintf (str, "%s=%s", name, value); 6250603fc0a3Smrg if (putenv (str) != EXIT_SUCCESS) 6251603fc0a3Smrg { 6252603fc0a3Smrg XFREE (str); 6253603fc0a3Smrg } 6254603fc0a3Smrg#endif 6255603fc0a3Smrg } 6256603fc0a3Smrg} 6257603fc0a3Smrg 6258603fc0a3Smrgchar * 6259603fc0a3Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 6260603fc0a3Smrg{ 6261603fc0a3Smrg char *new_value; 6262603fc0a3Smrg if (orig_value && *orig_value) 6263603fc0a3Smrg { 6264603fc0a3Smrg size_t orig_value_len = strlen (orig_value); 6265603fc0a3Smrg size_t add_len = strlen (add); 6266603fc0a3Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6267603fc0a3Smrg if (to_end) 6268603fc0a3Smrg { 6269603fc0a3Smrg strcpy (new_value, orig_value); 6270603fc0a3Smrg strcpy (new_value + orig_value_len, add); 6271603fc0a3Smrg } 6272603fc0a3Smrg else 6273603fc0a3Smrg { 6274603fc0a3Smrg strcpy (new_value, add); 6275603fc0a3Smrg strcpy (new_value + add_len, orig_value); 6276603fc0a3Smrg } 6277603fc0a3Smrg } 6278603fc0a3Smrg else 6279603fc0a3Smrg { 6280603fc0a3Smrg new_value = xstrdup (add); 6281603fc0a3Smrg } 6282603fc0a3Smrg return new_value; 6283603fc0a3Smrg} 6284603fc0a3Smrg 6285603fc0a3Smrgvoid 6286603fc0a3Smrglt_update_exe_path (const char *name, const char *value) 6287603fc0a3Smrg{ 6288603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, 6289603fc0a3Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6290603fc0a3Smrg nonnull (name), nonnull (value)); 6291603fc0a3Smrg 6292603fc0a3Smrg if (name && *name && value && *value) 6293603fc0a3Smrg { 6294603fc0a3Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6295603fc0a3Smrg /* some systems can't cope with a ':'-terminated path #' */ 6296603fc0a3Smrg size_t len = strlen (new_value); 6297603fc0a3Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6298603fc0a3Smrg { 6299603fc0a3Smrg new_value[--len] = '\0'; 6300603fc0a3Smrg } 6301603fc0a3Smrg lt_setenv (name, new_value); 6302603fc0a3Smrg XFREE (new_value); 6303603fc0a3Smrg } 6304603fc0a3Smrg} 6305603fc0a3Smrg 6306603fc0a3Smrgvoid 6307603fc0a3Smrglt_update_lib_path (const char *name, const char *value) 6308603fc0a3Smrg{ 6309603fc0a3Smrg lt_debugprintf (__FILE__, __LINE__, 6310603fc0a3Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6311603fc0a3Smrg nonnull (name), nonnull (value)); 6312603fc0a3Smrg 6313603fc0a3Smrg if (name && *name && value && *value) 6314603fc0a3Smrg { 6315603fc0a3Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 6316603fc0a3Smrg lt_setenv (name, new_value); 6317603fc0a3Smrg XFREE (new_value); 6318603fc0a3Smrg } 6319603fc0a3Smrg} 6320603fc0a3Smrg 6321603fc0a3SmrgEOF 6322603fc0a3Smrg case $host_os in 6323603fc0a3Smrg mingw*) 6324603fc0a3Smrg cat <<"EOF" 6325603fc0a3Smrg 6326603fc0a3Smrg/* Prepares an argument vector before calling spawn(). 6327603fc0a3Smrg Note that spawn() does not by itself call the command interpreter 6328603fc0a3Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6329603fc0a3Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6330603fc0a3Smrg GetVersionEx(&v); 6331603fc0a3Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6332603fc0a3Smrg }) ? "cmd.exe" : "command.com"). 6333603fc0a3Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 6334603fc0a3Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6335603fc0a3Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6336603fc0a3Smrg special way: 6337603fc0a3Smrg - Space and tab are interpreted as delimiters. They are not treated as 6338603fc0a3Smrg delimiters if they are surrounded by double quotes: "...". 6339603fc0a3Smrg - Unescaped double quotes are removed from the input. Their only effect is 6340603fc0a3Smrg that within double quotes, space and tab are treated like normal 6341603fc0a3Smrg characters. 6342603fc0a3Smrg - Backslashes not followed by double quotes are not special. 6343603fc0a3Smrg - But 2*n+1 backslashes followed by a double quote become 6344603fc0a3Smrg n backslashes followed by a double quote (n >= 0): 6345603fc0a3Smrg \" -> " 6346603fc0a3Smrg \\\" -> \" 6347603fc0a3Smrg \\\\\" -> \\" 6348603fc0a3Smrg */ 6349603fc0a3Smrg#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" 6350603fc0a3Smrg#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" 6351603fc0a3Smrgchar ** 6352603fc0a3Smrgprepare_spawn (char **argv) 6353603fc0a3Smrg{ 6354603fc0a3Smrg size_t argc; 6355603fc0a3Smrg char **new_argv; 6356603fc0a3Smrg size_t i; 6357603fc0a3Smrg 6358603fc0a3Smrg /* Count number of arguments. */ 6359603fc0a3Smrg for (argc = 0; argv[argc] != NULL; argc++) 6360603fc0a3Smrg ; 6361603fc0a3Smrg 6362603fc0a3Smrg /* Allocate new argument vector. */ 6363603fc0a3Smrg new_argv = XMALLOC (char *, argc + 1); 6364603fc0a3Smrg 6365603fc0a3Smrg /* Put quoted arguments into the new argument vector. */ 6366603fc0a3Smrg for (i = 0; i < argc; i++) 6367603fc0a3Smrg { 6368603fc0a3Smrg const char *string = argv[i]; 6369603fc0a3Smrg 6370603fc0a3Smrg if (string[0] == '\0') 6371603fc0a3Smrg new_argv[i] = xstrdup ("\"\""); 6372603fc0a3Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6373603fc0a3Smrg { 6374603fc0a3Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6375603fc0a3Smrg size_t length; 6376603fc0a3Smrg unsigned int backslashes; 6377603fc0a3Smrg const char *s; 6378603fc0a3Smrg char *quoted_string; 6379603fc0a3Smrg char *p; 6380603fc0a3Smrg 6381603fc0a3Smrg length = 0; 6382603fc0a3Smrg backslashes = 0; 6383603fc0a3Smrg if (quote_around) 6384603fc0a3Smrg length++; 6385603fc0a3Smrg for (s = string; *s != '\0'; s++) 6386603fc0a3Smrg { 6387603fc0a3Smrg char c = *s; 6388603fc0a3Smrg if (c == '"') 6389603fc0a3Smrg length += backslashes + 1; 6390603fc0a3Smrg length++; 6391603fc0a3Smrg if (c == '\\') 6392603fc0a3Smrg backslashes++; 6393603fc0a3Smrg else 6394603fc0a3Smrg backslashes = 0; 6395603fc0a3Smrg } 6396603fc0a3Smrg if (quote_around) 6397603fc0a3Smrg length += backslashes + 1; 6398603fc0a3Smrg 6399603fc0a3Smrg quoted_string = XMALLOC (char, length + 1); 6400603fc0a3Smrg 6401603fc0a3Smrg p = quoted_string; 6402603fc0a3Smrg backslashes = 0; 6403603fc0a3Smrg if (quote_around) 6404603fc0a3Smrg *p++ = '"'; 6405603fc0a3Smrg for (s = string; *s != '\0'; s++) 6406603fc0a3Smrg { 6407603fc0a3Smrg char c = *s; 6408603fc0a3Smrg if (c == '"') 6409603fc0a3Smrg { 6410603fc0a3Smrg unsigned int j; 6411603fc0a3Smrg for (j = backslashes + 1; j > 0; j--) 6412603fc0a3Smrg *p++ = '\\'; 6413603fc0a3Smrg } 6414603fc0a3Smrg *p++ = c; 6415603fc0a3Smrg if (c == '\\') 6416603fc0a3Smrg backslashes++; 6417603fc0a3Smrg else 6418603fc0a3Smrg backslashes = 0; 6419603fc0a3Smrg } 6420603fc0a3Smrg if (quote_around) 6421603fc0a3Smrg { 6422603fc0a3Smrg unsigned int j; 6423603fc0a3Smrg for (j = backslashes; j > 0; j--) 6424603fc0a3Smrg *p++ = '\\'; 6425603fc0a3Smrg *p++ = '"'; 6426603fc0a3Smrg } 6427603fc0a3Smrg *p = '\0'; 6428603fc0a3Smrg 6429603fc0a3Smrg new_argv[i] = quoted_string; 6430603fc0a3Smrg } 6431603fc0a3Smrg else 6432603fc0a3Smrg new_argv[i] = (char *) string; 6433603fc0a3Smrg } 6434603fc0a3Smrg new_argv[argc] = NULL; 6435603fc0a3Smrg 6436603fc0a3Smrg return new_argv; 6437603fc0a3Smrg} 6438603fc0a3SmrgEOF 6439603fc0a3Smrg ;; 6440603fc0a3Smrg esac 6441603fc0a3Smrg 6442603fc0a3Smrg cat <<"EOF" 6443603fc0a3Smrgvoid lt_dump_script (FILE* f) 6444603fc0a3Smrg{ 6445603fc0a3SmrgEOF 6446603fc0a3Smrg func_emit_wrapper yes | 6447603fc0a3Smrg $SED -n -e ' 6448603fc0a3Smrgs/^\(.\{79\}\)\(..*\)/\1\ 6449603fc0a3Smrg\2/ 6450603fc0a3Smrgh 6451603fc0a3Smrgs/\([\\"]\)/\\\1/g 6452603fc0a3Smrgs/$/\\n/ 6453603fc0a3Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6454603fc0a3Smrgg 6455603fc0a3SmrgD' 6456603fc0a3Smrg cat <<"EOF" 6457603fc0a3Smrg} 6458603fc0a3SmrgEOF 6459603fc0a3Smrg} 6460603fc0a3Smrg# end: func_emit_cwrapperexe_src 6461603fc0a3Smrg 6462603fc0a3Smrg# func_win32_import_lib_p ARG 6463603fc0a3Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6464603fc0a3Smrgfunc_win32_import_lib_p () 6465603fc0a3Smrg{ 6466603fc0a3Smrg $debug_cmd 6467603fc0a3Smrg 6468603fc0a3Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6469603fc0a3Smrg *import*) : ;; 6470603fc0a3Smrg *) false ;; 6471603fc0a3Smrg esac 6472603fc0a3Smrg} 6473603fc0a3Smrg 6474603fc0a3Smrg# func_suncc_cstd_abi 6475603fc0a3Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6476603fc0a3Smrg# Several compiler flags select an ABI that is incompatible with the 6477603fc0a3Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6478603fc0a3Smrgfunc_suncc_cstd_abi () 6479603fc0a3Smrg{ 6480603fc0a3Smrg $debug_cmd 6481603fc0a3Smrg 6482603fc0a3Smrg case " $compile_command " in 6483603fc0a3Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6484603fc0a3Smrg suncc_use_cstd_abi=no 6485603fc0a3Smrg ;; 6486603fc0a3Smrg *) 6487603fc0a3Smrg suncc_use_cstd_abi=yes 6488603fc0a3Smrg ;; 6489603fc0a3Smrg esac 6490603fc0a3Smrg} 6491603fc0a3Smrg 6492603fc0a3Smrg# func_mode_link arg... 6493603fc0a3Smrgfunc_mode_link () 6494603fc0a3Smrg{ 6495603fc0a3Smrg $debug_cmd 6496603fc0a3Smrg 6497603fc0a3Smrg case $host in 6498603fc0a3Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6499603fc0a3Smrg # It is impossible to link a dll without this setting, and 6500603fc0a3Smrg # we shouldn't force the makefile maintainer to figure out 6501603fc0a3Smrg # what system we are compiling for in order to pass an extra 6502603fc0a3Smrg # flag for every libtool invocation. 6503603fc0a3Smrg # allow_undefined=no 6504603fc0a3Smrg 6505603fc0a3Smrg # FIXME: Unfortunately, there are problems with the above when trying 6506603fc0a3Smrg # to make a dll that has undefined symbols, in which case not 6507603fc0a3Smrg # even a static library is built. For now, we need to specify 6508603fc0a3Smrg # -no-undefined on the libtool link line when we can be certain 6509603fc0a3Smrg # that all symbols are satisfied, otherwise we get a static library. 6510603fc0a3Smrg allow_undefined=yes 6511603fc0a3Smrg ;; 6512603fc0a3Smrg *) 6513603fc0a3Smrg allow_undefined=yes 6514603fc0a3Smrg ;; 6515603fc0a3Smrg esac 6516603fc0a3Smrg libtool_args=$nonopt 6517603fc0a3Smrg base_compile="$nonopt $@" 6518603fc0a3Smrg compile_command=$nonopt 6519603fc0a3Smrg finalize_command=$nonopt 6520603fc0a3Smrg 6521603fc0a3Smrg compile_rpath= 6522603fc0a3Smrg finalize_rpath= 6523603fc0a3Smrg compile_shlibpath= 6524603fc0a3Smrg finalize_shlibpath= 6525603fc0a3Smrg convenience= 6526603fc0a3Smrg old_convenience= 6527603fc0a3Smrg deplibs= 6528603fc0a3Smrg old_deplibs= 6529603fc0a3Smrg compiler_flags= 6530603fc0a3Smrg linker_flags= 6531603fc0a3Smrg dllsearchpath= 6532603fc0a3Smrg lib_search_path=`pwd` 6533603fc0a3Smrg inst_prefix_dir= 6534603fc0a3Smrg new_inherited_linker_flags= 6535603fc0a3Smrg 6536603fc0a3Smrg avoid_version=no 6537603fc0a3Smrg bindir= 6538603fc0a3Smrg dlfiles= 6539603fc0a3Smrg dlprefiles= 6540603fc0a3Smrg dlself=no 6541603fc0a3Smrg export_dynamic=no 6542603fc0a3Smrg export_symbols= 6543603fc0a3Smrg export_symbols_regex= 6544603fc0a3Smrg generated= 6545603fc0a3Smrg libobjs= 6546603fc0a3Smrg ltlibs= 6547603fc0a3Smrg module=no 6548603fc0a3Smrg no_install=no 6549603fc0a3Smrg objs= 6550603fc0a3Smrg os2dllname= 6551603fc0a3Smrg non_pic_objects= 6552603fc0a3Smrg precious_files_regex= 6553603fc0a3Smrg prefer_static_libs=no 6554603fc0a3Smrg preload=false 6555603fc0a3Smrg prev= 6556603fc0a3Smrg prevarg= 6557603fc0a3Smrg release= 6558603fc0a3Smrg rpath= 6559603fc0a3Smrg xrpath= 6560603fc0a3Smrg perm_rpath= 6561603fc0a3Smrg temp_rpath= 6562603fc0a3Smrg thread_safe=no 6563603fc0a3Smrg vinfo= 6564603fc0a3Smrg vinfo_number=no 6565603fc0a3Smrg weak_libs= 6566603fc0a3Smrg single_module=$wl-single_module 6567603fc0a3Smrg func_infer_tag $base_compile 6568603fc0a3Smrg 6569603fc0a3Smrg # We need to know -static, to get the right output filenames. 6570603fc0a3Smrg for arg 6571603fc0a3Smrg do 6572603fc0a3Smrg case $arg in 6573603fc0a3Smrg -shared) 6574603fc0a3Smrg test yes != "$build_libtool_libs" \ 6575603fc0a3Smrg && func_fatal_configuration "cannot build a shared library" 6576603fc0a3Smrg build_old_libs=no 6577603fc0a3Smrg break 6578603fc0a3Smrg ;; 6579603fc0a3Smrg -all-static | -static | -static-libtool-libs) 6580603fc0a3Smrg case $arg in 6581603fc0a3Smrg -all-static) 6582603fc0a3Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6583603fc0a3Smrg func_warning "complete static linking is impossible in this configuration" 6584603fc0a3Smrg fi 6585603fc0a3Smrg if test -n "$link_static_flag"; then 6586603fc0a3Smrg dlopen_self=$dlopen_self_static 6587603fc0a3Smrg fi 6588603fc0a3Smrg prefer_static_libs=yes 6589603fc0a3Smrg ;; 6590603fc0a3Smrg -static) 6591603fc0a3Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6592603fc0a3Smrg dlopen_self=$dlopen_self_static 6593603fc0a3Smrg fi 6594603fc0a3Smrg prefer_static_libs=built 6595603fc0a3Smrg ;; 6596603fc0a3Smrg -static-libtool-libs) 6597603fc0a3Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6598603fc0a3Smrg dlopen_self=$dlopen_self_static 6599603fc0a3Smrg fi 6600603fc0a3Smrg prefer_static_libs=yes 6601603fc0a3Smrg ;; 6602603fc0a3Smrg esac 6603603fc0a3Smrg build_libtool_libs=no 6604603fc0a3Smrg build_old_libs=yes 6605603fc0a3Smrg break 6606603fc0a3Smrg ;; 6607603fc0a3Smrg esac 6608603fc0a3Smrg done 6609603fc0a3Smrg 6610603fc0a3Smrg # See if our shared archives depend on static archives. 6611603fc0a3Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6612603fc0a3Smrg 6613603fc0a3Smrg # Go through the arguments, transforming them on the way. 6614603fc0a3Smrg while test "$#" -gt 0; do 6615603fc0a3Smrg arg=$1 6616603fc0a3Smrg shift 6617603fc0a3Smrg func_quote_for_eval "$arg" 6618603fc0a3Smrg qarg=$func_quote_for_eval_unquoted_result 6619603fc0a3Smrg func_append libtool_args " $func_quote_for_eval_result" 6620603fc0a3Smrg 6621603fc0a3Smrg # If the previous option needs an argument, assign it. 6622603fc0a3Smrg if test -n "$prev"; then 6623603fc0a3Smrg case $prev in 6624603fc0a3Smrg output) 6625603fc0a3Smrg func_append compile_command " @OUTPUT@" 6626603fc0a3Smrg func_append finalize_command " @OUTPUT@" 6627603fc0a3Smrg ;; 6628603fc0a3Smrg esac 6629603fc0a3Smrg 6630603fc0a3Smrg case $prev in 6631603fc0a3Smrg bindir) 6632603fc0a3Smrg bindir=$arg 6633603fc0a3Smrg prev= 6634603fc0a3Smrg continue 6635603fc0a3Smrg ;; 6636603fc0a3Smrg dlfiles|dlprefiles) 6637603fc0a3Smrg $preload || { 6638603fc0a3Smrg # Add the symbol object into the linking commands. 6639603fc0a3Smrg func_append compile_command " @SYMFILE@" 6640603fc0a3Smrg func_append finalize_command " @SYMFILE@" 6641603fc0a3Smrg preload=: 6642603fc0a3Smrg } 6643603fc0a3Smrg case $arg in 6644603fc0a3Smrg *.la | *.lo) ;; # We handle these cases below. 6645603fc0a3Smrg force) 6646603fc0a3Smrg if test no = "$dlself"; then 6647603fc0a3Smrg dlself=needless 6648603fc0a3Smrg export_dynamic=yes 6649603fc0a3Smrg fi 6650603fc0a3Smrg prev= 6651603fc0a3Smrg continue 6652603fc0a3Smrg ;; 6653603fc0a3Smrg self) 6654603fc0a3Smrg if test dlprefiles = "$prev"; then 6655603fc0a3Smrg dlself=yes 6656603fc0a3Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6657603fc0a3Smrg dlself=yes 6658603fc0a3Smrg else 6659603fc0a3Smrg dlself=needless 6660603fc0a3Smrg export_dynamic=yes 6661603fc0a3Smrg fi 6662603fc0a3Smrg prev= 6663603fc0a3Smrg continue 6664603fc0a3Smrg ;; 6665603fc0a3Smrg *) 6666603fc0a3Smrg if test dlfiles = "$prev"; then 6667603fc0a3Smrg func_append dlfiles " $arg" 6668603fc0a3Smrg else 6669603fc0a3Smrg func_append dlprefiles " $arg" 6670603fc0a3Smrg fi 6671603fc0a3Smrg prev= 6672603fc0a3Smrg continue 6673603fc0a3Smrg ;; 6674603fc0a3Smrg esac 6675603fc0a3Smrg ;; 6676603fc0a3Smrg expsyms) 6677603fc0a3Smrg export_symbols=$arg 6678603fc0a3Smrg test -f "$arg" \ 6679603fc0a3Smrg || func_fatal_error "symbol file '$arg' does not exist" 6680603fc0a3Smrg prev= 6681603fc0a3Smrg continue 6682603fc0a3Smrg ;; 6683603fc0a3Smrg expsyms_regex) 6684603fc0a3Smrg export_symbols_regex=$arg 6685603fc0a3Smrg prev= 6686603fc0a3Smrg continue 6687603fc0a3Smrg ;; 6688603fc0a3Smrg framework) 6689603fc0a3Smrg case $host in 6690603fc0a3Smrg *-*-darwin*) 6691603fc0a3Smrg case "$deplibs " in 6692603fc0a3Smrg *" $qarg.ltframework "*) ;; 6693603fc0a3Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6694603fc0a3Smrg ;; 6695603fc0a3Smrg esac 6696603fc0a3Smrg ;; 6697603fc0a3Smrg esac 6698603fc0a3Smrg prev= 6699603fc0a3Smrg continue 6700603fc0a3Smrg ;; 6701603fc0a3Smrg inst_prefix) 6702603fc0a3Smrg inst_prefix_dir=$arg 6703603fc0a3Smrg prev= 6704603fc0a3Smrg continue 6705603fc0a3Smrg ;; 6706603fc0a3Smrg mllvm) 6707603fc0a3Smrg # Clang does not use LLVM to link, so we can simply discard any 6708603fc0a3Smrg # '-mllvm $arg' options when doing the link step. 6709603fc0a3Smrg prev= 6710603fc0a3Smrg continue 6711603fc0a3Smrg ;; 6712603fc0a3Smrg objectlist) 6713603fc0a3Smrg if test -f "$arg"; then 6714603fc0a3Smrg save_arg=$arg 6715603fc0a3Smrg moreargs= 6716603fc0a3Smrg for fil in `cat "$save_arg"` 6717603fc0a3Smrg do 6718603fc0a3Smrg# func_append moreargs " $fil" 6719603fc0a3Smrg arg=$fil 6720603fc0a3Smrg # A libtool-controlled object. 6721603fc0a3Smrg 6722603fc0a3Smrg # Check to see that this really is a libtool object. 6723603fc0a3Smrg if func_lalib_unsafe_p "$arg"; then 6724603fc0a3Smrg pic_object= 6725603fc0a3Smrg non_pic_object= 6726603fc0a3Smrg 6727603fc0a3Smrg # Read the .lo file 6728603fc0a3Smrg func_source "$arg" 6729603fc0a3Smrg 6730603fc0a3Smrg if test -z "$pic_object" || 6731603fc0a3Smrg test -z "$non_pic_object" || 6732603fc0a3Smrg test none = "$pic_object" && 6733603fc0a3Smrg test none = "$non_pic_object"; then 6734603fc0a3Smrg func_fatal_error "cannot find name of object for '$arg'" 6735603fc0a3Smrg fi 6736603fc0a3Smrg 6737603fc0a3Smrg # Extract subdirectory from the argument. 6738603fc0a3Smrg func_dirname "$arg" "/" "" 6739603fc0a3Smrg xdir=$func_dirname_result 6740603fc0a3Smrg 6741603fc0a3Smrg if test none != "$pic_object"; then 6742603fc0a3Smrg # Prepend the subdirectory the object is found in. 6743603fc0a3Smrg pic_object=$xdir$pic_object 6744603fc0a3Smrg 6745603fc0a3Smrg if test dlfiles = "$prev"; then 6746603fc0a3Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6747603fc0a3Smrg func_append dlfiles " $pic_object" 6748603fc0a3Smrg prev= 6749603fc0a3Smrg continue 6750603fc0a3Smrg else 6751603fc0a3Smrg # If libtool objects are unsupported, then we need to preload. 6752603fc0a3Smrg prev=dlprefiles 6753603fc0a3Smrg fi 6754603fc0a3Smrg fi 6755603fc0a3Smrg 6756603fc0a3Smrg # CHECK ME: I think I busted this. -Ossama 6757603fc0a3Smrg if test dlprefiles = "$prev"; then 6758603fc0a3Smrg # Preload the old-style object. 6759603fc0a3Smrg func_append dlprefiles " $pic_object" 6760603fc0a3Smrg prev= 6761603fc0a3Smrg fi 6762603fc0a3Smrg 6763603fc0a3Smrg # A PIC object. 6764603fc0a3Smrg func_append libobjs " $pic_object" 6765603fc0a3Smrg arg=$pic_object 6766603fc0a3Smrg fi 6767603fc0a3Smrg 6768603fc0a3Smrg # Non-PIC object. 6769603fc0a3Smrg if test none != "$non_pic_object"; then 6770603fc0a3Smrg # Prepend the subdirectory the object is found in. 6771603fc0a3Smrg non_pic_object=$xdir$non_pic_object 6772603fc0a3Smrg 6773603fc0a3Smrg # A standard non-PIC object 6774603fc0a3Smrg func_append non_pic_objects " $non_pic_object" 6775603fc0a3Smrg if test -z "$pic_object" || test none = "$pic_object"; then 6776603fc0a3Smrg arg=$non_pic_object 6777603fc0a3Smrg fi 6778603fc0a3Smrg else 6779603fc0a3Smrg # If the PIC object exists, use it instead. 6780603fc0a3Smrg # $xdir was prepended to $pic_object above. 6781603fc0a3Smrg non_pic_object=$pic_object 6782603fc0a3Smrg func_append non_pic_objects " $non_pic_object" 6783603fc0a3Smrg fi 6784603fc0a3Smrg else 6785603fc0a3Smrg # Only an error if not doing a dry-run. 6786603fc0a3Smrg if $opt_dry_run; then 6787603fc0a3Smrg # Extract subdirectory from the argument. 6788603fc0a3Smrg func_dirname "$arg" "/" "" 6789603fc0a3Smrg xdir=$func_dirname_result 6790603fc0a3Smrg 6791603fc0a3Smrg func_lo2o "$arg" 6792603fc0a3Smrg pic_object=$xdir$objdir/$func_lo2o_result 6793603fc0a3Smrg non_pic_object=$xdir$func_lo2o_result 6794603fc0a3Smrg func_append libobjs " $pic_object" 6795603fc0a3Smrg func_append non_pic_objects " $non_pic_object" 6796603fc0a3Smrg else 6797603fc0a3Smrg func_fatal_error "'$arg' is not a valid libtool object" 6798603fc0a3Smrg fi 6799603fc0a3Smrg fi 6800603fc0a3Smrg done 6801603fc0a3Smrg else 6802603fc0a3Smrg func_fatal_error "link input file '$arg' does not exist" 6803603fc0a3Smrg fi 6804603fc0a3Smrg arg=$save_arg 6805603fc0a3Smrg prev= 6806603fc0a3Smrg continue 6807603fc0a3Smrg ;; 6808603fc0a3Smrg os2dllname) 6809603fc0a3Smrg os2dllname=$arg 6810603fc0a3Smrg prev= 6811603fc0a3Smrg continue 6812603fc0a3Smrg ;; 6813603fc0a3Smrg precious_regex) 6814603fc0a3Smrg precious_files_regex=$arg 6815603fc0a3Smrg prev= 6816603fc0a3Smrg continue 6817603fc0a3Smrg ;; 6818603fc0a3Smrg release) 6819603fc0a3Smrg release=-$arg 6820603fc0a3Smrg prev= 6821603fc0a3Smrg continue 6822603fc0a3Smrg ;; 6823603fc0a3Smrg rpath | xrpath) 6824603fc0a3Smrg # We need an absolute path. 6825603fc0a3Smrg case $arg in 6826603fc0a3Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6827603fc0a3Smrg *) 6828603fc0a3Smrg func_fatal_error "only absolute run-paths are allowed" 6829603fc0a3Smrg ;; 6830603fc0a3Smrg esac 6831603fc0a3Smrg if test rpath = "$prev"; then 6832603fc0a3Smrg case "$rpath " in 6833603fc0a3Smrg *" $arg "*) ;; 6834603fc0a3Smrg *) func_append rpath " $arg" ;; 6835603fc0a3Smrg esac 6836603fc0a3Smrg else 6837603fc0a3Smrg case "$xrpath " in 6838603fc0a3Smrg *" $arg "*) ;; 6839603fc0a3Smrg *) func_append xrpath " $arg" ;; 6840603fc0a3Smrg esac 6841603fc0a3Smrg fi 6842603fc0a3Smrg prev= 6843603fc0a3Smrg continue 6844603fc0a3Smrg ;; 6845603fc0a3Smrg shrext) 6846603fc0a3Smrg shrext_cmds=$arg 6847603fc0a3Smrg prev= 6848603fc0a3Smrg continue 6849603fc0a3Smrg ;; 6850603fc0a3Smrg weak) 6851603fc0a3Smrg func_append weak_libs " $arg" 6852603fc0a3Smrg prev= 6853603fc0a3Smrg continue 6854603fc0a3Smrg ;; 6855603fc0a3Smrg xcclinker) 6856603fc0a3Smrg func_append linker_flags " $qarg" 6857603fc0a3Smrg func_append compiler_flags " $qarg" 6858603fc0a3Smrg prev= 6859603fc0a3Smrg func_append compile_command " $qarg" 6860603fc0a3Smrg func_append finalize_command " $qarg" 6861603fc0a3Smrg continue 6862603fc0a3Smrg ;; 6863603fc0a3Smrg xcompiler) 6864603fc0a3Smrg func_append compiler_flags " $qarg" 6865603fc0a3Smrg prev= 6866603fc0a3Smrg func_append compile_command " $qarg" 6867603fc0a3Smrg func_append finalize_command " $qarg" 6868603fc0a3Smrg continue 6869603fc0a3Smrg ;; 6870603fc0a3Smrg xlinker) 6871603fc0a3Smrg func_append linker_flags " $qarg" 6872603fc0a3Smrg func_append compiler_flags " $wl$qarg" 6873603fc0a3Smrg prev= 6874603fc0a3Smrg func_append compile_command " $wl$qarg" 6875603fc0a3Smrg func_append finalize_command " $wl$qarg" 6876603fc0a3Smrg continue 6877603fc0a3Smrg ;; 6878603fc0a3Smrg *) 6879603fc0a3Smrg eval "$prev=\"\$arg\"" 6880603fc0a3Smrg prev= 6881603fc0a3Smrg continue 6882603fc0a3Smrg ;; 6883603fc0a3Smrg esac 6884603fc0a3Smrg fi # test -n "$prev" 6885603fc0a3Smrg 6886603fc0a3Smrg prevarg=$arg 6887603fc0a3Smrg 6888603fc0a3Smrg case $arg in 6889603fc0a3Smrg -all-static) 6890603fc0a3Smrg if test -n "$link_static_flag"; then 6891603fc0a3Smrg # See comment for -static flag below, for more details. 6892603fc0a3Smrg func_append compile_command " $link_static_flag" 6893603fc0a3Smrg func_append finalize_command " $link_static_flag" 6894603fc0a3Smrg fi 6895603fc0a3Smrg continue 6896603fc0a3Smrg ;; 6897603fc0a3Smrg 6898603fc0a3Smrg -allow-undefined) 6899603fc0a3Smrg # FIXME: remove this flag sometime in the future. 6900603fc0a3Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 6901603fc0a3Smrg ;; 6902603fc0a3Smrg 6903603fc0a3Smrg -avoid-version) 6904603fc0a3Smrg avoid_version=yes 6905603fc0a3Smrg continue 6906603fc0a3Smrg ;; 6907603fc0a3Smrg 6908603fc0a3Smrg -bindir) 6909603fc0a3Smrg prev=bindir 6910603fc0a3Smrg continue 6911603fc0a3Smrg ;; 6912603fc0a3Smrg 6913603fc0a3Smrg -dlopen) 6914603fc0a3Smrg prev=dlfiles 6915603fc0a3Smrg continue 6916603fc0a3Smrg ;; 6917603fc0a3Smrg 6918603fc0a3Smrg -dlpreopen) 6919603fc0a3Smrg prev=dlprefiles 6920603fc0a3Smrg continue 6921603fc0a3Smrg ;; 6922603fc0a3Smrg 6923603fc0a3Smrg -export-dynamic) 6924603fc0a3Smrg export_dynamic=yes 6925603fc0a3Smrg continue 6926603fc0a3Smrg ;; 6927603fc0a3Smrg 6928603fc0a3Smrg -export-symbols | -export-symbols-regex) 6929603fc0a3Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 6930603fc0a3Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 6931603fc0a3Smrg fi 6932603fc0a3Smrg if test X-export-symbols = "X$arg"; then 6933603fc0a3Smrg prev=expsyms 6934603fc0a3Smrg else 6935603fc0a3Smrg prev=expsyms_regex 6936603fc0a3Smrg fi 6937603fc0a3Smrg continue 6938603fc0a3Smrg ;; 6939603fc0a3Smrg 6940603fc0a3Smrg -framework) 6941603fc0a3Smrg prev=framework 6942603fc0a3Smrg continue 6943603fc0a3Smrg ;; 6944603fc0a3Smrg 6945603fc0a3Smrg -inst-prefix-dir) 6946603fc0a3Smrg prev=inst_prefix 6947603fc0a3Smrg continue 6948603fc0a3Smrg ;; 6949603fc0a3Smrg 6950603fc0a3Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 6951603fc0a3Smrg # so, if we see these flags be careful not to treat them like -L 6952603fc0a3Smrg -L[A-Z][A-Z]*:*) 6953603fc0a3Smrg case $with_gcc/$host in 6954603fc0a3Smrg no/*-*-irix* | /*-*-irix*) 6955603fc0a3Smrg func_append compile_command " $arg" 6956603fc0a3Smrg func_append finalize_command " $arg" 6957603fc0a3Smrg ;; 6958603fc0a3Smrg esac 6959603fc0a3Smrg continue 6960603fc0a3Smrg ;; 6961603fc0a3Smrg 6962603fc0a3Smrg -L*) 6963603fc0a3Smrg func_stripname "-L" '' "$arg" 6964603fc0a3Smrg if test -z "$func_stripname_result"; then 6965603fc0a3Smrg if test "$#" -gt 0; then 6966603fc0a3Smrg func_fatal_error "require no space between '-L' and '$1'" 6967603fc0a3Smrg else 6968603fc0a3Smrg func_fatal_error "need path for '-L' option" 6969603fc0a3Smrg fi 6970603fc0a3Smrg fi 6971603fc0a3Smrg func_resolve_sysroot "$func_stripname_result" 6972603fc0a3Smrg dir=$func_resolve_sysroot_result 6973603fc0a3Smrg # We need an absolute path. 6974603fc0a3Smrg case $dir in 6975603fc0a3Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6976603fc0a3Smrg *) 6977603fc0a3Smrg absdir=`cd "$dir" && pwd` 6978603fc0a3Smrg test -z "$absdir" && \ 6979603fc0a3Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 6980603fc0a3Smrg dir=$absdir 6981603fc0a3Smrg ;; 6982603fc0a3Smrg esac 6983603fc0a3Smrg case "$deplibs " in 6984603fc0a3Smrg *" -L$dir "* | *" $arg "*) 6985603fc0a3Smrg # Will only happen for absolute or sysroot arguments 6986603fc0a3Smrg ;; 6987603fc0a3Smrg *) 6988603fc0a3Smrg # Preserve sysroot, but never include relative directories 6989603fc0a3Smrg case $dir in 6990603fc0a3Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 6991603fc0a3Smrg *) func_append deplibs " -L$dir" ;; 6992603fc0a3Smrg esac 6993603fc0a3Smrg func_append lib_search_path " $dir" 6994603fc0a3Smrg ;; 6995603fc0a3Smrg esac 6996603fc0a3Smrg case $host in 6997603fc0a3Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6998603fc0a3Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 6999603fc0a3Smrg case :$dllsearchpath: in 7000603fc0a3Smrg *":$dir:"*) ;; 7001603fc0a3Smrg ::) dllsearchpath=$dir;; 7002603fc0a3Smrg *) func_append dllsearchpath ":$dir";; 7003603fc0a3Smrg esac 7004603fc0a3Smrg case :$dllsearchpath: in 7005603fc0a3Smrg *":$testbindir:"*) ;; 7006603fc0a3Smrg ::) dllsearchpath=$testbindir;; 7007603fc0a3Smrg *) func_append dllsearchpath ":$testbindir";; 7008603fc0a3Smrg esac 7009603fc0a3Smrg ;; 7010603fc0a3Smrg esac 7011603fc0a3Smrg continue 7012603fc0a3Smrg ;; 7013603fc0a3Smrg 7014603fc0a3Smrg -l*) 7015603fc0a3Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7016603fc0a3Smrg case $host in 7017603fc0a3Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7018603fc0a3Smrg # These systems don't actually have a C or math library (as such) 7019603fc0a3Smrg continue 7020603fc0a3Smrg ;; 7021603fc0a3Smrg *-*-os2*) 7022603fc0a3Smrg # These systems don't actually have a C library (as such) 7023603fc0a3Smrg test X-lc = "X$arg" && continue 7024603fc0a3Smrg ;; 7025603fc0a3Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7026603fc0a3Smrg # Do not include libc due to us having libc/libc_r. 7027603fc0a3Smrg test X-lc = "X$arg" && continue 7028603fc0a3Smrg ;; 7029603fc0a3Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7030603fc0a3Smrg # Rhapsody C and math libraries are in the System framework 7031603fc0a3Smrg func_append deplibs " System.ltframework" 7032603fc0a3Smrg continue 7033603fc0a3Smrg ;; 7034603fc0a3Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7035603fc0a3Smrg # Causes problems with __ctype 7036603fc0a3Smrg test X-lc = "X$arg" && continue 7037603fc0a3Smrg ;; 7038603fc0a3Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7039603fc0a3Smrg # Compiler inserts libc in the correct place for threads to work 7040603fc0a3Smrg test X-lc = "X$arg" && continue 7041603fc0a3Smrg ;; 7042603fc0a3Smrg esac 7043603fc0a3Smrg elif test X-lc_r = "X$arg"; then 7044603fc0a3Smrg case $host in 7045603fc0a3Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7046603fc0a3Smrg # Do not include libc_r directly, use -pthread flag. 7047603fc0a3Smrg continue 7048603fc0a3Smrg ;; 7049603fc0a3Smrg esac 7050603fc0a3Smrg fi 7051603fc0a3Smrg func_append deplibs " $arg" 7052603fc0a3Smrg continue 7053603fc0a3Smrg ;; 7054603fc0a3Smrg 7055603fc0a3Smrg -mllvm) 7056603fc0a3Smrg prev=mllvm 7057603fc0a3Smrg continue 7058603fc0a3Smrg ;; 7059603fc0a3Smrg 7060603fc0a3Smrg -module) 7061603fc0a3Smrg module=yes 7062603fc0a3Smrg continue 7063603fc0a3Smrg ;; 7064603fc0a3Smrg 7065603fc0a3Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7066603fc0a3Smrg # classes, name mangling, and exception handling. 7067603fc0a3Smrg # Darwin uses the -arch flag to determine output architecture. 7068603fc0a3Smrg -model|-arch|-isysroot|--sysroot) 7069603fc0a3Smrg func_append compiler_flags " $arg" 7070603fc0a3Smrg func_append compile_command " $arg" 7071603fc0a3Smrg func_append finalize_command " $arg" 7072603fc0a3Smrg prev=xcompiler 7073603fc0a3Smrg continue 7074603fc0a3Smrg ;; 7075603fc0a3Smrg 7076603fc0a3Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7077603fc0a3Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7078603fc0a3Smrg func_append compiler_flags " $arg" 7079603fc0a3Smrg func_append compile_command " $arg" 7080603fc0a3Smrg func_append finalize_command " $arg" 7081603fc0a3Smrg case "$new_inherited_linker_flags " in 7082603fc0a3Smrg *" $arg "*) ;; 7083603fc0a3Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 7084603fc0a3Smrg esac 7085603fc0a3Smrg continue 7086603fc0a3Smrg ;; 7087603fc0a3Smrg 7088603fc0a3Smrg -multi_module) 7089603fc0a3Smrg single_module=$wl-multi_module 7090603fc0a3Smrg continue 7091603fc0a3Smrg ;; 7092603fc0a3Smrg 7093603fc0a3Smrg -no-fast-install) 7094603fc0a3Smrg fast_install=no 7095603fc0a3Smrg continue 7096603fc0a3Smrg ;; 7097603fc0a3Smrg 7098603fc0a3Smrg -no-install) 7099603fc0a3Smrg case $host in 7100603fc0a3Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7101603fc0a3Smrg # The PATH hackery in wrapper scripts is required on Windows 7102603fc0a3Smrg # and Darwin in order for the loader to find any dlls it needs. 7103603fc0a3Smrg func_warning "'-no-install' is ignored for $host" 7104603fc0a3Smrg func_warning "assuming '-no-fast-install' instead" 7105603fc0a3Smrg fast_install=no 7106603fc0a3Smrg ;; 7107603fc0a3Smrg *) no_install=yes ;; 7108603fc0a3Smrg esac 7109603fc0a3Smrg continue 7110603fc0a3Smrg ;; 7111603fc0a3Smrg 7112603fc0a3Smrg -no-undefined) 7113603fc0a3Smrg allow_undefined=no 7114603fc0a3Smrg continue 7115603fc0a3Smrg ;; 7116603fc0a3Smrg 7117603fc0a3Smrg -objectlist) 7118603fc0a3Smrg prev=objectlist 7119603fc0a3Smrg continue 7120603fc0a3Smrg ;; 7121603fc0a3Smrg 7122603fc0a3Smrg -os2dllname) 7123603fc0a3Smrg prev=os2dllname 7124603fc0a3Smrg continue 7125603fc0a3Smrg ;; 7126603fc0a3Smrg 7127603fc0a3Smrg -o) prev=output ;; 7128603fc0a3Smrg 7129603fc0a3Smrg -precious-files-regex) 7130603fc0a3Smrg prev=precious_regex 7131603fc0a3Smrg continue 7132603fc0a3Smrg ;; 7133603fc0a3Smrg 7134603fc0a3Smrg -release) 7135603fc0a3Smrg prev=release 7136603fc0a3Smrg continue 7137603fc0a3Smrg ;; 7138603fc0a3Smrg 7139603fc0a3Smrg -rpath) 7140603fc0a3Smrg prev=rpath 7141603fc0a3Smrg continue 7142603fc0a3Smrg ;; 7143603fc0a3Smrg 7144603fc0a3Smrg -R) 7145603fc0a3Smrg prev=xrpath 7146603fc0a3Smrg continue 7147603fc0a3Smrg ;; 7148603fc0a3Smrg 7149603fc0a3Smrg -R*) 7150603fc0a3Smrg func_stripname '-R' '' "$arg" 7151603fc0a3Smrg dir=$func_stripname_result 7152603fc0a3Smrg # We need an absolute path. 7153603fc0a3Smrg case $dir in 7154603fc0a3Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7155603fc0a3Smrg =*) 7156603fc0a3Smrg func_stripname '=' '' "$dir" 7157603fc0a3Smrg dir=$lt_sysroot$func_stripname_result 7158603fc0a3Smrg ;; 7159603fc0a3Smrg *) 7160603fc0a3Smrg func_fatal_error "only absolute run-paths are allowed" 7161603fc0a3Smrg ;; 7162603fc0a3Smrg esac 7163603fc0a3Smrg case "$xrpath " in 7164603fc0a3Smrg *" $dir "*) ;; 7165603fc0a3Smrg *) func_append xrpath " $dir" ;; 7166603fc0a3Smrg esac 7167603fc0a3Smrg continue 7168603fc0a3Smrg ;; 7169603fc0a3Smrg 7170603fc0a3Smrg -shared) 7171603fc0a3Smrg # The effects of -shared are defined in a previous loop. 7172603fc0a3Smrg continue 7173603fc0a3Smrg ;; 7174603fc0a3Smrg 7175603fc0a3Smrg -shrext) 7176603fc0a3Smrg prev=shrext 7177603fc0a3Smrg continue 7178603fc0a3Smrg ;; 7179603fc0a3Smrg 7180603fc0a3Smrg -static | -static-libtool-libs) 7181603fc0a3Smrg # The effects of -static are defined in a previous loop. 7182603fc0a3Smrg # We used to do the same as -all-static on platforms that 7183603fc0a3Smrg # didn't have a PIC flag, but the assumption that the effects 7184603fc0a3Smrg # would be equivalent was wrong. It would break on at least 7185603fc0a3Smrg # Digital Unix and AIX. 7186603fc0a3Smrg continue 7187603fc0a3Smrg ;; 7188603fc0a3Smrg 7189603fc0a3Smrg -thread-safe) 7190603fc0a3Smrg thread_safe=yes 7191603fc0a3Smrg continue 7192603fc0a3Smrg ;; 7193603fc0a3Smrg 7194603fc0a3Smrg -version-info) 7195603fc0a3Smrg prev=vinfo 7196603fc0a3Smrg continue 7197603fc0a3Smrg ;; 7198603fc0a3Smrg 7199603fc0a3Smrg -version-number) 7200603fc0a3Smrg prev=vinfo 7201603fc0a3Smrg vinfo_number=yes 7202603fc0a3Smrg continue 7203603fc0a3Smrg ;; 7204603fc0a3Smrg 7205603fc0a3Smrg -weak) 7206603fc0a3Smrg prev=weak 7207603fc0a3Smrg continue 7208603fc0a3Smrg ;; 7209603fc0a3Smrg 7210603fc0a3Smrg -Wc,*) 7211603fc0a3Smrg func_stripname '-Wc,' '' "$arg" 7212603fc0a3Smrg args=$func_stripname_result 7213603fc0a3Smrg arg= 7214603fc0a3Smrg save_ifs=$IFS; IFS=, 7215603fc0a3Smrg for flag in $args; do 7216603fc0a3Smrg IFS=$save_ifs 7217603fc0a3Smrg func_quote_for_eval "$flag" 7218603fc0a3Smrg func_append arg " $func_quote_for_eval_result" 7219603fc0a3Smrg func_append compiler_flags " $func_quote_for_eval_result" 7220603fc0a3Smrg done 7221603fc0a3Smrg IFS=$save_ifs 7222603fc0a3Smrg func_stripname ' ' '' "$arg" 7223603fc0a3Smrg arg=$func_stripname_result 7224603fc0a3Smrg ;; 7225603fc0a3Smrg 7226603fc0a3Smrg -Wl,*) 7227603fc0a3Smrg func_stripname '-Wl,' '' "$arg" 7228603fc0a3Smrg args=$func_stripname_result 7229603fc0a3Smrg arg= 7230603fc0a3Smrg save_ifs=$IFS; IFS=, 7231603fc0a3Smrg for flag in $args; do 7232603fc0a3Smrg IFS=$save_ifs 7233603fc0a3Smrg func_quote_for_eval "$flag" 7234603fc0a3Smrg func_append arg " $wl$func_quote_for_eval_result" 7235603fc0a3Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 7236603fc0a3Smrg func_append linker_flags " $func_quote_for_eval_result" 7237603fc0a3Smrg done 7238603fc0a3Smrg IFS=$save_ifs 7239603fc0a3Smrg func_stripname ' ' '' "$arg" 7240603fc0a3Smrg arg=$func_stripname_result 7241603fc0a3Smrg ;; 7242603fc0a3Smrg 7243603fc0a3Smrg -Xcompiler) 7244603fc0a3Smrg prev=xcompiler 7245603fc0a3Smrg continue 7246603fc0a3Smrg ;; 7247603fc0a3Smrg 7248603fc0a3Smrg -Xlinker) 7249603fc0a3Smrg prev=xlinker 7250603fc0a3Smrg continue 7251603fc0a3Smrg ;; 7252603fc0a3Smrg 7253603fc0a3Smrg -XCClinker) 7254603fc0a3Smrg prev=xcclinker 7255603fc0a3Smrg continue 7256603fc0a3Smrg ;; 7257603fc0a3Smrg 7258603fc0a3Smrg # -msg_* for osf cc 7259603fc0a3Smrg -msg_*) 7260603fc0a3Smrg func_quote_for_eval "$arg" 7261603fc0a3Smrg arg=$func_quote_for_eval_result 7262603fc0a3Smrg ;; 7263603fc0a3Smrg 7264603fc0a3Smrg # Flags to be passed through unchanged, with rationale: 7265603fc0a3Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7266603fc0a3Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 7267603fc0a3Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7268603fc0a3Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7269603fc0a3Smrg # -q* compiler args for the IBM compiler 7270603fc0a3Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7271603fc0a3Smrg # -F/path path to uninstalled frameworks, gcc on darwin 7272603fc0a3Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7273603fc0a3Smrg # -fstack-protector* stack protector flags for GCC 7274603fc0a3Smrg # @file GCC response files 7275603fc0a3Smrg # -tp=* Portland pgcc target processor selection 7276603fc0a3Smrg # --sysroot=* for sysroot support 7277603fc0a3Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7278603fc0a3Smrg # -stdlib=* select c++ std lib with clang 7279603fc0a3Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7280603fc0a3Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7281603fc0a3Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 7282603fc0a3Smrg func_quote_for_eval "$arg" 7283603fc0a3Smrg arg=$func_quote_for_eval_result 7284603fc0a3Smrg func_append compile_command " $arg" 7285603fc0a3Smrg func_append finalize_command " $arg" 7286603fc0a3Smrg func_append compiler_flags " $arg" 7287603fc0a3Smrg continue 7288603fc0a3Smrg ;; 7289603fc0a3Smrg 7290603fc0a3Smrg -Z*) 7291603fc0a3Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7292603fc0a3Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 7293603fc0a3Smrg compiler_flags="$compiler_flags $arg" 7294603fc0a3Smrg func_append compile_command " $arg" 7295603fc0a3Smrg func_append finalize_command " $arg" 7296603fc0a3Smrg case $arg in 7297603fc0a3Smrg -Zlinker | -Zstack) 7298603fc0a3Smrg prev=xcompiler 7299603fc0a3Smrg ;; 7300603fc0a3Smrg esac 7301603fc0a3Smrg continue 7302603fc0a3Smrg else 7303603fc0a3Smrg # Otherwise treat like 'Some other compiler flag' below 7304603fc0a3Smrg func_quote_for_eval "$arg" 7305603fc0a3Smrg arg=$func_quote_for_eval_result 7306603fc0a3Smrg fi 7307603fc0a3Smrg ;; 7308603fc0a3Smrg 7309603fc0a3Smrg # Some other compiler flag. 7310603fc0a3Smrg -* | +*) 7311603fc0a3Smrg func_quote_for_eval "$arg" 7312603fc0a3Smrg arg=$func_quote_for_eval_result 7313603fc0a3Smrg ;; 7314603fc0a3Smrg 7315603fc0a3Smrg *.$objext) 7316603fc0a3Smrg # A standard object. 7317603fc0a3Smrg func_append objs " $arg" 7318603fc0a3Smrg ;; 7319603fc0a3Smrg 7320603fc0a3Smrg *.lo) 7321603fc0a3Smrg # A libtool-controlled object. 7322603fc0a3Smrg 7323603fc0a3Smrg # Check to see that this really is a libtool object. 7324603fc0a3Smrg if func_lalib_unsafe_p "$arg"; then 7325603fc0a3Smrg pic_object= 7326603fc0a3Smrg non_pic_object= 7327603fc0a3Smrg 7328603fc0a3Smrg # Read the .lo file 7329603fc0a3Smrg func_source "$arg" 7330603fc0a3Smrg 7331603fc0a3Smrg if test -z "$pic_object" || 7332603fc0a3Smrg test -z "$non_pic_object" || 7333603fc0a3Smrg test none = "$pic_object" && 7334603fc0a3Smrg test none = "$non_pic_object"; then 7335603fc0a3Smrg func_fatal_error "cannot find name of object for '$arg'" 7336603fc0a3Smrg fi 7337603fc0a3Smrg 7338603fc0a3Smrg # Extract subdirectory from the argument. 7339603fc0a3Smrg func_dirname "$arg" "/" "" 7340603fc0a3Smrg xdir=$func_dirname_result 7341603fc0a3Smrg 7342603fc0a3Smrg test none = "$pic_object" || { 7343603fc0a3Smrg # Prepend the subdirectory the object is found in. 7344603fc0a3Smrg pic_object=$xdir$pic_object 7345603fc0a3Smrg 7346603fc0a3Smrg if test dlfiles = "$prev"; then 7347603fc0a3Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7348603fc0a3Smrg func_append dlfiles " $pic_object" 7349603fc0a3Smrg prev= 7350603fc0a3Smrg continue 7351603fc0a3Smrg else 7352603fc0a3Smrg # If libtool objects are unsupported, then we need to preload. 7353603fc0a3Smrg prev=dlprefiles 7354603fc0a3Smrg fi 7355603fc0a3Smrg fi 7356603fc0a3Smrg 7357603fc0a3Smrg # CHECK ME: I think I busted this. -Ossama 7358603fc0a3Smrg if test dlprefiles = "$prev"; then 7359603fc0a3Smrg # Preload the old-style object. 7360603fc0a3Smrg func_append dlprefiles " $pic_object" 7361603fc0a3Smrg prev= 7362603fc0a3Smrg fi 7363603fc0a3Smrg 7364603fc0a3Smrg # A PIC object. 7365603fc0a3Smrg func_append libobjs " $pic_object" 7366603fc0a3Smrg arg=$pic_object 7367603fc0a3Smrg } 7368603fc0a3Smrg 7369603fc0a3Smrg # Non-PIC object. 7370603fc0a3Smrg if test none != "$non_pic_object"; then 7371603fc0a3Smrg # Prepend the subdirectory the object is found in. 7372603fc0a3Smrg non_pic_object=$xdir$non_pic_object 7373603fc0a3Smrg 7374603fc0a3Smrg # A standard non-PIC object 7375603fc0a3Smrg func_append non_pic_objects " $non_pic_object" 7376603fc0a3Smrg if test -z "$pic_object" || test none = "$pic_object"; then 7377603fc0a3Smrg arg=$non_pic_object 7378603fc0a3Smrg fi 7379603fc0a3Smrg else 7380603fc0a3Smrg # If the PIC object exists, use it instead. 7381603fc0a3Smrg # $xdir was prepended to $pic_object above. 7382603fc0a3Smrg non_pic_object=$pic_object 7383603fc0a3Smrg func_append non_pic_objects " $non_pic_object" 7384603fc0a3Smrg fi 7385603fc0a3Smrg else 7386603fc0a3Smrg # Only an error if not doing a dry-run. 7387603fc0a3Smrg if $opt_dry_run; then 7388603fc0a3Smrg # Extract subdirectory from the argument. 7389603fc0a3Smrg func_dirname "$arg" "/" "" 7390603fc0a3Smrg xdir=$func_dirname_result 7391603fc0a3Smrg 7392603fc0a3Smrg func_lo2o "$arg" 7393603fc0a3Smrg pic_object=$xdir$objdir/$func_lo2o_result 7394603fc0a3Smrg non_pic_object=$xdir$func_lo2o_result 7395603fc0a3Smrg func_append libobjs " $pic_object" 7396603fc0a3Smrg func_append non_pic_objects " $non_pic_object" 7397603fc0a3Smrg else 7398603fc0a3Smrg func_fatal_error "'$arg' is not a valid libtool object" 7399603fc0a3Smrg fi 7400603fc0a3Smrg fi 7401603fc0a3Smrg ;; 7402603fc0a3Smrg 7403603fc0a3Smrg *.$libext) 7404603fc0a3Smrg # An archive. 7405603fc0a3Smrg func_append deplibs " $arg" 7406603fc0a3Smrg func_append old_deplibs " $arg" 7407603fc0a3Smrg continue 7408603fc0a3Smrg ;; 7409603fc0a3Smrg 7410603fc0a3Smrg *.la) 7411603fc0a3Smrg # A libtool-controlled library. 7412603fc0a3Smrg 7413603fc0a3Smrg func_resolve_sysroot "$arg" 7414603fc0a3Smrg if test dlfiles = "$prev"; then 7415603fc0a3Smrg # This library was specified with -dlopen. 7416603fc0a3Smrg func_append dlfiles " $func_resolve_sysroot_result" 7417603fc0a3Smrg prev= 7418603fc0a3Smrg elif test dlprefiles = "$prev"; then 7419603fc0a3Smrg # The library was specified with -dlpreopen. 7420603fc0a3Smrg func_append dlprefiles " $func_resolve_sysroot_result" 7421603fc0a3Smrg prev= 7422603fc0a3Smrg else 7423603fc0a3Smrg func_append deplibs " $func_resolve_sysroot_result" 7424603fc0a3Smrg fi 7425603fc0a3Smrg continue 7426603fc0a3Smrg ;; 7427603fc0a3Smrg 7428603fc0a3Smrg # Some other compiler argument. 7429603fc0a3Smrg *) 7430603fc0a3Smrg # Unknown arguments in both finalize_command and compile_command need 7431603fc0a3Smrg # to be aesthetically quoted because they are evaled later. 7432603fc0a3Smrg func_quote_for_eval "$arg" 7433603fc0a3Smrg arg=$func_quote_for_eval_result 7434603fc0a3Smrg ;; 7435603fc0a3Smrg esac # arg 7436603fc0a3Smrg 7437603fc0a3Smrg # Now actually substitute the argument into the commands. 7438603fc0a3Smrg if test -n "$arg"; then 7439603fc0a3Smrg func_append compile_command " $arg" 7440603fc0a3Smrg func_append finalize_command " $arg" 7441603fc0a3Smrg fi 7442603fc0a3Smrg done # argument parsing loop 7443603fc0a3Smrg 7444603fc0a3Smrg test -n "$prev" && \ 7445603fc0a3Smrg func_fatal_help "the '$prevarg' option requires an argument" 7446603fc0a3Smrg 7447603fc0a3Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7448603fc0a3Smrg eval arg=\"$export_dynamic_flag_spec\" 7449603fc0a3Smrg func_append compile_command " $arg" 7450603fc0a3Smrg func_append finalize_command " $arg" 7451603fc0a3Smrg fi 7452603fc0a3Smrg 7453603fc0a3Smrg oldlibs= 7454603fc0a3Smrg # calculate the name of the file, without its directory 7455603fc0a3Smrg func_basename "$output" 7456603fc0a3Smrg outputname=$func_basename_result 7457603fc0a3Smrg libobjs_save=$libobjs 7458603fc0a3Smrg 7459603fc0a3Smrg if test -n "$shlibpath_var"; then 7460603fc0a3Smrg # get the directories listed in $shlibpath_var 7461603fc0a3Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7462603fc0a3Smrg else 7463603fc0a3Smrg shlib_search_path= 7464603fc0a3Smrg fi 7465603fc0a3Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7466603fc0a3Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7467603fc0a3Smrg 7468603fc0a3Smrg # Definition is injected by LT_CONFIG during libtool generation. 7469603fc0a3Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7470603fc0a3Smrg 7471603fc0a3Smrg func_dirname "$output" "/" "" 7472603fc0a3Smrg output_objdir=$func_dirname_result$objdir 7473603fc0a3Smrg func_to_tool_file "$output_objdir/" 7474603fc0a3Smrg tool_output_objdir=$func_to_tool_file_result 7475603fc0a3Smrg # Create the object directory. 7476603fc0a3Smrg func_mkdir_p "$output_objdir" 7477603fc0a3Smrg 7478603fc0a3Smrg # Determine the type of output 7479603fc0a3Smrg case $output in 7480603fc0a3Smrg "") 7481603fc0a3Smrg func_fatal_help "you must specify an output file" 7482603fc0a3Smrg ;; 7483603fc0a3Smrg *.$libext) linkmode=oldlib ;; 7484603fc0a3Smrg *.lo | *.$objext) linkmode=obj ;; 7485603fc0a3Smrg *.la) linkmode=lib ;; 7486603fc0a3Smrg *) linkmode=prog ;; # Anything else should be a program. 7487603fc0a3Smrg esac 7488603fc0a3Smrg 7489603fc0a3Smrg specialdeplibs= 7490603fc0a3Smrg 7491603fc0a3Smrg libs= 7492603fc0a3Smrg # Find all interdependent deplibs by searching for libraries 7493603fc0a3Smrg # that are linked more than once (e.g. -la -lb -la) 7494603fc0a3Smrg for deplib in $deplibs; do 7495603fc0a3Smrg if $opt_preserve_dup_deps; then 7496603fc0a3Smrg case "$libs " in 7497603fc0a3Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7498603fc0a3Smrg esac 7499603fc0a3Smrg fi 7500603fc0a3Smrg func_append libs " $deplib" 7501603fc0a3Smrg done 7502603fc0a3Smrg 7503603fc0a3Smrg if test lib = "$linkmode"; then 7504603fc0a3Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7505603fc0a3Smrg 7506603fc0a3Smrg # Compute libraries that are listed more than once in $predeps 7507603fc0a3Smrg # $postdeps and mark them as special (i.e., whose duplicates are 7508603fc0a3Smrg # not to be eliminated). 7509603fc0a3Smrg pre_post_deps= 7510603fc0a3Smrg if $opt_duplicate_compiler_generated_deps; then 7511603fc0a3Smrg for pre_post_dep in $predeps $postdeps; do 7512603fc0a3Smrg case "$pre_post_deps " in 7513603fc0a3Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7514603fc0a3Smrg esac 7515603fc0a3Smrg func_append pre_post_deps " $pre_post_dep" 7516603fc0a3Smrg done 7517603fc0a3Smrg fi 7518603fc0a3Smrg pre_post_deps= 7519603fc0a3Smrg fi 7520603fc0a3Smrg 7521603fc0a3Smrg deplibs= 7522603fc0a3Smrg newdependency_libs= 7523603fc0a3Smrg newlib_search_path= 7524603fc0a3Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 7525603fc0a3Smrg notinst_deplibs= # not-installed libtool libraries 7526603fc0a3Smrg notinst_path= # paths that contain not-installed libtool libraries 7527603fc0a3Smrg 7528603fc0a3Smrg case $linkmode in 7529603fc0a3Smrg lib) 7530603fc0a3Smrg passes="conv dlpreopen link" 7531603fc0a3Smrg for file in $dlfiles $dlprefiles; do 7532603fc0a3Smrg case $file in 7533603fc0a3Smrg *.la) ;; 7534603fc0a3Smrg *) 7535603fc0a3Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7536603fc0a3Smrg ;; 7537603fc0a3Smrg esac 7538603fc0a3Smrg done 7539603fc0a3Smrg ;; 7540603fc0a3Smrg prog) 7541603fc0a3Smrg compile_deplibs= 7542603fc0a3Smrg finalize_deplibs= 7543603fc0a3Smrg alldeplibs=false 7544603fc0a3Smrg newdlfiles= 7545603fc0a3Smrg newdlprefiles= 7546603fc0a3Smrg passes="conv scan dlopen dlpreopen link" 7547603fc0a3Smrg ;; 7548603fc0a3Smrg *) passes="conv" 7549603fc0a3Smrg ;; 7550603fc0a3Smrg esac 7551603fc0a3Smrg 7552603fc0a3Smrg for pass in $passes; do 7553603fc0a3Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 7554603fc0a3Smrg # so that -L comes before libs that need it for instance... 7555603fc0a3Smrg if test lib,link = "$linkmode,$pass"; then 7556603fc0a3Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 7557603fc0a3Smrg ## order, and fix it there properly 7558603fc0a3Smrg tmp_deplibs= 7559603fc0a3Smrg for deplib in $deplibs; do 7560603fc0a3Smrg tmp_deplibs="$deplib $tmp_deplibs" 7561603fc0a3Smrg done 7562603fc0a3Smrg deplibs=$tmp_deplibs 7563603fc0a3Smrg fi 7564603fc0a3Smrg 7565603fc0a3Smrg if test lib,link = "$linkmode,$pass" || 7566603fc0a3Smrg test prog,scan = "$linkmode,$pass"; then 7567603fc0a3Smrg libs=$deplibs 7568603fc0a3Smrg deplibs= 7569603fc0a3Smrg fi 7570603fc0a3Smrg if test prog = "$linkmode"; then 7571603fc0a3Smrg case $pass in 7572603fc0a3Smrg dlopen) libs=$dlfiles ;; 7573603fc0a3Smrg dlpreopen) libs=$dlprefiles ;; 7574603fc0a3Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7575603fc0a3Smrg esac 7576603fc0a3Smrg fi 7577603fc0a3Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 7578603fc0a3Smrg # Collect and forward deplibs of preopened libtool libs 7579603fc0a3Smrg for lib in $dlprefiles; do 7580603fc0a3Smrg # Ignore non-libtool-libs 7581603fc0a3Smrg dependency_libs= 7582603fc0a3Smrg func_resolve_sysroot "$lib" 7583603fc0a3Smrg case $lib in 7584603fc0a3Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 7585603fc0a3Smrg esac 7586603fc0a3Smrg 7587603fc0a3Smrg # Collect preopened libtool deplibs, except any this library 7588603fc0a3Smrg # has declared as weak libs 7589603fc0a3Smrg for deplib in $dependency_libs; do 7590603fc0a3Smrg func_basename "$deplib" 7591603fc0a3Smrg deplib_base=$func_basename_result 7592603fc0a3Smrg case " $weak_libs " in 7593603fc0a3Smrg *" $deplib_base "*) ;; 7594603fc0a3Smrg *) func_append deplibs " $deplib" ;; 7595603fc0a3Smrg esac 7596603fc0a3Smrg done 7597603fc0a3Smrg done 7598603fc0a3Smrg libs=$dlprefiles 7599603fc0a3Smrg fi 7600603fc0a3Smrg if test dlopen = "$pass"; then 7601603fc0a3Smrg # Collect dlpreopened libraries 7602603fc0a3Smrg save_deplibs=$deplibs 7603603fc0a3Smrg deplibs= 7604603fc0a3Smrg fi 7605603fc0a3Smrg 7606603fc0a3Smrg for deplib in $libs; do 7607603fc0a3Smrg lib= 7608603fc0a3Smrg found=false 7609603fc0a3Smrg case $deplib in 7610603fc0a3Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7611603fc0a3Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7612603fc0a3Smrg if test prog,link = "$linkmode,$pass"; then 7613603fc0a3Smrg compile_deplibs="$deplib $compile_deplibs" 7614603fc0a3Smrg finalize_deplibs="$deplib $finalize_deplibs" 7615603fc0a3Smrg else 7616603fc0a3Smrg func_append compiler_flags " $deplib" 7617603fc0a3Smrg if test lib = "$linkmode"; then 7618603fc0a3Smrg case "$new_inherited_linker_flags " in 7619603fc0a3Smrg *" $deplib "*) ;; 7620603fc0a3Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7621603fc0a3Smrg esac 7622603fc0a3Smrg fi 7623603fc0a3Smrg fi 7624603fc0a3Smrg continue 7625603fc0a3Smrg ;; 7626603fc0a3Smrg -l*) 7627603fc0a3Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7628603fc0a3Smrg func_warning "'-l' is ignored for archives/objects" 7629603fc0a3Smrg continue 7630603fc0a3Smrg fi 7631603fc0a3Smrg func_stripname '-l' '' "$deplib" 7632603fc0a3Smrg name=$func_stripname_result 7633603fc0a3Smrg if test lib = "$linkmode"; then 7634603fc0a3Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7635603fc0a3Smrg else 7636603fc0a3Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7637603fc0a3Smrg fi 7638603fc0a3Smrg for searchdir in $searchdirs; do 7639603fc0a3Smrg for search_ext in .la $std_shrext .so .a; do 7640603fc0a3Smrg # Search the libtool library 7641603fc0a3Smrg lib=$searchdir/lib$name$search_ext 7642603fc0a3Smrg if test -f "$lib"; then 7643603fc0a3Smrg if test .la = "$search_ext"; then 7644603fc0a3Smrg found=: 7645603fc0a3Smrg else 7646603fc0a3Smrg found=false 7647603fc0a3Smrg fi 7648603fc0a3Smrg break 2 7649603fc0a3Smrg fi 7650603fc0a3Smrg done 7651603fc0a3Smrg done 7652603fc0a3Smrg if $found; then 7653603fc0a3Smrg # deplib is a libtool library 7654603fc0a3Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7655603fc0a3Smrg # We need to do some special things here, and not later. 7656603fc0a3Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7657603fc0a3Smrg case " $predeps $postdeps " in 7658603fc0a3Smrg *" $deplib "*) 7659603fc0a3Smrg if func_lalib_p "$lib"; then 7660603fc0a3Smrg library_names= 7661603fc0a3Smrg old_library= 7662603fc0a3Smrg func_source "$lib" 7663603fc0a3Smrg for l in $old_library $library_names; do 7664603fc0a3Smrg ll=$l 7665603fc0a3Smrg done 7666603fc0a3Smrg if test "X$ll" = "X$old_library"; then # only static version available 7667603fc0a3Smrg found=false 7668603fc0a3Smrg func_dirname "$lib" "" "." 7669603fc0a3Smrg ladir=$func_dirname_result 7670603fc0a3Smrg lib=$ladir/$old_library 7671603fc0a3Smrg if test prog,link = "$linkmode,$pass"; then 7672603fc0a3Smrg compile_deplibs="$deplib $compile_deplibs" 7673603fc0a3Smrg finalize_deplibs="$deplib $finalize_deplibs" 7674603fc0a3Smrg else 7675603fc0a3Smrg deplibs="$deplib $deplibs" 7676603fc0a3Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7677603fc0a3Smrg fi 7678603fc0a3Smrg continue 7679603fc0a3Smrg fi 7680603fc0a3Smrg fi 7681603fc0a3Smrg ;; 7682603fc0a3Smrg *) ;; 7683603fc0a3Smrg esac 7684603fc0a3Smrg fi 7685603fc0a3Smrg else 7686603fc0a3Smrg # deplib doesn't seem to be a libtool library 7687603fc0a3Smrg if test prog,link = "$linkmode,$pass"; then 7688603fc0a3Smrg compile_deplibs="$deplib $compile_deplibs" 7689603fc0a3Smrg finalize_deplibs="$deplib $finalize_deplibs" 7690603fc0a3Smrg else 7691603fc0a3Smrg deplibs="$deplib $deplibs" 7692603fc0a3Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7693603fc0a3Smrg fi 7694603fc0a3Smrg continue 7695603fc0a3Smrg fi 7696603fc0a3Smrg ;; # -l 7697603fc0a3Smrg *.ltframework) 7698603fc0a3Smrg if test prog,link = "$linkmode,$pass"; then 7699603fc0a3Smrg compile_deplibs="$deplib $compile_deplibs" 7700603fc0a3Smrg finalize_deplibs="$deplib $finalize_deplibs" 7701603fc0a3Smrg else 7702603fc0a3Smrg deplibs="$deplib $deplibs" 7703603fc0a3Smrg if test lib = "$linkmode"; then 7704603fc0a3Smrg case "$new_inherited_linker_flags " in 7705603fc0a3Smrg *" $deplib "*) ;; 7706603fc0a3Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7707603fc0a3Smrg esac 7708603fc0a3Smrg fi 7709603fc0a3Smrg fi 7710603fc0a3Smrg continue 7711603fc0a3Smrg ;; 7712603fc0a3Smrg -L*) 7713603fc0a3Smrg case $linkmode in 7714603fc0a3Smrg lib) 7715603fc0a3Smrg deplibs="$deplib $deplibs" 7716603fc0a3Smrg test conv = "$pass" && continue 7717603fc0a3Smrg newdependency_libs="$deplib $newdependency_libs" 7718603fc0a3Smrg func_stripname '-L' '' "$deplib" 7719603fc0a3Smrg func_resolve_sysroot "$func_stripname_result" 7720603fc0a3Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 7721603fc0a3Smrg ;; 7722603fc0a3Smrg prog) 7723603fc0a3Smrg if test conv = "$pass"; then 7724603fc0a3Smrg deplibs="$deplib $deplibs" 7725603fc0a3Smrg continue 7726603fc0a3Smrg fi 7727603fc0a3Smrg if test scan = "$pass"; then 7728603fc0a3Smrg deplibs="$deplib $deplibs" 7729603fc0a3Smrg else 7730603fc0a3Smrg compile_deplibs="$deplib $compile_deplibs" 7731603fc0a3Smrg finalize_deplibs="$deplib $finalize_deplibs" 7732603fc0a3Smrg fi 7733603fc0a3Smrg func_stripname '-L' '' "$deplib" 7734603fc0a3Smrg func_resolve_sysroot "$func_stripname_result" 7735603fc0a3Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 7736603fc0a3Smrg ;; 7737603fc0a3Smrg *) 7738603fc0a3Smrg func_warning "'-L' is ignored for archives/objects" 7739603fc0a3Smrg ;; 7740603fc0a3Smrg esac # linkmode 7741603fc0a3Smrg continue 7742603fc0a3Smrg ;; # -L 7743603fc0a3Smrg -R*) 7744603fc0a3Smrg if test link = "$pass"; then 7745603fc0a3Smrg func_stripname '-R' '' "$deplib" 7746603fc0a3Smrg func_resolve_sysroot "$func_stripname_result" 7747603fc0a3Smrg dir=$func_resolve_sysroot_result 7748603fc0a3Smrg # Make sure the xrpath contains only unique directories. 7749603fc0a3Smrg case "$xrpath " in 7750603fc0a3Smrg *" $dir "*) ;; 7751603fc0a3Smrg *) func_append xrpath " $dir" ;; 7752603fc0a3Smrg esac 7753603fc0a3Smrg fi 7754603fc0a3Smrg deplibs="$deplib $deplibs" 7755603fc0a3Smrg continue 7756603fc0a3Smrg ;; 7757603fc0a3Smrg *.la) 7758603fc0a3Smrg func_resolve_sysroot "$deplib" 7759603fc0a3Smrg lib=$func_resolve_sysroot_result 7760603fc0a3Smrg ;; 7761603fc0a3Smrg *.$libext) 7762603fc0a3Smrg if test conv = "$pass"; then 7763603fc0a3Smrg deplibs="$deplib $deplibs" 7764603fc0a3Smrg continue 7765603fc0a3Smrg fi 7766603fc0a3Smrg case $linkmode in 7767603fc0a3Smrg lib) 7768603fc0a3Smrg # Linking convenience modules into shared libraries is allowed, 7769603fc0a3Smrg # but linking other static libraries is non-portable. 7770603fc0a3Smrg case " $dlpreconveniencelibs " in 7771603fc0a3Smrg *" $deplib "*) ;; 7772603fc0a3Smrg *) 7773603fc0a3Smrg valid_a_lib=false 7774603fc0a3Smrg case $deplibs_check_method in 7775603fc0a3Smrg match_pattern*) 7776603fc0a3Smrg set dummy $deplibs_check_method; shift 7777603fc0a3Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7778603fc0a3Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7779603fc0a3Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 7780603fc0a3Smrg valid_a_lib=: 7781603fc0a3Smrg fi 7782603fc0a3Smrg ;; 7783603fc0a3Smrg pass_all) 7784603fc0a3Smrg valid_a_lib=: 7785603fc0a3Smrg ;; 7786603fc0a3Smrg esac 7787603fc0a3Smrg if $valid_a_lib; then 7788603fc0a3Smrg echo 7789603fc0a3Smrg $ECHO "*** Warning: Linking the shared library $output against the" 7790603fc0a3Smrg $ECHO "*** static library $deplib is not portable!" 7791603fc0a3Smrg deplibs="$deplib $deplibs" 7792603fc0a3Smrg else 7793603fc0a3Smrg echo 7794603fc0a3Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 7795603fc0a3Smrg echo "*** I have the capability to make that library automatically link in when" 7796603fc0a3Smrg echo "*** you link to this library. But I can only do this if you have a" 7797603fc0a3Smrg echo "*** shared version of the library, which you do not appear to have" 7798603fc0a3Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 7799603fc0a3Smrg echo "*** that it is just a static archive that I should not use here." 7800603fc0a3Smrg fi 7801603fc0a3Smrg ;; 7802603fc0a3Smrg esac 7803603fc0a3Smrg continue 7804603fc0a3Smrg ;; 7805603fc0a3Smrg prog) 7806603fc0a3Smrg if test link != "$pass"; then 7807603fc0a3Smrg deplibs="$deplib $deplibs" 7808603fc0a3Smrg else 7809603fc0a3Smrg compile_deplibs="$deplib $compile_deplibs" 7810603fc0a3Smrg finalize_deplibs="$deplib $finalize_deplibs" 7811603fc0a3Smrg fi 7812603fc0a3Smrg continue 7813603fc0a3Smrg ;; 7814603fc0a3Smrg esac # linkmode 7815603fc0a3Smrg ;; # *.$libext 7816603fc0a3Smrg *.lo | *.$objext) 7817603fc0a3Smrg if test conv = "$pass"; then 7818603fc0a3Smrg deplibs="$deplib $deplibs" 7819603fc0a3Smrg elif test prog = "$linkmode"; then 7820603fc0a3Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7821603fc0a3Smrg # If there is no dlopen support or we're linking statically, 7822603fc0a3Smrg # we need to preload. 7823603fc0a3Smrg func_append newdlprefiles " $deplib" 7824603fc0a3Smrg compile_deplibs="$deplib $compile_deplibs" 7825603fc0a3Smrg finalize_deplibs="$deplib $finalize_deplibs" 7826603fc0a3Smrg else 7827603fc0a3Smrg func_append newdlfiles " $deplib" 7828603fc0a3Smrg fi 7829603fc0a3Smrg fi 7830603fc0a3Smrg continue 7831603fc0a3Smrg ;; 7832603fc0a3Smrg %DEPLIBS%) 7833603fc0a3Smrg alldeplibs=: 7834603fc0a3Smrg continue 7835603fc0a3Smrg ;; 7836603fc0a3Smrg esac # case $deplib 7837603fc0a3Smrg 7838603fc0a3Smrg $found || test -f "$lib" \ 7839603fc0a3Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7840603fc0a3Smrg 7841603fc0a3Smrg # Check to see that this really is a libtool archive. 7842603fc0a3Smrg func_lalib_unsafe_p "$lib" \ 7843603fc0a3Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 7844603fc0a3Smrg 7845603fc0a3Smrg func_dirname "$lib" "" "." 7846603fc0a3Smrg ladir=$func_dirname_result 7847603fc0a3Smrg 7848603fc0a3Smrg dlname= 7849603fc0a3Smrg dlopen= 7850603fc0a3Smrg dlpreopen= 7851603fc0a3Smrg libdir= 7852603fc0a3Smrg library_names= 7853603fc0a3Smrg old_library= 7854603fc0a3Smrg inherited_linker_flags= 7855603fc0a3Smrg # If the library was installed with an old release of libtool, 7856603fc0a3Smrg # it will not redefine variables installed, or shouldnotlink 7857603fc0a3Smrg installed=yes 7858603fc0a3Smrg shouldnotlink=no 7859603fc0a3Smrg avoidtemprpath= 7860603fc0a3Smrg 7861603fc0a3Smrg 7862603fc0a3Smrg # Read the .la file 7863603fc0a3Smrg func_source "$lib" 7864603fc0a3Smrg 7865603fc0a3Smrg # Convert "-framework foo" to "foo.ltframework" 7866603fc0a3Smrg if test -n "$inherited_linker_flags"; then 7867603fc0a3Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7868603fc0a3Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7869603fc0a3Smrg case " $new_inherited_linker_flags " in 7870603fc0a3Smrg *" $tmp_inherited_linker_flag "*) ;; 7871603fc0a3Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7872603fc0a3Smrg esac 7873603fc0a3Smrg done 7874603fc0a3Smrg fi 7875603fc0a3Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7876603fc0a3Smrg if test lib,link = "$linkmode,$pass" || 7877603fc0a3Smrg test prog,scan = "$linkmode,$pass" || 7878603fc0a3Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 7879603fc0a3Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 7880603fc0a3Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7881603fc0a3Smrg fi 7882603fc0a3Smrg 7883603fc0a3Smrg if test conv = "$pass"; then 7884603fc0a3Smrg # Only check for convenience libraries 7885603fc0a3Smrg deplibs="$lib $deplibs" 7886603fc0a3Smrg if test -z "$libdir"; then 7887603fc0a3Smrg if test -z "$old_library"; then 7888603fc0a3Smrg func_fatal_error "cannot find name of link library for '$lib'" 7889603fc0a3Smrg fi 7890603fc0a3Smrg # It is a libtool convenience library, so add in its objects. 7891603fc0a3Smrg func_append convenience " $ladir/$objdir/$old_library" 7892603fc0a3Smrg func_append old_convenience " $ladir/$objdir/$old_library" 7893603fc0a3Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 7894603fc0a3Smrg func_fatal_error "'$lib' is not a convenience library" 7895603fc0a3Smrg fi 7896603fc0a3Smrg tmp_libs= 7897603fc0a3Smrg for deplib in $dependency_libs; do 7898603fc0a3Smrg deplibs="$deplib $deplibs" 7899603fc0a3Smrg if $opt_preserve_dup_deps; then 7900603fc0a3Smrg case "$tmp_libs " in 7901603fc0a3Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7902603fc0a3Smrg esac 7903603fc0a3Smrg fi 7904603fc0a3Smrg func_append tmp_libs " $deplib" 7905603fc0a3Smrg done 7906603fc0a3Smrg continue 7907603fc0a3Smrg fi # $pass = conv 7908603fc0a3Smrg 7909603fc0a3Smrg 7910603fc0a3Smrg # Get the name of the library we link against. 7911603fc0a3Smrg linklib= 7912603fc0a3Smrg if test -n "$old_library" && 7913603fc0a3Smrg { test yes = "$prefer_static_libs" || 7914603fc0a3Smrg test built,no = "$prefer_static_libs,$installed"; }; then 7915603fc0a3Smrg linklib=$old_library 7916603fc0a3Smrg else 7917603fc0a3Smrg for l in $old_library $library_names; do 7918603fc0a3Smrg linklib=$l 7919603fc0a3Smrg done 7920603fc0a3Smrg fi 7921603fc0a3Smrg if test -z "$linklib"; then 7922603fc0a3Smrg func_fatal_error "cannot find name of link library for '$lib'" 7923603fc0a3Smrg fi 7924603fc0a3Smrg 7925603fc0a3Smrg # This library was specified with -dlopen. 7926603fc0a3Smrg if test dlopen = "$pass"; then 7927603fc0a3Smrg test -z "$libdir" \ 7928603fc0a3Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 7929603fc0a3Smrg if test -z "$dlname" || 7930603fc0a3Smrg test yes != "$dlopen_support" || 7931603fc0a3Smrg test no = "$build_libtool_libs" 7932603fc0a3Smrg then 7933603fc0a3Smrg # If there is no dlname, no dlopen support or we're linking 7934603fc0a3Smrg # statically, we need to preload. We also need to preload any 7935603fc0a3Smrg # dependent libraries so libltdl's deplib preloader doesn't 7936603fc0a3Smrg # bomb out in the load deplibs phase. 7937603fc0a3Smrg func_append dlprefiles " $lib $dependency_libs" 7938603fc0a3Smrg else 7939603fc0a3Smrg func_append newdlfiles " $lib" 7940603fc0a3Smrg fi 7941603fc0a3Smrg continue 7942603fc0a3Smrg fi # $pass = dlopen 7943603fc0a3Smrg 7944603fc0a3Smrg # We need an absolute path. 7945603fc0a3Smrg case $ladir in 7946603fc0a3Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 7947603fc0a3Smrg *) 7948603fc0a3Smrg abs_ladir=`cd "$ladir" && pwd` 7949603fc0a3Smrg if test -z "$abs_ladir"; then 7950603fc0a3Smrg func_warning "cannot determine absolute directory name of '$ladir'" 7951603fc0a3Smrg func_warning "passing it literally to the linker, although it might fail" 7952603fc0a3Smrg abs_ladir=$ladir 7953603fc0a3Smrg fi 7954603fc0a3Smrg ;; 7955603fc0a3Smrg esac 7956603fc0a3Smrg func_basename "$lib" 7957603fc0a3Smrg laname=$func_basename_result 7958603fc0a3Smrg 7959603fc0a3Smrg # Find the relevant object directory and library name. 7960603fc0a3Smrg if test yes = "$installed"; then 7961603fc0a3Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7962603fc0a3Smrg func_warning "library '$lib' was moved." 7963603fc0a3Smrg dir=$ladir 7964603fc0a3Smrg absdir=$abs_ladir 7965603fc0a3Smrg libdir=$abs_ladir 7966603fc0a3Smrg else 7967603fc0a3Smrg dir=$lt_sysroot$libdir 7968603fc0a3Smrg absdir=$lt_sysroot$libdir 7969603fc0a3Smrg fi 7970603fc0a3Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 7971603fc0a3Smrg else 7972603fc0a3Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7973603fc0a3Smrg dir=$ladir 7974603fc0a3Smrg absdir=$abs_ladir 7975603fc0a3Smrg # Remove this search path later 7976603fc0a3Smrg func_append notinst_path " $abs_ladir" 7977603fc0a3Smrg else 7978603fc0a3Smrg dir=$ladir/$objdir 7979603fc0a3Smrg absdir=$abs_ladir/$objdir 7980603fc0a3Smrg # Remove this search path later 7981603fc0a3Smrg func_append notinst_path " $abs_ladir" 7982603fc0a3Smrg fi 7983603fc0a3Smrg fi # $installed = yes 7984603fc0a3Smrg func_stripname 'lib' '.la' "$laname" 7985603fc0a3Smrg name=$func_stripname_result 7986603fc0a3Smrg 7987603fc0a3Smrg # This library was specified with -dlpreopen. 7988603fc0a3Smrg if test dlpreopen = "$pass"; then 7989603fc0a3Smrg if test -z "$libdir" && test prog = "$linkmode"; then 7990603fc0a3Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 7991603fc0a3Smrg fi 7992603fc0a3Smrg case $host in 7993603fc0a3Smrg # special handling for platforms with PE-DLLs. 7994603fc0a3Smrg *cygwin* | *mingw* | *cegcc* ) 7995603fc0a3Smrg # Linker will automatically link against shared library if both 7996603fc0a3Smrg # static and shared are present. Therefore, ensure we extract 7997603fc0a3Smrg # symbols from the import library if a shared library is present 7998603fc0a3Smrg # (otherwise, the dlopen module name will be incorrect). We do 7999603fc0a3Smrg # this by putting the import library name into $newdlprefiles. 8000603fc0a3Smrg # We recover the dlopen module name by 'saving' the la file 8001603fc0a3Smrg # name in a special purpose variable, and (later) extracting the 8002603fc0a3Smrg # dlname from the la file. 8003603fc0a3Smrg if test -n "$dlname"; then 8004603fc0a3Smrg func_tr_sh "$dir/$linklib" 8005603fc0a3Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8006603fc0a3Smrg func_append newdlprefiles " $dir/$linklib" 8007603fc0a3Smrg else 8008603fc0a3Smrg func_append newdlprefiles " $dir/$old_library" 8009603fc0a3Smrg # Keep a list of preopened convenience libraries to check 8010603fc0a3Smrg # that they are being used correctly in the link pass. 8011603fc0a3Smrg test -z "$libdir" && \ 8012603fc0a3Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8013603fc0a3Smrg fi 8014603fc0a3Smrg ;; 8015603fc0a3Smrg * ) 8016603fc0a3Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8017603fc0a3Smrg # are required to link). 8018603fc0a3Smrg if test -n "$old_library"; then 8019603fc0a3Smrg func_append newdlprefiles " $dir/$old_library" 8020603fc0a3Smrg # Keep a list of preopened convenience libraries to check 8021603fc0a3Smrg # that they are being used correctly in the link pass. 8022603fc0a3Smrg test -z "$libdir" && \ 8023603fc0a3Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8024603fc0a3Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8025603fc0a3Smrg elif test -n "$dlname"; then 8026603fc0a3Smrg func_append newdlprefiles " $dir/$dlname" 8027603fc0a3Smrg else 8028603fc0a3Smrg func_append newdlprefiles " $dir/$linklib" 8029603fc0a3Smrg fi 8030603fc0a3Smrg ;; 8031603fc0a3Smrg esac 8032603fc0a3Smrg fi # $pass = dlpreopen 8033603fc0a3Smrg 8034603fc0a3Smrg if test -z "$libdir"; then 8035603fc0a3Smrg # Link the convenience library 8036603fc0a3Smrg if test lib = "$linkmode"; then 8037603fc0a3Smrg deplibs="$dir/$old_library $deplibs" 8038603fc0a3Smrg elif test prog,link = "$linkmode,$pass"; then 8039603fc0a3Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 8040603fc0a3Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8041603fc0a3Smrg else 8042603fc0a3Smrg deplibs="$lib $deplibs" # used for prog,scan pass 8043603fc0a3Smrg fi 8044603fc0a3Smrg continue 8045603fc0a3Smrg fi 8046603fc0a3Smrg 8047603fc0a3Smrg 8048603fc0a3Smrg if test prog = "$linkmode" && test link != "$pass"; then 8049603fc0a3Smrg func_append newlib_search_path " $ladir" 8050603fc0a3Smrg deplibs="$lib $deplibs" 8051603fc0a3Smrg 8052603fc0a3Smrg linkalldeplibs=false 8053603fc0a3Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8054603fc0a3Smrg test no = "$build_libtool_libs"; then 8055603fc0a3Smrg linkalldeplibs=: 8056603fc0a3Smrg fi 8057603fc0a3Smrg 8058603fc0a3Smrg tmp_libs= 8059603fc0a3Smrg for deplib in $dependency_libs; do 8060603fc0a3Smrg case $deplib in 8061603fc0a3Smrg -L*) func_stripname '-L' '' "$deplib" 8062603fc0a3Smrg func_resolve_sysroot "$func_stripname_result" 8063603fc0a3Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 8064603fc0a3Smrg ;; 8065603fc0a3Smrg esac 8066603fc0a3Smrg # Need to link against all dependency_libs? 8067603fc0a3Smrg if $linkalldeplibs; then 8068603fc0a3Smrg deplibs="$deplib $deplibs" 8069603fc0a3Smrg else 8070603fc0a3Smrg # Need to hardcode shared library paths 8071603fc0a3Smrg # or/and link against static libraries 8072603fc0a3Smrg newdependency_libs="$deplib $newdependency_libs" 8073603fc0a3Smrg fi 8074603fc0a3Smrg if $opt_preserve_dup_deps; then 8075603fc0a3Smrg case "$tmp_libs " in 8076603fc0a3Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8077603fc0a3Smrg esac 8078603fc0a3Smrg fi 8079603fc0a3Smrg func_append tmp_libs " $deplib" 8080603fc0a3Smrg done # for deplib 8081603fc0a3Smrg continue 8082603fc0a3Smrg fi # $linkmode = prog... 8083603fc0a3Smrg 8084603fc0a3Smrg if test prog,link = "$linkmode,$pass"; then 8085603fc0a3Smrg if test -n "$library_names" && 8086603fc0a3Smrg { { test no = "$prefer_static_libs" || 8087603fc0a3Smrg test built,yes = "$prefer_static_libs,$installed"; } || 8088603fc0a3Smrg test -z "$old_library"; }; then 8089603fc0a3Smrg # We need to hardcode the library path 8090603fc0a3Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8091603fc0a3Smrg # Make sure the rpath contains only unique directories. 8092603fc0a3Smrg case $temp_rpath: in 8093603fc0a3Smrg *"$absdir:"*) ;; 8094603fc0a3Smrg *) func_append temp_rpath "$absdir:" ;; 8095603fc0a3Smrg esac 8096603fc0a3Smrg fi 8097603fc0a3Smrg 8098603fc0a3Smrg # Hardcode the library path. 8099603fc0a3Smrg # Skip directories that are in the system default run-time 8100603fc0a3Smrg # search path. 8101603fc0a3Smrg case " $sys_lib_dlsearch_path " in 8102603fc0a3Smrg *" $absdir "*) ;; 8103603fc0a3Smrg *) 8104603fc0a3Smrg case "$compile_rpath " in 8105603fc0a3Smrg *" $absdir "*) ;; 8106603fc0a3Smrg *) func_append compile_rpath " $absdir" ;; 8107603fc0a3Smrg esac 8108603fc0a3Smrg ;; 8109603fc0a3Smrg esac 8110603fc0a3Smrg case " $sys_lib_dlsearch_path " in 8111603fc0a3Smrg *" $libdir "*) ;; 8112603fc0a3Smrg *) 8113603fc0a3Smrg case "$finalize_rpath " in 8114603fc0a3Smrg *" $libdir "*) ;; 8115603fc0a3Smrg *) func_append finalize_rpath " $libdir" ;; 8116603fc0a3Smrg esac 8117603fc0a3Smrg ;; 8118603fc0a3Smrg esac 8119603fc0a3Smrg fi # $linkmode,$pass = prog,link... 8120603fc0a3Smrg 8121603fc0a3Smrg if $alldeplibs && 8122603fc0a3Smrg { test pass_all = "$deplibs_check_method" || 8123603fc0a3Smrg { test yes = "$build_libtool_libs" && 8124603fc0a3Smrg test -n "$library_names"; }; }; then 8125603fc0a3Smrg # We only need to search for static libraries 8126603fc0a3Smrg continue 8127603fc0a3Smrg fi 8128603fc0a3Smrg fi 8129603fc0a3Smrg 8130603fc0a3Smrg link_static=no # Whether the deplib will be linked statically 8131603fc0a3Smrg use_static_libs=$prefer_static_libs 8132603fc0a3Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 8133603fc0a3Smrg use_static_libs=no 8134603fc0a3Smrg fi 8135603fc0a3Smrg if test -n "$library_names" && 8136603fc0a3Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8137603fc0a3Smrg case $host in 8138603fc0a3Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 8139603fc0a3Smrg # No point in relinking DLLs because paths are not encoded 8140603fc0a3Smrg func_append notinst_deplibs " $lib" 8141603fc0a3Smrg need_relink=no 8142603fc0a3Smrg ;; 8143603fc0a3Smrg *) 8144603fc0a3Smrg if test no = "$installed"; then 8145603fc0a3Smrg func_append notinst_deplibs " $lib" 8146603fc0a3Smrg need_relink=yes 8147603fc0a3Smrg fi 8148603fc0a3Smrg ;; 8149603fc0a3Smrg esac 8150603fc0a3Smrg # This is a shared library 8151603fc0a3Smrg 8152603fc0a3Smrg # Warn about portability, can't link against -module's on some 8153603fc0a3Smrg # systems (darwin). Don't bleat about dlopened modules though! 8154603fc0a3Smrg dlopenmodule= 8155603fc0a3Smrg for dlpremoduletest in $dlprefiles; do 8156603fc0a3Smrg if test "X$dlpremoduletest" = "X$lib"; then 8157603fc0a3Smrg dlopenmodule=$dlpremoduletest 8158603fc0a3Smrg break 8159603fc0a3Smrg fi 8160603fc0a3Smrg done 8161603fc0a3Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8162603fc0a3Smrg echo 8163603fc0a3Smrg if test prog = "$linkmode"; then 8164603fc0a3Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8165603fc0a3Smrg else 8166603fc0a3Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8167603fc0a3Smrg fi 8168603fc0a3Smrg $ECHO "*** $linklib is not portable!" 8169603fc0a3Smrg fi 8170603fc0a3Smrg if test lib = "$linkmode" && 8171603fc0a3Smrg test yes = "$hardcode_into_libs"; then 8172603fc0a3Smrg # Hardcode the library path. 8173603fc0a3Smrg # Skip directories that are in the system default run-time 8174603fc0a3Smrg # search path. 8175603fc0a3Smrg case " $sys_lib_dlsearch_path " in 8176603fc0a3Smrg *" $absdir "*) ;; 8177603fc0a3Smrg *) 8178603fc0a3Smrg case "$compile_rpath " in 8179603fc0a3Smrg *" $absdir "*) ;; 8180603fc0a3Smrg *) func_append compile_rpath " $absdir" ;; 8181603fc0a3Smrg esac 8182603fc0a3Smrg ;; 8183603fc0a3Smrg esac 8184603fc0a3Smrg case " $sys_lib_dlsearch_path " in 8185603fc0a3Smrg *" $libdir "*) ;; 8186603fc0a3Smrg *) 8187603fc0a3Smrg case "$finalize_rpath " in 8188603fc0a3Smrg *" $libdir "*) ;; 8189603fc0a3Smrg *) func_append finalize_rpath " $libdir" ;; 8190603fc0a3Smrg esac 8191603fc0a3Smrg ;; 8192603fc0a3Smrg esac 8193603fc0a3Smrg fi 8194603fc0a3Smrg 8195603fc0a3Smrg if test -n "$old_archive_from_expsyms_cmds"; then 8196603fc0a3Smrg # figure out the soname 8197603fc0a3Smrg set dummy $library_names 8198603fc0a3Smrg shift 8199603fc0a3Smrg realname=$1 8200603fc0a3Smrg shift 8201603fc0a3Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 8202603fc0a3Smrg # use dlname if we got it. it's perfectly good, no? 8203603fc0a3Smrg if test -n "$dlname"; then 8204603fc0a3Smrg soname=$dlname 8205603fc0a3Smrg elif test -n "$soname_spec"; then 8206603fc0a3Smrg # bleh windows 8207603fc0a3Smrg case $host in 8208603fc0a3Smrg *cygwin* | mingw* | *cegcc* | *os2*) 8209603fc0a3Smrg func_arith $current - $age 8210603fc0a3Smrg major=$func_arith_result 8211603fc0a3Smrg versuffix=-$major 8212603fc0a3Smrg ;; 8213603fc0a3Smrg esac 8214603fc0a3Smrg eval soname=\"$soname_spec\" 8215603fc0a3Smrg else 8216603fc0a3Smrg soname=$realname 8217603fc0a3Smrg fi 8218603fc0a3Smrg 8219603fc0a3Smrg # Make a new name for the extract_expsyms_cmds to use 8220603fc0a3Smrg soroot=$soname 8221603fc0a3Smrg func_basename "$soroot" 8222603fc0a3Smrg soname=$func_basename_result 8223603fc0a3Smrg func_stripname 'lib' '.dll' "$soname" 8224603fc0a3Smrg newlib=libimp-$func_stripname_result.a 8225603fc0a3Smrg 8226603fc0a3Smrg # If the library has no export list, then create one now 8227603fc0a3Smrg if test -f "$output_objdir/$soname-def"; then : 8228603fc0a3Smrg else 8229603fc0a3Smrg func_verbose "extracting exported symbol list from '$soname'" 8230603fc0a3Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8231603fc0a3Smrg fi 8232603fc0a3Smrg 8233603fc0a3Smrg # Create $newlib 8234603fc0a3Smrg if test -f "$output_objdir/$newlib"; then :; else 8235603fc0a3Smrg func_verbose "generating import library for '$soname'" 8236603fc0a3Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8237603fc0a3Smrg fi 8238603fc0a3Smrg # make sure the library variables are pointing to the new library 8239603fc0a3Smrg dir=$output_objdir 8240603fc0a3Smrg linklib=$newlib 8241603fc0a3Smrg fi # test -n "$old_archive_from_expsyms_cmds" 8242603fc0a3Smrg 8243603fc0a3Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8244603fc0a3Smrg add_shlibpath= 8245603fc0a3Smrg add_dir= 8246603fc0a3Smrg add= 8247603fc0a3Smrg lib_linked=yes 8248603fc0a3Smrg case $hardcode_action in 8249603fc0a3Smrg immediate | unsupported) 8250603fc0a3Smrg if test no = "$hardcode_direct"; then 8251603fc0a3Smrg add=$dir/$linklib 8252603fc0a3Smrg case $host in 8253603fc0a3Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8254603fc0a3Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8255603fc0a3Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8256603fc0a3Smrg *-*-unixware7*) add_dir=-L$dir ;; 8257603fc0a3Smrg *-*-darwin* ) 8258603fc0a3Smrg # if the lib is a (non-dlopened) module then we cannot 8259603fc0a3Smrg # link against it, someone is ignoring the earlier warnings 8260603fc0a3Smrg if /usr/bin/file -L $add 2> /dev/null | 8261603fc0a3Smrg $GREP ": [^:]* bundle" >/dev/null; then 8262603fc0a3Smrg if test "X$dlopenmodule" != "X$lib"; then 8263603fc0a3Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8264603fc0a3Smrg if test -z "$old_library"; then 8265603fc0a3Smrg echo 8266603fc0a3Smrg echo "*** And there doesn't seem to be a static archive available" 8267603fc0a3Smrg echo "*** The link will probably fail, sorry" 8268603fc0a3Smrg else 8269603fc0a3Smrg add=$dir/$old_library 8270603fc0a3Smrg fi 8271603fc0a3Smrg elif test -n "$old_library"; then 8272603fc0a3Smrg add=$dir/$old_library 8273603fc0a3Smrg fi 8274603fc0a3Smrg fi 8275603fc0a3Smrg esac 8276603fc0a3Smrg elif test no = "$hardcode_minus_L"; then 8277603fc0a3Smrg case $host in 8278603fc0a3Smrg *-*-sunos*) add_shlibpath=$dir ;; 8279603fc0a3Smrg esac 8280603fc0a3Smrg add_dir=-L$dir 8281603fc0a3Smrg add=-l$name 8282603fc0a3Smrg elif test no = "$hardcode_shlibpath_var"; then 8283603fc0a3Smrg add_shlibpath=$dir 8284603fc0a3Smrg add=-l$name 8285603fc0a3Smrg else 8286603fc0a3Smrg lib_linked=no 8287603fc0a3Smrg fi 8288603fc0a3Smrg ;; 8289603fc0a3Smrg relink) 8290603fc0a3Smrg if test yes = "$hardcode_direct" && 8291603fc0a3Smrg test no = "$hardcode_direct_absolute"; then 8292603fc0a3Smrg add=$dir/$linklib 8293603fc0a3Smrg elif test yes = "$hardcode_minus_L"; then 8294603fc0a3Smrg add_dir=-L$absdir 8295603fc0a3Smrg # Try looking first in the location we're being installed to. 8296603fc0a3Smrg if test -n "$inst_prefix_dir"; then 8297603fc0a3Smrg case $libdir in 8298603fc0a3Smrg [\\/]*) 8299603fc0a3Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8300603fc0a3Smrg ;; 8301603fc0a3Smrg esac 8302603fc0a3Smrg fi 8303603fc0a3Smrg add=-l$name 8304603fc0a3Smrg elif test yes = "$hardcode_shlibpath_var"; then 8305603fc0a3Smrg add_shlibpath=$dir 8306603fc0a3Smrg add=-l$name 8307603fc0a3Smrg else 8308603fc0a3Smrg lib_linked=no 8309603fc0a3Smrg fi 8310603fc0a3Smrg ;; 8311603fc0a3Smrg *) lib_linked=no ;; 8312603fc0a3Smrg esac 8313603fc0a3Smrg 8314603fc0a3Smrg if test yes != "$lib_linked"; then 8315603fc0a3Smrg func_fatal_configuration "unsupported hardcode properties" 8316603fc0a3Smrg fi 8317603fc0a3Smrg 8318603fc0a3Smrg if test -n "$add_shlibpath"; then 8319603fc0a3Smrg case :$compile_shlibpath: in 8320603fc0a3Smrg *":$add_shlibpath:"*) ;; 8321603fc0a3Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8322603fc0a3Smrg esac 8323603fc0a3Smrg fi 8324603fc0a3Smrg if test prog = "$linkmode"; then 8325603fc0a3Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8326603fc0a3Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8327603fc0a3Smrg else 8328603fc0a3Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8329603fc0a3Smrg test -n "$add" && deplibs="$add $deplibs" 8330603fc0a3Smrg if test yes != "$hardcode_direct" && 8331603fc0a3Smrg test yes != "$hardcode_minus_L" && 8332603fc0a3Smrg test yes = "$hardcode_shlibpath_var"; then 8333603fc0a3Smrg case :$finalize_shlibpath: in 8334603fc0a3Smrg *":$libdir:"*) ;; 8335603fc0a3Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8336603fc0a3Smrg esac 8337603fc0a3Smrg fi 8338603fc0a3Smrg fi 8339603fc0a3Smrg fi 8340603fc0a3Smrg 8341603fc0a3Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8342603fc0a3Smrg add_shlibpath= 8343603fc0a3Smrg add_dir= 8344603fc0a3Smrg add= 8345603fc0a3Smrg # Finalize command for both is simple: just hardcode it. 8346603fc0a3Smrg if test yes = "$hardcode_direct" && 8347603fc0a3Smrg test no = "$hardcode_direct_absolute"; then 8348603fc0a3Smrg if test -f "$inst_prefix_dir$libdir/$linklib"; then 8349603fc0a3Smrg add="$inst_prefix_dir$libdir/$linklib" 8350603fc0a3Smrg else 8351603fc0a3Smrg add="$libdir/$linklib" 8352603fc0a3Smrg fi 8353603fc0a3Smrg elif test yes = "$hardcode_minus_L"; then 8354603fc0a3Smrg add_dir=-L$libdir 8355603fc0a3Smrg add=-l$name 8356603fc0a3Smrg elif test yes = "$hardcode_shlibpath_var"; then 8357603fc0a3Smrg case :$finalize_shlibpath: in 8358603fc0a3Smrg *":$libdir:"*) ;; 8359603fc0a3Smrg *) func_append finalize_shlibpath "$libdir:" ;; 8360603fc0a3Smrg esac 8361603fc0a3Smrg add=-l$name 8362603fc0a3Smrg elif test yes = "$hardcode_automatic"; then 8363603fc0a3Smrg if test -n "$inst_prefix_dir" && 8364603fc0a3Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8365603fc0a3Smrg add=$inst_prefix_dir$libdir/$linklib 8366603fc0a3Smrg else 8367603fc0a3Smrg add=$libdir/$linklib 8368603fc0a3Smrg fi 8369603fc0a3Smrg else 8370603fc0a3Smrg # We cannot seem to hardcode it, guess we'll fake it. 8371603fc0a3Smrg add_dir=-L$libdir 8372603fc0a3Smrg # Try looking first in the location we're being installed to. 8373603fc0a3Smrg if test -n "$inst_prefix_dir"; then 8374603fc0a3Smrg case $libdir in 8375603fc0a3Smrg [\\/]*) 8376603fc0a3Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 8377603fc0a3Smrg ;; 8378603fc0a3Smrg esac 8379603fc0a3Smrg fi 8380603fc0a3Smrg add=-l$name 8381603fc0a3Smrg fi 8382603fc0a3Smrg 8383603fc0a3Smrg if test prog = "$linkmode"; then 8384603fc0a3Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8385603fc0a3Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8386603fc0a3Smrg else 8387603fc0a3Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8388603fc0a3Smrg test -n "$add" && deplibs="$add $deplibs" 8389603fc0a3Smrg fi 8390603fc0a3Smrg fi 8391603fc0a3Smrg elif test prog = "$linkmode"; then 8392603fc0a3Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8393603fc0a3Smrg # is not unsupported. This is valid on all known static and 8394603fc0a3Smrg # shared platforms. 8395603fc0a3Smrg if test unsupported != "$hardcode_direct"; then 8396603fc0a3Smrg test -n "$old_library" && linklib=$old_library 8397603fc0a3Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 8398603fc0a3Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8399603fc0a3Smrg else 8400603fc0a3Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8401603fc0a3Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8402603fc0a3Smrg fi 8403603fc0a3Smrg elif test yes = "$build_libtool_libs"; then 8404603fc0a3Smrg # Not a shared library 8405603fc0a3Smrg if test pass_all != "$deplibs_check_method"; then 8406603fc0a3Smrg # We're trying link a shared library against a static one 8407603fc0a3Smrg # but the system doesn't support it. 8408603fc0a3Smrg 8409603fc0a3Smrg # Just print a warning and add the library to dependency_libs so 8410603fc0a3Smrg # that the program can be linked against the static library. 8411603fc0a3Smrg echo 8412603fc0a3Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8413603fc0a3Smrg echo "*** I have the capability to make that library automatically link in when" 8414603fc0a3Smrg echo "*** you link to this library. But I can only do this if you have a" 8415603fc0a3Smrg echo "*** shared version of the library, which you do not appear to have." 8416603fc0a3Smrg if test yes = "$module"; then 8417603fc0a3Smrg echo "*** But as you try to build a module library, libtool will still create " 8418603fc0a3Smrg echo "*** a static module, that should work as long as the dlopening application" 8419603fc0a3Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8420603fc0a3Smrg if test -z "$global_symbol_pipe"; then 8421603fc0a3Smrg echo 8422603fc0a3Smrg echo "*** However, this would only work if libtool was able to extract symbol" 8423603fc0a3Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8424603fc0a3Smrg echo "*** not find such a program. So, this module is probably useless." 8425603fc0a3Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8426603fc0a3Smrg fi 8427603fc0a3Smrg if test no = "$build_old_libs"; then 8428603fc0a3Smrg build_libtool_libs=module 8429603fc0a3Smrg build_old_libs=yes 8430603fc0a3Smrg else 8431603fc0a3Smrg build_libtool_libs=no 8432603fc0a3Smrg fi 8433603fc0a3Smrg fi 8434603fc0a3Smrg else 8435603fc0a3Smrg deplibs="$dir/$old_library $deplibs" 8436603fc0a3Smrg link_static=yes 8437603fc0a3Smrg fi 8438603fc0a3Smrg fi # link shared/static library? 8439603fc0a3Smrg 8440603fc0a3Smrg if test lib = "$linkmode"; then 8441603fc0a3Smrg if test -n "$dependency_libs" && 8442603fc0a3Smrg { test yes != "$hardcode_into_libs" || 8443603fc0a3Smrg test yes = "$build_old_libs" || 8444603fc0a3Smrg test yes = "$link_static"; }; then 8445603fc0a3Smrg # Extract -R from dependency_libs 8446603fc0a3Smrg temp_deplibs= 8447603fc0a3Smrg for libdir in $dependency_libs; do 8448603fc0a3Smrg case $libdir in 8449603fc0a3Smrg -R*) func_stripname '-R' '' "$libdir" 8450603fc0a3Smrg temp_xrpath=$func_stripname_result 8451603fc0a3Smrg case " $xrpath " in 8452603fc0a3Smrg *" $temp_xrpath "*) ;; 8453603fc0a3Smrg *) func_append xrpath " $temp_xrpath";; 8454603fc0a3Smrg esac;; 8455603fc0a3Smrg *) func_append temp_deplibs " $libdir";; 8456603fc0a3Smrg esac 8457603fc0a3Smrg done 8458603fc0a3Smrg dependency_libs=$temp_deplibs 8459603fc0a3Smrg fi 8460603fc0a3Smrg 8461603fc0a3Smrg func_append newlib_search_path " $absdir" 8462603fc0a3Smrg # Link against this library 8463603fc0a3Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8464603fc0a3Smrg # ... and its dependency_libs 8465603fc0a3Smrg tmp_libs= 8466603fc0a3Smrg for deplib in $dependency_libs; do 8467603fc0a3Smrg newdependency_libs="$deplib $newdependency_libs" 8468603fc0a3Smrg case $deplib in 8469603fc0a3Smrg -L*) func_stripname '-L' '' "$deplib" 8470603fc0a3Smrg func_resolve_sysroot "$func_stripname_result";; 8471603fc0a3Smrg *) func_resolve_sysroot "$deplib" ;; 8472603fc0a3Smrg esac 8473603fc0a3Smrg if $opt_preserve_dup_deps; then 8474603fc0a3Smrg case "$tmp_libs " in 8475603fc0a3Smrg *" $func_resolve_sysroot_result "*) 8476603fc0a3Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8477603fc0a3Smrg esac 8478603fc0a3Smrg fi 8479603fc0a3Smrg func_append tmp_libs " $func_resolve_sysroot_result" 8480603fc0a3Smrg done 8481603fc0a3Smrg 8482603fc0a3Smrg if test no != "$link_all_deplibs"; then 8483603fc0a3Smrg # Add the search paths of all dependency libraries 8484603fc0a3Smrg for deplib in $dependency_libs; do 8485603fc0a3Smrg path= 8486603fc0a3Smrg case $deplib in 8487603fc0a3Smrg -L*) path=$deplib ;; 8488603fc0a3Smrg *.la) 8489603fc0a3Smrg func_resolve_sysroot "$deplib" 8490603fc0a3Smrg deplib=$func_resolve_sysroot_result 8491603fc0a3Smrg func_dirname "$deplib" "" "." 8492603fc0a3Smrg dir=$func_dirname_result 8493603fc0a3Smrg # We need an absolute path. 8494603fc0a3Smrg case $dir in 8495603fc0a3Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8496603fc0a3Smrg *) 8497603fc0a3Smrg absdir=`cd "$dir" && pwd` 8498603fc0a3Smrg if test -z "$absdir"; then 8499603fc0a3Smrg func_warning "cannot determine absolute directory name of '$dir'" 8500603fc0a3Smrg absdir=$dir 8501603fc0a3Smrg fi 8502603fc0a3Smrg ;; 8503603fc0a3Smrg esac 8504603fc0a3Smrg if $GREP "^installed=no" $deplib > /dev/null; then 8505603fc0a3Smrg case $host in 8506603fc0a3Smrg *-*-darwin*) 8507603fc0a3Smrg depdepl= 8508603fc0a3Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8509603fc0a3Smrg if test -n "$deplibrary_names"; then 8510603fc0a3Smrg for tmp in $deplibrary_names; do 8511603fc0a3Smrg depdepl=$tmp 8512603fc0a3Smrg done 8513603fc0a3Smrg if test -f "$absdir/$objdir/$depdepl"; then 8514603fc0a3Smrg depdepl=$absdir/$objdir/$depdepl 8515603fc0a3Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8516603fc0a3Smrg if test -z "$darwin_install_name"; then 8517603fc0a3Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8518603fc0a3Smrg fi 8519603fc0a3Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8520603fc0a3Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8521603fc0a3Smrg path= 8522603fc0a3Smrg fi 8523603fc0a3Smrg fi 8524603fc0a3Smrg ;; 8525603fc0a3Smrg *) 8526603fc0a3Smrg path=-L$absdir/$objdir 8527603fc0a3Smrg ;; 8528603fc0a3Smrg esac 8529603fc0a3Smrg else 8530603fc0a3Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8531603fc0a3Smrg test -z "$libdir" && \ 8532603fc0a3Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 8533603fc0a3Smrg test "$absdir" != "$libdir" && \ 8534603fc0a3Smrg func_warning "'$deplib' seems to be moved" 8535603fc0a3Smrg 8536603fc0a3Smrg path=-L$absdir 8537603fc0a3Smrg fi 8538603fc0a3Smrg ;; 8539603fc0a3Smrg esac 8540603fc0a3Smrg case " $deplibs " in 8541603fc0a3Smrg *" $path "*) ;; 8542603fc0a3Smrg *) deplibs="$path $deplibs" ;; 8543603fc0a3Smrg esac 8544603fc0a3Smrg done 8545603fc0a3Smrg fi # link_all_deplibs != no 8546603fc0a3Smrg fi # linkmode = lib 8547603fc0a3Smrg done # for deplib in $libs 8548603fc0a3Smrg if test link = "$pass"; then 8549603fc0a3Smrg if test prog = "$linkmode"; then 8550603fc0a3Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8551603fc0a3Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8552603fc0a3Smrg else 8553603fc0a3Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8554603fc0a3Smrg fi 8555603fc0a3Smrg fi 8556603fc0a3Smrg dependency_libs=$newdependency_libs 8557603fc0a3Smrg if test dlpreopen = "$pass"; then 8558603fc0a3Smrg # Link the dlpreopened libraries before other libraries 8559603fc0a3Smrg for deplib in $save_deplibs; do 8560603fc0a3Smrg deplibs="$deplib $deplibs" 8561603fc0a3Smrg done 8562603fc0a3Smrg fi 8563603fc0a3Smrg if test dlopen != "$pass"; then 8564603fc0a3Smrg test conv = "$pass" || { 8565603fc0a3Smrg # Make sure lib_search_path contains only unique directories. 8566603fc0a3Smrg lib_search_path= 8567603fc0a3Smrg for dir in $newlib_search_path; do 8568603fc0a3Smrg case "$lib_search_path " in 8569603fc0a3Smrg *" $dir "*) ;; 8570603fc0a3Smrg *) func_append lib_search_path " $dir" ;; 8571603fc0a3Smrg esac 8572603fc0a3Smrg done 8573603fc0a3Smrg newlib_search_path= 8574603fc0a3Smrg } 8575603fc0a3Smrg 8576603fc0a3Smrg if test prog,link = "$linkmode,$pass"; then 8577603fc0a3Smrg vars="compile_deplibs finalize_deplibs" 8578603fc0a3Smrg else 8579603fc0a3Smrg vars=deplibs 8580603fc0a3Smrg fi 8581603fc0a3Smrg for var in $vars dependency_libs; do 8582603fc0a3Smrg # Add libraries to $var in reverse order 8583603fc0a3Smrg eval tmp_libs=\"\$$var\" 8584603fc0a3Smrg new_libs= 8585603fc0a3Smrg for deplib in $tmp_libs; do 8586603fc0a3Smrg # FIXME: Pedantically, this is the right thing to do, so 8587603fc0a3Smrg # that some nasty dependency loop isn't accidentally 8588603fc0a3Smrg # broken: 8589603fc0a3Smrg #new_libs="$deplib $new_libs" 8590603fc0a3Smrg # Pragmatically, this seems to cause very few problems in 8591603fc0a3Smrg # practice: 8592603fc0a3Smrg case $deplib in 8593603fc0a3Smrg -L*) new_libs="$deplib $new_libs" ;; 8594603fc0a3Smrg -R*) ;; 8595603fc0a3Smrg *) 8596603fc0a3Smrg # And here is the reason: when a library appears more 8597603fc0a3Smrg # than once as an explicit dependence of a library, or 8598603fc0a3Smrg # is implicitly linked in more than once by the 8599603fc0a3Smrg # compiler, it is considered special, and multiple 8600603fc0a3Smrg # occurrences thereof are not removed. Compare this 8601603fc0a3Smrg # with having the same library being listed as a 8602603fc0a3Smrg # dependency of multiple other libraries: in this case, 8603603fc0a3Smrg # we know (pedantically, we assume) the library does not 8604603fc0a3Smrg # need to be listed more than once, so we keep only the 8605603fc0a3Smrg # last copy. This is not always right, but it is rare 8606603fc0a3Smrg # enough that we require users that really mean to play 8607603fc0a3Smrg # such unportable linking tricks to link the library 8608603fc0a3Smrg # using -Wl,-lname, so that libtool does not consider it 8609603fc0a3Smrg # for duplicate removal. 8610603fc0a3Smrg case " $specialdeplibs " in 8611603fc0a3Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8612603fc0a3Smrg *) 8613603fc0a3Smrg case " $new_libs " in 8614603fc0a3Smrg *" $deplib "*) ;; 8615603fc0a3Smrg *) new_libs="$deplib $new_libs" ;; 8616603fc0a3Smrg esac 8617603fc0a3Smrg ;; 8618603fc0a3Smrg esac 8619603fc0a3Smrg ;; 8620603fc0a3Smrg esac 8621603fc0a3Smrg done 8622603fc0a3Smrg tmp_libs= 8623603fc0a3Smrg for deplib in $new_libs; do 8624603fc0a3Smrg case $deplib in 8625603fc0a3Smrg -L*) 8626603fc0a3Smrg case " $tmp_libs " in 8627603fc0a3Smrg *" $deplib "*) ;; 8628603fc0a3Smrg *) func_append tmp_libs " $deplib" ;; 8629603fc0a3Smrg esac 8630603fc0a3Smrg ;; 8631603fc0a3Smrg *) func_append tmp_libs " $deplib" ;; 8632603fc0a3Smrg esac 8633603fc0a3Smrg done 8634603fc0a3Smrg eval $var=\"$tmp_libs\" 8635603fc0a3Smrg done # for var 8636603fc0a3Smrg fi 8637603fc0a3Smrg 8638603fc0a3Smrg # Add Sun CC postdeps if required: 8639603fc0a3Smrg test CXX = "$tagname" && { 8640603fc0a3Smrg case $host_os in 8641603fc0a3Smrg linux*) 8642603fc0a3Smrg case `$CC -V 2>&1 | sed 5q` in 8643603fc0a3Smrg *Sun\ C*) # Sun C++ 5.9 8644603fc0a3Smrg func_suncc_cstd_abi 8645603fc0a3Smrg 8646603fc0a3Smrg if test no != "$suncc_use_cstd_abi"; then 8647603fc0a3Smrg func_append postdeps ' -library=Cstd -library=Crun' 8648603fc0a3Smrg fi 8649603fc0a3Smrg ;; 8650603fc0a3Smrg esac 8651603fc0a3Smrg ;; 8652603fc0a3Smrg 8653603fc0a3Smrg solaris*) 8654603fc0a3Smrg func_cc_basename "$CC" 8655603fc0a3Smrg case $func_cc_basename_result in 8656603fc0a3Smrg CC* | sunCC*) 8657603fc0a3Smrg func_suncc_cstd_abi 8658603fc0a3Smrg 8659603fc0a3Smrg if test no != "$suncc_use_cstd_abi"; then 8660603fc0a3Smrg func_append postdeps ' -library=Cstd -library=Crun' 8661603fc0a3Smrg fi 8662603fc0a3Smrg ;; 8663603fc0a3Smrg esac 8664603fc0a3Smrg ;; 8665603fc0a3Smrg esac 8666603fc0a3Smrg } 8667603fc0a3Smrg 8668603fc0a3Smrg # Last step: remove runtime libs from dependency_libs 8669603fc0a3Smrg # (they stay in deplibs) 8670603fc0a3Smrg tmp_libs= 8671603fc0a3Smrg for i in $dependency_libs; do 8672603fc0a3Smrg case " $predeps $postdeps $compiler_lib_search_path " in 8673603fc0a3Smrg *" $i "*) 8674603fc0a3Smrg i= 8675603fc0a3Smrg ;; 8676603fc0a3Smrg esac 8677603fc0a3Smrg if test -n "$i"; then 8678603fc0a3Smrg func_append tmp_libs " $i" 8679603fc0a3Smrg fi 8680603fc0a3Smrg done 8681603fc0a3Smrg dependency_libs=$tmp_libs 8682603fc0a3Smrg done # for pass 8683603fc0a3Smrg if test prog = "$linkmode"; then 8684603fc0a3Smrg dlfiles=$newdlfiles 8685603fc0a3Smrg fi 8686603fc0a3Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8687603fc0a3Smrg dlprefiles=$newdlprefiles 8688603fc0a3Smrg fi 8689603fc0a3Smrg 8690603fc0a3Smrg case $linkmode in 8691603fc0a3Smrg oldlib) 8692603fc0a3Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8693603fc0a3Smrg func_warning "'-dlopen' is ignored for archives" 8694603fc0a3Smrg fi 8695603fc0a3Smrg 8696603fc0a3Smrg case " $deplibs" in 8697603fc0a3Smrg *\ -l* | *\ -L*) 8698603fc0a3Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 8699603fc0a3Smrg esac 8700603fc0a3Smrg 8701603fc0a3Smrg test -n "$rpath" && \ 8702603fc0a3Smrg func_warning "'-rpath' is ignored for archives" 8703603fc0a3Smrg 8704603fc0a3Smrg test -n "$xrpath" && \ 8705603fc0a3Smrg func_warning "'-R' is ignored for archives" 8706603fc0a3Smrg 8707603fc0a3Smrg test -n "$vinfo" && \ 8708603fc0a3Smrg func_warning "'-version-info/-version-number' is ignored for archives" 8709603fc0a3Smrg 8710603fc0a3Smrg test -n "$release" && \ 8711603fc0a3Smrg func_warning "'-release' is ignored for archives" 8712603fc0a3Smrg 8713603fc0a3Smrg test -n "$export_symbols$export_symbols_regex" && \ 8714603fc0a3Smrg func_warning "'-export-symbols' is ignored for archives" 8715603fc0a3Smrg 8716603fc0a3Smrg # Now set the variables for building old libraries. 8717603fc0a3Smrg build_libtool_libs=no 8718603fc0a3Smrg oldlibs=$output 8719603fc0a3Smrg func_append objs "$old_deplibs" 8720603fc0a3Smrg ;; 8721603fc0a3Smrg 8722603fc0a3Smrg lib) 8723603fc0a3Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 8724603fc0a3Smrg case $outputname in 8725603fc0a3Smrg lib*) 8726603fc0a3Smrg func_stripname 'lib' '.la' "$outputname" 8727603fc0a3Smrg name=$func_stripname_result 8728603fc0a3Smrg eval shared_ext=\"$shrext_cmds\" 8729603fc0a3Smrg eval libname=\"$libname_spec\" 8730603fc0a3Smrg ;; 8731603fc0a3Smrg *) 8732603fc0a3Smrg test no = "$module" \ 8733603fc0a3Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 8734603fc0a3Smrg 8735603fc0a3Smrg if test no != "$need_lib_prefix"; then 8736603fc0a3Smrg # Add the "lib" prefix for modules if required 8737603fc0a3Smrg func_stripname '' '.la' "$outputname" 8738603fc0a3Smrg name=$func_stripname_result 8739603fc0a3Smrg eval shared_ext=\"$shrext_cmds\" 8740603fc0a3Smrg eval libname=\"$libname_spec\" 8741603fc0a3Smrg else 8742603fc0a3Smrg func_stripname '' '.la' "$outputname" 8743603fc0a3Smrg libname=$func_stripname_result 8744603fc0a3Smrg fi 8745603fc0a3Smrg ;; 8746603fc0a3Smrg esac 8747603fc0a3Smrg 8748603fc0a3Smrg if test -n "$objs"; then 8749603fc0a3Smrg if test pass_all != "$deplibs_check_method"; then 8750603fc0a3Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8751603fc0a3Smrg else 8752603fc0a3Smrg echo 8753603fc0a3Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8754603fc0a3Smrg $ECHO "*** objects $objs is not portable!" 8755603fc0a3Smrg func_append libobjs " $objs" 8756603fc0a3Smrg fi 8757603fc0a3Smrg fi 8758603fc0a3Smrg 8759603fc0a3Smrg test no = "$dlself" \ 8760603fc0a3Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 8761603fc0a3Smrg 8762603fc0a3Smrg set dummy $rpath 8763603fc0a3Smrg shift 8764603fc0a3Smrg test 1 -lt "$#" \ 8765603fc0a3Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 8766603fc0a3Smrg 8767603fc0a3Smrg install_libdir=$1 8768603fc0a3Smrg 8769603fc0a3Smrg oldlibs= 8770603fc0a3Smrg if test -z "$rpath"; then 8771603fc0a3Smrg if test yes = "$build_libtool_libs"; then 8772603fc0a3Smrg # Building a libtool convenience library. 8773603fc0a3Smrg # Some compilers have problems with a '.al' extension so 8774603fc0a3Smrg # convenience libraries should have the same extension an 8775603fc0a3Smrg # archive normally would. 8776603fc0a3Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 8777603fc0a3Smrg build_libtool_libs=convenience 8778603fc0a3Smrg build_old_libs=yes 8779603fc0a3Smrg fi 8780603fc0a3Smrg 8781603fc0a3Smrg test -n "$vinfo" && \ 8782603fc0a3Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8783603fc0a3Smrg 8784603fc0a3Smrg test -n "$release" && \ 8785603fc0a3Smrg func_warning "'-release' is ignored for convenience libraries" 8786603fc0a3Smrg else 8787603fc0a3Smrg 8788603fc0a3Smrg # Parse the version information argument. 8789603fc0a3Smrg save_ifs=$IFS; IFS=: 8790603fc0a3Smrg set dummy $vinfo 0 0 0 8791603fc0a3Smrg shift 8792603fc0a3Smrg IFS=$save_ifs 8793603fc0a3Smrg 8794603fc0a3Smrg test -n "$7" && \ 8795603fc0a3Smrg func_fatal_help "too many parameters to '-version-info'" 8796603fc0a3Smrg 8797603fc0a3Smrg # convert absolute version numbers to libtool ages 8798603fc0a3Smrg # this retains compatibility with .la files and attempts 8799603fc0a3Smrg # to make the code below a bit more comprehensible 8800603fc0a3Smrg 8801603fc0a3Smrg case $vinfo_number in 8802603fc0a3Smrg yes) 8803603fc0a3Smrg number_major=$1 8804603fc0a3Smrg number_minor=$2 8805603fc0a3Smrg number_revision=$3 8806603fc0a3Smrg # 8807603fc0a3Smrg # There are really only two kinds -- those that 8808603fc0a3Smrg # use the current revision as the major version 8809603fc0a3Smrg # and those that subtract age and use age as 8810603fc0a3Smrg # a minor version. But, then there is irix 8811603fc0a3Smrg # that has an extra 1 added just for fun 8812603fc0a3Smrg # 8813603fc0a3Smrg case $version_type in 8814603fc0a3Smrg # correct linux to gnu/linux during the next big refactor 8815603fc0a3Smrg darwin|freebsd-elf|linux|osf|windows|none) 8816603fc0a3Smrg func_arith $number_major + $number_minor 8817603fc0a3Smrg current=$func_arith_result 8818603fc0a3Smrg age=$number_minor 8819603fc0a3Smrg revision=$number_revision 8820603fc0a3Smrg ;; 8821603fc0a3Smrg freebsd-aout|qnx|sunos) 8822603fc0a3Smrg current=$number_major 8823603fc0a3Smrg revision=$number_minor 8824603fc0a3Smrg age=0 8825603fc0a3Smrg ;; 8826603fc0a3Smrg irix|nonstopux) 8827603fc0a3Smrg func_arith $number_major + $number_minor 8828603fc0a3Smrg current=$func_arith_result 8829603fc0a3Smrg age=$number_minor 8830603fc0a3Smrg revision=$number_minor 8831603fc0a3Smrg lt_irix_increment=no 8832603fc0a3Smrg ;; 8833603fc0a3Smrg esac 8834603fc0a3Smrg ;; 8835603fc0a3Smrg no) 8836603fc0a3Smrg current=$1 8837603fc0a3Smrg revision=$2 8838603fc0a3Smrg age=$3 8839603fc0a3Smrg ;; 8840603fc0a3Smrg esac 8841603fc0a3Smrg 8842603fc0a3Smrg # Check that each of the things are valid numbers. 8843603fc0a3Smrg case $current in 8844603fc0a3Smrg 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]) ;; 8845603fc0a3Smrg *) 8846603fc0a3Smrg func_error "CURRENT '$current' must be a nonnegative integer" 8847603fc0a3Smrg func_fatal_error "'$vinfo' is not valid version information" 8848603fc0a3Smrg ;; 8849603fc0a3Smrg esac 8850603fc0a3Smrg 8851603fc0a3Smrg case $revision in 8852603fc0a3Smrg 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]) ;; 8853603fc0a3Smrg *) 8854603fc0a3Smrg func_error "REVISION '$revision' must be a nonnegative integer" 8855603fc0a3Smrg func_fatal_error "'$vinfo' is not valid version information" 8856603fc0a3Smrg ;; 8857603fc0a3Smrg esac 8858603fc0a3Smrg 8859603fc0a3Smrg case $age in 8860603fc0a3Smrg 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]) ;; 8861603fc0a3Smrg *) 8862603fc0a3Smrg func_error "AGE '$age' must be a nonnegative integer" 8863603fc0a3Smrg func_fatal_error "'$vinfo' is not valid version information" 8864603fc0a3Smrg ;; 8865603fc0a3Smrg esac 8866603fc0a3Smrg 8867603fc0a3Smrg if test "$age" -gt "$current"; then 8868603fc0a3Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 8869603fc0a3Smrg func_fatal_error "'$vinfo' is not valid version information" 8870603fc0a3Smrg fi 8871603fc0a3Smrg 8872603fc0a3Smrg # Calculate the version variables. 8873603fc0a3Smrg major= 8874603fc0a3Smrg versuffix= 8875603fc0a3Smrg versuffix2= 8876603fc0a3Smrg verstring= 8877603fc0a3Smrg case $version_type in 8878603fc0a3Smrg none) ;; 8879603fc0a3Smrg 8880603fc0a3Smrg darwin) 8881603fc0a3Smrg # Like Linux, but with the current version available in 8882603fc0a3Smrg # verstring for coding it into the library header 8883603fc0a3Smrg func_arith $current - $age 8884603fc0a3Smrg major=.$func_arith_result 8885603fc0a3Smrg versuffix=$major.$age.$revision 8886603fc0a3Smrg # Darwin ld doesn't like 0 for these options... 8887603fc0a3Smrg func_arith $current + 1 8888603fc0a3Smrg minor_current=$func_arith_result 8889603fc0a3Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8890603fc0a3Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8891603fc0a3Smrg # On Darwin other compilers 8892603fc0a3Smrg case $CC in 8893603fc0a3Smrg nagfor*) 8894603fc0a3Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8895603fc0a3Smrg ;; 8896603fc0a3Smrg *) 8897603fc0a3Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8898603fc0a3Smrg ;; 8899603fc0a3Smrg esac 8900603fc0a3Smrg ;; 8901603fc0a3Smrg 8902603fc0a3Smrg freebsd-aout) 8903603fc0a3Smrg major=.$current 8904603fc0a3Smrg versuffix=.$current.$revision 8905603fc0a3Smrg ;; 8906603fc0a3Smrg 8907603fc0a3Smrg freebsd-elf) 8908603fc0a3Smrg func_arith $current - $age 8909603fc0a3Smrg major=.$func_arith_result 8910603fc0a3Smrg versuffix=$major.$age.$revision 8911603fc0a3Smrg ;; 8912603fc0a3Smrg 8913603fc0a3Smrg irix | nonstopux) 8914603fc0a3Smrg if test no = "$lt_irix_increment"; then 8915603fc0a3Smrg func_arith $current - $age 8916603fc0a3Smrg else 8917603fc0a3Smrg func_arith $current - $age + 1 8918603fc0a3Smrg fi 8919603fc0a3Smrg major=$func_arith_result 8920603fc0a3Smrg 8921603fc0a3Smrg case $version_type in 8922603fc0a3Smrg nonstopux) verstring_prefix=nonstopux ;; 8923603fc0a3Smrg *) verstring_prefix=sgi ;; 8924603fc0a3Smrg esac 8925603fc0a3Smrg verstring=$verstring_prefix$major.$revision 8926603fc0a3Smrg 8927603fc0a3Smrg # Add in all the interfaces that we are compatible with. 8928603fc0a3Smrg loop=$revision 8929603fc0a3Smrg while test 0 -ne "$loop"; do 8930603fc0a3Smrg func_arith $revision - $loop 8931603fc0a3Smrg iface=$func_arith_result 8932603fc0a3Smrg func_arith $loop - 1 8933603fc0a3Smrg loop=$func_arith_result 8934603fc0a3Smrg verstring=$verstring_prefix$major.$iface:$verstring 8935603fc0a3Smrg done 8936603fc0a3Smrg 8937603fc0a3Smrg # Before this point, $major must not contain '.'. 8938603fc0a3Smrg major=.$major 8939603fc0a3Smrg versuffix=$major.$revision 8940603fc0a3Smrg ;; 8941603fc0a3Smrg 8942603fc0a3Smrg linux) # correct to gnu/linux during the next big refactor 8943603fc0a3Smrg func_arith $current - $age 8944603fc0a3Smrg major=.$func_arith_result 8945603fc0a3Smrg versuffix=$major.$age.$revision 8946603fc0a3Smrg versuffix2=$major.$age 8947603fc0a3Smrg ;; 8948603fc0a3Smrg 8949603fc0a3Smrg osf) 8950603fc0a3Smrg func_arith $current - $age 8951603fc0a3Smrg major=.$func_arith_result 8952603fc0a3Smrg versuffix=.$current.$age.$revision 8953603fc0a3Smrg verstring=$current.$age.$revision 8954603fc0a3Smrg 8955603fc0a3Smrg # Add in all the interfaces that we are compatible with. 8956603fc0a3Smrg loop=$age 8957603fc0a3Smrg while test 0 -ne "$loop"; do 8958603fc0a3Smrg func_arith $current - $loop 8959603fc0a3Smrg iface=$func_arith_result 8960603fc0a3Smrg func_arith $loop - 1 8961603fc0a3Smrg loop=$func_arith_result 8962603fc0a3Smrg verstring=$verstring:$iface.0 8963603fc0a3Smrg done 8964603fc0a3Smrg 8965603fc0a3Smrg # Make executables depend on our current version. 8966603fc0a3Smrg func_append verstring ":$current.0" 8967603fc0a3Smrg ;; 8968603fc0a3Smrg 8969603fc0a3Smrg qnx) 8970603fc0a3Smrg major=.$current 8971603fc0a3Smrg versuffix=.$current 8972603fc0a3Smrg ;; 8973603fc0a3Smrg 8974603fc0a3Smrg sco) 8975603fc0a3Smrg major=.$current 8976603fc0a3Smrg versuffix=.$current 8977603fc0a3Smrg ;; 8978603fc0a3Smrg 8979603fc0a3Smrg sunos) 8980603fc0a3Smrg major=.$current 8981603fc0a3Smrg versuffix=.$current.$revision 8982603fc0a3Smrg ;; 8983603fc0a3Smrg 8984603fc0a3Smrg windows) 8985603fc0a3Smrg # Use '-' rather than '.', since we only want one 8986603fc0a3Smrg # extension on DOS 8.3 file systems. 8987603fc0a3Smrg func_arith $current - $age 8988603fc0a3Smrg major=$func_arith_result 8989603fc0a3Smrg versuffix=-$major 8990603fc0a3Smrg ;; 8991603fc0a3Smrg 8992603fc0a3Smrg *) 8993603fc0a3Smrg func_fatal_configuration "unknown library version type '$version_type'" 8994603fc0a3Smrg ;; 8995603fc0a3Smrg esac 8996603fc0a3Smrg 8997603fc0a3Smrg # Clear the version info if we defaulted, and they specified a release. 8998603fc0a3Smrg if test -z "$vinfo" && test -n "$release"; then 8999603fc0a3Smrg major= 9000603fc0a3Smrg case $version_type in 9001603fc0a3Smrg darwin) 9002603fc0a3Smrg # we can't check for "0.0" in archive_cmds due to quoting 9003603fc0a3Smrg # problems, so we reset it completely 9004603fc0a3Smrg verstring= 9005603fc0a3Smrg ;; 9006603fc0a3Smrg *) 9007603fc0a3Smrg verstring=0.0 9008603fc0a3Smrg ;; 9009603fc0a3Smrg esac 9010603fc0a3Smrg if test no = "$need_version"; then 9011603fc0a3Smrg versuffix= 9012603fc0a3Smrg versuffix2= 9013603fc0a3Smrg else 9014603fc0a3Smrg versuffix=.0.0 9015603fc0a3Smrg versuffix2=.0.0 9016603fc0a3Smrg fi 9017603fc0a3Smrg fi 9018603fc0a3Smrg 9019603fc0a3Smrg # Remove version info from name if versioning should be avoided 9020603fc0a3Smrg if test yes,no = "$avoid_version,$need_version"; then 9021603fc0a3Smrg major= 9022603fc0a3Smrg versuffix= 9023603fc0a3Smrg versuffix2= 9024603fc0a3Smrg verstring= 9025603fc0a3Smrg fi 9026603fc0a3Smrg 9027603fc0a3Smrg # Check to see if the archive will have undefined symbols. 9028603fc0a3Smrg if test yes = "$allow_undefined"; then 9029603fc0a3Smrg if test unsupported = "$allow_undefined_flag"; then 9030603fc0a3Smrg if test yes = "$build_old_libs"; then 9031603fc0a3Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9032603fc0a3Smrg build_libtool_libs=no 9033603fc0a3Smrg else 9034603fc0a3Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9035603fc0a3Smrg fi 9036603fc0a3Smrg fi 9037603fc0a3Smrg else 9038603fc0a3Smrg # Don't allow undefined symbols. 9039603fc0a3Smrg allow_undefined_flag=$no_undefined_flag 9040603fc0a3Smrg fi 9041603fc0a3Smrg 9042603fc0a3Smrg fi 9043603fc0a3Smrg 9044603fc0a3Smrg func_generate_dlsyms "$libname" "$libname" : 9045603fc0a3Smrg func_append libobjs " $symfileobj" 9046603fc0a3Smrg test " " = "$libobjs" && libobjs= 9047603fc0a3Smrg 9048603fc0a3Smrg if test relink != "$opt_mode"; then 9049603fc0a3Smrg # Remove our outputs, but don't remove object files since they 9050603fc0a3Smrg # may have been created when compiling PIC objects. 9051603fc0a3Smrg removelist= 9052603fc0a3Smrg tempremovelist=`$ECHO "$output_objdir/*"` 9053603fc0a3Smrg for p in $tempremovelist; do 9054603fc0a3Smrg case $p in 9055603fc0a3Smrg *.$objext | *.gcno) 9056603fc0a3Smrg ;; 9057603fc0a3Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9058603fc0a3Smrg if test -n "$precious_files_regex"; then 9059603fc0a3Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9060603fc0a3Smrg then 9061603fc0a3Smrg continue 9062603fc0a3Smrg fi 9063603fc0a3Smrg fi 9064603fc0a3Smrg func_append removelist " $p" 9065603fc0a3Smrg ;; 9066603fc0a3Smrg *) ;; 9067603fc0a3Smrg esac 9068603fc0a3Smrg done 9069603fc0a3Smrg test -n "$removelist" && \ 9070603fc0a3Smrg func_show_eval "${RM}r \$removelist" 9071603fc0a3Smrg fi 9072603fc0a3Smrg 9073603fc0a3Smrg # Now set the variables for building old libraries. 9074603fc0a3Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9075603fc0a3Smrg func_append oldlibs " $output_objdir/$libname.$libext" 9076603fc0a3Smrg 9077603fc0a3Smrg # Transform .lo files to .o files. 9078603fc0a3Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9079603fc0a3Smrg fi 9080603fc0a3Smrg 9081603fc0a3Smrg # Eliminate all temporary directories. 9082603fc0a3Smrg #for path in $notinst_path; do 9083603fc0a3Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9084603fc0a3Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9085603fc0a3Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9086603fc0a3Smrg #done 9087603fc0a3Smrg 9088603fc0a3Smrg if test -n "$xrpath"; then 9089603fc0a3Smrg # If the user specified any rpath flags, then add them. 9090603fc0a3Smrg temp_xrpath= 9091603fc0a3Smrg for libdir in $xrpath; do 9092603fc0a3Smrg func_replace_sysroot "$libdir" 9093603fc0a3Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9094603fc0a3Smrg case "$finalize_rpath " in 9095603fc0a3Smrg *" $libdir "*) ;; 9096603fc0a3Smrg *) func_append finalize_rpath " $libdir" ;; 9097603fc0a3Smrg esac 9098603fc0a3Smrg done 9099603fc0a3Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9100603fc0a3Smrg dependency_libs="$temp_xrpath $dependency_libs" 9101603fc0a3Smrg fi 9102603fc0a3Smrg fi 9103603fc0a3Smrg 9104603fc0a3Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9105603fc0a3Smrg old_dlfiles=$dlfiles 9106603fc0a3Smrg dlfiles= 9107603fc0a3Smrg for lib in $old_dlfiles; do 9108603fc0a3Smrg case " $dlprefiles $dlfiles " in 9109603fc0a3Smrg *" $lib "*) ;; 9110603fc0a3Smrg *) func_append dlfiles " $lib" ;; 9111603fc0a3Smrg esac 9112603fc0a3Smrg done 9113603fc0a3Smrg 9114603fc0a3Smrg # Make sure dlprefiles contains only unique files 9115603fc0a3Smrg old_dlprefiles=$dlprefiles 9116603fc0a3Smrg dlprefiles= 9117603fc0a3Smrg for lib in $old_dlprefiles; do 9118603fc0a3Smrg case "$dlprefiles " in 9119603fc0a3Smrg *" $lib "*) ;; 9120603fc0a3Smrg *) func_append dlprefiles " $lib" ;; 9121603fc0a3Smrg esac 9122603fc0a3Smrg done 9123603fc0a3Smrg 9124603fc0a3Smrg if test yes = "$build_libtool_libs"; then 9125603fc0a3Smrg if test -n "$rpath"; then 9126603fc0a3Smrg case $host in 9127603fc0a3Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9128603fc0a3Smrg # these systems don't actually have a c library (as such)! 9129603fc0a3Smrg ;; 9130603fc0a3Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9131603fc0a3Smrg # Rhapsody C library is in the System framework 9132603fc0a3Smrg func_append deplibs " System.ltframework" 9133603fc0a3Smrg ;; 9134603fc0a3Smrg *-*-netbsd*) 9135603fc0a3Smrg # Don't link with libc until the a.out ld.so is fixed. 9136603fc0a3Smrg ;; 9137603fc0a3Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-mirbsd*) 9138603fc0a3Smrg # Do not include libc due to us having libc/libc_r. 9139603fc0a3Smrg ;; 9140603fc0a3Smrg *-*-sco3.2v5* | *-*-sco5v6*) 9141603fc0a3Smrg # Causes problems with __ctype 9142603fc0a3Smrg ;; 9143603fc0a3Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9144603fc0a3Smrg # Compiler inserts libc in the correct place for threads to work 9145603fc0a3Smrg ;; 9146603fc0a3Smrg *) 9147603fc0a3Smrg # Add libc to deplibs on all other systems if necessary. 9148603fc0a3Smrg if test yes = "$build_libtool_need_lc"; then 9149603fc0a3Smrg func_append deplibs " -lc" 9150603fc0a3Smrg fi 9151603fc0a3Smrg ;; 9152603fc0a3Smrg esac 9153603fc0a3Smrg fi 9154603fc0a3Smrg 9155603fc0a3Smrg # Transform deplibs into only deplibs that can be linked in shared. 9156603fc0a3Smrg name_save=$name 9157603fc0a3Smrg libname_save=$libname 9158603fc0a3Smrg release_save=$release 9159603fc0a3Smrg versuffix_save=$versuffix 9160603fc0a3Smrg versuffix2_save=$versuffix2 9161603fc0a3Smrg major_save=$major 9162603fc0a3Smrg # I'm not sure if I'm treating the release correctly. I think 9163603fc0a3Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 9164603fc0a3Smrg # add it in twice. Is that correct? 9165603fc0a3Smrg release= 9166603fc0a3Smrg versuffix= 9167603fc0a3Smrg versuffix2= 9168603fc0a3Smrg major= 9169603fc0a3Smrg newdeplibs= 9170603fc0a3Smrg droppeddeps=no 9171603fc0a3Smrg case $deplibs_check_method in 9172603fc0a3Smrg pass_all) 9173603fc0a3Smrg # Don't check for shared/static. Everything works. 9174603fc0a3Smrg # This might be a little naive. We might want to check 9175603fc0a3Smrg # whether the library exists or not. But this is on 9176603fc0a3Smrg # osf3 & osf4 and I'm not really sure... Just 9177603fc0a3Smrg # implementing what was already the behavior. 9178603fc0a3Smrg newdeplibs=$deplibs 9179603fc0a3Smrg ;; 9180603fc0a3Smrg test_compile) 9181603fc0a3Smrg # This code stresses the "libraries are programs" paradigm to its 9182603fc0a3Smrg # limits. Maybe even breaks it. We compile a program, linking it 9183603fc0a3Smrg # against the deplibs as a proxy for the library. Then we can check 9184603fc0a3Smrg # whether they linked in statically or dynamically with ldd. 9185603fc0a3Smrg $opt_dry_run || $RM conftest.c 9186603fc0a3Smrg cat > conftest.c <<EOF 9187603fc0a3Smrg int main() { return 0; } 9188603fc0a3SmrgEOF 9189603fc0a3Smrg $opt_dry_run || $RM conftest 9190603fc0a3Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9191603fc0a3Smrg ldd_output=`ldd conftest` 9192603fc0a3Smrg for i in $deplibs; do 9193603fc0a3Smrg case $i in 9194603fc0a3Smrg -l*) 9195603fc0a3Smrg func_stripname -l '' "$i" 9196603fc0a3Smrg name=$func_stripname_result 9197603fc0a3Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9198603fc0a3Smrg case " $predeps $postdeps " in 9199603fc0a3Smrg *" $i "*) 9200603fc0a3Smrg func_append newdeplibs " $i" 9201603fc0a3Smrg i= 9202603fc0a3Smrg ;; 9203603fc0a3Smrg esac 9204603fc0a3Smrg fi 9205603fc0a3Smrg if test -n "$i"; then 9206603fc0a3Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9207603fc0a3Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9208603fc0a3Smrg set dummy $deplib_matches; shift 9209603fc0a3Smrg deplib_match=$1 9210603fc0a3Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9211603fc0a3Smrg func_append newdeplibs " $i" 9212603fc0a3Smrg else 9213603fc0a3Smrg droppeddeps=yes 9214603fc0a3Smrg echo 9215603fc0a3Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9216603fc0a3Smrg echo "*** I have the capability to make that library automatically link in when" 9217603fc0a3Smrg echo "*** you link to this library. But I can only do this if you have a" 9218603fc0a3Smrg echo "*** shared version of the library, which I believe you do not have" 9219603fc0a3Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 9220603fc0a3Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9221603fc0a3Smrg fi 9222603fc0a3Smrg fi 9223603fc0a3Smrg ;; 9224603fc0a3Smrg *) 9225603fc0a3Smrg func_append newdeplibs " $i" 9226603fc0a3Smrg ;; 9227603fc0a3Smrg esac 9228603fc0a3Smrg done 9229603fc0a3Smrg else 9230603fc0a3Smrg # Error occurred in the first compile. Let's try to salvage 9231603fc0a3Smrg # the situation: Compile a separate program for each library. 9232603fc0a3Smrg for i in $deplibs; do 9233603fc0a3Smrg case $i in 9234603fc0a3Smrg -l*) 9235603fc0a3Smrg func_stripname -l '' "$i" 9236603fc0a3Smrg name=$func_stripname_result 9237603fc0a3Smrg $opt_dry_run || $RM conftest 9238603fc0a3Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9239603fc0a3Smrg ldd_output=`ldd conftest` 9240603fc0a3Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9241603fc0a3Smrg case " $predeps $postdeps " in 9242603fc0a3Smrg *" $i "*) 9243603fc0a3Smrg func_append newdeplibs " $i" 9244603fc0a3Smrg i= 9245603fc0a3Smrg ;; 9246603fc0a3Smrg esac 9247603fc0a3Smrg fi 9248603fc0a3Smrg if test -n "$i"; then 9249603fc0a3Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9250603fc0a3Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9251603fc0a3Smrg set dummy $deplib_matches; shift 9252603fc0a3Smrg deplib_match=$1 9253603fc0a3Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9254603fc0a3Smrg func_append newdeplibs " $i" 9255603fc0a3Smrg else 9256603fc0a3Smrg droppeddeps=yes 9257603fc0a3Smrg echo 9258603fc0a3Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9259603fc0a3Smrg echo "*** I have the capability to make that library automatically link in when" 9260603fc0a3Smrg echo "*** you link to this library. But I can only do this if you have a" 9261603fc0a3Smrg echo "*** shared version of the library, which you do not appear to have" 9262603fc0a3Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 9263603fc0a3Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9264603fc0a3Smrg fi 9265603fc0a3Smrg fi 9266603fc0a3Smrg else 9267603fc0a3Smrg droppeddeps=yes 9268603fc0a3Smrg echo 9269603fc0a3Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9270603fc0a3Smrg echo "*** make it link in! You will probably need to install it or some" 9271603fc0a3Smrg echo "*** library that it depends on before this library will be fully" 9272603fc0a3Smrg echo "*** functional. Installing it before continuing would be even better." 9273603fc0a3Smrg fi 9274603fc0a3Smrg ;; 9275603fc0a3Smrg *) 9276603fc0a3Smrg func_append newdeplibs " $i" 9277603fc0a3Smrg ;; 9278603fc0a3Smrg esac 9279603fc0a3Smrg done 9280603fc0a3Smrg fi 9281603fc0a3Smrg ;; 9282603fc0a3Smrg file_magic*) 9283603fc0a3Smrg set dummy $deplibs_check_method; shift 9284603fc0a3Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9285603fc0a3Smrg for a_deplib in $deplibs; do 9286603fc0a3Smrg case $a_deplib in 9287603fc0a3Smrg -l*) 9288603fc0a3Smrg func_stripname -l '' "$a_deplib" 9289603fc0a3Smrg name=$func_stripname_result 9290603fc0a3Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9291603fc0a3Smrg case " $predeps $postdeps " in 9292603fc0a3Smrg *" $a_deplib "*) 9293603fc0a3Smrg func_append newdeplibs " $a_deplib" 9294603fc0a3Smrg a_deplib= 9295603fc0a3Smrg ;; 9296603fc0a3Smrg esac 9297603fc0a3Smrg fi 9298603fc0a3Smrg if test -n "$a_deplib"; then 9299603fc0a3Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9300603fc0a3Smrg if test -n "$file_magic_glob"; then 9301603fc0a3Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9302603fc0a3Smrg else 9303603fc0a3Smrg libnameglob=$libname 9304603fc0a3Smrg fi 9305603fc0a3Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9306603fc0a3Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9307603fc0a3Smrg if test yes = "$want_nocaseglob"; then 9308603fc0a3Smrg shopt -s nocaseglob 9309603fc0a3Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9310603fc0a3Smrg $nocaseglob 9311603fc0a3Smrg else 9312603fc0a3Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9313603fc0a3Smrg fi 9314603fc0a3Smrg for potent_lib in $potential_libs; do 9315603fc0a3Smrg # Follow soft links. 9316603fc0a3Smrg if ls -lLd "$potent_lib" 2>/dev/null | 9317603fc0a3Smrg $GREP " -> " >/dev/null; then 9318603fc0a3Smrg continue 9319603fc0a3Smrg fi 9320603fc0a3Smrg # The statement above tries to avoid entering an 9321603fc0a3Smrg # endless loop below, in case of cyclic links. 9322603fc0a3Smrg # We might still enter an endless loop, since a link 9323603fc0a3Smrg # loop can be closed while we follow links, 9324603fc0a3Smrg # but so what? 9325603fc0a3Smrg potlib=$potent_lib 9326603fc0a3Smrg while test -h "$potlib" 2>/dev/null; do 9327603fc0a3Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9328603fc0a3Smrg case $potliblink in 9329603fc0a3Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9330603fc0a3Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9331603fc0a3Smrg esac 9332603fc0a3Smrg done 9333603fc0a3Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9334603fc0a3Smrg $SED -e 10q | 9335603fc0a3Smrg $EGREP "$file_magic_regex" > /dev/null; then 9336603fc0a3Smrg func_append newdeplibs " $a_deplib" 9337603fc0a3Smrg a_deplib= 9338603fc0a3Smrg break 2 9339603fc0a3Smrg fi 9340603fc0a3Smrg done 9341603fc0a3Smrg done 9342603fc0a3Smrg fi 9343603fc0a3Smrg if test -n "$a_deplib"; then 9344603fc0a3Smrg droppeddeps=yes 9345603fc0a3Smrg echo 9346603fc0a3Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9347603fc0a3Smrg echo "*** I have the capability to make that library automatically link in when" 9348603fc0a3Smrg echo "*** you link to this library. But I can only do this if you have a" 9349603fc0a3Smrg echo "*** shared version of the library, which you do not appear to have" 9350603fc0a3Smrg echo "*** because I did check the linker path looking for a file starting" 9351603fc0a3Smrg if test -z "$potlib"; then 9352603fc0a3Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9353603fc0a3Smrg else 9354603fc0a3Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9355603fc0a3Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 9356603fc0a3Smrg fi 9357603fc0a3Smrg fi 9358603fc0a3Smrg ;; 9359603fc0a3Smrg *) 9360603fc0a3Smrg # Add a -L argument. 9361603fc0a3Smrg func_append newdeplibs " $a_deplib" 9362603fc0a3Smrg ;; 9363603fc0a3Smrg esac 9364603fc0a3Smrg done # Gone through all deplibs. 9365603fc0a3Smrg ;; 9366603fc0a3Smrg match_pattern*) 9367603fc0a3Smrg set dummy $deplibs_check_method; shift 9368603fc0a3Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9369603fc0a3Smrg for a_deplib in $deplibs; do 9370603fc0a3Smrg case $a_deplib in 9371603fc0a3Smrg -l*) 9372603fc0a3Smrg func_stripname -l '' "$a_deplib" 9373603fc0a3Smrg name=$func_stripname_result 9374603fc0a3Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9375603fc0a3Smrg case " $predeps $postdeps " in 9376603fc0a3Smrg *" $a_deplib "*) 9377603fc0a3Smrg func_append newdeplibs " $a_deplib" 9378603fc0a3Smrg a_deplib= 9379603fc0a3Smrg ;; 9380603fc0a3Smrg esac 9381603fc0a3Smrg fi 9382603fc0a3Smrg if test -n "$a_deplib"; then 9383603fc0a3Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9384603fc0a3Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9385603fc0a3Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9386603fc0a3Smrg for potent_lib in $potential_libs; do 9387603fc0a3Smrg potlib=$potent_lib # see symlink-check above in file_magic test 9388603fc0a3Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9389603fc0a3Smrg $EGREP "$match_pattern_regex" > /dev/null; then 9390603fc0a3Smrg func_append newdeplibs " $a_deplib" 9391603fc0a3Smrg a_deplib= 9392603fc0a3Smrg break 2 9393603fc0a3Smrg fi 9394603fc0a3Smrg done 9395603fc0a3Smrg done 9396603fc0a3Smrg fi 9397603fc0a3Smrg if test -n "$a_deplib"; then 9398603fc0a3Smrg droppeddeps=yes 9399603fc0a3Smrg echo 9400603fc0a3Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9401603fc0a3Smrg echo "*** I have the capability to make that library automatically link in when" 9402603fc0a3Smrg echo "*** you link to this library. But I can only do this if you have a" 9403603fc0a3Smrg echo "*** shared version of the library, which you do not appear to have" 9404603fc0a3Smrg echo "*** because I did check the linker path looking for a file starting" 9405603fc0a3Smrg if test -z "$potlib"; then 9406603fc0a3Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9407603fc0a3Smrg else 9408603fc0a3Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9409603fc0a3Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9410603fc0a3Smrg fi 9411603fc0a3Smrg fi 9412603fc0a3Smrg ;; 9413603fc0a3Smrg *) 9414603fc0a3Smrg # Add a -L argument. 9415603fc0a3Smrg func_append newdeplibs " $a_deplib" 9416603fc0a3Smrg ;; 9417603fc0a3Smrg esac 9418603fc0a3Smrg done # Gone through all deplibs. 9419603fc0a3Smrg ;; 9420603fc0a3Smrg none | unknown | *) 9421603fc0a3Smrg newdeplibs= 9422603fc0a3Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9423603fc0a3Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9424603fc0a3Smrg for i in $predeps $postdeps; do 9425603fc0a3Smrg # can't use Xsed below, because $i might contain '/' 9426603fc0a3Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9427603fc0a3Smrg done 9428603fc0a3Smrg fi 9429603fc0a3Smrg case $tmp_deplibs in 9430603fc0a3Smrg *[!\ \ ]*) 9431603fc0a3Smrg echo 9432603fc0a3Smrg if test none = "$deplibs_check_method"; then 9433603fc0a3Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9434603fc0a3Smrg else 9435603fc0a3Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 9436603fc0a3Smrg fi 9437603fc0a3Smrg echo "*** All declared inter-library dependencies are being dropped." 9438603fc0a3Smrg droppeddeps=yes 9439603fc0a3Smrg ;; 9440603fc0a3Smrg esac 9441603fc0a3Smrg ;; 9442603fc0a3Smrg esac 9443603fc0a3Smrg versuffix=$versuffix_save 9444603fc0a3Smrg versuffix2=$versuffix2_save 9445603fc0a3Smrg major=$major_save 9446603fc0a3Smrg release=$release_save 9447603fc0a3Smrg libname=$libname_save 9448603fc0a3Smrg name=$name_save 9449603fc0a3Smrg 9450603fc0a3Smrg case $host in 9451603fc0a3Smrg *-*-rhapsody* | *-*-darwin1.[012]) 9452603fc0a3Smrg # On Rhapsody replace the C library with the System framework 9453603fc0a3Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9454603fc0a3Smrg ;; 9455603fc0a3Smrg esac 9456603fc0a3Smrg 9457603fc0a3Smrg if test yes = "$droppeddeps"; then 9458603fc0a3Smrg if test yes = "$module"; then 9459603fc0a3Smrg echo 9460603fc0a3Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9461603fc0a3Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9462603fc0a3Smrg echo "*** a static module, that should work as long as the dlopening" 9463603fc0a3Smrg echo "*** application is linked with the -dlopen flag." 9464603fc0a3Smrg if test -z "$global_symbol_pipe"; then 9465603fc0a3Smrg echo 9466603fc0a3Smrg echo "*** However, this would only work if libtool was able to extract symbol" 9467603fc0a3Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9468603fc0a3Smrg echo "*** not find such a program. So, this module is probably useless." 9469603fc0a3Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9470603fc0a3Smrg fi 9471603fc0a3Smrg if test no = "$build_old_libs"; then 9472603fc0a3Smrg oldlibs=$output_objdir/$libname.$libext 9473603fc0a3Smrg build_libtool_libs=module 9474603fc0a3Smrg build_old_libs=yes 9475603fc0a3Smrg else 9476603fc0a3Smrg build_libtool_libs=no 9477603fc0a3Smrg fi 9478603fc0a3Smrg else 9479603fc0a3Smrg echo "*** The inter-library dependencies that have been dropped here will be" 9480603fc0a3Smrg echo "*** automatically added whenever a program is linked with this library" 9481603fc0a3Smrg echo "*** or is declared to -dlopen it." 9482603fc0a3Smrg 9483603fc0a3Smrg if test no = "$allow_undefined"; then 9484603fc0a3Smrg echo 9485603fc0a3Smrg echo "*** Since this library must not contain undefined symbols," 9486603fc0a3Smrg echo "*** because either the platform does not support them or" 9487603fc0a3Smrg echo "*** it was explicitly requested with -no-undefined," 9488603fc0a3Smrg echo "*** libtool will only create a static version of it." 9489603fc0a3Smrg if test no = "$build_old_libs"; then 9490603fc0a3Smrg oldlibs=$output_objdir/$libname.$libext 9491603fc0a3Smrg build_libtool_libs=module 9492603fc0a3Smrg build_old_libs=yes 9493603fc0a3Smrg else 9494603fc0a3Smrg build_libtool_libs=no 9495603fc0a3Smrg fi 9496603fc0a3Smrg fi 9497603fc0a3Smrg fi 9498603fc0a3Smrg fi 9499603fc0a3Smrg # Done checking deplibs! 9500603fc0a3Smrg deplibs=$newdeplibs 9501603fc0a3Smrg fi 9502603fc0a3Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9503603fc0a3Smrg case $host in 9504603fc0a3Smrg *-*-darwin*) 9505603fc0a3Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9506603fc0a3Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9507603fc0a3Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9508603fc0a3Smrg ;; 9509603fc0a3Smrg esac 9510603fc0a3Smrg 9511603fc0a3Smrg # move library search paths that coincide with paths to not yet 9512603fc0a3Smrg # installed libraries to the beginning of the library search list 9513603fc0a3Smrg new_libs= 9514603fc0a3Smrg for path in $notinst_path; do 9515603fc0a3Smrg case " $new_libs " in 9516603fc0a3Smrg *" -L$path/$objdir "*) ;; 9517603fc0a3Smrg *) 9518603fc0a3Smrg case " $deplibs " in 9519603fc0a3Smrg *" -L$path/$objdir "*) 9520603fc0a3Smrg func_append new_libs " -L$path/$objdir" ;; 9521603fc0a3Smrg esac 9522603fc0a3Smrg ;; 9523603fc0a3Smrg esac 9524603fc0a3Smrg done 9525603fc0a3Smrg for deplib in $deplibs; do 9526603fc0a3Smrg case $deplib in 9527603fc0a3Smrg -L*) 9528603fc0a3Smrg case " $new_libs " in 9529603fc0a3Smrg *" $deplib "*) ;; 9530603fc0a3Smrg *) func_append new_libs " $deplib" ;; 9531603fc0a3Smrg esac 9532603fc0a3Smrg ;; 9533603fc0a3Smrg *) func_append new_libs " $deplib" ;; 9534603fc0a3Smrg esac 9535603fc0a3Smrg done 9536603fc0a3Smrg deplibs=$new_libs 9537603fc0a3Smrg 9538603fc0a3Smrg # All the library-specific variables (install_libdir is set above). 9539603fc0a3Smrg library_names= 9540603fc0a3Smrg old_library= 9541603fc0a3Smrg dlname= 9542603fc0a3Smrg 9543603fc0a3Smrg # Test again, we may have decided not to build it any more 9544603fc0a3Smrg if test yes = "$build_libtool_libs"; then 9545603fc0a3Smrg # Remove $wl instances when linking with ld. 9546603fc0a3Smrg # FIXME: should test the right _cmds variable. 9547603fc0a3Smrg case $archive_cmds in 9548603fc0a3Smrg *\$LD\ *) wl= ;; 9549603fc0a3Smrg esac 9550603fc0a3Smrg if test yes = "$hardcode_into_libs"; then 9551603fc0a3Smrg # Hardcode the library paths 9552603fc0a3Smrg hardcode_libdirs= 9553603fc0a3Smrg dep_rpath= 9554603fc0a3Smrg rpath=$finalize_rpath 9555603fc0a3Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9556603fc0a3Smrg for libdir in $rpath; do 9557603fc0a3Smrg if test -n "$hardcode_libdir_flag_spec"; then 9558603fc0a3Smrg if test -n "$hardcode_libdir_separator"; then 9559603fc0a3Smrg func_replace_sysroot "$libdir" 9560603fc0a3Smrg libdir=$func_replace_sysroot_result 9561603fc0a3Smrg if test -z "$hardcode_libdirs"; then 9562603fc0a3Smrg hardcode_libdirs=$libdir 9563603fc0a3Smrg else 9564603fc0a3Smrg # Just accumulate the unique libdirs. 9565603fc0a3Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9566603fc0a3Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9567603fc0a3Smrg ;; 9568603fc0a3Smrg *) 9569603fc0a3Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9570603fc0a3Smrg ;; 9571603fc0a3Smrg esac 9572603fc0a3Smrg fi 9573603fc0a3Smrg else 9574603fc0a3Smrg eval flag=\"$hardcode_libdir_flag_spec\" 9575603fc0a3Smrg func_append dep_rpath " $flag" 9576603fc0a3Smrg fi 9577603fc0a3Smrg elif test -n "$runpath_var"; then 9578603fc0a3Smrg case "$perm_rpath " in 9579603fc0a3Smrg *" $libdir "*) ;; 9580603fc0a3Smrg *) func_append perm_rpath " $libdir" ;; 9581603fc0a3Smrg esac 9582603fc0a3Smrg fi 9583603fc0a3Smrg done 9584603fc0a3Smrg # Substitute the hardcoded libdirs into the rpath. 9585603fc0a3Smrg if test -n "$hardcode_libdir_separator" && 9586603fc0a3Smrg test -n "$hardcode_libdirs"; then 9587603fc0a3Smrg libdir=$hardcode_libdirs 9588603fc0a3Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9589603fc0a3Smrg fi 9590603fc0a3Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9591603fc0a3Smrg # We should set the runpath_var. 9592603fc0a3Smrg rpath= 9593603fc0a3Smrg for dir in $perm_rpath; do 9594603fc0a3Smrg func_append rpath "$dir:" 9595603fc0a3Smrg done 9596603fc0a3Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9597603fc0a3Smrg fi 9598603fc0a3Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9599603fc0a3Smrg fi 9600603fc0a3Smrg 9601603fc0a3Smrg shlibpath=$finalize_shlibpath 9602603fc0a3Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9603603fc0a3Smrg if test -n "$shlibpath"; then 9604603fc0a3Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9605603fc0a3Smrg fi 9606603fc0a3Smrg 9607603fc0a3Smrg # Get the real and link names of the library. 9608603fc0a3Smrg eval shared_ext=\"$shrext_cmds\" 9609603fc0a3Smrg eval library_names=\"$library_names_spec\" 9610603fc0a3Smrg set dummy $library_names 9611603fc0a3Smrg shift 9612603fc0a3Smrg realname=$1 9613603fc0a3Smrg shift 9614603fc0a3Smrg 9615603fc0a3Smrg if test -n "$soname_spec"; then 9616603fc0a3Smrg eval soname=\"$soname_spec\" 9617603fc0a3Smrg else 9618603fc0a3Smrg soname=$realname 9619603fc0a3Smrg fi 9620603fc0a3Smrg if test -z "$dlname"; then 9621603fc0a3Smrg dlname=$soname 9622603fc0a3Smrg fi 9623603fc0a3Smrg 9624603fc0a3Smrg lib=$output_objdir/$realname 9625603fc0a3Smrg linknames= 9626603fc0a3Smrg for link 9627603fc0a3Smrg do 9628603fc0a3Smrg func_append linknames " $link" 9629603fc0a3Smrg done 9630603fc0a3Smrg 9631603fc0a3Smrg # Use standard objects if they are pic 9632603fc0a3Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9633603fc0a3Smrg test "X$libobjs" = "X " && libobjs= 9634603fc0a3Smrg 9635603fc0a3Smrg delfiles= 9636603fc0a3Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9637603fc0a3Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9638603fc0a3Smrg export_symbols=$output_objdir/$libname.uexp 9639603fc0a3Smrg func_append delfiles " $export_symbols" 9640603fc0a3Smrg fi 9641603fc0a3Smrg 9642603fc0a3Smrg orig_export_symbols= 9643603fc0a3Smrg case $host_os in 9644603fc0a3Smrg cygwin* | mingw* | cegcc*) 9645603fc0a3Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9646603fc0a3Smrg # exporting using user supplied symfile 9647603fc0a3Smrg func_dll_def_p "$export_symbols" || { 9648603fc0a3Smrg # and it's NOT already a .def file. Must figure out 9649603fc0a3Smrg # which of the given symbols are data symbols and tag 9650603fc0a3Smrg # them as such. So, trigger use of export_symbols_cmds. 9651603fc0a3Smrg # export_symbols gets reassigned inside the "prepare 9652603fc0a3Smrg # the list of exported symbols" if statement, so the 9653603fc0a3Smrg # include_expsyms logic still works. 9654603fc0a3Smrg orig_export_symbols=$export_symbols 9655603fc0a3Smrg export_symbols= 9656603fc0a3Smrg always_export_symbols=yes 9657603fc0a3Smrg } 9658603fc0a3Smrg fi 9659603fc0a3Smrg ;; 9660603fc0a3Smrg esac 9661603fc0a3Smrg 9662603fc0a3Smrg # Prepare the list of exported symbols 9663603fc0a3Smrg if test -z "$export_symbols"; then 9664603fc0a3Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9665603fc0a3Smrg func_verbose "generating symbol list for '$libname.la'" 9666603fc0a3Smrg export_symbols=$output_objdir/$libname.exp 9667603fc0a3Smrg $opt_dry_run || $RM $export_symbols 9668603fc0a3Smrg cmds=$export_symbols_cmds 9669603fc0a3Smrg save_ifs=$IFS; IFS='~' 9670603fc0a3Smrg for cmd1 in $cmds; do 9671603fc0a3Smrg IFS=$save_ifs 9672603fc0a3Smrg # Take the normal branch if the nm_file_list_spec branch 9673603fc0a3Smrg # doesn't work or if tool conversion is not needed. 9674603fc0a3Smrg case $nm_file_list_spec~$to_tool_file_cmd in 9675603fc0a3Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9676603fc0a3Smrg try_normal_branch=yes 9677603fc0a3Smrg eval cmd=\"$cmd1\" 9678603fc0a3Smrg func_len " $cmd" 9679603fc0a3Smrg len=$func_len_result 9680603fc0a3Smrg ;; 9681603fc0a3Smrg *) 9682603fc0a3Smrg try_normal_branch=no 9683603fc0a3Smrg ;; 9684603fc0a3Smrg esac 9685603fc0a3Smrg if test yes = "$try_normal_branch" \ 9686603fc0a3Smrg && { test "$len" -lt "$max_cmd_len" \ 9687603fc0a3Smrg || test "$max_cmd_len" -le -1; } 9688603fc0a3Smrg then 9689603fc0a3Smrg func_show_eval "$cmd" 'exit $?' 9690603fc0a3Smrg skipped_export=false 9691603fc0a3Smrg elif test -n "$nm_file_list_spec"; then 9692603fc0a3Smrg func_basename "$output" 9693603fc0a3Smrg output_la=$func_basename_result 9694603fc0a3Smrg save_libobjs=$libobjs 9695603fc0a3Smrg save_output=$output 9696603fc0a3Smrg output=$output_objdir/$output_la.nm 9697603fc0a3Smrg func_to_tool_file "$output" 9698603fc0a3Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9699603fc0a3Smrg func_append delfiles " $output" 9700603fc0a3Smrg func_verbose "creating $NM input file list: $output" 9701603fc0a3Smrg for obj in $save_libobjs; do 9702603fc0a3Smrg func_to_tool_file "$obj" 9703603fc0a3Smrg $ECHO "$func_to_tool_file_result" 9704603fc0a3Smrg done > "$output" 9705603fc0a3Smrg eval cmd=\"$cmd1\" 9706603fc0a3Smrg func_show_eval "$cmd" 'exit $?' 9707603fc0a3Smrg output=$save_output 9708603fc0a3Smrg libobjs=$save_libobjs 9709603fc0a3Smrg skipped_export=false 9710603fc0a3Smrg else 9711603fc0a3Smrg # The command line is too long to execute in one step. 9712603fc0a3Smrg func_verbose "using reloadable object file for export list..." 9713603fc0a3Smrg skipped_export=: 9714603fc0a3Smrg # Break out early, otherwise skipped_export may be 9715603fc0a3Smrg # set to false by a later but shorter cmd. 9716603fc0a3Smrg break 9717603fc0a3Smrg fi 9718603fc0a3Smrg done 9719603fc0a3Smrg IFS=$save_ifs 9720603fc0a3Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9721603fc0a3Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9722603fc0a3Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9723603fc0a3Smrg fi 9724603fc0a3Smrg fi 9725603fc0a3Smrg fi 9726603fc0a3Smrg 9727603fc0a3Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9728603fc0a3Smrg tmp_export_symbols=$export_symbols 9729603fc0a3Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9730603fc0a3Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9731603fc0a3Smrg fi 9732603fc0a3Smrg 9733603fc0a3Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9734603fc0a3Smrg # The given exports_symbols file has to be filtered, so filter it. 9735603fc0a3Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9736603fc0a3Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9737603fc0a3Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 9738603fc0a3Smrg # though. Also, the filter scales superlinearly with the number of 9739603fc0a3Smrg # global variables. join(1) would be nice here, but unfortunately 9740603fc0a3Smrg # isn't a blessed tool. 9741603fc0a3Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9742603fc0a3Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9743603fc0a3Smrg export_symbols=$output_objdir/$libname.def 9744603fc0a3Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9745603fc0a3Smrg fi 9746603fc0a3Smrg 9747603fc0a3Smrg tmp_deplibs= 9748603fc0a3Smrg for test_deplib in $deplibs; do 9749603fc0a3Smrg case " $convenience " in 9750603fc0a3Smrg *" $test_deplib "*) ;; 9751603fc0a3Smrg *) 9752603fc0a3Smrg func_append tmp_deplibs " $test_deplib" 9753603fc0a3Smrg ;; 9754603fc0a3Smrg esac 9755603fc0a3Smrg done 9756603fc0a3Smrg deplibs=$tmp_deplibs 9757603fc0a3Smrg 9758603fc0a3Smrg if test -n "$convenience"; then 9759603fc0a3Smrg if test -n "$whole_archive_flag_spec" && 9760603fc0a3Smrg test yes = "$compiler_needs_object" && 9761603fc0a3Smrg test -z "$libobjs"; then 9762603fc0a3Smrg # extract the archives, so we have objects to list. 9763603fc0a3Smrg # TODO: could optimize this to just extract one archive. 9764603fc0a3Smrg whole_archive_flag_spec= 9765603fc0a3Smrg fi 9766603fc0a3Smrg if test -n "$whole_archive_flag_spec"; then 9767603fc0a3Smrg save_libobjs=$libobjs 9768603fc0a3Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9769603fc0a3Smrg test "X$libobjs" = "X " && libobjs= 9770603fc0a3Smrg else 9771603fc0a3Smrg gentop=$output_objdir/${outputname}x 9772603fc0a3Smrg func_append generated " $gentop" 9773603fc0a3Smrg 9774603fc0a3Smrg func_extract_archives $gentop $convenience 9775603fc0a3Smrg func_append libobjs " $func_extract_archives_result" 9776603fc0a3Smrg test "X$libobjs" = "X " && libobjs= 9777603fc0a3Smrg fi 9778603fc0a3Smrg fi 9779603fc0a3Smrg 9780603fc0a3Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9781603fc0a3Smrg eval flag=\"$thread_safe_flag_spec\" 9782603fc0a3Smrg func_append linker_flags " $flag" 9783603fc0a3Smrg fi 9784603fc0a3Smrg 9785603fc0a3Smrg # Make a backup of the uninstalled library when relinking 9786603fc0a3Smrg if test relink = "$opt_mode"; then 9787603fc0a3Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9788603fc0a3Smrg fi 9789603fc0a3Smrg 9790603fc0a3Smrg # Do each of the archive commands. 9791603fc0a3Smrg if test yes = "$module" && test -n "$module_cmds"; then 9792603fc0a3Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9793603fc0a3Smrg eval test_cmds=\"$module_expsym_cmds\" 9794603fc0a3Smrg cmds=$module_expsym_cmds 9795603fc0a3Smrg else 9796603fc0a3Smrg eval test_cmds=\"$module_cmds\" 9797603fc0a3Smrg cmds=$module_cmds 9798603fc0a3Smrg fi 9799603fc0a3Smrg else 9800603fc0a3Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9801603fc0a3Smrg eval test_cmds=\"$archive_expsym_cmds\" 9802603fc0a3Smrg cmds=$archive_expsym_cmds 9803603fc0a3Smrg else 9804603fc0a3Smrg eval test_cmds=\"$archive_cmds\" 9805603fc0a3Smrg cmds=$archive_cmds 9806603fc0a3Smrg fi 9807603fc0a3Smrg fi 9808603fc0a3Smrg 9809603fc0a3Smrg if test : != "$skipped_export" && 9810603fc0a3Smrg func_len " $test_cmds" && 9811603fc0a3Smrg len=$func_len_result && 9812603fc0a3Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9813603fc0a3Smrg : 9814603fc0a3Smrg else 9815603fc0a3Smrg # The command line is too long to link in one step, link piecewise 9816603fc0a3Smrg # or, if using GNU ld and skipped_export is not :, use a linker 9817603fc0a3Smrg # script. 9818603fc0a3Smrg 9819603fc0a3Smrg # Save the value of $output and $libobjs because we want to 9820603fc0a3Smrg # use them later. If we have whole_archive_flag_spec, we 9821603fc0a3Smrg # want to use save_libobjs as it was before 9822603fc0a3Smrg # whole_archive_flag_spec was expanded, because we can't 9823603fc0a3Smrg # assume the linker understands whole_archive_flag_spec. 9824603fc0a3Smrg # This may have to be revisited, in case too many 9825603fc0a3Smrg # convenience libraries get linked in and end up exceeding 9826603fc0a3Smrg # the spec. 9827603fc0a3Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9828603fc0a3Smrg save_libobjs=$libobjs 9829603fc0a3Smrg fi 9830603fc0a3Smrg save_output=$output 9831603fc0a3Smrg func_basename "$output" 9832603fc0a3Smrg output_la=$func_basename_result 9833603fc0a3Smrg 9834603fc0a3Smrg # Clear the reloadable object creation command queue and 9835603fc0a3Smrg # initialize k to one. 9836603fc0a3Smrg test_cmds= 9837603fc0a3Smrg concat_cmds= 9838603fc0a3Smrg objlist= 9839603fc0a3Smrg last_robj= 9840603fc0a3Smrg k=1 9841603fc0a3Smrg 9842603fc0a3Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 9843603fc0a3Smrg output=$output_objdir/$output_la.lnkscript 9844603fc0a3Smrg func_verbose "creating GNU ld script: $output" 9845603fc0a3Smrg echo 'INPUT (' > $output 9846603fc0a3Smrg for obj in $save_libobjs 9847603fc0a3Smrg do 9848603fc0a3Smrg func_to_tool_file "$obj" 9849603fc0a3Smrg $ECHO "$func_to_tool_file_result" >> $output 9850603fc0a3Smrg done 9851603fc0a3Smrg echo ')' >> $output 9852603fc0a3Smrg func_append delfiles " $output" 9853603fc0a3Smrg func_to_tool_file "$output" 9854603fc0a3Smrg output=$func_to_tool_file_result 9855603fc0a3Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 9856603fc0a3Smrg output=$output_objdir/$output_la.lnk 9857603fc0a3Smrg func_verbose "creating linker input file list: $output" 9858603fc0a3Smrg : > $output 9859603fc0a3Smrg set x $save_libobjs 9860603fc0a3Smrg shift 9861603fc0a3Smrg firstobj= 9862603fc0a3Smrg if test yes = "$compiler_needs_object"; then 9863603fc0a3Smrg firstobj="$1 " 9864603fc0a3Smrg shift 9865603fc0a3Smrg fi 9866603fc0a3Smrg for obj 9867603fc0a3Smrg do 9868603fc0a3Smrg func_to_tool_file "$obj" 9869603fc0a3Smrg $ECHO "$func_to_tool_file_result" >> $output 9870603fc0a3Smrg done 9871603fc0a3Smrg func_append delfiles " $output" 9872603fc0a3Smrg func_to_tool_file "$output" 9873603fc0a3Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9874603fc0a3Smrg else 9875603fc0a3Smrg if test -n "$save_libobjs"; then 9876603fc0a3Smrg func_verbose "creating reloadable object files..." 9877603fc0a3Smrg output=$output_objdir/$output_la-$k.$objext 9878603fc0a3Smrg eval test_cmds=\"$reload_cmds\" 9879603fc0a3Smrg func_len " $test_cmds" 9880603fc0a3Smrg len0=$func_len_result 9881603fc0a3Smrg len=$len0 9882603fc0a3Smrg 9883603fc0a3Smrg # Loop over the list of objects to be linked. 9884603fc0a3Smrg for obj in $save_libobjs 9885603fc0a3Smrg do 9886603fc0a3Smrg func_len " $obj" 9887603fc0a3Smrg func_arith $len + $func_len_result 9888603fc0a3Smrg len=$func_arith_result 9889603fc0a3Smrg if test -z "$objlist" || 9890603fc0a3Smrg test "$len" -lt "$max_cmd_len"; then 9891603fc0a3Smrg func_append objlist " $obj" 9892603fc0a3Smrg else 9893603fc0a3Smrg # The command $test_cmds is almost too long, add a 9894603fc0a3Smrg # command to the queue. 9895603fc0a3Smrg if test 1 -eq "$k"; then 9896603fc0a3Smrg # The first file doesn't have a previous command to add. 9897603fc0a3Smrg reload_objs=$objlist 9898603fc0a3Smrg eval concat_cmds=\"$reload_cmds\" 9899603fc0a3Smrg else 9900603fc0a3Smrg # All subsequent reloadable object files will link in 9901603fc0a3Smrg # the last one created. 9902603fc0a3Smrg reload_objs="$objlist $last_robj" 9903603fc0a3Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9904603fc0a3Smrg fi 9905603fc0a3Smrg last_robj=$output_objdir/$output_la-$k.$objext 9906603fc0a3Smrg func_arith $k + 1 9907603fc0a3Smrg k=$func_arith_result 9908603fc0a3Smrg output=$output_objdir/$output_la-$k.$objext 9909603fc0a3Smrg objlist=" $obj" 9910603fc0a3Smrg func_len " $last_robj" 9911603fc0a3Smrg func_arith $len0 + $func_len_result 9912603fc0a3Smrg len=$func_arith_result 9913603fc0a3Smrg fi 9914603fc0a3Smrg done 9915603fc0a3Smrg # Handle the remaining objects by creating one last 9916603fc0a3Smrg # reloadable object file. All subsequent reloadable object 9917603fc0a3Smrg # files will link in the last one created. 9918603fc0a3Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9919603fc0a3Smrg reload_objs="$objlist $last_robj" 9920603fc0a3Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 9921603fc0a3Smrg if test -n "$last_robj"; then 9922603fc0a3Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9923603fc0a3Smrg fi 9924603fc0a3Smrg func_append delfiles " $output" 9925603fc0a3Smrg 9926603fc0a3Smrg else 9927603fc0a3Smrg output= 9928603fc0a3Smrg fi 9929603fc0a3Smrg 9930603fc0a3Smrg ${skipped_export-false} && { 9931603fc0a3Smrg func_verbose "generating symbol list for '$libname.la'" 9932603fc0a3Smrg export_symbols=$output_objdir/$libname.exp 9933603fc0a3Smrg $opt_dry_run || $RM $export_symbols 9934603fc0a3Smrg libobjs=$output 9935603fc0a3Smrg # Append the command to create the export file. 9936603fc0a3Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9937603fc0a3Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 9938603fc0a3Smrg if test -n "$last_robj"; then 9939603fc0a3Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9940603fc0a3Smrg fi 9941603fc0a3Smrg } 9942603fc0a3Smrg 9943603fc0a3Smrg test -n "$save_libobjs" && 9944603fc0a3Smrg func_verbose "creating a temporary reloadable object file: $output" 9945603fc0a3Smrg 9946603fc0a3Smrg # Loop through the commands generated above and execute them. 9947603fc0a3Smrg save_ifs=$IFS; IFS='~' 9948603fc0a3Smrg for cmd in $concat_cmds; do 9949603fc0a3Smrg IFS=$save_ifs 9950603fc0a3Smrg $opt_quiet || { 9951603fc0a3Smrg func_quote_for_expand "$cmd" 9952603fc0a3Smrg eval "func_echo $func_quote_for_expand_result" 9953603fc0a3Smrg } 9954603fc0a3Smrg $opt_dry_run || eval "$cmd" || { 9955603fc0a3Smrg lt_exit=$? 9956603fc0a3Smrg 9957603fc0a3Smrg # Restore the uninstalled library and exit 9958603fc0a3Smrg if test relink = "$opt_mode"; then 9959603fc0a3Smrg ( cd "$output_objdir" && \ 9960603fc0a3Smrg $RM "${realname}T" && \ 9961603fc0a3Smrg $MV "${realname}U" "$realname" ) 9962603fc0a3Smrg fi 9963603fc0a3Smrg 9964603fc0a3Smrg exit $lt_exit 9965603fc0a3Smrg } 9966603fc0a3Smrg done 9967603fc0a3Smrg IFS=$save_ifs 9968603fc0a3Smrg 9969603fc0a3Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 9970603fc0a3Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9971603fc0a3Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9972603fc0a3Smrg fi 9973603fc0a3Smrg fi 9974603fc0a3Smrg 9975603fc0a3Smrg ${skipped_export-false} && { 9976603fc0a3Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9977603fc0a3Smrg tmp_export_symbols=$export_symbols 9978603fc0a3Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9979603fc0a3Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9980603fc0a3Smrg fi 9981603fc0a3Smrg 9982603fc0a3Smrg if test -n "$orig_export_symbols"; then 9983603fc0a3Smrg # The given exports_symbols file has to be filtered, so filter it. 9984603fc0a3Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9985603fc0a3Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9986603fc0a3Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 9987603fc0a3Smrg # though. Also, the filter scales superlinearly with the number of 9988603fc0a3Smrg # global variables. join(1) would be nice here, but unfortunately 9989603fc0a3Smrg # isn't a blessed tool. 9990603fc0a3Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9991603fc0a3Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9992603fc0a3Smrg export_symbols=$output_objdir/$libname.def 9993603fc0a3Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9994603fc0a3Smrg fi 9995603fc0a3Smrg } 9996603fc0a3Smrg 9997603fc0a3Smrg libobjs=$output 9998603fc0a3Smrg # Restore the value of output. 9999603fc0a3Smrg output=$save_output 10000603fc0a3Smrg 10001603fc0a3Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10002603fc0a3Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10003603fc0a3Smrg test "X$libobjs" = "X " && libobjs= 10004603fc0a3Smrg fi 10005603fc0a3Smrg # Expand the library linking commands again to reset the 10006603fc0a3Smrg # value of $libobjs for piecewise linking. 10007603fc0a3Smrg 10008603fc0a3Smrg # Do each of the archive commands. 10009603fc0a3Smrg if test yes = "$module" && test -n "$module_cmds"; then 10010603fc0a3Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10011603fc0a3Smrg cmds=$module_expsym_cmds 10012603fc0a3Smrg else 10013603fc0a3Smrg cmds=$module_cmds 10014603fc0a3Smrg fi 10015603fc0a3Smrg else 10016603fc0a3Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10017603fc0a3Smrg cmds=$archive_expsym_cmds 10018603fc0a3Smrg else 10019603fc0a3Smrg cmds=$archive_cmds 10020603fc0a3Smrg fi 10021603fc0a3Smrg fi 10022603fc0a3Smrg fi 10023603fc0a3Smrg 10024603fc0a3Smrg if test -n "$delfiles"; then 10025603fc0a3Smrg # Append the command to remove temporary files to $cmds. 10026603fc0a3Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 10027603fc0a3Smrg fi 10028603fc0a3Smrg 10029603fc0a3Smrg # Add any objects from preloaded convenience libraries 10030603fc0a3Smrg if test -n "$dlprefiles"; then 10031603fc0a3Smrg gentop=$output_objdir/${outputname}x 10032603fc0a3Smrg func_append generated " $gentop" 10033603fc0a3Smrg 10034603fc0a3Smrg func_extract_archives $gentop $dlprefiles 10035603fc0a3Smrg func_append libobjs " $func_extract_archives_result" 10036603fc0a3Smrg test "X$libobjs" = "X " && libobjs= 10037603fc0a3Smrg fi 10038603fc0a3Smrg 10039603fc0a3Smrg save_ifs=$IFS; IFS='~' 10040603fc0a3Smrg for cmd in $cmds; do 10041603fc0a3Smrg IFS=$sp$nl 10042603fc0a3Smrg eval cmd=\"$cmd\" 10043603fc0a3Smrg IFS=$save_ifs 10044603fc0a3Smrg $opt_quiet || { 10045603fc0a3Smrg func_quote_for_expand "$cmd" 10046603fc0a3Smrg eval "func_echo $func_quote_for_expand_result" 10047603fc0a3Smrg } 10048603fc0a3Smrg $opt_dry_run || eval "$cmd" || { 10049603fc0a3Smrg lt_exit=$? 10050603fc0a3Smrg 10051603fc0a3Smrg # Restore the uninstalled library and exit 10052603fc0a3Smrg if test relink = "$opt_mode"; then 10053603fc0a3Smrg ( cd "$output_objdir" && \ 10054603fc0a3Smrg $RM "${realname}T" && \ 10055603fc0a3Smrg $MV "${realname}U" "$realname" ) 10056603fc0a3Smrg fi 10057603fc0a3Smrg 10058603fc0a3Smrg exit $lt_exit 10059603fc0a3Smrg } 10060603fc0a3Smrg done 10061603fc0a3Smrg IFS=$save_ifs 10062603fc0a3Smrg 10063603fc0a3Smrg # Restore the uninstalled library and exit 10064603fc0a3Smrg if test relink = "$opt_mode"; then 10065603fc0a3Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10066603fc0a3Smrg 10067603fc0a3Smrg if test -n "$convenience"; then 10068603fc0a3Smrg if test -z "$whole_archive_flag_spec"; then 10069603fc0a3Smrg func_show_eval '${RM}r "$gentop"' 10070603fc0a3Smrg fi 10071603fc0a3Smrg fi 10072603fc0a3Smrg 10073603fc0a3Smrg exit $EXIT_SUCCESS 10074603fc0a3Smrg fi 10075603fc0a3Smrg 10076603fc0a3Smrg # Create links to the real library. 10077603fc0a3Smrg for linkname in $linknames; do 10078603fc0a3Smrg if test "$realname" != "$linkname"; then 10079603fc0a3Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10080603fc0a3Smrg fi 10081603fc0a3Smrg done 10082603fc0a3Smrg 10083603fc0a3Smrg # If -module or -export-dynamic was specified, set the dlname. 10084603fc0a3Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 10085603fc0a3Smrg # On all known operating systems, these are identical. 10086603fc0a3Smrg dlname=$soname 10087603fc0a3Smrg fi 10088603fc0a3Smrg fi 10089603fc0a3Smrg ;; 10090603fc0a3Smrg 10091603fc0a3Smrg obj) 10092603fc0a3Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10093603fc0a3Smrg func_warning "'-dlopen' is ignored for objects" 10094603fc0a3Smrg fi 10095603fc0a3Smrg 10096603fc0a3Smrg case " $deplibs" in 10097603fc0a3Smrg *\ -l* | *\ -L*) 10098603fc0a3Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 10099603fc0a3Smrg esac 10100603fc0a3Smrg 10101603fc0a3Smrg test -n "$rpath" && \ 10102603fc0a3Smrg func_warning "'-rpath' is ignored for objects" 10103603fc0a3Smrg 10104603fc0a3Smrg test -n "$xrpath" && \ 10105603fc0a3Smrg func_warning "'-R' is ignored for objects" 10106603fc0a3Smrg 10107603fc0a3Smrg test -n "$vinfo" && \ 10108603fc0a3Smrg func_warning "'-version-info' is ignored for objects" 10109603fc0a3Smrg 10110603fc0a3Smrg test -n "$release" && \ 10111603fc0a3Smrg func_warning "'-release' is ignored for objects" 10112603fc0a3Smrg 10113603fc0a3Smrg case $output in 10114603fc0a3Smrg *.lo) 10115603fc0a3Smrg test -n "$objs$old_deplibs" && \ 10116603fc0a3Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10117603fc0a3Smrg 10118603fc0a3Smrg libobj=$output 10119603fc0a3Smrg func_lo2o "$libobj" 10120603fc0a3Smrg obj=$func_lo2o_result 10121603fc0a3Smrg ;; 10122603fc0a3Smrg *) 10123603fc0a3Smrg libobj= 10124603fc0a3Smrg obj=$output 10125603fc0a3Smrg ;; 10126603fc0a3Smrg esac 10127603fc0a3Smrg 10128603fc0a3Smrg # Delete the old objects. 10129603fc0a3Smrg $opt_dry_run || $RM $obj $libobj 10130603fc0a3Smrg 10131603fc0a3Smrg # Objects from convenience libraries. This assumes 10132603fc0a3Smrg # single-version convenience libraries. Whenever we create 10133603fc0a3Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 10134603fc0a3Smrg # the extraction. 10135603fc0a3Smrg reload_conv_objs= 10136603fc0a3Smrg gentop= 10137603fc0a3Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 10138603fc0a3Smrg # whole_archive_flag_spec and hope we can get by with turning comma 10139603fc0a3Smrg # into space. 10140603fc0a3Smrg case $reload_cmds in 10141603fc0a3Smrg *\$LD[\ \$]*) wl= ;; 10142603fc0a3Smrg esac 10143603fc0a3Smrg if test -n "$convenience"; then 10144603fc0a3Smrg if test -n "$whole_archive_flag_spec"; then 10145603fc0a3Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10146603fc0a3Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10147603fc0a3Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10148603fc0a3Smrg else 10149603fc0a3Smrg gentop=$output_objdir/${obj}x 10150603fc0a3Smrg func_append generated " $gentop" 10151603fc0a3Smrg 10152603fc0a3Smrg func_extract_archives $gentop $convenience 10153603fc0a3Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10154603fc0a3Smrg fi 10155603fc0a3Smrg fi 10156603fc0a3Smrg 10157603fc0a3Smrg # If we're not building shared, we need to use non_pic_objs 10158603fc0a3Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10159603fc0a3Smrg 10160603fc0a3Smrg # Create the old-style object. 10161603fc0a3Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10162603fc0a3Smrg 10163603fc0a3Smrg output=$obj 10164603fc0a3Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10165603fc0a3Smrg 10166603fc0a3Smrg # Exit if we aren't doing a library object file. 10167603fc0a3Smrg if test -z "$libobj"; then 10168603fc0a3Smrg if test -n "$gentop"; then 10169603fc0a3Smrg func_show_eval '${RM}r "$gentop"' 10170603fc0a3Smrg fi 10171603fc0a3Smrg 10172603fc0a3Smrg exit $EXIT_SUCCESS 10173603fc0a3Smrg fi 10174603fc0a3Smrg 10175603fc0a3Smrg test yes = "$build_libtool_libs" || { 10176603fc0a3Smrg if test -n "$gentop"; then 10177603fc0a3Smrg func_show_eval '${RM}r "$gentop"' 10178603fc0a3Smrg fi 10179603fc0a3Smrg 10180603fc0a3Smrg # Create an invalid libtool object if no PIC, so that we don't 10181603fc0a3Smrg # accidentally link it into a program. 10182603fc0a3Smrg # $show "echo timestamp > $libobj" 10183603fc0a3Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10184603fc0a3Smrg exit $EXIT_SUCCESS 10185603fc0a3Smrg } 10186603fc0a3Smrg 10187603fc0a3Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10188603fc0a3Smrg # Only do commands if we really have different PIC objects. 10189603fc0a3Smrg reload_objs="$libobjs $reload_conv_objs" 10190603fc0a3Smrg output=$libobj 10191603fc0a3Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10192603fc0a3Smrg fi 10193603fc0a3Smrg 10194603fc0a3Smrg if test -n "$gentop"; then 10195603fc0a3Smrg func_show_eval '${RM}r "$gentop"' 10196603fc0a3Smrg fi 10197603fc0a3Smrg 10198603fc0a3Smrg exit $EXIT_SUCCESS 10199603fc0a3Smrg ;; 10200603fc0a3Smrg 10201603fc0a3Smrg prog) 10202603fc0a3Smrg case $host in 10203603fc0a3Smrg *cygwin*) func_stripname '' '.exe' "$output" 10204603fc0a3Smrg output=$func_stripname_result.exe;; 10205603fc0a3Smrg esac 10206603fc0a3Smrg test -n "$vinfo" && \ 10207603fc0a3Smrg func_warning "'-version-info' is ignored for programs" 10208603fc0a3Smrg 10209603fc0a3Smrg test -n "$release" && \ 10210603fc0a3Smrg func_warning "'-release' is ignored for programs" 10211603fc0a3Smrg 10212603fc0a3Smrg $preload \ 10213603fc0a3Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10214603fc0a3Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10215603fc0a3Smrg 10216603fc0a3Smrg case $host in 10217603fc0a3Smrg *-*-rhapsody* | *-*-darwin1.[012]) 10218603fc0a3Smrg # On Rhapsody replace the C library is the System framework 10219603fc0a3Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10220603fc0a3Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10221603fc0a3Smrg ;; 10222603fc0a3Smrg esac 10223603fc0a3Smrg 10224603fc0a3Smrg case $host in 10225603fc0a3Smrg *-*-darwin*) 10226603fc0a3Smrg # Don't allow lazy linking, it breaks C++ global constructors 10227603fc0a3Smrg # But is supposedly fixed on 10.4 or later (yay!). 10228603fc0a3Smrg if test CXX = "$tagname"; then 10229603fc0a3Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10230603fc0a3Smrg 10.[0123]) 10231603fc0a3Smrg func_append compile_command " $wl-bind_at_load" 10232603fc0a3Smrg func_append finalize_command " $wl-bind_at_load" 10233603fc0a3Smrg ;; 10234603fc0a3Smrg esac 10235603fc0a3Smrg fi 10236603fc0a3Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10237603fc0a3Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10238603fc0a3Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10239603fc0a3Smrg ;; 10240603fc0a3Smrg esac 10241603fc0a3Smrg 10242603fc0a3Smrg 10243603fc0a3Smrg # move library search paths that coincide with paths to not yet 10244603fc0a3Smrg # installed libraries to the beginning of the library search list 10245603fc0a3Smrg new_libs= 10246603fc0a3Smrg for path in $notinst_path; do 10247603fc0a3Smrg case " $new_libs " in 10248603fc0a3Smrg *" -L$path/$objdir "*) ;; 10249603fc0a3Smrg *) 10250603fc0a3Smrg case " $compile_deplibs " in 10251603fc0a3Smrg *" -L$path/$objdir "*) 10252603fc0a3Smrg func_append new_libs " -L$path/$objdir" ;; 10253603fc0a3Smrg esac 10254603fc0a3Smrg ;; 10255603fc0a3Smrg esac 10256603fc0a3Smrg done 10257603fc0a3Smrg for deplib in $compile_deplibs; do 10258603fc0a3Smrg case $deplib in 10259603fc0a3Smrg -L*) 10260603fc0a3Smrg case " $new_libs " in 10261603fc0a3Smrg *" $deplib "*) ;; 10262603fc0a3Smrg *) func_append new_libs " $deplib" ;; 10263603fc0a3Smrg esac 10264603fc0a3Smrg ;; 10265603fc0a3Smrg *) func_append new_libs " $deplib" ;; 10266603fc0a3Smrg esac 10267603fc0a3Smrg done 10268603fc0a3Smrg compile_deplibs=$new_libs 10269603fc0a3Smrg 10270603fc0a3Smrg 10271603fc0a3Smrg func_append compile_command " $compile_deplibs" 10272603fc0a3Smrg func_append finalize_command " $finalize_deplibs" 10273603fc0a3Smrg 10274603fc0a3Smrg if test -n "$rpath$xrpath"; then 10275603fc0a3Smrg # If the user specified any rpath flags, then add them. 10276603fc0a3Smrg for libdir in $rpath $xrpath; do 10277603fc0a3Smrg # This is the magic to use -rpath. 10278603fc0a3Smrg case "$finalize_rpath " in 10279603fc0a3Smrg *" $libdir "*) ;; 10280603fc0a3Smrg *) func_append finalize_rpath " $libdir" ;; 10281603fc0a3Smrg esac 10282603fc0a3Smrg done 10283603fc0a3Smrg fi 10284603fc0a3Smrg 10285603fc0a3Smrg # Now hardcode the library paths 10286603fc0a3Smrg rpath= 10287603fc0a3Smrg hardcode_libdirs= 10288603fc0a3Smrg for libdir in $compile_rpath $finalize_rpath; do 10289603fc0a3Smrg if test -n "$hardcode_libdir_flag_spec"; then 10290603fc0a3Smrg if test -n "$hardcode_libdir_separator"; then 10291603fc0a3Smrg if test -z "$hardcode_libdirs"; then 10292603fc0a3Smrg hardcode_libdirs=$libdir 10293603fc0a3Smrg else 10294603fc0a3Smrg # Just accumulate the unique libdirs. 10295603fc0a3Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10296603fc0a3Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10297603fc0a3Smrg ;; 10298603fc0a3Smrg *) 10299603fc0a3Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10300603fc0a3Smrg ;; 10301603fc0a3Smrg esac 10302603fc0a3Smrg fi 10303603fc0a3Smrg else 10304603fc0a3Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10305603fc0a3Smrg func_append rpath " $flag" 10306603fc0a3Smrg fi 10307603fc0a3Smrg elif test -n "$runpath_var"; then 10308603fc0a3Smrg case "$perm_rpath " in 10309603fc0a3Smrg *" $libdir "*) ;; 10310603fc0a3Smrg *) func_append perm_rpath " $libdir" ;; 10311603fc0a3Smrg esac 10312603fc0a3Smrg fi 10313603fc0a3Smrg case $host in 10314603fc0a3Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10315603fc0a3Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10316603fc0a3Smrg case :$dllsearchpath: in 10317603fc0a3Smrg *":$libdir:"*) ;; 10318603fc0a3Smrg ::) dllsearchpath=$libdir;; 10319603fc0a3Smrg *) func_append dllsearchpath ":$libdir";; 10320603fc0a3Smrg esac 10321603fc0a3Smrg case :$dllsearchpath: in 10322603fc0a3Smrg *":$testbindir:"*) ;; 10323603fc0a3Smrg ::) dllsearchpath=$testbindir;; 10324603fc0a3Smrg *) func_append dllsearchpath ":$testbindir";; 10325603fc0a3Smrg esac 10326603fc0a3Smrg ;; 10327603fc0a3Smrg esac 10328603fc0a3Smrg done 10329603fc0a3Smrg # Substitute the hardcoded libdirs into the rpath. 10330603fc0a3Smrg if test -n "$hardcode_libdir_separator" && 10331603fc0a3Smrg test -n "$hardcode_libdirs"; then 10332603fc0a3Smrg libdir=$hardcode_libdirs 10333603fc0a3Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10334603fc0a3Smrg fi 10335603fc0a3Smrg compile_rpath=$rpath 10336603fc0a3Smrg 10337603fc0a3Smrg rpath= 10338603fc0a3Smrg hardcode_libdirs= 10339603fc0a3Smrg for libdir in $finalize_rpath; do 10340603fc0a3Smrg if test -n "$hardcode_libdir_flag_spec"; then 10341603fc0a3Smrg if test -n "$hardcode_libdir_separator"; then 10342603fc0a3Smrg if test -z "$hardcode_libdirs"; then 10343603fc0a3Smrg hardcode_libdirs=$libdir 10344603fc0a3Smrg else 10345603fc0a3Smrg # Just accumulate the unique libdirs. 10346603fc0a3Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10347603fc0a3Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10348603fc0a3Smrg ;; 10349603fc0a3Smrg *) 10350603fc0a3Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10351603fc0a3Smrg ;; 10352603fc0a3Smrg esac 10353603fc0a3Smrg fi 10354603fc0a3Smrg else 10355603fc0a3Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10356603fc0a3Smrg func_append rpath " $flag" 10357603fc0a3Smrg fi 10358603fc0a3Smrg elif test -n "$runpath_var"; then 10359603fc0a3Smrg case "$finalize_perm_rpath " in 10360603fc0a3Smrg *" $libdir "*) ;; 10361603fc0a3Smrg *) func_append finalize_perm_rpath " $libdir" ;; 10362603fc0a3Smrg esac 10363603fc0a3Smrg fi 10364603fc0a3Smrg done 10365603fc0a3Smrg # Substitute the hardcoded libdirs into the rpath. 10366603fc0a3Smrg if test -n "$hardcode_libdir_separator" && 10367603fc0a3Smrg test -n "$hardcode_libdirs"; then 10368603fc0a3Smrg libdir=$hardcode_libdirs 10369603fc0a3Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 10370603fc0a3Smrg fi 10371603fc0a3Smrg finalize_rpath=$rpath 10372603fc0a3Smrg 10373603fc0a3Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10374603fc0a3Smrg # Transform all the library objects into standard objects. 10375603fc0a3Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10376603fc0a3Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10377603fc0a3Smrg fi 10378603fc0a3Smrg 10379603fc0a3Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10380603fc0a3Smrg 10381603fc0a3Smrg # template prelinking step 10382603fc0a3Smrg if test -n "$prelink_cmds"; then 10383603fc0a3Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 10384603fc0a3Smrg fi 10385603fc0a3Smrg 10386603fc0a3Smrg wrappers_required=: 10387603fc0a3Smrg case $host in 10388603fc0a3Smrg *cegcc* | *mingw32ce*) 10389603fc0a3Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10390603fc0a3Smrg wrappers_required=false 10391603fc0a3Smrg ;; 10392603fc0a3Smrg *cygwin* | *mingw* ) 10393603fc0a3Smrg test yes = "$build_libtool_libs" || wrappers_required=false 10394603fc0a3Smrg ;; 10395603fc0a3Smrg *) 10396603fc0a3Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10397603fc0a3Smrg wrappers_required=false 10398603fc0a3Smrg fi 10399603fc0a3Smrg ;; 10400603fc0a3Smrg esac 10401603fc0a3Smrg $wrappers_required || { 10402603fc0a3Smrg # Replace the output file specification. 10403603fc0a3Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10404603fc0a3Smrg link_command=$compile_command$compile_rpath 10405603fc0a3Smrg 10406603fc0a3Smrg # We have no uninstalled library dependencies, so finalize right now. 10407603fc0a3Smrg exit_status=0 10408603fc0a3Smrg func_show_eval "$link_command" 'exit_status=$?' 10409603fc0a3Smrg 10410603fc0a3Smrg if test -n "$postlink_cmds"; then 10411603fc0a3Smrg func_to_tool_file "$output" 10412603fc0a3Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10413603fc0a3Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10414603fc0a3Smrg fi 10415603fc0a3Smrg 10416603fc0a3Smrg # Delete the generated files. 10417603fc0a3Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 10418603fc0a3Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10419603fc0a3Smrg fi 10420603fc0a3Smrg 10421603fc0a3Smrg exit $exit_status 10422603fc0a3Smrg } 10423603fc0a3Smrg 10424603fc0a3Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10425603fc0a3Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10426603fc0a3Smrg fi 10427603fc0a3Smrg if test -n "$finalize_shlibpath"; then 10428603fc0a3Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10429603fc0a3Smrg fi 10430603fc0a3Smrg 10431603fc0a3Smrg compile_var= 10432603fc0a3Smrg finalize_var= 10433603fc0a3Smrg if test -n "$runpath_var"; then 10434603fc0a3Smrg if test -n "$perm_rpath"; then 10435603fc0a3Smrg # We should set the runpath_var. 10436603fc0a3Smrg rpath= 10437603fc0a3Smrg for dir in $perm_rpath; do 10438603fc0a3Smrg func_append rpath "$dir:" 10439603fc0a3Smrg done 10440603fc0a3Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10441603fc0a3Smrg fi 10442603fc0a3Smrg if test -n "$finalize_perm_rpath"; then 10443603fc0a3Smrg # We should set the runpath_var. 10444603fc0a3Smrg rpath= 10445603fc0a3Smrg for dir in $finalize_perm_rpath; do 10446603fc0a3Smrg func_append rpath "$dir:" 10447603fc0a3Smrg done 10448603fc0a3Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10449603fc0a3Smrg fi 10450603fc0a3Smrg fi 10451603fc0a3Smrg 10452603fc0a3Smrg if test yes = "$no_install"; then 10453603fc0a3Smrg # We don't need to create a wrapper script. 10454603fc0a3Smrg link_command=$compile_var$compile_command$compile_rpath 10455603fc0a3Smrg # Replace the output file specification. 10456603fc0a3Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10457603fc0a3Smrg # Delete the old output file. 10458603fc0a3Smrg $opt_dry_run || $RM $output 10459603fc0a3Smrg # Link the executable and exit 10460603fc0a3Smrg func_show_eval "$link_command" 'exit $?' 10461603fc0a3Smrg 10462603fc0a3Smrg if test -n "$postlink_cmds"; then 10463603fc0a3Smrg func_to_tool_file "$output" 10464603fc0a3Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10465603fc0a3Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10466603fc0a3Smrg fi 10467603fc0a3Smrg 10468603fc0a3Smrg exit $EXIT_SUCCESS 10469603fc0a3Smrg fi 10470603fc0a3Smrg 10471603fc0a3Smrg case $hardcode_action,$fast_install in 10472603fc0a3Smrg relink,*) 10473603fc0a3Smrg # Fast installation is not supported 10474603fc0a3Smrg link_command=$compile_var$compile_command$compile_rpath 10475603fc0a3Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10476603fc0a3Smrg 10477603fc0a3Smrg func_warning "this platform does not like uninstalled shared libraries" 10478603fc0a3Smrg func_warning "'$output' will be relinked during installation" 10479603fc0a3Smrg ;; 10480603fc0a3Smrg *,yes) 10481603fc0a3Smrg link_command=$finalize_var$compile_command$finalize_rpath 10482603fc0a3Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10483603fc0a3Smrg ;; 10484603fc0a3Smrg *,no) 10485603fc0a3Smrg link_command=$compile_var$compile_command$compile_rpath 10486603fc0a3Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10487603fc0a3Smrg ;; 10488603fc0a3Smrg *,needless) 10489603fc0a3Smrg link_command=$finalize_var$compile_command$finalize_rpath 10490603fc0a3Smrg relink_command= 10491603fc0a3Smrg ;; 10492603fc0a3Smrg esac 10493603fc0a3Smrg 10494603fc0a3Smrg # Replace the output file specification. 10495603fc0a3Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10496603fc0a3Smrg 10497603fc0a3Smrg # Delete the old output files. 10498603fc0a3Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10499603fc0a3Smrg 10500603fc0a3Smrg func_show_eval "$link_command" 'exit $?' 10501603fc0a3Smrg 10502603fc0a3Smrg if test -n "$postlink_cmds"; then 10503603fc0a3Smrg func_to_tool_file "$output_objdir/$outputname" 10504603fc0a3Smrg 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'` 10505603fc0a3Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10506603fc0a3Smrg fi 10507603fc0a3Smrg 10508603fc0a3Smrg # Now create the wrapper script. 10509603fc0a3Smrg func_verbose "creating $output" 10510603fc0a3Smrg 10511603fc0a3Smrg # Quote the relink command for shipping. 10512603fc0a3Smrg if test -n "$relink_command"; then 10513603fc0a3Smrg # Preserve any variables that may affect compiler behavior 10514603fc0a3Smrg for var in $variables_saved_for_relink; do 10515603fc0a3Smrg if eval test -z \"\${$var+set}\"; then 10516603fc0a3Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10517603fc0a3Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10518603fc0a3Smrg relink_command="$var=; export $var; $relink_command" 10519603fc0a3Smrg else 10520603fc0a3Smrg func_quote_for_eval "$var_value" 10521603fc0a3Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10522603fc0a3Smrg fi 10523603fc0a3Smrg done 10524603fc0a3Smrg relink_command="(cd `pwd`; $relink_command)" 10525603fc0a3Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10526603fc0a3Smrg fi 10527603fc0a3Smrg 10528603fc0a3Smrg # Only actually do things if not in dry run mode. 10529603fc0a3Smrg $opt_dry_run || { 10530603fc0a3Smrg # win32 will think the script is a binary if it has 10531603fc0a3Smrg # a .exe suffix, so we strip it off here. 10532603fc0a3Smrg case $output in 10533603fc0a3Smrg *.exe) func_stripname '' '.exe' "$output" 10534603fc0a3Smrg output=$func_stripname_result ;; 10535603fc0a3Smrg esac 10536603fc0a3Smrg # test for cygwin because mv fails w/o .exe extensions 10537603fc0a3Smrg case $host in 10538603fc0a3Smrg *cygwin*) 10539603fc0a3Smrg exeext=.exe 10540603fc0a3Smrg func_stripname '' '.exe' "$outputname" 10541603fc0a3Smrg outputname=$func_stripname_result ;; 10542603fc0a3Smrg *) exeext= ;; 10543603fc0a3Smrg esac 10544603fc0a3Smrg case $host in 10545603fc0a3Smrg *cygwin* | *mingw* ) 10546603fc0a3Smrg func_dirname_and_basename "$output" "" "." 10547603fc0a3Smrg output_name=$func_basename_result 10548603fc0a3Smrg output_path=$func_dirname_result 10549603fc0a3Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10550603fc0a3Smrg cwrapper=$output_path/$output_name.exe 10551603fc0a3Smrg $RM $cwrappersource $cwrapper 10552603fc0a3Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10553603fc0a3Smrg 10554603fc0a3Smrg func_emit_cwrapperexe_src > $cwrappersource 10555603fc0a3Smrg 10556603fc0a3Smrg # The wrapper executable is built using the $host compiler, 10557603fc0a3Smrg # because it contains $host paths and files. If cross- 10558603fc0a3Smrg # compiling, it, like the target executable, must be 10559603fc0a3Smrg # executed on the $host or under an emulation environment. 10560603fc0a3Smrg $opt_dry_run || { 10561603fc0a3Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10562603fc0a3Smrg $STRIP $cwrapper 10563603fc0a3Smrg } 10564603fc0a3Smrg 10565603fc0a3Smrg # Now, create the wrapper script for func_source use: 10566603fc0a3Smrg func_ltwrapper_scriptname $cwrapper 10567603fc0a3Smrg $RM $func_ltwrapper_scriptname_result 10568603fc0a3Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10569603fc0a3Smrg $opt_dry_run || { 10570603fc0a3Smrg # note: this script will not be executed, so do not chmod. 10571603fc0a3Smrg if test "x$build" = "x$host"; then 10572603fc0a3Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10573603fc0a3Smrg else 10574603fc0a3Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10575603fc0a3Smrg fi 10576603fc0a3Smrg } 10577603fc0a3Smrg ;; 10578603fc0a3Smrg * ) 10579603fc0a3Smrg $RM $output 10580603fc0a3Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10581603fc0a3Smrg 10582603fc0a3Smrg func_emit_wrapper no > $output 10583603fc0a3Smrg chmod +x $output 10584603fc0a3Smrg ;; 10585603fc0a3Smrg esac 10586603fc0a3Smrg } 10587603fc0a3Smrg exit $EXIT_SUCCESS 10588603fc0a3Smrg ;; 10589603fc0a3Smrg esac 10590603fc0a3Smrg 10591603fc0a3Smrg # See if we need to build an old-fashioned archive. 10592603fc0a3Smrg for oldlib in $oldlibs; do 10593603fc0a3Smrg 10594603fc0a3Smrg case $build_libtool_libs in 10595603fc0a3Smrg convenience) 10596603fc0a3Smrg oldobjs="$libobjs_save $symfileobj" 10597603fc0a3Smrg addlibs=$convenience 10598603fc0a3Smrg build_libtool_libs=no 10599603fc0a3Smrg ;; 10600603fc0a3Smrg module) 10601603fc0a3Smrg oldobjs=$libobjs_save 10602603fc0a3Smrg addlibs=$old_convenience 10603603fc0a3Smrg build_libtool_libs=no 10604603fc0a3Smrg ;; 10605603fc0a3Smrg *) 10606603fc0a3Smrg oldobjs="$old_deplibs $non_pic_objects" 10607603fc0a3Smrg $preload && test -f "$symfileobj" \ 10608603fc0a3Smrg && func_append oldobjs " $symfileobj" 10609603fc0a3Smrg addlibs=$old_convenience 10610603fc0a3Smrg ;; 10611603fc0a3Smrg esac 10612603fc0a3Smrg 10613603fc0a3Smrg if test -n "$addlibs"; then 10614603fc0a3Smrg gentop=$output_objdir/${outputname}x 10615603fc0a3Smrg func_append generated " $gentop" 10616603fc0a3Smrg 10617603fc0a3Smrg func_extract_archives $gentop $addlibs 10618603fc0a3Smrg func_append oldobjs " $func_extract_archives_result" 10619603fc0a3Smrg fi 10620603fc0a3Smrg 10621603fc0a3Smrg # Do each command in the archive commands. 10622603fc0a3Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10623603fc0a3Smrg cmds=$old_archive_from_new_cmds 10624603fc0a3Smrg else 10625603fc0a3Smrg 10626603fc0a3Smrg # Add any objects from preloaded convenience libraries 10627603fc0a3Smrg if test -n "$dlprefiles"; then 10628603fc0a3Smrg gentop=$output_objdir/${outputname}x 10629603fc0a3Smrg func_append generated " $gentop" 10630603fc0a3Smrg 10631603fc0a3Smrg func_extract_archives $gentop $dlprefiles 10632603fc0a3Smrg func_append oldobjs " $func_extract_archives_result" 10633603fc0a3Smrg fi 10634603fc0a3Smrg 10635603fc0a3Smrg # POSIX demands no paths to be encoded in archives. We have 10636603fc0a3Smrg # to avoid creating archives with duplicate basenames if we 10637603fc0a3Smrg # might have to extract them afterwards, e.g., when creating a 10638603fc0a3Smrg # static archive out of a convenience library, or when linking 10639603fc0a3Smrg # the entirety of a libtool archive into another (currently 10640603fc0a3Smrg # not supported by libtool). 10641603fc0a3Smrg if (for obj in $oldobjs 10642603fc0a3Smrg do 10643603fc0a3Smrg func_basename "$obj" 10644603fc0a3Smrg $ECHO "$func_basename_result" 10645603fc0a3Smrg done | sort | sort -uc >/dev/null 2>&1); then 10646603fc0a3Smrg : 10647603fc0a3Smrg else 10648603fc0a3Smrg echo "copying selected object files to avoid basename conflicts..." 10649603fc0a3Smrg gentop=$output_objdir/${outputname}x 10650603fc0a3Smrg func_append generated " $gentop" 10651603fc0a3Smrg func_mkdir_p "$gentop" 10652603fc0a3Smrg save_oldobjs=$oldobjs 10653603fc0a3Smrg oldobjs= 10654603fc0a3Smrg counter=1 10655603fc0a3Smrg for obj in $save_oldobjs 10656603fc0a3Smrg do 10657603fc0a3Smrg func_basename "$obj" 10658603fc0a3Smrg objbase=$func_basename_result 10659603fc0a3Smrg case " $oldobjs " in 10660603fc0a3Smrg " ") oldobjs=$obj ;; 10661603fc0a3Smrg *[\ /]"$objbase "*) 10662603fc0a3Smrg while :; do 10663603fc0a3Smrg # Make sure we don't pick an alternate name that also 10664603fc0a3Smrg # overlaps. 10665603fc0a3Smrg newobj=lt$counter-$objbase 10666603fc0a3Smrg func_arith $counter + 1 10667603fc0a3Smrg counter=$func_arith_result 10668603fc0a3Smrg case " $oldobjs " in 10669603fc0a3Smrg *[\ /]"$newobj "*) ;; 10670603fc0a3Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10671603fc0a3Smrg esac 10672603fc0a3Smrg done 10673603fc0a3Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10674603fc0a3Smrg func_append oldobjs " $gentop/$newobj" 10675603fc0a3Smrg ;; 10676603fc0a3Smrg *) func_append oldobjs " $obj" ;; 10677603fc0a3Smrg esac 10678603fc0a3Smrg done 10679603fc0a3Smrg fi 10680603fc0a3Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10681603fc0a3Smrg tool_oldlib=$func_to_tool_file_result 10682603fc0a3Smrg eval cmds=\"$old_archive_cmds\" 10683603fc0a3Smrg 10684603fc0a3Smrg func_len " $cmds" 10685603fc0a3Smrg len=$func_len_result 10686603fc0a3Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10687603fc0a3Smrg cmds=$old_archive_cmds 10688603fc0a3Smrg elif test -n "$archiver_list_spec"; then 10689603fc0a3Smrg func_verbose "using command file archive linking..." 10690603fc0a3Smrg for obj in $oldobjs 10691603fc0a3Smrg do 10692603fc0a3Smrg func_to_tool_file "$obj" 10693603fc0a3Smrg $ECHO "$func_to_tool_file_result" 10694603fc0a3Smrg done > $output_objdir/$libname.libcmd 10695603fc0a3Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 10696603fc0a3Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10697603fc0a3Smrg cmds=$old_archive_cmds 10698603fc0a3Smrg else 10699603fc0a3Smrg # the command line is too long to link in one step, link in parts 10700603fc0a3Smrg func_verbose "using piecewise archive linking..." 10701603fc0a3Smrg save_RANLIB=$RANLIB 10702603fc0a3Smrg RANLIB=: 10703603fc0a3Smrg objlist= 10704603fc0a3Smrg concat_cmds= 10705603fc0a3Smrg save_oldobjs=$oldobjs 10706603fc0a3Smrg oldobjs= 10707603fc0a3Smrg # Is there a better way of finding the last object in the list? 10708603fc0a3Smrg for obj in $save_oldobjs 10709603fc0a3Smrg do 10710603fc0a3Smrg last_oldobj=$obj 10711603fc0a3Smrg done 10712603fc0a3Smrg eval test_cmds=\"$old_archive_cmds\" 10713603fc0a3Smrg func_len " $test_cmds" 10714603fc0a3Smrg len0=$func_len_result 10715603fc0a3Smrg len=$len0 10716603fc0a3Smrg for obj in $save_oldobjs 10717603fc0a3Smrg do 10718603fc0a3Smrg func_len " $obj" 10719603fc0a3Smrg func_arith $len + $func_len_result 10720603fc0a3Smrg len=$func_arith_result 10721603fc0a3Smrg func_append objlist " $obj" 10722603fc0a3Smrg if test "$len" -lt "$max_cmd_len"; then 10723603fc0a3Smrg : 10724603fc0a3Smrg else 10725603fc0a3Smrg # the above command should be used before it gets too long 10726603fc0a3Smrg oldobjs=$objlist 10727603fc0a3Smrg if test "$obj" = "$last_oldobj"; then 10728603fc0a3Smrg RANLIB=$save_RANLIB 10729603fc0a3Smrg fi 10730603fc0a3Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10731603fc0a3Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10732603fc0a3Smrg objlist= 10733603fc0a3Smrg len=$len0 10734603fc0a3Smrg fi 10735603fc0a3Smrg done 10736603fc0a3Smrg RANLIB=$save_RANLIB 10737603fc0a3Smrg oldobjs=$objlist 10738603fc0a3Smrg if test -z "$oldobjs"; then 10739603fc0a3Smrg eval cmds=\"\$concat_cmds\" 10740603fc0a3Smrg else 10741603fc0a3Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10742603fc0a3Smrg fi 10743603fc0a3Smrg fi 10744603fc0a3Smrg fi 10745603fc0a3Smrg func_execute_cmds "$cmds" 'exit $?' 10746603fc0a3Smrg done 10747603fc0a3Smrg 10748603fc0a3Smrg test -n "$generated" && \ 10749603fc0a3Smrg func_show_eval "${RM}r$generated" 10750603fc0a3Smrg 10751603fc0a3Smrg # Now create the libtool archive. 10752603fc0a3Smrg case $output in 10753603fc0a3Smrg *.la) 10754603fc0a3Smrg old_library= 10755603fc0a3Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 10756603fc0a3Smrg func_verbose "creating $output" 10757603fc0a3Smrg 10758603fc0a3Smrg # Preserve any variables that may affect compiler behavior 10759603fc0a3Smrg for var in $variables_saved_for_relink; do 10760603fc0a3Smrg if eval test -z \"\${$var+set}\"; then 10761603fc0a3Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10762603fc0a3Smrg elif eval var_value=\$$var; test -z "$var_value"; then 10763603fc0a3Smrg relink_command="$var=; export $var; $relink_command" 10764603fc0a3Smrg else 10765603fc0a3Smrg func_quote_for_eval "$var_value" 10766603fc0a3Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10767603fc0a3Smrg fi 10768603fc0a3Smrg done 10769603fc0a3Smrg # Quote the link command for shipping. 10770603fc0a3Smrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 10771603fc0a3Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10772603fc0a3Smrg if test yes = "$hardcode_automatic"; then 10773603fc0a3Smrg relink_command= 10774603fc0a3Smrg fi 10775603fc0a3Smrg 10776603fc0a3Smrg # Only create the output if not a dry run. 10777603fc0a3Smrg $opt_dry_run || { 10778603fc0a3Smrg for installed in no yes; do 10779603fc0a3Smrg if test yes = "$installed"; then 10780603fc0a3Smrg if test -z "$install_libdir"; then 10781603fc0a3Smrg break 10782603fc0a3Smrg fi 10783603fc0a3Smrg output=$output_objdir/${outputname}i 10784603fc0a3Smrg # Replace all uninstalled libtool libraries with the installed ones 10785603fc0a3Smrg newdependency_libs= 10786603fc0a3Smrg for deplib in $dependency_libs; do 10787603fc0a3Smrg case $deplib in 10788603fc0a3Smrg *.la) 10789603fc0a3Smrg func_basename "$deplib" 10790603fc0a3Smrg name=$func_basename_result 10791603fc0a3Smrg func_resolve_sysroot "$deplib" 10792603fc0a3Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10793603fc0a3Smrg test -z "$libdir" && \ 10794603fc0a3Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 10795603fc0a3Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 10796603fc0a3Smrg ;; 10797603fc0a3Smrg -L*) 10798603fc0a3Smrg func_stripname -L '' "$deplib" 10799603fc0a3Smrg func_replace_sysroot "$func_stripname_result" 10800603fc0a3Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 10801603fc0a3Smrg ;; 10802603fc0a3Smrg -R*) 10803603fc0a3Smrg func_stripname -R '' "$deplib" 10804603fc0a3Smrg func_replace_sysroot "$func_stripname_result" 10805603fc0a3Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 10806603fc0a3Smrg ;; 10807603fc0a3Smrg *) func_append newdependency_libs " $deplib" ;; 10808603fc0a3Smrg esac 10809603fc0a3Smrg done 10810603fc0a3Smrg dependency_libs=$newdependency_libs 10811603fc0a3Smrg newdlfiles= 10812603fc0a3Smrg 10813603fc0a3Smrg for lib in $dlfiles; do 10814603fc0a3Smrg case $lib in 10815603fc0a3Smrg *.la) 10816603fc0a3Smrg func_basename "$lib" 10817603fc0a3Smrg name=$func_basename_result 10818603fc0a3Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10819603fc0a3Smrg test -z "$libdir" && \ 10820603fc0a3Smrg func_fatal_error "'$lib' is not a valid libtool archive" 10821603fc0a3Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10822603fc0a3Smrg ;; 10823603fc0a3Smrg *) func_append newdlfiles " $lib" ;; 10824603fc0a3Smrg esac 10825603fc0a3Smrg done 10826603fc0a3Smrg dlfiles=$newdlfiles 10827603fc0a3Smrg newdlprefiles= 10828603fc0a3Smrg for lib in $dlprefiles; do 10829603fc0a3Smrg case $lib in 10830603fc0a3Smrg *.la) 10831603fc0a3Smrg # Only pass preopened files to the pseudo-archive (for 10832603fc0a3Smrg # eventual linking with the app. that links it) if we 10833603fc0a3Smrg # didn't already link the preopened objects directly into 10834603fc0a3Smrg # the library: 10835603fc0a3Smrg func_basename "$lib" 10836603fc0a3Smrg name=$func_basename_result 10837603fc0a3Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10838603fc0a3Smrg test -z "$libdir" && \ 10839603fc0a3Smrg func_fatal_error "'$lib' is not a valid libtool archive" 10840603fc0a3Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10841603fc0a3Smrg ;; 10842603fc0a3Smrg esac 10843603fc0a3Smrg done 10844603fc0a3Smrg dlprefiles=$newdlprefiles 10845603fc0a3Smrg else 10846603fc0a3Smrg newdlfiles= 10847603fc0a3Smrg for lib in $dlfiles; do 10848603fc0a3Smrg case $lib in 10849603fc0a3Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10850603fc0a3Smrg *) abs=`pwd`"/$lib" ;; 10851603fc0a3Smrg esac 10852603fc0a3Smrg func_append newdlfiles " $abs" 10853603fc0a3Smrg done 10854603fc0a3Smrg dlfiles=$newdlfiles 10855603fc0a3Smrg newdlprefiles= 10856603fc0a3Smrg for lib in $dlprefiles; do 10857603fc0a3Smrg case $lib in 10858603fc0a3Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10859603fc0a3Smrg *) abs=`pwd`"/$lib" ;; 10860603fc0a3Smrg esac 10861603fc0a3Smrg func_append newdlprefiles " $abs" 10862603fc0a3Smrg done 10863603fc0a3Smrg dlprefiles=$newdlprefiles 10864603fc0a3Smrg fi 10865603fc0a3Smrg $RM $output 10866603fc0a3Smrg # place dlname in correct position for cygwin 10867603fc0a3Smrg # In fact, it would be nice if we could use this code for all target 10868603fc0a3Smrg # systems that can't hard-code library paths into their executables 10869603fc0a3Smrg # and that have no shared library path variable independent of PATH, 10870603fc0a3Smrg # but it turns out we can't easily determine that from inspecting 10871603fc0a3Smrg # libtool variables, so we have to hard-code the OSs to which it 10872603fc0a3Smrg # applies here; at the moment, that means platforms that use the PE 10873603fc0a3Smrg # object format with DLL files. See the long comment at the top of 10874603fc0a3Smrg # tests/bindir.at for full details. 10875603fc0a3Smrg tdlname=$dlname 10876603fc0a3Smrg case $host,$output,$installed,$module,$dlname in 10877603fc0a3Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 10878603fc0a3Smrg # If a -bindir argument was supplied, place the dll there. 10879603fc0a3Smrg if test -n "$bindir"; then 10880603fc0a3Smrg func_relative_path "$install_libdir" "$bindir" 10881603fc0a3Smrg tdlname=$func_relative_path_result/$dlname 10882603fc0a3Smrg else 10883603fc0a3Smrg # Otherwise fall back on heuristic. 10884603fc0a3Smrg tdlname=../bin/$dlname 10885603fc0a3Smrg fi 10886603fc0a3Smrg ;; 10887603fc0a3Smrg esac 10888603fc0a3Smrg $ECHO > $output "\ 10889603fc0a3Smrg# $outputname - a libtool library file 10890603fc0a3Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10891603fc0a3Smrg# 10892603fc0a3Smrg# Please DO NOT delete this file! 10893603fc0a3Smrg# It is necessary for linking the library. 10894603fc0a3Smrg 10895603fc0a3Smrg# The name that we can dlopen(3). 10896603fc0a3Smrgdlname='$tdlname' 10897603fc0a3Smrg 10898603fc0a3Smrg# Names of this library. 10899603fc0a3Smrglibrary_names='$library_names' 10900603fc0a3Smrg 10901603fc0a3Smrg# The name of the static archive. 10902603fc0a3Smrgold_library='$old_library' 10903603fc0a3Smrg 10904603fc0a3Smrg# Linker flags that cannot go in dependency_libs. 10905603fc0a3Smrginherited_linker_flags='$new_inherited_linker_flags' 10906603fc0a3Smrg 10907603fc0a3Smrg# Libraries that this one depends upon. 10908603fc0a3Smrgdependency_libs='$dependency_libs' 10909603fc0a3Smrg 10910603fc0a3Smrg# Names of additional weak libraries provided by this library 10911603fc0a3Smrgweak_library_names='$weak_libs' 10912603fc0a3Smrg 10913603fc0a3Smrg# Version information for $libname. 10914603fc0a3Smrgcurrent=$current 10915603fc0a3Smrgage=$age 10916603fc0a3Smrgrevision=$revision 10917603fc0a3Smrg 10918603fc0a3Smrg# Is this an already installed library? 10919603fc0a3Smrginstalled=$installed 10920603fc0a3Smrg 10921603fc0a3Smrg# Should we warn about portability when linking against -modules? 10922603fc0a3Smrgshouldnotlink=$module 10923603fc0a3Smrg 10924603fc0a3Smrg# Files to dlopen/dlpreopen 10925603fc0a3Smrgdlopen='$dlfiles' 10926603fc0a3Smrgdlpreopen='$dlprefiles' 10927603fc0a3Smrg 10928603fc0a3Smrg# Directory that this library needs to be installed in: 10929603fc0a3Smrglibdir='$install_libdir'" 10930603fc0a3Smrg if test no,yes = "$installed,$need_relink" && test -n "$relink_command"; then 10931603fc0a3Smrg $ECHO >> $output "\ 10932603fc0a3Smrgrelink_command=\"$relink_command\"" 10933603fc0a3Smrg fi 10934603fc0a3Smrg done 10935603fc0a3Smrg } 10936603fc0a3Smrg 10937603fc0a3Smrg # Do a symbolic link so that the libtool archive can be found in 10938603fc0a3Smrg # LD_LIBRARY_PATH before the program is installed. 10939603fc0a3Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 10940603fc0a3Smrg ;; 10941603fc0a3Smrg esac 10942603fc0a3Smrg exit $EXIT_SUCCESS 10943603fc0a3Smrg} 10944603fc0a3Smrg 10945603fc0a3Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 10946603fc0a3Smrg func_mode_link ${1+"$@"} 10947603fc0a3Smrgfi 10948603fc0a3Smrg 10949603fc0a3Smrg 10950603fc0a3Smrg# func_mode_uninstall arg... 10951603fc0a3Smrgfunc_mode_uninstall () 10952603fc0a3Smrg{ 10953603fc0a3Smrg $debug_cmd 10954603fc0a3Smrg 10955603fc0a3Smrg RM=$nonopt 10956603fc0a3Smrg files= 10957603fc0a3Smrg rmforce=false 10958603fc0a3Smrg exit_status=0 10959603fc0a3Smrg 10960603fc0a3Smrg # This variable tells wrapper scripts just to set variables rather 10961603fc0a3Smrg # than running their programs. 10962603fc0a3Smrg libtool_install_magic=$magic 10963603fc0a3Smrg 10964603fc0a3Smrg for arg 10965603fc0a3Smrg do 10966603fc0a3Smrg case $arg in 10967603fc0a3Smrg -f) func_append RM " $arg"; rmforce=: ;; 10968603fc0a3Smrg -*) func_append RM " $arg" ;; 10969603fc0a3Smrg *) func_append files " $arg" ;; 10970603fc0a3Smrg esac 10971603fc0a3Smrg done 10972603fc0a3Smrg 10973603fc0a3Smrg test -z "$RM" && \ 10974603fc0a3Smrg func_fatal_help "you must specify an RM program" 10975603fc0a3Smrg 10976603fc0a3Smrg rmdirs= 10977603fc0a3Smrg 10978603fc0a3Smrg for file in $files; do 10979603fc0a3Smrg func_dirname "$file" "" "." 10980603fc0a3Smrg dir=$func_dirname_result 10981603fc0a3Smrg if test . = "$dir"; then 10982603fc0a3Smrg odir=$objdir 10983603fc0a3Smrg else 10984603fc0a3Smrg odir=$dir/$objdir 10985603fc0a3Smrg fi 10986603fc0a3Smrg func_basename "$file" 10987603fc0a3Smrg name=$func_basename_result 10988603fc0a3Smrg test uninstall = "$opt_mode" && odir=$dir 10989603fc0a3Smrg 10990603fc0a3Smrg # Remember odir for removal later, being careful to avoid duplicates 10991603fc0a3Smrg if test clean = "$opt_mode"; then 10992603fc0a3Smrg case " $rmdirs " in 10993603fc0a3Smrg *" $odir "*) ;; 10994603fc0a3Smrg *) func_append rmdirs " $odir" ;; 10995603fc0a3Smrg esac 10996603fc0a3Smrg fi 10997603fc0a3Smrg 10998603fc0a3Smrg # Don't error if the file doesn't exist and rm -f was used. 10999603fc0a3Smrg if { test -L "$file"; } >/dev/null 2>&1 || 11000603fc0a3Smrg { test -h "$file"; } >/dev/null 2>&1 || 11001603fc0a3Smrg test -f "$file"; then 11002603fc0a3Smrg : 11003603fc0a3Smrg elif test -d "$file"; then 11004603fc0a3Smrg exit_status=1 11005603fc0a3Smrg continue 11006603fc0a3Smrg elif $rmforce; then 11007603fc0a3Smrg continue 11008603fc0a3Smrg fi 11009603fc0a3Smrg 11010603fc0a3Smrg rmfiles=$file 11011603fc0a3Smrg 11012603fc0a3Smrg case $name in 11013603fc0a3Smrg *.la) 11014603fc0a3Smrg # Possibly a libtool archive, so verify it. 11015603fc0a3Smrg if func_lalib_p "$file"; then 11016603fc0a3Smrg func_source $dir/$name 11017603fc0a3Smrg 11018603fc0a3Smrg # Delete the libtool libraries and symlinks. 11019603fc0a3Smrg for n in $library_names; do 11020603fc0a3Smrg func_append rmfiles " $odir/$n" 11021603fc0a3Smrg done 11022603fc0a3Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11023603fc0a3Smrg 11024603fc0a3Smrg case $opt_mode in 11025603fc0a3Smrg clean) 11026603fc0a3Smrg case " $library_names " in 11027603fc0a3Smrg *" $dlname "*) ;; 11028603fc0a3Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11029603fc0a3Smrg esac 11030603fc0a3Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11031603fc0a3Smrg ;; 11032603fc0a3Smrg uninstall) 11033603fc0a3Smrg if test -n "$library_names"; then 11034603fc0a3Smrg # Do each command in the postuninstall commands. 11035603fc0a3Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11036603fc0a3Smrg fi 11037603fc0a3Smrg 11038603fc0a3Smrg if test -n "$old_library"; then 11039603fc0a3Smrg # Do each command in the old_postuninstall commands. 11040603fc0a3Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11041603fc0a3Smrg fi 11042603fc0a3Smrg # FIXME: should reinstall the best remaining shared library. 11043603fc0a3Smrg ;; 11044603fc0a3Smrg esac 11045603fc0a3Smrg fi 11046603fc0a3Smrg ;; 11047603fc0a3Smrg 11048603fc0a3Smrg *.lo) 11049603fc0a3Smrg # Possibly a libtool object, so verify it. 11050603fc0a3Smrg if func_lalib_p "$file"; then 11051603fc0a3Smrg 11052603fc0a3Smrg # Read the .lo file 11053603fc0a3Smrg func_source $dir/$name 11054603fc0a3Smrg 11055603fc0a3Smrg # Add PIC object to the list of files to remove. 11056603fc0a3Smrg if test -n "$pic_object" && test none != "$pic_object"; then 11057603fc0a3Smrg func_append rmfiles " $dir/$pic_object" 11058603fc0a3Smrg fi 11059603fc0a3Smrg 11060603fc0a3Smrg # Add non-PIC object to the list of files to remove. 11061603fc0a3Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11062603fc0a3Smrg func_append rmfiles " $dir/$non_pic_object" 11063603fc0a3Smrg fi 11064603fc0a3Smrg fi 11065603fc0a3Smrg ;; 11066603fc0a3Smrg 11067603fc0a3Smrg *) 11068603fc0a3Smrg if test clean = "$opt_mode"; then 11069603fc0a3Smrg noexename=$name 11070603fc0a3Smrg case $file in 11071603fc0a3Smrg *.exe) 11072603fc0a3Smrg func_stripname '' '.exe' "$file" 11073603fc0a3Smrg file=$func_stripname_result 11074603fc0a3Smrg func_stripname '' '.exe' "$name" 11075603fc0a3Smrg noexename=$func_stripname_result 11076603fc0a3Smrg # $file with .exe has already been added to rmfiles, 11077603fc0a3Smrg # add $file without .exe 11078603fc0a3Smrg func_append rmfiles " $file" 11079603fc0a3Smrg ;; 11080603fc0a3Smrg esac 11081603fc0a3Smrg # Do a test to see if this is a libtool program. 11082603fc0a3Smrg if func_ltwrapper_p "$file"; then 11083603fc0a3Smrg if func_ltwrapper_executable_p "$file"; then 11084603fc0a3Smrg func_ltwrapper_scriptname "$file" 11085603fc0a3Smrg relink_command= 11086603fc0a3Smrg func_source $func_ltwrapper_scriptname_result 11087603fc0a3Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11088603fc0a3Smrg else 11089603fc0a3Smrg relink_command= 11090603fc0a3Smrg func_source $dir/$noexename 11091603fc0a3Smrg fi 11092603fc0a3Smrg 11093603fc0a3Smrg # note $name still contains .exe if it was in $file originally 11094603fc0a3Smrg # as does the version of $file that was added into $rmfiles 11095603fc0a3Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11096603fc0a3Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 11097603fc0a3Smrg func_append rmfiles " $odir/lt-$name" 11098603fc0a3Smrg fi 11099603fc0a3Smrg if test "X$noexename" != "X$name"; then 11100603fc0a3Smrg func_append rmfiles " $odir/lt-$noexename.c" 11101603fc0a3Smrg fi 11102603fc0a3Smrg fi 11103603fc0a3Smrg fi 11104603fc0a3Smrg ;; 11105603fc0a3Smrg esac 11106603fc0a3Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11107603fc0a3Smrg done 11108603fc0a3Smrg 11109603fc0a3Smrg # Try to remove the $objdir's in the directories where we deleted files 11110603fc0a3Smrg for dir in $rmdirs; do 11111603fc0a3Smrg if test -d "$dir"; then 11112603fc0a3Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11113603fc0a3Smrg fi 11114603fc0a3Smrg done 11115603fc0a3Smrg 11116603fc0a3Smrg exit $exit_status 11117603fc0a3Smrg} 11118603fc0a3Smrg 11119603fc0a3Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11120603fc0a3Smrg func_mode_uninstall ${1+"$@"} 11121603fc0a3Smrgfi 11122603fc0a3Smrg 11123603fc0a3Smrgtest -z "$opt_mode" && { 11124603fc0a3Smrg help=$generic_help 11125603fc0a3Smrg func_fatal_help "you must specify a MODE" 11126603fc0a3Smrg} 11127603fc0a3Smrg 11128603fc0a3Smrgtest -z "$exec_cmd" && \ 11129603fc0a3Smrg func_fatal_help "invalid operation mode '$opt_mode'" 11130603fc0a3Smrg 11131603fc0a3Smrgif test -n "$exec_cmd"; then 11132603fc0a3Smrg eval exec "$exec_cmd" 11133603fc0a3Smrg exit $EXIT_FAILURE 11134603fc0a3Smrgfi 11135603fc0a3Smrg 11136603fc0a3Smrgexit $exit_status 11137603fc0a3Smrg 11138603fc0a3Smrg 11139603fc0a3Smrg# The TAGs below are defined such that we never get into a situation 11140603fc0a3Smrg# where we disable both kinds of libraries. Given conflicting 11141603fc0a3Smrg# choices, we go for a static library, that is the most portable, 11142603fc0a3Smrg# since we can't tell whether shared libraries were disabled because 11143603fc0a3Smrg# the user asked for that or because the platform doesn't support 11144603fc0a3Smrg# them. This is particularly important on AIX, because we don't 11145603fc0a3Smrg# support having both static and shared libraries enabled at the same 11146603fc0a3Smrg# time on that platform, so we default to a shared-only configuration. 11147603fc0a3Smrg# If a disable-shared tag is given, we'll fallback to a static-only 11148603fc0a3Smrg# configuration. But we'll never go from static-only to shared-only. 11149603fc0a3Smrg 11150603fc0a3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11151603fc0a3Smrgbuild_libtool_libs=no 11152603fc0a3Smrgbuild_old_libs=yes 11153603fc0a3Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 11154603fc0a3Smrg 11155603fc0a3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11156603fc0a3Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11157603fc0a3Smrg# ### END LIBTOOL TAG CONFIG: disable-static 11158603fc0a3Smrg 11159603fc0a3Smrg# Local Variables: 11160603fc0a3Smrg# mode:shell-script 11161603fc0a3Smrg# sh-indentation:2 11162603fc0a3Smrg# End: 11163