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