ltmain.sh revision c43cc173
1c43cc173Smrg# ltmain.sh - Provide generalized library-building support services. 2c43cc173Smrg# NOTE: Changing this file will not affect anything until you rerun configure. 3c43cc173Smrg# 4c43cc173Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 5c43cc173Smrg# Free Software Foundation, Inc. 6c43cc173Smrg# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 7c43cc173Smrg# 8c43cc173Smrg# This program is free software; you can redistribute it and/or modify 9c43cc173Smrg# it under the terms of the GNU General Public License as published by 10c43cc173Smrg# the Free Software Foundation; either version 2 of the License, or 11c43cc173Smrg# (at your option) any later version. 12c43cc173Smrg# 13c43cc173Smrg# This program is distributed in the hope that it will be useful, but 14c43cc173Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 15c43cc173Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16c43cc173Smrg# General Public License for more details. 17c43cc173Smrg# 18c43cc173Smrg# You should have received a copy of the GNU General Public License 19c43cc173Smrg# along with this program; if not, write to the Free Software 20c43cc173Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21c43cc173Smrg# 22c43cc173Smrg# As a special exception to the GNU General Public License, if you 23c43cc173Smrg# distribute this file as part of a program that contains a 24c43cc173Smrg# configuration script generated by Autoconf, you may include it under 25c43cc173Smrg# the same distribution terms that you use for the rest of that program. 26c43cc173Smrg 27c43cc173Smrgbasename="s,^.*/,,g" 28c43cc173Smrg 29c43cc173Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 30c43cc173Smrg# is ksh but when the shell is invoked as "sh" and the current value of 31c43cc173Smrg# the _XPG environment variable is not equal to 1 (one), the special 32c43cc173Smrg# positional parameter $0, within a function call, is the name of the 33c43cc173Smrg# function. 34c43cc173Smrgprogpath="$0" 35c43cc173Smrg 36c43cc173Smrg# The name of this program: 37c43cc173Smrgprogname=`echo "$progpath" | $SED $basename` 38c43cc173Smrgmodename="$progname" 39c43cc173Smrg 40c43cc173Smrg# Global variables: 41c43cc173SmrgEXIT_SUCCESS=0 42c43cc173SmrgEXIT_FAILURE=1 43c43cc173Smrg 44c43cc173SmrgPROGRAM=ltmain.sh 45c43cc173SmrgPACKAGE=libtool 46c43cc173SmrgVERSION=1.5.22 47c43cc173SmrgTIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)" 48c43cc173Smrg 49c43cc173Smrg# See if we are running on zsh, and set the options which allow our 50c43cc173Smrg# commands through without removal of \ escapes. 51c43cc173Smrgif test -n "${ZSH_VERSION+set}" ; then 52c43cc173Smrg setopt NO_GLOB_SUBST 53c43cc173Smrgfi 54c43cc173Smrg 55c43cc173Smrg# Check that we have a working $echo. 56c43cc173Smrgif test "X$1" = X--no-reexec; then 57c43cc173Smrg # Discard the --no-reexec flag, and continue. 58c43cc173Smrg shift 59c43cc173Smrgelif test "X$1" = X--fallback-echo; then 60c43cc173Smrg # Avoid inline document here, it may be left over 61c43cc173Smrg : 62c43cc173Smrgelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then 63c43cc173Smrg # Yippee, $echo works! 64c43cc173Smrg : 65c43cc173Smrgelse 66c43cc173Smrg # Restart under the correct shell, and then maybe $echo will work. 67c43cc173Smrg exec $SHELL "$progpath" --no-reexec ${1+"$@"} 68c43cc173Smrgfi 69c43cc173Smrg 70c43cc173Smrgif test "X$1" = X--fallback-echo; then 71c43cc173Smrg # used as fallback echo 72c43cc173Smrg shift 73c43cc173Smrg cat <<EOF 74c43cc173Smrg$* 75c43cc173SmrgEOF 76c43cc173Smrg exit $EXIT_SUCCESS 77c43cc173Smrgfi 78c43cc173Smrg 79c43cc173Smrgdefault_mode= 80c43cc173Smrghelp="Try \`$progname --help' for more information." 81c43cc173Smrgmagic="%%%MAGIC variable%%%" 82c43cc173Smrgmkdir="mkdir" 83c43cc173Smrgmv="mv -f" 84c43cc173Smrgrm="rm -f" 85c43cc173Smrg 86c43cc173Smrg# Sed substitution that helps us do robust quoting. It backslashifies 87c43cc173Smrg# metacharacters that are still active within double-quoted strings. 88c43cc173SmrgXsed="${SED}"' -e 1s/^X//' 89c43cc173Smrgsed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' 90c43cc173Smrg# test EBCDIC or ASCII 91c43cc173Smrgcase `echo X|tr X '\101'` in 92c43cc173Smrg A) # ASCII based system 93c43cc173Smrg # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr 94c43cc173Smrg SP2NL='tr \040 \012' 95c43cc173Smrg NL2SP='tr \015\012 \040\040' 96c43cc173Smrg ;; 97c43cc173Smrg *) # EBCDIC based system 98c43cc173Smrg SP2NL='tr \100 \n' 99c43cc173Smrg NL2SP='tr \r\n \100\100' 100c43cc173Smrg ;; 101c43cc173Smrgesac 102c43cc173Smrg 103c43cc173Smrg# NLS nuisances. 104c43cc173Smrg# Only set LANG and LC_ALL to C if already set. 105c43cc173Smrg# These must not be set unconditionally because not all systems understand 106c43cc173Smrg# e.g. LANG=C (notably SCO). 107c43cc173Smrg# We save the old values to restore during execute mode. 108c43cc173Smrgif test "${LC_ALL+set}" = set; then 109c43cc173Smrg save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL 110c43cc173Smrgfi 111c43cc173Smrgif test "${LANG+set}" = set; then 112c43cc173Smrg save_LANG="$LANG"; LANG=C; export LANG 113c43cc173Smrgfi 114c43cc173Smrg 115c43cc173Smrg# Make sure IFS has a sensible default 116c43cc173Smrglt_nl=' 117c43cc173Smrg' 118c43cc173SmrgIFS=" $lt_nl" 119c43cc173Smrg 120c43cc173Smrgif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 121c43cc173Smrg $echo "$modename: not configured to build any kind of library" 1>&2 122c43cc173Smrg $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 123c43cc173Smrg exit $EXIT_FAILURE 124c43cc173Smrgfi 125c43cc173Smrg 126c43cc173Smrg# Global variables. 127c43cc173Smrgmode=$default_mode 128c43cc173Smrgnonopt= 129c43cc173Smrgprev= 130c43cc173Smrgprevopt= 131c43cc173Smrgrun= 132c43cc173Smrgshow="$echo" 133c43cc173Smrgshow_help= 134c43cc173Smrgexecute_dlfiles= 135c43cc173Smrgduplicate_deps=no 136c43cc173Smrgpreserve_args= 137c43cc173Smrglo2o="s/\\.lo\$/.${objext}/" 138c43cc173Smrgo2lo="s/\\.${objext}\$/.lo/" 139c43cc173Smrg 140c43cc173Smrg##################################### 141c43cc173Smrg# Shell function definitions: 142c43cc173Smrg# This seems to be the best place for them 143c43cc173Smrg 144c43cc173Smrg# func_mktempdir [string] 145c43cc173Smrg# Make a temporary directory that won't clash with other running 146c43cc173Smrg# libtool processes, and avoids race conditions if possible. If 147c43cc173Smrg# given, STRING is the basename for that directory. 148c43cc173Smrgfunc_mktempdir () 149c43cc173Smrg{ 150c43cc173Smrg my_template="${TMPDIR-/tmp}/${1-$progname}" 151c43cc173Smrg 152c43cc173Smrg if test "$run" = ":"; then 153c43cc173Smrg # Return a directory name, but don't create it in dry-run mode 154c43cc173Smrg my_tmpdir="${my_template}-$$" 155c43cc173Smrg else 156c43cc173Smrg 157c43cc173Smrg # If mktemp works, use that first and foremost 158c43cc173Smrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 159c43cc173Smrg 160c43cc173Smrg if test ! -d "$my_tmpdir"; then 161c43cc173Smrg # Failing that, at least try and use $RANDOM to avoid a race 162c43cc173Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 163c43cc173Smrg 164c43cc173Smrg save_mktempdir_umask=`umask` 165c43cc173Smrg umask 0077 166c43cc173Smrg $mkdir "$my_tmpdir" 167c43cc173Smrg umask $save_mktempdir_umask 168c43cc173Smrg fi 169c43cc173Smrg 170c43cc173Smrg # If we're not in dry-run mode, bomb out on failure 171c43cc173Smrg test -d "$my_tmpdir" || { 172c43cc173Smrg $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2 173c43cc173Smrg exit $EXIT_FAILURE 174c43cc173Smrg } 175c43cc173Smrg fi 176c43cc173Smrg 177c43cc173Smrg $echo "X$my_tmpdir" | $Xsed 178c43cc173Smrg} 179c43cc173Smrg 180c43cc173Smrg 181c43cc173Smrg# func_win32_libid arg 182c43cc173Smrg# return the library type of file 'arg' 183c43cc173Smrg# 184c43cc173Smrg# Need a lot of goo to handle *both* DLLs and import libs 185c43cc173Smrg# Has to be a shell function in order to 'eat' the argument 186c43cc173Smrg# that is supplied when $file_magic_command is called. 187c43cc173Smrgfunc_win32_libid () 188c43cc173Smrg{ 189c43cc173Smrg win32_libid_type="unknown" 190c43cc173Smrg win32_fileres=`file -L $1 2>/dev/null` 191c43cc173Smrg case $win32_fileres in 192c43cc173Smrg *ar\ archive\ import\ library*) # definitely import 193c43cc173Smrg win32_libid_type="x86 archive import" 194c43cc173Smrg ;; 195c43cc173Smrg *ar\ archive*) # could be an import, or static 196c43cc173Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ 197c43cc173Smrg $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then 198c43cc173Smrg win32_nmres=`eval $NM -f posix -A $1 | \ 199c43cc173Smrg $SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'` 200c43cc173Smrg case $win32_nmres in 201c43cc173Smrg import*) win32_libid_type="x86 archive import";; 202c43cc173Smrg *) win32_libid_type="x86 archive static";; 203c43cc173Smrg esac 204c43cc173Smrg fi 205c43cc173Smrg ;; 206c43cc173Smrg *DLL*) 207c43cc173Smrg win32_libid_type="x86 DLL" 208c43cc173Smrg ;; 209c43cc173Smrg *executable*) # but shell scripts are "executable" too... 210c43cc173Smrg case $win32_fileres in 211c43cc173Smrg *MS\ Windows\ PE\ Intel*) 212c43cc173Smrg win32_libid_type="x86 DLL" 213c43cc173Smrg ;; 214c43cc173Smrg esac 215c43cc173Smrg ;; 216c43cc173Smrg esac 217c43cc173Smrg $echo $win32_libid_type 218c43cc173Smrg} 219c43cc173Smrg 220c43cc173Smrg 221c43cc173Smrg# func_infer_tag arg 222c43cc173Smrg# Infer tagged configuration to use if any are available and 223c43cc173Smrg# if one wasn't chosen via the "--tag" command line option. 224c43cc173Smrg# Only attempt this if the compiler in the base compile 225c43cc173Smrg# command doesn't match the default compiler. 226c43cc173Smrg# arg is usually of the form 'gcc ...' 227c43cc173Smrgfunc_infer_tag () 228c43cc173Smrg{ 229c43cc173Smrg # FreeBSD-specific: where we install compilers with non-standard names 230c43cc173Smrg tag_compilers_CC="*cc cc* *gcc gcc*" 231c43cc173Smrg tag_compilers_CXX="*c++ c++* *g++ g++*" 232c43cc173Smrg base_compiler=`set -- "$@"; echo $1` 233c43cc173Smrg 234c43cc173Smrg # If $tagname isn't set, then try to infer if the default "CC" tag applies 235c43cc173Smrg if test -z "$tagname"; then 236c43cc173Smrg for zp in $tag_compilers_CC; do 237c43cc173Smrg case $base_compiler in 238c43cc173Smrg $zp) tagname="CC"; break;; 239c43cc173Smrg esac 240c43cc173Smrg done 241c43cc173Smrg fi 242c43cc173Smrg 243c43cc173Smrg if test -n "$available_tags" && test -z "$tagname"; then 244c43cc173Smrg CC_quoted= 245c43cc173Smrg for arg in $CC; do 246c43cc173Smrg case $arg in 247c43cc173Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 248c43cc173Smrg arg="\"$arg\"" 249c43cc173Smrg ;; 250c43cc173Smrg esac 251c43cc173Smrg CC_quoted="$CC_quoted $arg" 252c43cc173Smrg done 253c43cc173Smrg case $@ in 254c43cc173Smrg # Blanks in the command may have been stripped by the calling shell, 255c43cc173Smrg # but not from the CC environment variable when configure was run. 256c43cc173Smrg " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;; 257c43cc173Smrg # Blanks at the start of $base_compile will cause this to fail 258c43cc173Smrg # if we don't check for them as well. 259c43cc173Smrg *) 260c43cc173Smrg for z in $available_tags; do 261c43cc173Smrg if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 262c43cc173Smrg # Evaluate the configuration. 263c43cc173Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 264c43cc173Smrg CC_quoted= 265c43cc173Smrg for arg in $CC; do 266c43cc173Smrg # Double-quote args containing other shell metacharacters. 267c43cc173Smrg case $arg in 268c43cc173Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 269c43cc173Smrg arg="\"$arg\"" 270c43cc173Smrg ;; 271c43cc173Smrg esac 272c43cc173Smrg CC_quoted="$CC_quoted $arg" 273c43cc173Smrg done 274c43cc173Smrg case "$@ " in 275c43cc173Smrg " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) 276c43cc173Smrg # The compiler in the base compile command matches 277c43cc173Smrg # the one in the tagged configuration. 278c43cc173Smrg # Assume this is the tagged configuration we want. 279c43cc173Smrg tagname=$z 280c43cc173Smrg break 281c43cc173Smrg ;; 282c43cc173Smrg esac 283c43cc173Smrg 284c43cc173Smrg # FreeBSD-specific: try compilers based on inferred tag 285c43cc173Smrg if test -z "$tagname"; then 286c43cc173Smrg eval "tag_compilers=\$tag_compilers_${z}" 287c43cc173Smrg if test -n "$tag_compilers"; then 288c43cc173Smrg for zp in $tag_compilers; do 289c43cc173Smrg case $base_compiler in 290c43cc173Smrg $zp) tagname=$z; break;; 291c43cc173Smrg esac 292c43cc173Smrg done 293c43cc173Smrg if test -n "$tagname"; then 294c43cc173Smrg break 295c43cc173Smrg fi 296c43cc173Smrg fi 297c43cc173Smrg fi 298c43cc173Smrg fi 299c43cc173Smrg done 300c43cc173Smrg # If $tagname still isn't set, then no tagged configuration 301c43cc173Smrg # was found and let the user know that the "--tag" command 302c43cc173Smrg # line option must be used. 303c43cc173Smrg if test -z "$tagname"; then 304c43cc173Smrg $echo "$modename: unable to infer tagged configuration" 305c43cc173Smrg $echo "$modename: specify a tag with \`--tag'" 1>&2 306c43cc173Smrg exit $EXIT_FAILURE 307c43cc173Smrg# else 308c43cc173Smrg# $echo "$modename: using $tagname tagged configuration" 309c43cc173Smrg fi 310c43cc173Smrg ;; 311c43cc173Smrg esac 312c43cc173Smrg fi 313c43cc173Smrg} 314c43cc173Smrg 315c43cc173Smrg 316c43cc173Smrg# func_extract_an_archive dir oldlib 317c43cc173Smrgfunc_extract_an_archive () 318c43cc173Smrg{ 319c43cc173Smrg f_ex_an_ar_dir="$1"; shift 320c43cc173Smrg f_ex_an_ar_oldlib="$1" 321c43cc173Smrg 322c43cc173Smrg $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)" 323c43cc173Smrg $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $? 324c43cc173Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 325c43cc173Smrg : 326c43cc173Smrg else 327c43cc173Smrg $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2 328c43cc173Smrg exit $EXIT_FAILURE 329c43cc173Smrg fi 330c43cc173Smrg} 331c43cc173Smrg 332c43cc173Smrg# func_extract_archives gentop oldlib ... 333c43cc173Smrgfunc_extract_archives () 334c43cc173Smrg{ 335c43cc173Smrg my_gentop="$1"; shift 336c43cc173Smrg my_oldlibs=${1+"$@"} 337c43cc173Smrg my_oldobjs="" 338c43cc173Smrg my_xlib="" 339c43cc173Smrg my_xabs="" 340c43cc173Smrg my_xdir="" 341c43cc173Smrg my_status="" 342c43cc173Smrg 343c43cc173Smrg $show "${rm}r $my_gentop" 344c43cc173Smrg $run ${rm}r "$my_gentop" 345c43cc173Smrg $show "$mkdir $my_gentop" 346c43cc173Smrg $run $mkdir "$my_gentop" 347c43cc173Smrg my_status=$? 348c43cc173Smrg if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then 349c43cc173Smrg exit $my_status 350c43cc173Smrg fi 351c43cc173Smrg 352c43cc173Smrg for my_xlib in $my_oldlibs; do 353c43cc173Smrg # Extract the objects. 354c43cc173Smrg case $my_xlib in 355c43cc173Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 356c43cc173Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 357c43cc173Smrg esac 358c43cc173Smrg my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'` 359c43cc173Smrg my_xdir="$my_gentop/$my_xlib" 360c43cc173Smrg 361c43cc173Smrg $show "${rm}r $my_xdir" 362c43cc173Smrg $run ${rm}r "$my_xdir" 363c43cc173Smrg $show "$mkdir $my_xdir" 364c43cc173Smrg $run $mkdir "$my_xdir" 365c43cc173Smrg exit_status=$? 366c43cc173Smrg if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then 367c43cc173Smrg exit $exit_status 368c43cc173Smrg fi 369c43cc173Smrg case $host in 370c43cc173Smrg *-darwin*) 371c43cc173Smrg $show "Extracting $my_xabs" 372c43cc173Smrg # Do not bother doing anything if just a dry run 373c43cc173Smrg if test -z "$run"; then 374c43cc173Smrg darwin_orig_dir=`pwd` 375c43cc173Smrg cd $my_xdir || exit $? 376c43cc173Smrg darwin_archive=$my_xabs 377c43cc173Smrg darwin_curdir=`pwd` 378c43cc173Smrg darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'` 379c43cc173Smrg darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null` 380c43cc173Smrg if test -n "$darwin_arches"; then 381c43cc173Smrg darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'` 382c43cc173Smrg darwin_arch= 383c43cc173Smrg $show "$darwin_base_archive has multiple architectures $darwin_arches" 384c43cc173Smrg for darwin_arch in $darwin_arches ; do 385c43cc173Smrg mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 386c43cc173Smrg lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 387c43cc173Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 388c43cc173Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 389c43cc173Smrg cd "$darwin_curdir" 390c43cc173Smrg $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 391c43cc173Smrg done # $darwin_arches 392c43cc173Smrg ## Okay now we have a bunch of thin objects, gotta fatten them up :) 393c43cc173Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP` 394c43cc173Smrg darwin_file= 395c43cc173Smrg darwin_files= 396c43cc173Smrg for darwin_file in $darwin_filelist; do 397c43cc173Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` 398c43cc173Smrg lipo -create -output "$darwin_file" $darwin_files 399c43cc173Smrg done # $darwin_filelist 400c43cc173Smrg ${rm}r unfat-$$ 401c43cc173Smrg cd "$darwin_orig_dir" 402c43cc173Smrg else 403c43cc173Smrg cd "$darwin_orig_dir" 404c43cc173Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 405c43cc173Smrg fi # $darwin_arches 406c43cc173Smrg fi # $run 407c43cc173Smrg ;; 408c43cc173Smrg *) 409c43cc173Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 410c43cc173Smrg ;; 411c43cc173Smrg esac 412c43cc173Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` 413c43cc173Smrg done 414c43cc173Smrg func_extract_archives_result="$my_oldobjs" 415c43cc173Smrg} 416c43cc173Smrg# End of Shell function definitions 417c43cc173Smrg##################################### 418c43cc173Smrg 419c43cc173Smrg# Darwin sucks 420c43cc173Smrgeval std_shrext=\"$shrext_cmds\" 421c43cc173Smrg 422c43cc173Smrgdisable_libs=no 423c43cc173Smrg 424c43cc173Smrg# Parse our command line options once, thoroughly. 425c43cc173Smrgwhile test "$#" -gt 0 426c43cc173Smrgdo 427c43cc173Smrg arg="$1" 428c43cc173Smrg shift 429c43cc173Smrg 430c43cc173Smrg case $arg in 431c43cc173Smrg -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; 432c43cc173Smrg *) optarg= ;; 433c43cc173Smrg esac 434c43cc173Smrg 435c43cc173Smrg # If the previous option needs an argument, assign it. 436c43cc173Smrg if test -n "$prev"; then 437c43cc173Smrg case $prev in 438c43cc173Smrg execute_dlfiles) 439c43cc173Smrg execute_dlfiles="$execute_dlfiles $arg" 440c43cc173Smrg ;; 441c43cc173Smrg tag) 442c43cc173Smrg tagname="$arg" 443c43cc173Smrg preserve_args="${preserve_args}=$arg" 444c43cc173Smrg 445c43cc173Smrg # Check whether tagname contains only valid characters 446c43cc173Smrg case $tagname in 447c43cc173Smrg *[!-_A-Za-z0-9,/]*) 448c43cc173Smrg $echo "$progname: invalid tag name: $tagname" 1>&2 449c43cc173Smrg exit $EXIT_FAILURE 450c43cc173Smrg ;; 451c43cc173Smrg esac 452c43cc173Smrg 453c43cc173Smrg case $tagname in 454c43cc173Smrg CC) 455c43cc173Smrg # Don't test for the "default" C tag, as we know, it's there, but 456c43cc173Smrg # not specially marked. 457c43cc173Smrg ;; 458c43cc173Smrg *) 459c43cc173Smrg if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then 460c43cc173Smrg taglist="$taglist $tagname" 461c43cc173Smrg # Evaluate the configuration. 462c43cc173Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`" 463c43cc173Smrg else 464c43cc173Smrg $echo "$progname: ignoring unknown tag $tagname" 1>&2 465c43cc173Smrg fi 466c43cc173Smrg ;; 467c43cc173Smrg esac 468c43cc173Smrg ;; 469c43cc173Smrg *) 470c43cc173Smrg eval "$prev=\$arg" 471c43cc173Smrg ;; 472c43cc173Smrg esac 473c43cc173Smrg 474c43cc173Smrg prev= 475c43cc173Smrg prevopt= 476c43cc173Smrg continue 477c43cc173Smrg fi 478c43cc173Smrg 479c43cc173Smrg # Have we seen a non-optional argument yet? 480c43cc173Smrg case $arg in 481c43cc173Smrg --help) 482c43cc173Smrg show_help=yes 483c43cc173Smrg ;; 484c43cc173Smrg 485c43cc173Smrg --version) 486c43cc173Smrg $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" 487c43cc173Smrg $echo 488c43cc173Smrg $echo "Copyright (C) 2005 Free Software Foundation, Inc." 489c43cc173Smrg $echo "This is free software; see the source for copying conditions. There is NO" 490c43cc173Smrg $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." 491c43cc173Smrg exit $? 492c43cc173Smrg ;; 493c43cc173Smrg 494c43cc173Smrg --config) 495c43cc173Smrg ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath 496c43cc173Smrg # Now print the configurations for the tags. 497c43cc173Smrg for tagname in $taglist; do 498c43cc173Smrg ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath" 499c43cc173Smrg done 500c43cc173Smrg exit $? 501c43cc173Smrg ;; 502c43cc173Smrg 503c43cc173Smrg --debug) 504c43cc173Smrg $echo "$progname: enabling shell trace mode" 505c43cc173Smrg set -x 506c43cc173Smrg preserve_args="$preserve_args $arg" 507c43cc173Smrg ;; 508c43cc173Smrg 509c43cc173Smrg --dry-run | -n) 510c43cc173Smrg run=: 511c43cc173Smrg ;; 512c43cc173Smrg 513c43cc173Smrg --features) 514c43cc173Smrg $echo "host: $host" 515c43cc173Smrg if test "$build_libtool_libs" = yes; then 516c43cc173Smrg $echo "enable shared libraries" 517c43cc173Smrg else 518c43cc173Smrg $echo "disable shared libraries" 519c43cc173Smrg fi 520c43cc173Smrg if test "$build_old_libs" = yes; then 521c43cc173Smrg $echo "enable static libraries" 522c43cc173Smrg else 523c43cc173Smrg $echo "disable static libraries" 524c43cc173Smrg fi 525c43cc173Smrg exit $? 526c43cc173Smrg ;; 527c43cc173Smrg 528c43cc173Smrg --finish) mode="finish" ;; 529c43cc173Smrg 530c43cc173Smrg --mode) prevopt="--mode" prev=mode ;; 531c43cc173Smrg --mode=*) mode="$optarg" ;; 532c43cc173Smrg 533c43cc173Smrg --preserve-dup-deps) duplicate_deps="yes" ;; 534c43cc173Smrg 535c43cc173Smrg --quiet | --silent) 536c43cc173Smrg show=: 537c43cc173Smrg preserve_args="$preserve_args $arg" 538c43cc173Smrg ;; 539c43cc173Smrg 540c43cc173Smrg --tag) 541c43cc173Smrg prevopt="--tag" 542c43cc173Smrg prev=tag 543c43cc173Smrg preserve_args="$preserve_args --tag" 544c43cc173Smrg ;; 545c43cc173Smrg --tag=*) 546c43cc173Smrg set tag "$optarg" ${1+"$@"} 547c43cc173Smrg shift 548c43cc173Smrg prev=tag 549c43cc173Smrg preserve_args="$preserve_args --tag" 550c43cc173Smrg ;; 551c43cc173Smrg 552c43cc173Smrg -dlopen) 553c43cc173Smrg prevopt="-dlopen" 554c43cc173Smrg prev=execute_dlfiles 555c43cc173Smrg ;; 556c43cc173Smrg 557c43cc173Smrg -*) 558c43cc173Smrg $echo "$modename: unrecognized option \`$arg'" 1>&2 559c43cc173Smrg $echo "$help" 1>&2 560c43cc173Smrg exit $EXIT_FAILURE 561c43cc173Smrg ;; 562c43cc173Smrg 563c43cc173Smrg *) 564c43cc173Smrg nonopt="$arg" 565c43cc173Smrg break 566c43cc173Smrg ;; 567c43cc173Smrg esac 568c43cc173Smrgdone 569c43cc173Smrg 570c43cc173Smrgif test -n "$prevopt"; then 571c43cc173Smrg $echo "$modename: option \`$prevopt' requires an argument" 1>&2 572c43cc173Smrg $echo "$help" 1>&2 573c43cc173Smrg exit $EXIT_FAILURE 574c43cc173Smrgfi 575c43cc173Smrg 576c43cc173Smrgcase $disable_libs in 577c43cc173Smrgno) 578c43cc173Smrg ;; 579c43cc173Smrgshared) 580c43cc173Smrg build_libtool_libs=no 581c43cc173Smrg build_old_libs=yes 582c43cc173Smrg ;; 583c43cc173Smrgstatic) 584c43cc173Smrg build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 585c43cc173Smrg ;; 586c43cc173Smrgesac 587c43cc173Smrg 588c43cc173Smrg# If this variable is set in any of the actions, the command in it 589c43cc173Smrg# will be execed at the end. This prevents here-documents from being 590c43cc173Smrg# left over by shells. 591c43cc173Smrgexec_cmd= 592c43cc173Smrg 593c43cc173Smrgif test -z "$show_help"; then 594c43cc173Smrg 595c43cc173Smrg # Infer the operation mode. 596c43cc173Smrg if test -z "$mode"; then 597c43cc173Smrg $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 598c43cc173Smrg $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2 599c43cc173Smrg case $nonopt in 600c43cc173Smrg *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) 601c43cc173Smrg mode=link 602c43cc173Smrg for arg 603c43cc173Smrg do 604c43cc173Smrg case $arg in 605c43cc173Smrg -c) 606c43cc173Smrg mode=compile 607c43cc173Smrg break 608c43cc173Smrg ;; 609c43cc173Smrg esac 610c43cc173Smrg done 611c43cc173Smrg ;; 612c43cc173Smrg *db | *dbx | *strace | *truss) 613c43cc173Smrg mode=execute 614c43cc173Smrg ;; 615c43cc173Smrg *install*|cp|mv) 616c43cc173Smrg mode=install 617c43cc173Smrg ;; 618c43cc173Smrg *rm) 619c43cc173Smrg mode=uninstall 620c43cc173Smrg ;; 621c43cc173Smrg *) 622c43cc173Smrg # If we have no mode, but dlfiles were specified, then do execute mode. 623c43cc173Smrg test -n "$execute_dlfiles" && mode=execute 624c43cc173Smrg 625c43cc173Smrg # Just use the default operation mode. 626c43cc173Smrg if test -z "$mode"; then 627c43cc173Smrg if test -n "$nonopt"; then 628c43cc173Smrg $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 629c43cc173Smrg else 630c43cc173Smrg $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 631c43cc173Smrg fi 632c43cc173Smrg fi 633c43cc173Smrg ;; 634c43cc173Smrg esac 635c43cc173Smrg fi 636c43cc173Smrg 637c43cc173Smrg # Only execute mode is allowed to have -dlopen flags. 638c43cc173Smrg if test -n "$execute_dlfiles" && test "$mode" != execute; then 639c43cc173Smrg $echo "$modename: unrecognized option \`-dlopen'" 1>&2 640c43cc173Smrg $echo "$help" 1>&2 641c43cc173Smrg exit $EXIT_FAILURE 642c43cc173Smrg fi 643c43cc173Smrg 644c43cc173Smrg # Change the help message to a mode-specific one. 645c43cc173Smrg generic_help="$help" 646c43cc173Smrg help="Try \`$modename --help --mode=$mode' for more information." 647c43cc173Smrg 648c43cc173Smrg # These modes are in order of execution frequency so that they run quickly. 649c43cc173Smrg case $mode in 650c43cc173Smrg # libtool compile mode 651c43cc173Smrg compile) 652c43cc173Smrg modename="$modename: compile" 653c43cc173Smrg # Get the compilation command and the source file. 654c43cc173Smrg base_compile= 655c43cc173Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 656c43cc173Smrg suppress_opt=yes 657c43cc173Smrg suppress_output= 658c43cc173Smrg arg_mode=normal 659c43cc173Smrg libobj= 660c43cc173Smrg later= 661c43cc173Smrg 662c43cc173Smrg for arg 663c43cc173Smrg do 664c43cc173Smrg case $arg_mode in 665c43cc173Smrg arg ) 666c43cc173Smrg # do not "continue". Instead, add this to base_compile 667c43cc173Smrg lastarg="$arg" 668c43cc173Smrg arg_mode=normal 669c43cc173Smrg ;; 670c43cc173Smrg 671c43cc173Smrg target ) 672c43cc173Smrg libobj="$arg" 673c43cc173Smrg arg_mode=normal 674c43cc173Smrg continue 675c43cc173Smrg ;; 676c43cc173Smrg 677c43cc173Smrg normal ) 678c43cc173Smrg # Accept any command-line options. 679c43cc173Smrg case $arg in 680c43cc173Smrg -o) 681c43cc173Smrg if test -n "$libobj" ; then 682c43cc173Smrg $echo "$modename: you cannot specify \`-o' more than once" 1>&2 683c43cc173Smrg exit $EXIT_FAILURE 684c43cc173Smrg fi 685c43cc173Smrg arg_mode=target 686c43cc173Smrg continue 687c43cc173Smrg ;; 688c43cc173Smrg 689c43cc173Smrg -static | -prefer-pic | -prefer-non-pic) 690c43cc173Smrg later="$later $arg" 691c43cc173Smrg continue 692c43cc173Smrg ;; 693c43cc173Smrg 694c43cc173Smrg -no-suppress) 695c43cc173Smrg suppress_opt=no 696c43cc173Smrg continue 697c43cc173Smrg ;; 698c43cc173Smrg 699c43cc173Smrg -Xcompiler) 700c43cc173Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 701c43cc173Smrg continue # The current "srcfile" will either be retained or 702c43cc173Smrg ;; # replaced later. I would guess that would be a bug. 703c43cc173Smrg 704c43cc173Smrg -Wc,*) 705c43cc173Smrg args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` 706c43cc173Smrg lastarg= 707c43cc173Smrg save_ifs="$IFS"; IFS=',' 708c43cc173Smrg for arg in $args; do 709c43cc173Smrg IFS="$save_ifs" 710c43cc173Smrg 711c43cc173Smrg # Double-quote args containing other shell metacharacters. 712c43cc173Smrg # Many Bourne shells cannot handle close brackets correctly 713c43cc173Smrg # in scan sets, so we specify it separately. 714c43cc173Smrg case $arg in 715c43cc173Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 716c43cc173Smrg arg="\"$arg\"" 717c43cc173Smrg ;; 718c43cc173Smrg esac 719c43cc173Smrg lastarg="$lastarg $arg" 720c43cc173Smrg done 721c43cc173Smrg IFS="$save_ifs" 722c43cc173Smrg lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` 723c43cc173Smrg 724c43cc173Smrg # Add the arguments to base_compile. 725c43cc173Smrg base_compile="$base_compile $lastarg" 726c43cc173Smrg continue 727c43cc173Smrg ;; 728c43cc173Smrg 729c43cc173Smrg * ) 730c43cc173Smrg # Accept the current argument as the source file. 731c43cc173Smrg # The previous "srcfile" becomes the current argument. 732c43cc173Smrg # 733c43cc173Smrg lastarg="$srcfile" 734c43cc173Smrg srcfile="$arg" 735c43cc173Smrg ;; 736c43cc173Smrg esac # case $arg 737c43cc173Smrg ;; 738c43cc173Smrg esac # case $arg_mode 739c43cc173Smrg 740c43cc173Smrg # Aesthetically quote the previous argument. 741c43cc173Smrg lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` 742c43cc173Smrg 743c43cc173Smrg case $lastarg in 744c43cc173Smrg # Double-quote args containing other shell metacharacters. 745c43cc173Smrg # Many Bourne shells cannot handle close brackets correctly 746c43cc173Smrg # in scan sets, and some SunOS ksh mistreat backslash-escaping 747c43cc173Smrg # in scan sets (worked around with variable expansion), 748c43cc173Smrg # and furthermore cannot handle '|' '&' '(' ')' in scan sets 749c43cc173Smrg # at all, so we specify them separately. 750c43cc173Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 751c43cc173Smrg lastarg="\"$lastarg\"" 752c43cc173Smrg ;; 753c43cc173Smrg esac 754c43cc173Smrg 755c43cc173Smrg base_compile="$base_compile $lastarg" 756c43cc173Smrg done # for arg 757c43cc173Smrg 758c43cc173Smrg case $arg_mode in 759c43cc173Smrg arg) 760c43cc173Smrg $echo "$modename: you must specify an argument for -Xcompile" 761c43cc173Smrg exit $EXIT_FAILURE 762c43cc173Smrg ;; 763c43cc173Smrg target) 764c43cc173Smrg $echo "$modename: you must specify a target with \`-o'" 1>&2 765c43cc173Smrg exit $EXIT_FAILURE 766c43cc173Smrg ;; 767c43cc173Smrg *) 768c43cc173Smrg # Get the name of the library object. 769c43cc173Smrg [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` 770c43cc173Smrg ;; 771c43cc173Smrg esac 772c43cc173Smrg 773c43cc173Smrg # Recognize several different file suffixes. 774c43cc173Smrg # If the user specifies -o file.o, it is replaced with file.lo 775c43cc173Smrg xform='[cCFSifmso]' 776c43cc173Smrg case $libobj in 777c43cc173Smrg *.ada) xform=ada ;; 778c43cc173Smrg *.adb) xform=adb ;; 779c43cc173Smrg *.ads) xform=ads ;; 780c43cc173Smrg *.asm) xform=asm ;; 781c43cc173Smrg *.c++) xform=c++ ;; 782c43cc173Smrg *.cc) xform=cc ;; 783c43cc173Smrg *.ii) xform=ii ;; 784c43cc173Smrg *.class) xform=class ;; 785c43cc173Smrg *.cpp) xform=cpp ;; 786c43cc173Smrg *.cxx) xform=cxx ;; 787c43cc173Smrg *.f90) xform=f90 ;; 788c43cc173Smrg *.for) xform=for ;; 789c43cc173Smrg *.java) xform=java ;; 790c43cc173Smrg esac 791c43cc173Smrg 792c43cc173Smrg libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` 793c43cc173Smrg 794c43cc173Smrg case $libobj in 795c43cc173Smrg *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; 796c43cc173Smrg *) 797c43cc173Smrg $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 798c43cc173Smrg exit $EXIT_FAILURE 799c43cc173Smrg ;; 800c43cc173Smrg esac 801c43cc173Smrg 802c43cc173Smrg func_infer_tag $base_compile 803c43cc173Smrg 804c43cc173Smrg for arg in $later; do 805c43cc173Smrg case $arg in 806c43cc173Smrg -static) 807c43cc173Smrg build_old_libs=yes 808c43cc173Smrg continue 809c43cc173Smrg ;; 810c43cc173Smrg 811c43cc173Smrg -prefer-pic) 812c43cc173Smrg pic_mode=yes 813c43cc173Smrg continue 814c43cc173Smrg ;; 815c43cc173Smrg 816c43cc173Smrg -prefer-non-pic) 817c43cc173Smrg pic_mode=no 818c43cc173Smrg continue 819c43cc173Smrg ;; 820c43cc173Smrg esac 821c43cc173Smrg done 822c43cc173Smrg 823c43cc173Smrg qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"` 824c43cc173Smrg case $qlibobj in 825c43cc173Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 826c43cc173Smrg qlibobj="\"$qlibobj\"" ;; 827c43cc173Smrg esac 828c43cc173Smrg test "X$libobj" != "X$qlibobj" \ 829c43cc173Smrg && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \ 830c43cc173Smrg && $echo "$modename: libobj name \`$libobj' may not contain shell special characters." 831c43cc173Smrg objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` 832c43cc173Smrg xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` 833c43cc173Smrg if test "X$xdir" = "X$obj"; then 834c43cc173Smrg xdir= 835c43cc173Smrg else 836c43cc173Smrg xdir=$xdir/ 837c43cc173Smrg fi 838c43cc173Smrg lobj=${xdir}$objdir/$objname 839c43cc173Smrg 840c43cc173Smrg if test -z "$base_compile"; then 841c43cc173Smrg $echo "$modename: you must specify a compilation command" 1>&2 842c43cc173Smrg $echo "$help" 1>&2 843c43cc173Smrg exit $EXIT_FAILURE 844c43cc173Smrg fi 845c43cc173Smrg 846c43cc173Smrg # Delete any leftover library objects. 847c43cc173Smrg if test "$build_old_libs" = yes; then 848c43cc173Smrg removelist="$obj $lobj $libobj ${libobj}T" 849c43cc173Smrg else 850c43cc173Smrg removelist="$lobj $libobj ${libobj}T" 851c43cc173Smrg fi 852c43cc173Smrg 853c43cc173Smrg $run $rm $removelist 854c43cc173Smrg trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 855c43cc173Smrg 856c43cc173Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 857c43cc173Smrg case $host_os in 858c43cc173Smrg cygwin* | mingw* | pw32* | os2*) 859c43cc173Smrg pic_mode=default 860c43cc173Smrg ;; 861c43cc173Smrg esac 862c43cc173Smrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 863c43cc173Smrg # non-PIC code in shared libraries is not supported 864c43cc173Smrg pic_mode=default 865c43cc173Smrg fi 866c43cc173Smrg 867c43cc173Smrg # Calculate the filename of the output object if compiler does 868c43cc173Smrg # not support -o with -c 869c43cc173Smrg if test "$compiler_c_o" = no; then 870c43cc173Smrg output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} 871c43cc173Smrg lockfile="$output_obj.lock" 872c43cc173Smrg removelist="$removelist $output_obj $lockfile" 873c43cc173Smrg trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 874c43cc173Smrg else 875c43cc173Smrg output_obj= 876c43cc173Smrg need_locks=no 877c43cc173Smrg lockfile= 878c43cc173Smrg fi 879c43cc173Smrg 880c43cc173Smrg # Lock this critical section if it is needed 881c43cc173Smrg # We use this script file to make the link, it avoids creating a new file 882c43cc173Smrg if test "$need_locks" = yes; then 883c43cc173Smrg until $run ln "$progpath" "$lockfile" 2>/dev/null; do 884c43cc173Smrg $show "Waiting for $lockfile to be removed" 885c43cc173Smrg sleep 2 886c43cc173Smrg done 887c43cc173Smrg elif test "$need_locks" = warn; then 888c43cc173Smrg if test -f "$lockfile"; then 889c43cc173Smrg $echo "\ 890c43cc173Smrg*** ERROR, $lockfile exists and contains: 891c43cc173Smrg`cat $lockfile 2>/dev/null` 892c43cc173Smrg 893c43cc173SmrgThis indicates that another process is trying to use the same 894c43cc173Smrgtemporary object file, and libtool could not work around it because 895c43cc173Smrgyour compiler does not support \`-c' and \`-o' together. If you 896c43cc173Smrgrepeat this compilation, it may succeed, by chance, but you had better 897c43cc173Smrgavoid parallel builds (make -j) in this platform, or get a better 898c43cc173Smrgcompiler." 899c43cc173Smrg 900c43cc173Smrg $run $rm $removelist 901c43cc173Smrg exit $EXIT_FAILURE 902c43cc173Smrg fi 903c43cc173Smrg $echo "$srcfile" > "$lockfile" 904c43cc173Smrg fi 905c43cc173Smrg 906c43cc173Smrg if test -n "$fix_srcfile_path"; then 907c43cc173Smrg eval srcfile=\"$fix_srcfile_path\" 908c43cc173Smrg fi 909c43cc173Smrg qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"` 910c43cc173Smrg case $qsrcfile in 911c43cc173Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 912c43cc173Smrg qsrcfile="\"$qsrcfile\"" ;; 913c43cc173Smrg esac 914c43cc173Smrg 915c43cc173Smrg $run $rm "$libobj" "${libobj}T" 916c43cc173Smrg 917c43cc173Smrg # Create a libtool object file (analogous to a ".la" file), 918c43cc173Smrg # but don't create it if we're doing a dry run. 919c43cc173Smrg test -z "$run" && cat > ${libobj}T <<EOF 920c43cc173Smrg# $libobj - a libtool object file 921c43cc173Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP 922c43cc173Smrg# 923c43cc173Smrg# Please DO NOT delete this file! 924c43cc173Smrg# It is necessary for linking the library. 925c43cc173Smrg 926c43cc173Smrg# Name of the PIC object. 927c43cc173SmrgEOF 928c43cc173Smrg 929c43cc173Smrg # Only build a PIC object if we are building libtool libraries. 930c43cc173Smrg if test "$build_libtool_libs" = yes; then 931c43cc173Smrg # Without this assignment, base_compile gets emptied. 932c43cc173Smrg fbsd_hideous_sh_bug=$base_compile 933c43cc173Smrg 934c43cc173Smrg if test "$pic_mode" != no; then 935c43cc173Smrg command="$base_compile $qsrcfile $pic_flag" 936c43cc173Smrg else 937c43cc173Smrg # Don't build PIC code 938c43cc173Smrg command="$base_compile $qsrcfile" 939c43cc173Smrg fi 940c43cc173Smrg 941c43cc173Smrg if test ! -d "${xdir}$objdir"; then 942c43cc173Smrg $show "$mkdir ${xdir}$objdir" 943c43cc173Smrg $run $mkdir ${xdir}$objdir 944c43cc173Smrg exit_status=$? 945c43cc173Smrg if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then 946c43cc173Smrg exit $exit_status 947c43cc173Smrg fi 948c43cc173Smrg fi 949c43cc173Smrg 950c43cc173Smrg if test -z "$output_obj"; then 951c43cc173Smrg # Place PIC objects in $objdir 952c43cc173Smrg command="$command -o $lobj" 953c43cc173Smrg fi 954c43cc173Smrg 955c43cc173Smrg $run $rm "$lobj" "$output_obj" 956c43cc173Smrg 957c43cc173Smrg $show "$command" 958c43cc173Smrg if $run eval "$command"; then : 959c43cc173Smrg else 960c43cc173Smrg test -n "$output_obj" && $run $rm $removelist 961c43cc173Smrg exit $EXIT_FAILURE 962c43cc173Smrg fi 963c43cc173Smrg 964c43cc173Smrg if test "$need_locks" = warn && 965c43cc173Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 966c43cc173Smrg $echo "\ 967c43cc173Smrg*** ERROR, $lockfile contains: 968c43cc173Smrg`cat $lockfile 2>/dev/null` 969c43cc173Smrg 970c43cc173Smrgbut it should contain: 971c43cc173Smrg$srcfile 972c43cc173Smrg 973c43cc173SmrgThis indicates that another process is trying to use the same 974c43cc173Smrgtemporary object file, and libtool could not work around it because 975c43cc173Smrgyour compiler does not support \`-c' and \`-o' together. If you 976c43cc173Smrgrepeat this compilation, it may succeed, by chance, but you had better 977c43cc173Smrgavoid parallel builds (make -j) in this platform, or get a better 978c43cc173Smrgcompiler." 979c43cc173Smrg 980c43cc173Smrg $run $rm $removelist 981c43cc173Smrg exit $EXIT_FAILURE 982c43cc173Smrg fi 983c43cc173Smrg 984c43cc173Smrg # Just move the object if needed, then go on to compile the next one 985c43cc173Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 986c43cc173Smrg $show "$mv $output_obj $lobj" 987c43cc173Smrg if $run $mv $output_obj $lobj; then : 988c43cc173Smrg else 989c43cc173Smrg error=$? 990c43cc173Smrg $run $rm $removelist 991c43cc173Smrg exit $error 992c43cc173Smrg fi 993c43cc173Smrg fi 994c43cc173Smrg 995c43cc173Smrg # Append the name of the PIC object to the libtool object file. 996c43cc173Smrg test -z "$run" && cat >> ${libobj}T <<EOF 997c43cc173Smrgpic_object='$objdir/$objname' 998c43cc173Smrg 999c43cc173SmrgEOF 1000c43cc173Smrg 1001c43cc173Smrg # Allow error messages only from the first compilation. 1002c43cc173Smrg if test "$suppress_opt" = yes; then 1003c43cc173Smrg suppress_output=' >/dev/null 2>&1' 1004c43cc173Smrg fi 1005c43cc173Smrg else 1006c43cc173Smrg # No PIC object so indicate it doesn't exist in the libtool 1007c43cc173Smrg # object file. 1008c43cc173Smrg test -z "$run" && cat >> ${libobj}T <<EOF 1009c43cc173Smrgpic_object=none 1010c43cc173Smrg 1011c43cc173SmrgEOF 1012c43cc173Smrg fi 1013c43cc173Smrg 1014c43cc173Smrg # Only build a position-dependent object if we build old libraries. 1015c43cc173Smrg if test "$build_old_libs" = yes; then 1016c43cc173Smrg if test "$pic_mode" != yes; then 1017c43cc173Smrg # Don't build PIC code 1018c43cc173Smrg command="$base_compile $qsrcfile" 1019c43cc173Smrg else 1020c43cc173Smrg command="$base_compile $qsrcfile $pic_flag" 1021c43cc173Smrg fi 1022c43cc173Smrg if test "$compiler_c_o" = yes; then 1023c43cc173Smrg command="$command -o $obj" 1024c43cc173Smrg fi 1025c43cc173Smrg 1026c43cc173Smrg # Suppress compiler output if we already did a PIC compilation. 1027c43cc173Smrg command="$command$suppress_output" 1028c43cc173Smrg $run $rm "$obj" "$output_obj" 1029c43cc173Smrg $show "$command" 1030c43cc173Smrg if $run eval "$command"; then : 1031c43cc173Smrg else 1032c43cc173Smrg $run $rm $removelist 1033c43cc173Smrg exit $EXIT_FAILURE 1034c43cc173Smrg fi 1035c43cc173Smrg 1036c43cc173Smrg if test "$need_locks" = warn && 1037c43cc173Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 1038c43cc173Smrg $echo "\ 1039c43cc173Smrg*** ERROR, $lockfile contains: 1040c43cc173Smrg`cat $lockfile 2>/dev/null` 1041c43cc173Smrg 1042c43cc173Smrgbut it should contain: 1043c43cc173Smrg$srcfile 1044c43cc173Smrg 1045c43cc173SmrgThis indicates that another process is trying to use the same 1046c43cc173Smrgtemporary object file, and libtool could not work around it because 1047c43cc173Smrgyour compiler does not support \`-c' and \`-o' together. If you 1048c43cc173Smrgrepeat this compilation, it may succeed, by chance, but you had better 1049c43cc173Smrgavoid parallel builds (make -j) in this platform, or get a better 1050c43cc173Smrgcompiler." 1051c43cc173Smrg 1052c43cc173Smrg $run $rm $removelist 1053c43cc173Smrg exit $EXIT_FAILURE 1054c43cc173Smrg fi 1055c43cc173Smrg 1056c43cc173Smrg # Just move the object if needed 1057c43cc173Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 1058c43cc173Smrg $show "$mv $output_obj $obj" 1059c43cc173Smrg if $run $mv $output_obj $obj; then : 1060c43cc173Smrg else 1061c43cc173Smrg error=$? 1062c43cc173Smrg $run $rm $removelist 1063c43cc173Smrg exit $error 1064c43cc173Smrg fi 1065c43cc173Smrg fi 1066c43cc173Smrg 1067c43cc173Smrg # Append the name of the non-PIC object the libtool object file. 1068c43cc173Smrg # Only append if the libtool object file exists. 1069c43cc173Smrg test -z "$run" && cat >> ${libobj}T <<EOF 1070c43cc173Smrg# Name of the non-PIC object. 1071c43cc173Smrgnon_pic_object='$objname' 1072c43cc173Smrg 1073c43cc173SmrgEOF 1074c43cc173Smrg else 1075c43cc173Smrg # Append the name of the non-PIC object the libtool object file. 1076c43cc173Smrg # Only append if the libtool object file exists. 1077c43cc173Smrg test -z "$run" && cat >> ${libobj}T <<EOF 1078c43cc173Smrg# Name of the non-PIC object. 1079c43cc173Smrgnon_pic_object=none 1080c43cc173Smrg 1081c43cc173SmrgEOF 1082c43cc173Smrg fi 1083c43cc173Smrg 1084c43cc173Smrg $run $mv "${libobj}T" "${libobj}" 1085c43cc173Smrg 1086c43cc173Smrg # Unlock the critical section if it was locked 1087c43cc173Smrg if test "$need_locks" != no; then 1088c43cc173Smrg $run $rm "$lockfile" 1089c43cc173Smrg fi 1090c43cc173Smrg 1091c43cc173Smrg exit $EXIT_SUCCESS 1092c43cc173Smrg ;; 1093c43cc173Smrg 1094c43cc173Smrg # libtool link mode 1095c43cc173Smrg link | relink) 1096c43cc173Smrg modename="$modename: link" 1097c43cc173Smrg case $host in 1098c43cc173Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) 1099c43cc173Smrg # It is impossible to link a dll without this setting, and 1100c43cc173Smrg # we shouldn't force the makefile maintainer to figure out 1101c43cc173Smrg # which system we are compiling for in order to pass an extra 1102c43cc173Smrg # flag for every libtool invocation. 1103c43cc173Smrg # allow_undefined=no 1104c43cc173Smrg 1105c43cc173Smrg # FIXME: Unfortunately, there are problems with the above when trying 1106c43cc173Smrg # to make a dll which has undefined symbols, in which case not 1107c43cc173Smrg # even a static library is built. For now, we need to specify 1108c43cc173Smrg # -no-undefined on the libtool link line when we can be certain 1109c43cc173Smrg # that all symbols are satisfied, otherwise we get a static library. 1110c43cc173Smrg allow_undefined=yes 1111c43cc173Smrg ;; 1112c43cc173Smrg *) 1113c43cc173Smrg allow_undefined=yes 1114c43cc173Smrg ;; 1115c43cc173Smrg esac 1116c43cc173Smrg libtool_args="$nonopt" 1117c43cc173Smrg base_compile="$nonopt $@" 1118c43cc173Smrg compile_command="$nonopt" 1119c43cc173Smrg finalize_command="$nonopt" 1120c43cc173Smrg 1121c43cc173Smrg compile_rpath= 1122c43cc173Smrg finalize_rpath= 1123c43cc173Smrg compile_shlibpath= 1124c43cc173Smrg finalize_shlibpath= 1125c43cc173Smrg convenience= 1126c43cc173Smrg old_convenience= 1127c43cc173Smrg deplibs= 1128c43cc173Smrg old_deplibs= 1129c43cc173Smrg compiler_flags= 1130c43cc173Smrg linker_flags= 1131c43cc173Smrg dllsearchpath= 1132c43cc173Smrg lib_search_path=`pwd` 1133c43cc173Smrg inst_prefix_dir= 1134c43cc173Smrg 1135c43cc173Smrg avoid_version=no 1136c43cc173Smrg dlfiles= 1137c43cc173Smrg dlprefiles= 1138c43cc173Smrg dlself=no 1139c43cc173Smrg export_dynamic=no 1140c43cc173Smrg export_symbols= 1141c43cc173Smrg export_symbols_regex= 1142c43cc173Smrg generated= 1143c43cc173Smrg libobjs= 1144c43cc173Smrg ltlibs= 1145c43cc173Smrg module=no 1146c43cc173Smrg no_install=no 1147c43cc173Smrg objs= 1148c43cc173Smrg non_pic_objects= 1149c43cc173Smrg notinst_path= # paths that contain not-installed libtool libraries 1150c43cc173Smrg precious_files_regex= 1151c43cc173Smrg prefer_static_libs=no 1152c43cc173Smrg preload=no 1153c43cc173Smrg prev= 1154c43cc173Smrg prevarg= 1155c43cc173Smrg release= 1156c43cc173Smrg rpath= 1157c43cc173Smrg xrpath= 1158c43cc173Smrg perm_rpath= 1159c43cc173Smrg temp_rpath= 1160c43cc173Smrg thread_safe=no 1161c43cc173Smrg vinfo= 1162c43cc173Smrg vinfo_number=no 1163c43cc173Smrg 1164c43cc173Smrg func_infer_tag $base_compile 1165c43cc173Smrg 1166c43cc173Smrg # We need to know -static, to get the right output filenames. 1167c43cc173Smrg for arg 1168c43cc173Smrg do 1169c43cc173Smrg case $arg in 1170c43cc173Smrg -all-static | -static) 1171c43cc173Smrg if test "X$arg" = "X-all-static"; then 1172c43cc173Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 1173c43cc173Smrg $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 1174c43cc173Smrg fi 1175c43cc173Smrg if test -n "$link_static_flag"; then 1176c43cc173Smrg dlopen_self=$dlopen_self_static 1177c43cc173Smrg fi 1178c43cc173Smrg prefer_static_libs=yes 1179c43cc173Smrg else 1180c43cc173Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 1181c43cc173Smrg dlopen_self=$dlopen_self_static 1182c43cc173Smrg fi 1183c43cc173Smrg prefer_static_libs=built 1184c43cc173Smrg fi 1185c43cc173Smrg build_libtool_libs=no 1186c43cc173Smrg build_old_libs=yes 1187c43cc173Smrg break 1188c43cc173Smrg ;; 1189c43cc173Smrg esac 1190c43cc173Smrg done 1191c43cc173Smrg 1192c43cc173Smrg # See if our shared archives depend on static archives. 1193c43cc173Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 1194c43cc173Smrg 1195c43cc173Smrg # Go through the arguments, transforming them on the way. 1196c43cc173Smrg while test "$#" -gt 0; do 1197c43cc173Smrg arg="$1" 1198c43cc173Smrg shift 1199c43cc173Smrg case $arg in 1200c43cc173Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1201c43cc173Smrg qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test 1202c43cc173Smrg ;; 1203c43cc173Smrg *) qarg=$arg ;; 1204c43cc173Smrg esac 1205c43cc173Smrg libtool_args="$libtool_args $qarg" 1206c43cc173Smrg 1207c43cc173Smrg # If the previous option needs an argument, assign it. 1208c43cc173Smrg if test -n "$prev"; then 1209c43cc173Smrg case $prev in 1210c43cc173Smrg output) 1211c43cc173Smrg compile_command="$compile_command @OUTPUT@" 1212c43cc173Smrg finalize_command="$finalize_command @OUTPUT@" 1213c43cc173Smrg ;; 1214c43cc173Smrg esac 1215c43cc173Smrg 1216c43cc173Smrg case $prev in 1217c43cc173Smrg dlfiles|dlprefiles) 1218c43cc173Smrg if test "$preload" = no; then 1219c43cc173Smrg # Add the symbol object into the linking commands. 1220c43cc173Smrg compile_command="$compile_command @SYMFILE@" 1221c43cc173Smrg finalize_command="$finalize_command @SYMFILE@" 1222c43cc173Smrg preload=yes 1223c43cc173Smrg fi 1224c43cc173Smrg case $arg in 1225c43cc173Smrg *.la | *.lo) ;; # We handle these cases below. 1226c43cc173Smrg force) 1227c43cc173Smrg if test "$dlself" = no; then 1228c43cc173Smrg dlself=needless 1229c43cc173Smrg export_dynamic=yes 1230c43cc173Smrg fi 1231c43cc173Smrg prev= 1232c43cc173Smrg continue 1233c43cc173Smrg ;; 1234c43cc173Smrg self) 1235c43cc173Smrg if test "$prev" = dlprefiles; then 1236c43cc173Smrg dlself=yes 1237c43cc173Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 1238c43cc173Smrg dlself=yes 1239c43cc173Smrg else 1240c43cc173Smrg dlself=needless 1241c43cc173Smrg export_dynamic=yes 1242c43cc173Smrg fi 1243c43cc173Smrg prev= 1244c43cc173Smrg continue 1245c43cc173Smrg ;; 1246c43cc173Smrg *) 1247c43cc173Smrg if test "$prev" = dlfiles; then 1248c43cc173Smrg dlfiles="$dlfiles $arg" 1249c43cc173Smrg else 1250c43cc173Smrg dlprefiles="$dlprefiles $arg" 1251c43cc173Smrg fi 1252c43cc173Smrg prev= 1253c43cc173Smrg continue 1254c43cc173Smrg ;; 1255c43cc173Smrg esac 1256c43cc173Smrg ;; 1257c43cc173Smrg expsyms) 1258c43cc173Smrg export_symbols="$arg" 1259c43cc173Smrg if test ! -f "$arg"; then 1260c43cc173Smrg $echo "$modename: symbol file \`$arg' does not exist" 1261c43cc173Smrg exit $EXIT_FAILURE 1262c43cc173Smrg fi 1263c43cc173Smrg prev= 1264c43cc173Smrg continue 1265c43cc173Smrg ;; 1266c43cc173Smrg expsyms_regex) 1267c43cc173Smrg export_symbols_regex="$arg" 1268c43cc173Smrg prev= 1269c43cc173Smrg continue 1270c43cc173Smrg ;; 1271c43cc173Smrg inst_prefix) 1272c43cc173Smrg inst_prefix_dir="$arg" 1273c43cc173Smrg prev= 1274c43cc173Smrg continue 1275c43cc173Smrg ;; 1276c43cc173Smrg precious_regex) 1277c43cc173Smrg precious_files_regex="$arg" 1278c43cc173Smrg prev= 1279c43cc173Smrg continue 1280c43cc173Smrg ;; 1281c43cc173Smrg release) 1282c43cc173Smrg release="-$arg" 1283c43cc173Smrg prev= 1284c43cc173Smrg continue 1285c43cc173Smrg ;; 1286c43cc173Smrg objectlist) 1287c43cc173Smrg if test -f "$arg"; then 1288c43cc173Smrg save_arg=$arg 1289c43cc173Smrg moreargs= 1290c43cc173Smrg for fil in `cat $save_arg` 1291c43cc173Smrg do 1292c43cc173Smrg# moreargs="$moreargs $fil" 1293c43cc173Smrg arg=$fil 1294c43cc173Smrg # A libtool-controlled object. 1295c43cc173Smrg 1296c43cc173Smrg # Check to see that this really is a libtool object. 1297c43cc173Smrg if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then 1298c43cc173Smrg pic_object= 1299c43cc173Smrg non_pic_object= 1300c43cc173Smrg 1301c43cc173Smrg # Read the .lo file 1302c43cc173Smrg # If there is no directory component, then add one. 1303c43cc173Smrg case $arg in 1304c43cc173Smrg */* | *\\*) . $arg ;; 1305c43cc173Smrg *) . ./$arg ;; 1306c43cc173Smrg esac 1307c43cc173Smrg 1308c43cc173Smrg if test -z "$pic_object" || \ 1309c43cc173Smrg test -z "$non_pic_object" || 1310c43cc173Smrg test "$pic_object" = none && \ 1311c43cc173Smrg test "$non_pic_object" = none; then 1312c43cc173Smrg $echo "$modename: cannot find name of object for \`$arg'" 1>&2 1313c43cc173Smrg exit $EXIT_FAILURE 1314c43cc173Smrg fi 1315c43cc173Smrg 1316c43cc173Smrg # Extract subdirectory from the argument. 1317c43cc173Smrg xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` 1318c43cc173Smrg if test "X$xdir" = "X$arg"; then 1319c43cc173Smrg xdir= 1320c43cc173Smrg else 1321c43cc173Smrg xdir="$xdir/" 1322c43cc173Smrg fi 1323c43cc173Smrg 1324c43cc173Smrg if test "$pic_object" != none; then 1325c43cc173Smrg # Prepend the subdirectory the object is found in. 1326c43cc173Smrg pic_object="$xdir$pic_object" 1327c43cc173Smrg 1328c43cc173Smrg if test "$prev" = dlfiles; then 1329c43cc173Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 1330c43cc173Smrg dlfiles="$dlfiles $pic_object" 1331c43cc173Smrg prev= 1332c43cc173Smrg continue 1333c43cc173Smrg else 1334c43cc173Smrg # If libtool objects are unsupported, then we need to preload. 1335c43cc173Smrg prev=dlprefiles 1336c43cc173Smrg fi 1337c43cc173Smrg fi 1338c43cc173Smrg 1339c43cc173Smrg # CHECK ME: I think I busted this. -Ossama 1340c43cc173Smrg if test "$prev" = dlprefiles; then 1341c43cc173Smrg # Preload the old-style object. 1342c43cc173Smrg dlprefiles="$dlprefiles $pic_object" 1343c43cc173Smrg prev= 1344c43cc173Smrg fi 1345c43cc173Smrg 1346c43cc173Smrg # A PIC object. 1347c43cc173Smrg libobjs="$libobjs $pic_object" 1348c43cc173Smrg arg="$pic_object" 1349c43cc173Smrg fi 1350c43cc173Smrg 1351c43cc173Smrg # Non-PIC object. 1352c43cc173Smrg if test "$non_pic_object" != none; then 1353c43cc173Smrg # Prepend the subdirectory the object is found in. 1354c43cc173Smrg non_pic_object="$xdir$non_pic_object" 1355c43cc173Smrg 1356c43cc173Smrg # A standard non-PIC object 1357c43cc173Smrg non_pic_objects="$non_pic_objects $non_pic_object" 1358c43cc173Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 1359c43cc173Smrg arg="$non_pic_object" 1360c43cc173Smrg fi 1361c43cc173Smrg else 1362c43cc173Smrg # If the PIC object exists, use it instead. 1363c43cc173Smrg # $xdir was prepended to $pic_object above. 1364c43cc173Smrg non_pic_object="$pic_object" 1365c43cc173Smrg non_pic_objects="$non_pic_objects $non_pic_object" 1366c43cc173Smrg fi 1367c43cc173Smrg else 1368c43cc173Smrg # Only an error if not doing a dry-run. 1369c43cc173Smrg if test -z "$run"; then 1370c43cc173Smrg $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 1371c43cc173Smrg exit $EXIT_FAILURE 1372c43cc173Smrg else 1373c43cc173Smrg # Dry-run case. 1374c43cc173Smrg 1375c43cc173Smrg # Extract subdirectory from the argument. 1376c43cc173Smrg xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` 1377c43cc173Smrg if test "X$xdir" = "X$arg"; then 1378c43cc173Smrg xdir= 1379c43cc173Smrg else 1380c43cc173Smrg xdir="$xdir/" 1381c43cc173Smrg fi 1382c43cc173Smrg 1383c43cc173Smrg pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` 1384c43cc173Smrg non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` 1385c43cc173Smrg libobjs="$libobjs $pic_object" 1386c43cc173Smrg non_pic_objects="$non_pic_objects $non_pic_object" 1387c43cc173Smrg fi 1388c43cc173Smrg fi 1389c43cc173Smrg done 1390c43cc173Smrg else 1391c43cc173Smrg $echo "$modename: link input file \`$save_arg' does not exist" 1392c43cc173Smrg exit $EXIT_FAILURE 1393c43cc173Smrg fi 1394c43cc173Smrg arg=$save_arg 1395c43cc173Smrg prev= 1396c43cc173Smrg continue 1397c43cc173Smrg ;; 1398c43cc173Smrg rpath | xrpath) 1399c43cc173Smrg # We need an absolute path. 1400c43cc173Smrg case $arg in 1401c43cc173Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 1402c43cc173Smrg *) 1403c43cc173Smrg $echo "$modename: only absolute run-paths are allowed" 1>&2 1404c43cc173Smrg exit $EXIT_FAILURE 1405c43cc173Smrg ;; 1406c43cc173Smrg esac 1407c43cc173Smrg if test "$prev" = rpath; then 1408c43cc173Smrg case "$rpath " in 1409c43cc173Smrg *" $arg "*) ;; 1410c43cc173Smrg *) rpath="$rpath $arg" ;; 1411c43cc173Smrg esac 1412c43cc173Smrg else 1413c43cc173Smrg case "$xrpath " in 1414c43cc173Smrg *" $arg "*) ;; 1415c43cc173Smrg *) xrpath="$xrpath $arg" ;; 1416c43cc173Smrg esac 1417c43cc173Smrg fi 1418c43cc173Smrg prev= 1419c43cc173Smrg continue 1420c43cc173Smrg ;; 1421c43cc173Smrg xcompiler) 1422c43cc173Smrg compiler_flags="$compiler_flags $qarg" 1423c43cc173Smrg prev= 1424c43cc173Smrg compile_command="$compile_command $qarg" 1425c43cc173Smrg finalize_command="$finalize_command $qarg" 1426c43cc173Smrg continue 1427c43cc173Smrg ;; 1428c43cc173Smrg xlinker) 1429c43cc173Smrg linker_flags="$linker_flags $qarg" 1430c43cc173Smrg compiler_flags="$compiler_flags $wl$qarg" 1431c43cc173Smrg prev= 1432c43cc173Smrg compile_command="$compile_command $wl$qarg" 1433c43cc173Smrg finalize_command="$finalize_command $wl$qarg" 1434c43cc173Smrg continue 1435c43cc173Smrg ;; 1436c43cc173Smrg xcclinker) 1437c43cc173Smrg linker_flags="$linker_flags $qarg" 1438c43cc173Smrg compiler_flags="$compiler_flags $qarg" 1439c43cc173Smrg prev= 1440c43cc173Smrg compile_command="$compile_command $qarg" 1441c43cc173Smrg finalize_command="$finalize_command $qarg" 1442c43cc173Smrg continue 1443c43cc173Smrg ;; 1444c43cc173Smrg shrext) 1445c43cc173Smrg shrext_cmds="$arg" 1446c43cc173Smrg prev= 1447c43cc173Smrg continue 1448c43cc173Smrg ;; 1449c43cc173Smrg darwin_framework|darwin_framework_skip) 1450c43cc173Smrg test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg" 1451c43cc173Smrg compile_command="$compile_command $arg" 1452c43cc173Smrg finalize_command="$finalize_command $arg" 1453c43cc173Smrg prev= 1454c43cc173Smrg continue 1455c43cc173Smrg ;; 1456c43cc173Smrg *) 1457c43cc173Smrg eval "$prev=\"\$arg\"" 1458c43cc173Smrg prev= 1459c43cc173Smrg continue 1460c43cc173Smrg ;; 1461c43cc173Smrg esac 1462c43cc173Smrg fi # test -n "$prev" 1463c43cc173Smrg 1464c43cc173Smrg prevarg="$arg" 1465c43cc173Smrg 1466c43cc173Smrg case $arg in 1467c43cc173Smrg -all-static) 1468c43cc173Smrg if test -n "$link_static_flag"; then 1469c43cc173Smrg compile_command="$compile_command $link_static_flag" 1470c43cc173Smrg finalize_command="$finalize_command $link_static_flag" 1471c43cc173Smrg fi 1472c43cc173Smrg continue 1473c43cc173Smrg ;; 1474c43cc173Smrg 1475c43cc173Smrg -allow-undefined) 1476c43cc173Smrg # FIXME: remove this flag sometime in the future. 1477c43cc173Smrg $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 1478c43cc173Smrg continue 1479c43cc173Smrg ;; 1480c43cc173Smrg 1481c43cc173Smrg -avoid-version) 1482c43cc173Smrg avoid_version=yes 1483c43cc173Smrg continue 1484c43cc173Smrg ;; 1485c43cc173Smrg 1486c43cc173Smrg -dlopen) 1487c43cc173Smrg prev=dlfiles 1488c43cc173Smrg continue 1489c43cc173Smrg ;; 1490c43cc173Smrg 1491c43cc173Smrg -dlpreopen) 1492c43cc173Smrg prev=dlprefiles 1493c43cc173Smrg continue 1494c43cc173Smrg ;; 1495c43cc173Smrg 1496c43cc173Smrg -export-dynamic) 1497c43cc173Smrg export_dynamic=yes 1498c43cc173Smrg continue 1499c43cc173Smrg ;; 1500c43cc173Smrg 1501c43cc173Smrg -export-symbols | -export-symbols-regex) 1502c43cc173Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 1503c43cc173Smrg $echo "$modename: more than one -exported-symbols argument is not allowed" 1504c43cc173Smrg exit $EXIT_FAILURE 1505c43cc173Smrg fi 1506c43cc173Smrg if test "X$arg" = "X-export-symbols"; then 1507c43cc173Smrg prev=expsyms 1508c43cc173Smrg else 1509c43cc173Smrg prev=expsyms_regex 1510c43cc173Smrg fi 1511c43cc173Smrg continue 1512c43cc173Smrg ;; 1513c43cc173Smrg 1514c43cc173Smrg -framework|-arch|-isysroot) 1515c43cc173Smrg case " $CC " in 1516c43cc173Smrg *" ${arg} ${1} "* | *" ${arg} ${1} "*) 1517c43cc173Smrg prev=darwin_framework_skip ;; 1518c43cc173Smrg *) compiler_flags="$compiler_flags $arg" 1519c43cc173Smrg prev=darwin_framework ;; 1520c43cc173Smrg esac 1521c43cc173Smrg compile_command="$compile_command $arg" 1522c43cc173Smrg finalize_command="$finalize_command $arg" 1523c43cc173Smrg continue 1524c43cc173Smrg ;; 1525c43cc173Smrg 1526c43cc173Smrg -inst-prefix-dir) 1527c43cc173Smrg prev=inst_prefix 1528c43cc173Smrg continue 1529c43cc173Smrg ;; 1530c43cc173Smrg 1531c43cc173Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 1532c43cc173Smrg # so, if we see these flags be careful not to treat them like -L 1533c43cc173Smrg -L[A-Z][A-Z]*:*) 1534c43cc173Smrg case $with_gcc/$host in 1535c43cc173Smrg no/*-*-irix* | /*-*-irix*) 1536c43cc173Smrg compile_command="$compile_command $arg" 1537c43cc173Smrg finalize_command="$finalize_command $arg" 1538c43cc173Smrg ;; 1539c43cc173Smrg esac 1540c43cc173Smrg continue 1541c43cc173Smrg ;; 1542c43cc173Smrg 1543c43cc173Smrg -L*) 1544c43cc173Smrg dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` 1545c43cc173Smrg # We need an absolute path. 1546c43cc173Smrg case $dir in 1547c43cc173Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 1548c43cc173Smrg *) 1549c43cc173Smrg absdir=`cd "$dir" && pwd` 1550c43cc173Smrg if test -z "$absdir"; then 1551c43cc173Smrg $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 1552c43cc173Smrg absdir="$dir" 1553c43cc173Smrg notinst_path="$notinst_path $dir" 1554c43cc173Smrg fi 1555c43cc173Smrg dir="$absdir" 1556c43cc173Smrg ;; 1557c43cc173Smrg esac 1558c43cc173Smrg case "$deplibs " in 1559c43cc173Smrg *" -L$dir "*) ;; 1560c43cc173Smrg *) 1561c43cc173Smrg deplibs="$deplibs -L$dir" 1562c43cc173Smrg lib_search_path="$lib_search_path $dir" 1563c43cc173Smrg ;; 1564c43cc173Smrg esac 1565c43cc173Smrg case $host in 1566c43cc173Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) 1567c43cc173Smrg testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'` 1568c43cc173Smrg case :$dllsearchpath: in 1569c43cc173Smrg *":$dir:"*) ;; 1570c43cc173Smrg *) dllsearchpath="$dllsearchpath:$dir";; 1571c43cc173Smrg esac 1572c43cc173Smrg case :$dllsearchpath: in 1573c43cc173Smrg *":$testbindir:"*) ;; 1574c43cc173Smrg *) dllsearchpath="$dllsearchpath:$testbindir";; 1575c43cc173Smrg esac 1576c43cc173Smrg ;; 1577c43cc173Smrg esac 1578c43cc173Smrg continue 1579c43cc173Smrg ;; 1580c43cc173Smrg 1581c43cc173Smrg -l*) 1582c43cc173Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 1583c43cc173Smrg case $host in 1584c43cc173Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*) 1585c43cc173Smrg # These systems don't actually have a C or math library (as such) 1586c43cc173Smrg continue 1587c43cc173Smrg ;; 1588c43cc173Smrg *-*-os2*) 1589c43cc173Smrg # These systems don't actually have a C library (as such) 1590c43cc173Smrg test "X$arg" = "X-lc" && continue 1591c43cc173Smrg ;; 1592c43cc173Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 1593c43cc173Smrg # Do not include libc due to us having libc/libc_r. 1594c43cc173Smrg test "X$arg" = "X-lc" && continue 1595c43cc173Smrg ;; 1596c43cc173Smrg *-*-rhapsody* | *-*-darwin1.[012]) 1597c43cc173Smrg # Rhapsody C and math libraries are in the System framework 1598c43cc173Smrg deplibs="$deplibs -framework System" 1599c43cc173Smrg continue 1600c43cc173Smrg ;; 1601c43cc173Smrg *-*-sco3.2v5* | *-*-sco5v6*) 1602c43cc173Smrg # Causes problems with __ctype 1603c43cc173Smrg test "X$arg" = "X-lc" && continue 1604c43cc173Smrg ;; 1605c43cc173Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 1606c43cc173Smrg # Compiler inserts libc in the correct place for threads to work 1607c43cc173Smrg test "X$arg" = "X-lc" && continue 1608c43cc173Smrg ;; 1609c43cc173Smrg esac 1610c43cc173Smrg elif test "X$arg" = "X-lc_r"; then 1611c43cc173Smrg case $host in 1612c43cc173Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 1613c43cc173Smrg # Do not include libc_r directly, use -pthread flag. 1614c43cc173Smrg continue 1615c43cc173Smrg ;; 1616c43cc173Smrg esac 1617c43cc173Smrg fi 1618c43cc173Smrg deplibs="$deplibs $arg" 1619c43cc173Smrg continue 1620c43cc173Smrg ;; 1621c43cc173Smrg 1622c43cc173Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 1623c43cc173Smrg # classes, name mangling, and exception handling. 1624c43cc173Smrg -model) 1625c43cc173Smrg compile_command="$compile_command $arg" 1626c43cc173Smrg compiler_flags="$compiler_flags $arg" 1627c43cc173Smrg finalize_command="$finalize_command $arg" 1628c43cc173Smrg prev=xcompiler 1629c43cc173Smrg continue 1630c43cc173Smrg ;; 1631c43cc173Smrg 1632c43cc173Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) 1633c43cc173Smrg compiler_flags="$compiler_flags $arg" 1634c43cc173Smrg compile_command="$compile_command $arg" 1635c43cc173Smrg finalize_command="$finalize_command $arg" 1636c43cc173Smrg deplibs="$deplibs $arg" 1637c43cc173Smrg continue 1638c43cc173Smrg ;; 1639c43cc173Smrg 1640c43cc173Smrg -module) 1641c43cc173Smrg module=yes 1642c43cc173Smrg continue 1643c43cc173Smrg ;; 1644c43cc173Smrg 1645c43cc173Smrg # -64, -mips[0-9] enable 64-bit mode on the SGI compiler 1646c43cc173Smrg # -r[0-9][0-9]* specifies the processor on the SGI compiler 1647c43cc173Smrg # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler 1648c43cc173Smrg # +DA*, +DD* enable 64-bit mode on the HP compiler 1649c43cc173Smrg # -q* pass through compiler args for the IBM compiler 1650c43cc173Smrg # -m* pass through architecture-specific compiler args for GCC 1651c43cc173Smrg # -m*, -t[45]*, -txscale* pass through architecture-specific 1652c43cc173Smrg # compiler args for GCC 1653c43cc173Smrg # -pg pass through profiling flag for GCC 1654c43cc173Smrg # @file GCC response files 1655c43cc173Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \ 1656c43cc173Smrg -t[45]*|-txscale*|@*) 1657c43cc173Smrg 1658c43cc173Smrg # Unknown arguments in both finalize_command and compile_command need 1659c43cc173Smrg # to be aesthetically quoted because they are evaled later. 1660c43cc173Smrg arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` 1661c43cc173Smrg case $arg in 1662c43cc173Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1663c43cc173Smrg arg="\"$arg\"" 1664c43cc173Smrg ;; 1665c43cc173Smrg esac 1666c43cc173Smrg compile_command="$compile_command $arg" 1667c43cc173Smrg finalize_command="$finalize_command $arg" 1668c43cc173Smrg compiler_flags="$compiler_flags $arg" 1669c43cc173Smrg continue 1670c43cc173Smrg ;; 1671c43cc173Smrg 1672c43cc173Smrg -shrext) 1673c43cc173Smrg prev=shrext 1674c43cc173Smrg continue 1675c43cc173Smrg ;; 1676c43cc173Smrg 1677c43cc173Smrg -no-fast-install) 1678c43cc173Smrg fast_install=no 1679c43cc173Smrg continue 1680c43cc173Smrg ;; 1681c43cc173Smrg 1682c43cc173Smrg -no-install) 1683c43cc173Smrg case $host in 1684c43cc173Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) 1685c43cc173Smrg # The PATH hackery in wrapper scripts is required on Windows 1686c43cc173Smrg # in order for the loader to find any dlls it needs. 1687c43cc173Smrg $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 1688c43cc173Smrg $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 1689c43cc173Smrg fast_install=no 1690c43cc173Smrg ;; 1691c43cc173Smrg *) no_install=yes ;; 1692c43cc173Smrg esac 1693c43cc173Smrg continue 1694c43cc173Smrg ;; 1695c43cc173Smrg 1696c43cc173Smrg -no-undefined) 1697c43cc173Smrg allow_undefined=no 1698c43cc173Smrg continue 1699c43cc173Smrg ;; 1700c43cc173Smrg 1701c43cc173Smrg -objectlist) 1702c43cc173Smrg prev=objectlist 1703c43cc173Smrg continue 1704c43cc173Smrg ;; 1705c43cc173Smrg 1706c43cc173Smrg -o) prev=output ;; 1707c43cc173Smrg 1708c43cc173Smrg -precious-files-regex) 1709c43cc173Smrg prev=precious_regex 1710c43cc173Smrg continue 1711c43cc173Smrg ;; 1712c43cc173Smrg 1713c43cc173Smrg -release) 1714c43cc173Smrg prev=release 1715c43cc173Smrg continue 1716c43cc173Smrg ;; 1717c43cc173Smrg 1718c43cc173Smrg -rpath) 1719c43cc173Smrg prev=rpath 1720c43cc173Smrg continue 1721c43cc173Smrg ;; 1722c43cc173Smrg 1723c43cc173Smrg -R) 1724c43cc173Smrg prev=xrpath 1725c43cc173Smrg continue 1726c43cc173Smrg ;; 1727c43cc173Smrg 1728c43cc173Smrg -R*) 1729c43cc173Smrg dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` 1730c43cc173Smrg # We need an absolute path. 1731c43cc173Smrg case $dir in 1732c43cc173Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 1733c43cc173Smrg *) 1734c43cc173Smrg $echo "$modename: only absolute run-paths are allowed" 1>&2 1735c43cc173Smrg exit $EXIT_FAILURE 1736c43cc173Smrg ;; 1737c43cc173Smrg esac 1738c43cc173Smrg case "$xrpath " in 1739c43cc173Smrg *" $dir "*) ;; 1740c43cc173Smrg *) xrpath="$xrpath $dir" ;; 1741c43cc173Smrg esac 1742c43cc173Smrg continue 1743c43cc173Smrg ;; 1744c43cc173Smrg 1745c43cc173Smrg -static) 1746c43cc173Smrg # The effects of -static are defined in a previous loop. 1747c43cc173Smrg # We used to do the same as -all-static on platforms that 1748c43cc173Smrg # didn't have a PIC flag, but the assumption that the effects 1749c43cc173Smrg # would be equivalent was wrong. It would break on at least 1750c43cc173Smrg # Digital Unix and AIX. 1751c43cc173Smrg continue 1752c43cc173Smrg ;; 1753c43cc173Smrg 1754c43cc173Smrg -thread-safe) 1755c43cc173Smrg thread_safe=yes 1756c43cc173Smrg continue 1757c43cc173Smrg ;; 1758c43cc173Smrg 1759c43cc173Smrg -version-info) 1760c43cc173Smrg prev=vinfo 1761c43cc173Smrg continue 1762c43cc173Smrg ;; 1763c43cc173Smrg -version-number) 1764c43cc173Smrg prev=vinfo 1765c43cc173Smrg vinfo_number=yes 1766c43cc173Smrg continue 1767c43cc173Smrg ;; 1768c43cc173Smrg 1769c43cc173Smrg -Wc,*) 1770c43cc173Smrg args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` 1771c43cc173Smrg arg= 1772c43cc173Smrg save_ifs="$IFS"; IFS=',' 1773c43cc173Smrg for flag in $args; do 1774c43cc173Smrg IFS="$save_ifs" 1775c43cc173Smrg case $flag in 1776c43cc173Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1777c43cc173Smrg flag="\"$flag\"" 1778c43cc173Smrg ;; 1779c43cc173Smrg esac 1780c43cc173Smrg arg="$arg $wl$flag" 1781c43cc173Smrg compiler_flags="$compiler_flags $flag" 1782c43cc173Smrg done 1783c43cc173Smrg IFS="$save_ifs" 1784c43cc173Smrg arg=`$echo "X$arg" | $Xsed -e "s/^ //"` 1785c43cc173Smrg ;; 1786c43cc173Smrg 1787c43cc173Smrg -Wl,*) 1788c43cc173Smrg args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` 1789c43cc173Smrg arg= 1790c43cc173Smrg save_ifs="$IFS"; IFS=',' 1791c43cc173Smrg for flag in $args; do 1792c43cc173Smrg IFS="$save_ifs" 1793c43cc173Smrg case $flag in 1794c43cc173Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1795c43cc173Smrg flag="\"$flag\"" 1796c43cc173Smrg ;; 1797c43cc173Smrg esac 1798c43cc173Smrg arg="$arg $wl$flag" 1799c43cc173Smrg compiler_flags="$compiler_flags $wl$flag" 1800c43cc173Smrg linker_flags="$linker_flags $flag" 1801c43cc173Smrg done 1802c43cc173Smrg IFS="$save_ifs" 1803c43cc173Smrg arg=`$echo "X$arg" | $Xsed -e "s/^ //"` 1804c43cc173Smrg ;; 1805c43cc173Smrg 1806c43cc173Smrg -Xcompiler) 1807c43cc173Smrg prev=xcompiler 1808c43cc173Smrg continue 1809c43cc173Smrg ;; 1810c43cc173Smrg 1811c43cc173Smrg -Xlinker) 1812c43cc173Smrg prev=xlinker 1813c43cc173Smrg continue 1814c43cc173Smrg ;; 1815c43cc173Smrg 1816c43cc173Smrg -XCClinker) 1817c43cc173Smrg prev=xcclinker 1818c43cc173Smrg continue 1819c43cc173Smrg ;; 1820c43cc173Smrg 1821c43cc173Smrg # Some other compiler flag. 1822c43cc173Smrg -* | +*) 1823c43cc173Smrg # Unknown arguments in both finalize_command and compile_command need 1824c43cc173Smrg # to be aesthetically quoted because they are evaled later. 1825c43cc173Smrg arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` 1826c43cc173Smrg case $arg in 1827c43cc173Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1828c43cc173Smrg arg="\"$arg\"" 1829c43cc173Smrg ;; 1830c43cc173Smrg esac 1831c43cc173Smrg ;; 1832c43cc173Smrg 1833c43cc173Smrg *.$objext) 1834c43cc173Smrg # A standard object. 1835c43cc173Smrg objs="$objs $arg" 1836c43cc173Smrg ;; 1837c43cc173Smrg 1838c43cc173Smrg *.lo) 1839c43cc173Smrg # A libtool-controlled object. 1840c43cc173Smrg 1841c43cc173Smrg # Check to see that this really is a libtool object. 1842c43cc173Smrg if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then 1843c43cc173Smrg pic_object= 1844c43cc173Smrg non_pic_object= 1845c43cc173Smrg 1846c43cc173Smrg # Read the .lo file 1847c43cc173Smrg # If there is no directory component, then add one. 1848c43cc173Smrg case $arg in 1849c43cc173Smrg */* | *\\*) . $arg ;; 1850c43cc173Smrg *) . ./$arg ;; 1851c43cc173Smrg esac 1852c43cc173Smrg 1853c43cc173Smrg if test -z "$pic_object" || \ 1854c43cc173Smrg test -z "$non_pic_object" || 1855c43cc173Smrg test "$pic_object" = none && \ 1856c43cc173Smrg test "$non_pic_object" = none; then 1857c43cc173Smrg $echo "$modename: cannot find name of object for \`$arg'" 1>&2 1858c43cc173Smrg exit $EXIT_FAILURE 1859c43cc173Smrg fi 1860c43cc173Smrg 1861c43cc173Smrg # Extract subdirectory from the argument. 1862c43cc173Smrg xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` 1863c43cc173Smrg if test "X$xdir" = "X$arg"; then 1864c43cc173Smrg xdir= 1865c43cc173Smrg else 1866c43cc173Smrg xdir="$xdir/" 1867c43cc173Smrg fi 1868c43cc173Smrg 1869c43cc173Smrg if test "$pic_object" != none; then 1870c43cc173Smrg # Prepend the subdirectory the object is found in. 1871c43cc173Smrg pic_object="$xdir$pic_object" 1872c43cc173Smrg 1873c43cc173Smrg if test "$prev" = dlfiles; then 1874c43cc173Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 1875c43cc173Smrg dlfiles="$dlfiles $pic_object" 1876c43cc173Smrg prev= 1877c43cc173Smrg continue 1878c43cc173Smrg else 1879c43cc173Smrg # If libtool objects are unsupported, then we need to preload. 1880c43cc173Smrg prev=dlprefiles 1881c43cc173Smrg fi 1882c43cc173Smrg fi 1883c43cc173Smrg 1884c43cc173Smrg # CHECK ME: I think I busted this. -Ossama 1885c43cc173Smrg if test "$prev" = dlprefiles; then 1886c43cc173Smrg # Preload the old-style object. 1887c43cc173Smrg dlprefiles="$dlprefiles $pic_object" 1888c43cc173Smrg prev= 1889c43cc173Smrg fi 1890c43cc173Smrg 1891c43cc173Smrg # A PIC object. 1892c43cc173Smrg libobjs="$libobjs $pic_object" 1893c43cc173Smrg arg="$pic_object" 1894c43cc173Smrg fi 1895c43cc173Smrg 1896c43cc173Smrg # Non-PIC object. 1897c43cc173Smrg if test "$non_pic_object" != none; then 1898c43cc173Smrg # Prepend the subdirectory the object is found in. 1899c43cc173Smrg non_pic_object="$xdir$non_pic_object" 1900c43cc173Smrg 1901c43cc173Smrg # A standard non-PIC object 1902c43cc173Smrg non_pic_objects="$non_pic_objects $non_pic_object" 1903c43cc173Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 1904c43cc173Smrg arg="$non_pic_object" 1905c43cc173Smrg fi 1906c43cc173Smrg else 1907c43cc173Smrg # If the PIC object exists, use it instead. 1908c43cc173Smrg # $xdir was prepended to $pic_object above. 1909c43cc173Smrg non_pic_object="$pic_object" 1910c43cc173Smrg non_pic_objects="$non_pic_objects $non_pic_object" 1911c43cc173Smrg fi 1912c43cc173Smrg else 1913c43cc173Smrg # Only an error if not doing a dry-run. 1914c43cc173Smrg if test -z "$run"; then 1915c43cc173Smrg $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 1916c43cc173Smrg exit $EXIT_FAILURE 1917c43cc173Smrg else 1918c43cc173Smrg # Dry-run case. 1919c43cc173Smrg 1920c43cc173Smrg # Extract subdirectory from the argument. 1921c43cc173Smrg xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` 1922c43cc173Smrg if test "X$xdir" = "X$arg"; then 1923c43cc173Smrg xdir= 1924c43cc173Smrg else 1925c43cc173Smrg xdir="$xdir/" 1926c43cc173Smrg fi 1927c43cc173Smrg 1928c43cc173Smrg pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` 1929c43cc173Smrg non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` 1930c43cc173Smrg libobjs="$libobjs $pic_object" 1931c43cc173Smrg non_pic_objects="$non_pic_objects $non_pic_object" 1932c43cc173Smrg fi 1933c43cc173Smrg fi 1934c43cc173Smrg ;; 1935c43cc173Smrg 1936c43cc173Smrg *.$libext) 1937c43cc173Smrg # An archive. 1938c43cc173Smrg deplibs="$deplibs $arg" 1939c43cc173Smrg old_deplibs="$old_deplibs $arg" 1940c43cc173Smrg continue 1941c43cc173Smrg ;; 1942c43cc173Smrg 1943c43cc173Smrg *.la) 1944c43cc173Smrg # A libtool-controlled library. 1945c43cc173Smrg 1946c43cc173Smrg if test "$prev" = dlfiles; then 1947c43cc173Smrg # This library was specified with -dlopen. 1948c43cc173Smrg dlfiles="$dlfiles $arg" 1949c43cc173Smrg prev= 1950c43cc173Smrg elif test "$prev" = dlprefiles; then 1951c43cc173Smrg # The library was specified with -dlpreopen. 1952c43cc173Smrg dlprefiles="$dlprefiles $arg" 1953c43cc173Smrg prev= 1954c43cc173Smrg else 1955c43cc173Smrg deplibs="$deplibs $arg" 1956c43cc173Smrg fi 1957c43cc173Smrg continue 1958c43cc173Smrg ;; 1959c43cc173Smrg 1960c43cc173Smrg # Some other compiler argument. 1961c43cc173Smrg *) 1962c43cc173Smrg # Unknown arguments in both finalize_command and compile_command need 1963c43cc173Smrg # to be aesthetically quoted because they are evaled later. 1964c43cc173Smrg arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` 1965c43cc173Smrg case $arg in 1966c43cc173Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1967c43cc173Smrg arg="\"$arg\"" 1968c43cc173Smrg ;; 1969c43cc173Smrg esac 1970c43cc173Smrg ;; 1971c43cc173Smrg esac # arg 1972c43cc173Smrg 1973c43cc173Smrg # Now actually substitute the argument into the commands. 1974c43cc173Smrg if test -n "$arg"; then 1975c43cc173Smrg compile_command="$compile_command $arg" 1976c43cc173Smrg finalize_command="$finalize_command $arg" 1977c43cc173Smrg fi 1978c43cc173Smrg done # argument parsing loop 1979c43cc173Smrg 1980c43cc173Smrg if test -n "$prev"; then 1981c43cc173Smrg $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 1982c43cc173Smrg $echo "$help" 1>&2 1983c43cc173Smrg exit $EXIT_FAILURE 1984c43cc173Smrg fi 1985c43cc173Smrg 1986c43cc173Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 1987c43cc173Smrg eval arg=\"$export_dynamic_flag_spec\" 1988c43cc173Smrg compile_command="$compile_command $arg" 1989c43cc173Smrg finalize_command="$finalize_command $arg" 1990c43cc173Smrg fi 1991c43cc173Smrg 1992c43cc173Smrg oldlibs= 1993c43cc173Smrg # calculate the name of the file, without its directory 1994c43cc173Smrg outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` 1995c43cc173Smrg libobjs_save="$libobjs" 1996c43cc173Smrg 1997c43cc173Smrg if test -n "$shlibpath_var"; then 1998c43cc173Smrg # get the directories listed in $shlibpath_var 1999c43cc173Smrg eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` 2000c43cc173Smrg else 2001c43cc173Smrg shlib_search_path= 2002c43cc173Smrg fi 2003c43cc173Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 2004c43cc173Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 2005c43cc173Smrg 2006c43cc173Smrg output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` 2007c43cc173Smrg if test "X$output_objdir" = "X$output"; then 2008c43cc173Smrg output_objdir="$objdir" 2009c43cc173Smrg else 2010c43cc173Smrg output_objdir="$output_objdir/$objdir" 2011c43cc173Smrg fi 2012c43cc173Smrg # Create the object directory. 2013c43cc173Smrg if test ! -d "$output_objdir"; then 2014c43cc173Smrg $show "$mkdir $output_objdir" 2015c43cc173Smrg $run $mkdir $output_objdir 2016c43cc173Smrg exit_status=$? 2017c43cc173Smrg if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then 2018c43cc173Smrg exit $exit_status 2019c43cc173Smrg fi 2020c43cc173Smrg fi 2021c43cc173Smrg 2022c43cc173Smrg # Determine the type of output 2023c43cc173Smrg case $output in 2024c43cc173Smrg "") 2025c43cc173Smrg $echo "$modename: you must specify an output file" 1>&2 2026c43cc173Smrg $echo "$help" 1>&2 2027c43cc173Smrg exit $EXIT_FAILURE 2028c43cc173Smrg ;; 2029c43cc173Smrg *.$libext) linkmode=oldlib ;; 2030c43cc173Smrg *.lo | *.$objext) linkmode=obj ;; 2031c43cc173Smrg *.la) linkmode=lib ;; 2032c43cc173Smrg *) linkmode=prog ;; # Anything else should be a program. 2033c43cc173Smrg esac 2034c43cc173Smrg 2035c43cc173Smrg case $host in 2036c43cc173Smrg *cygwin* | *mingw* | *pw32*) 2037c43cc173Smrg # don't eliminate duplications in $postdeps and $predeps 2038c43cc173Smrg duplicate_compiler_generated_deps=yes 2039c43cc173Smrg ;; 2040c43cc173Smrg *) 2041c43cc173Smrg duplicate_compiler_generated_deps=$duplicate_deps 2042c43cc173Smrg ;; 2043c43cc173Smrg esac 2044c43cc173Smrg specialdeplibs= 2045c43cc173Smrg 2046c43cc173Smrg libs= 2047c43cc173Smrg # Find all interdependent deplibs by searching for libraries 2048c43cc173Smrg # that are linked more than once (e.g. -la -lb -la) 2049c43cc173Smrg for deplib in $deplibs; do 2050c43cc173Smrg if test "X$duplicate_deps" = "Xyes" ; then 2051c43cc173Smrg case "$libs " in 2052c43cc173Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 2053c43cc173Smrg esac 2054c43cc173Smrg fi 2055c43cc173Smrg libs="$libs $deplib" 2056c43cc173Smrg done 2057c43cc173Smrg 2058c43cc173Smrg if test "$linkmode" = lib; then 2059c43cc173Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 2060c43cc173Smrg 2061c43cc173Smrg # Compute libraries that are listed more than once in $predeps 2062c43cc173Smrg # $postdeps and mark them as special (i.e., whose duplicates are 2063c43cc173Smrg # not to be eliminated). 2064c43cc173Smrg pre_post_deps= 2065c43cc173Smrg if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then 2066c43cc173Smrg for pre_post_dep in $predeps $postdeps; do 2067c43cc173Smrg case "$pre_post_deps " in 2068c43cc173Smrg *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; 2069c43cc173Smrg esac 2070c43cc173Smrg pre_post_deps="$pre_post_deps $pre_post_dep" 2071c43cc173Smrg done 2072c43cc173Smrg fi 2073c43cc173Smrg pre_post_deps= 2074c43cc173Smrg fi 2075c43cc173Smrg 2076c43cc173Smrg deplibs= 2077c43cc173Smrg newdependency_libs= 2078c43cc173Smrg newlib_search_path= 2079c43cc173Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 2080c43cc173Smrg notinst_deplibs= # not-installed libtool libraries 2081c43cc173Smrg case $linkmode in 2082c43cc173Smrg lib) 2083c43cc173Smrg passes="conv link" 2084c43cc173Smrg for file in $dlfiles $dlprefiles; do 2085c43cc173Smrg case $file in 2086c43cc173Smrg *.la) ;; 2087c43cc173Smrg *) 2088c43cc173Smrg $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 2089c43cc173Smrg exit $EXIT_FAILURE 2090c43cc173Smrg ;; 2091c43cc173Smrg esac 2092c43cc173Smrg done 2093c43cc173Smrg ;; 2094c43cc173Smrg prog) 2095c43cc173Smrg compile_deplibs= 2096c43cc173Smrg finalize_deplibs= 2097c43cc173Smrg alldeplibs=no 2098c43cc173Smrg newdlfiles= 2099c43cc173Smrg newdlprefiles= 2100c43cc173Smrg passes="conv scan dlopen dlpreopen link" 2101c43cc173Smrg ;; 2102c43cc173Smrg *) passes="conv" 2103c43cc173Smrg ;; 2104c43cc173Smrg esac 2105c43cc173Smrg for pass in $passes; do 2106c43cc173Smrg if test "$linkmode,$pass" = "lib,link" || 2107c43cc173Smrg test "$linkmode,$pass" = "prog,scan"; then 2108c43cc173Smrg libs="$deplibs" 2109c43cc173Smrg deplibs= 2110c43cc173Smrg fi 2111c43cc173Smrg if test "$linkmode" = prog; then 2112c43cc173Smrg case $pass in 2113c43cc173Smrg dlopen) libs="$dlfiles" ;; 2114c43cc173Smrg dlpreopen) libs="$dlprefiles" ;; 2115c43cc173Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 2116c43cc173Smrg esac 2117c43cc173Smrg fi 2118c43cc173Smrg if test "$pass" = dlopen; then 2119c43cc173Smrg # Collect dlpreopened libraries 2120c43cc173Smrg save_deplibs="$deplibs" 2121c43cc173Smrg deplibs= 2122c43cc173Smrg fi 2123c43cc173Smrg for deplib in $libs; do 2124c43cc173Smrg lib= 2125c43cc173Smrg found=no 2126c43cc173Smrg case $deplib in 2127c43cc173Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) 2128c43cc173Smrg if test "$linkmode,$pass" = "prog,link"; then 2129c43cc173Smrg compile_deplibs="$deplib $compile_deplibs" 2130c43cc173Smrg finalize_deplibs="$deplib $finalize_deplibs" 2131c43cc173Smrg else 2132c43cc173Smrg compiler_flags="$compiler_flags $deplib" 2133c43cc173Smrg fi 2134c43cc173Smrg 2135c43cc173Smrg case $linkmode in 2136c43cc173Smrg lib) 2137c43cc173Smrg deplibs="$deplib $deplibs" 2138c43cc173Smrg test "$pass" = conv && continue 2139c43cc173Smrg newdependency_libs="$deplib $newdependency_libs" 2140c43cc173Smrg ;; 2141c43cc173Smrg prog) 2142c43cc173Smrg if test "$pass" = conv; then 2143c43cc173Smrg deplibs="$deplib $deplibs" 2144c43cc173Smrg continue 2145c43cc173Smrg fi 2146c43cc173Smrg if test "$pass" = scan; then 2147c43cc173Smrg deplibs="$deplib $deplibs" 2148c43cc173Smrg else 2149c43cc173Smrg compile_deplibs="$deplib $compile_deplibs" 2150c43cc173Smrg finalize_deplibs="$deplib $finalize_deplibs" 2151c43cc173Smrg fi 2152c43cc173Smrg ;; 2153c43cc173Smrg *) 2154c43cc173Smrg ;; 2155c43cc173Smrg esac # linkmode 2156c43cc173Smrg 2157c43cc173Smrg continue 2158c43cc173Smrg ;; 2159c43cc173Smrg -l*) 2160c43cc173Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 2161c43cc173Smrg $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 2162c43cc173Smrg continue 2163c43cc173Smrg fi 2164c43cc173Smrg name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` 2165c43cc173Smrg for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do 2166c43cc173Smrg for search_ext in .la $std_shrext .so .a; do 2167c43cc173Smrg # Search the libtool library 2168c43cc173Smrg lib="$searchdir/lib${name}${search_ext}" 2169c43cc173Smrg if test -f "$lib"; then 2170c43cc173Smrg if test "$search_ext" = ".la"; then 2171c43cc173Smrg found=yes 2172c43cc173Smrg else 2173c43cc173Smrg found=no 2174c43cc173Smrg fi 2175c43cc173Smrg break 2 2176c43cc173Smrg fi 2177c43cc173Smrg done 2178c43cc173Smrg done 2179c43cc173Smrg if test "$found" != yes; then 2180c43cc173Smrg # deplib doesn't seem to be a libtool library 2181c43cc173Smrg if test "$linkmode,$pass" = "prog,link"; then 2182c43cc173Smrg compile_deplibs="$deplib $compile_deplibs" 2183c43cc173Smrg finalize_deplibs="$deplib $finalize_deplibs" 2184c43cc173Smrg else 2185c43cc173Smrg deplibs="$deplib $deplibs" 2186c43cc173Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 2187c43cc173Smrg fi 2188c43cc173Smrg continue 2189c43cc173Smrg else # deplib is a libtool library 2190c43cc173Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 2191c43cc173Smrg # We need to do some special things here, and not later. 2192c43cc173Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 2193c43cc173Smrg case " $predeps $postdeps " in 2194c43cc173Smrg *" $deplib "*) 2195c43cc173Smrg if (${SED} -e '2q' $lib | 2196c43cc173Smrg grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then 2197c43cc173Smrg library_names= 2198c43cc173Smrg old_library= 2199c43cc173Smrg case $lib in 2200c43cc173Smrg */* | *\\*) . $lib ;; 2201c43cc173Smrg *) . ./$lib ;; 2202c43cc173Smrg esac 2203c43cc173Smrg for l in $old_library $library_names; do 2204c43cc173Smrg ll="$l" 2205c43cc173Smrg done 2206c43cc173Smrg if test "X$ll" = "X$old_library" ; then # only static version available 2207c43cc173Smrg found=no 2208c43cc173Smrg ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` 2209c43cc173Smrg test "X$ladir" = "X$lib" && ladir="." 2210c43cc173Smrg lib=$ladir/$old_library 2211c43cc173Smrg if test "$linkmode,$pass" = "prog,link"; then 2212c43cc173Smrg compile_deplibs="$deplib $compile_deplibs" 2213c43cc173Smrg finalize_deplibs="$deplib $finalize_deplibs" 2214c43cc173Smrg else 2215c43cc173Smrg deplibs="$deplib $deplibs" 2216c43cc173Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 2217c43cc173Smrg fi 2218c43cc173Smrg continue 2219c43cc173Smrg fi 2220c43cc173Smrg fi 2221c43cc173Smrg ;; 2222c43cc173Smrg *) ;; 2223c43cc173Smrg esac 2224c43cc173Smrg fi 2225c43cc173Smrg fi 2226c43cc173Smrg ;; # -l 2227c43cc173Smrg -L*) 2228c43cc173Smrg case $linkmode in 2229c43cc173Smrg lib) 2230c43cc173Smrg deplibs="$deplib $deplibs" 2231c43cc173Smrg test "$pass" = conv && continue 2232c43cc173Smrg newdependency_libs="$deplib $newdependency_libs" 2233c43cc173Smrg newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` 2234c43cc173Smrg ;; 2235c43cc173Smrg prog) 2236c43cc173Smrg if test "$pass" = conv; then 2237c43cc173Smrg deplibs="$deplib $deplibs" 2238c43cc173Smrg continue 2239c43cc173Smrg fi 2240c43cc173Smrg if test "$pass" = scan; then 2241c43cc173Smrg deplibs="$deplib $deplibs" 2242c43cc173Smrg else 2243c43cc173Smrg compile_deplibs="$deplib $compile_deplibs" 2244c43cc173Smrg finalize_deplibs="$deplib $finalize_deplibs" 2245c43cc173Smrg fi 2246c43cc173Smrg newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` 2247c43cc173Smrg ;; 2248c43cc173Smrg *) 2249c43cc173Smrg $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 2250c43cc173Smrg ;; 2251c43cc173Smrg esac # linkmode 2252c43cc173Smrg continue 2253c43cc173Smrg ;; # -L 2254c43cc173Smrg -R*) 2255c43cc173Smrg if test "$pass" = link; then 2256c43cc173Smrg dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` 2257c43cc173Smrg # Make sure the xrpath contains only unique directories. 2258c43cc173Smrg case "$xrpath " in 2259c43cc173Smrg *" $dir "*) ;; 2260c43cc173Smrg *) xrpath="$xrpath $dir" ;; 2261c43cc173Smrg esac 2262c43cc173Smrg fi 2263c43cc173Smrg deplibs="$deplib $deplibs" 2264c43cc173Smrg continue 2265c43cc173Smrg ;; 2266c43cc173Smrg *.la) lib="$deplib" ;; 2267c43cc173Smrg *.$libext) 2268c43cc173Smrg if test "$pass" = conv; then 2269c43cc173Smrg deplibs="$deplib $deplibs" 2270c43cc173Smrg continue 2271c43cc173Smrg fi 2272c43cc173Smrg case $linkmode in 2273c43cc173Smrg lib) 2274c43cc173Smrg valid_a_lib=no 2275c43cc173Smrg case $deplibs_check_method in 2276c43cc173Smrg match_pattern*) 2277c43cc173Smrg set dummy $deplibs_check_method 2278c43cc173Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` 2279c43cc173Smrg if eval $echo \"$deplib\" 2>/dev/null \ 2280c43cc173Smrg | $SED 10q \ 2281c43cc173Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 2282c43cc173Smrg valid_a_lib=yes 2283c43cc173Smrg fi 2284c43cc173Smrg ;; 2285c43cc173Smrg pass_all) 2286c43cc173Smrg valid_a_lib=yes 2287c43cc173Smrg ;; 2288c43cc173Smrg esac 2289c43cc173Smrg if test "$valid_a_lib" != yes; then 2290c43cc173Smrg $echo 2291c43cc173Smrg $echo "*** Warning: Trying to link with static lib archive $deplib." 2292c43cc173Smrg $echo "*** I have the capability to make that library automatically link in when" 2293c43cc173Smrg $echo "*** you link to this library. But I can only do this if you have a" 2294c43cc173Smrg $echo "*** shared version of the library, which you do not appear to have" 2295c43cc173Smrg $echo "*** because the file extensions .$libext of this argument makes me believe" 2296c43cc173Smrg $echo "*** that it is just a static archive that I should not used here." 2297c43cc173Smrg else 2298c43cc173Smrg $echo 2299c43cc173Smrg $echo "*** Warning: Linking the shared library $output against the" 2300c43cc173Smrg $echo "*** static library $deplib is not portable!" 2301c43cc173Smrg deplibs="$deplib $deplibs" 2302c43cc173Smrg fi 2303c43cc173Smrg continue 2304c43cc173Smrg ;; 2305c43cc173Smrg prog) 2306c43cc173Smrg if test "$pass" != link; then 2307c43cc173Smrg deplibs="$deplib $deplibs" 2308c43cc173Smrg else 2309c43cc173Smrg compile_deplibs="$deplib $compile_deplibs" 2310c43cc173Smrg finalize_deplibs="$deplib $finalize_deplibs" 2311c43cc173Smrg fi 2312c43cc173Smrg continue 2313c43cc173Smrg ;; 2314c43cc173Smrg esac # linkmode 2315c43cc173Smrg ;; # *.$libext 2316c43cc173Smrg *.lo | *.$objext) 2317c43cc173Smrg if test "$pass" = conv; then 2318c43cc173Smrg deplibs="$deplib $deplibs" 2319c43cc173Smrg elif test "$linkmode" = prog; then 2320c43cc173Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 2321c43cc173Smrg # If there is no dlopen support or we're linking statically, 2322c43cc173Smrg # we need to preload. 2323c43cc173Smrg newdlprefiles="$newdlprefiles $deplib" 2324c43cc173Smrg compile_deplibs="$deplib $compile_deplibs" 2325c43cc173Smrg finalize_deplibs="$deplib $finalize_deplibs" 2326c43cc173Smrg else 2327c43cc173Smrg newdlfiles="$newdlfiles $deplib" 2328c43cc173Smrg fi 2329c43cc173Smrg fi 2330c43cc173Smrg continue 2331c43cc173Smrg ;; 2332c43cc173Smrg %DEPLIBS%) 2333c43cc173Smrg alldeplibs=yes 2334c43cc173Smrg continue 2335c43cc173Smrg ;; 2336c43cc173Smrg esac # case $deplib 2337c43cc173Smrg if test "$found" = yes || test -f "$lib"; then : 2338c43cc173Smrg else 2339c43cc173Smrg $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2 2340c43cc173Smrg exit $EXIT_FAILURE 2341c43cc173Smrg fi 2342c43cc173Smrg 2343c43cc173Smrg # Check to see that this really is a libtool archive. 2344c43cc173Smrg if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : 2345c43cc173Smrg else 2346c43cc173Smrg $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 2347c43cc173Smrg exit $EXIT_FAILURE 2348c43cc173Smrg fi 2349c43cc173Smrg 2350c43cc173Smrg ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` 2351c43cc173Smrg test "X$ladir" = "X$lib" && ladir="." 2352c43cc173Smrg 2353c43cc173Smrg dlname= 2354c43cc173Smrg dlopen= 2355c43cc173Smrg dlpreopen= 2356c43cc173Smrg libdir= 2357c43cc173Smrg library_names= 2358c43cc173Smrg old_library= 2359c43cc173Smrg # If the library was installed with an old release of libtool, 2360c43cc173Smrg # it will not redefine variables installed, or shouldnotlink 2361c43cc173Smrg installed=yes 2362c43cc173Smrg shouldnotlink=no 2363c43cc173Smrg avoidtemprpath= 2364c43cc173Smrg 2365c43cc173Smrg 2366c43cc173Smrg # Read the .la file 2367c43cc173Smrg case $lib in 2368c43cc173Smrg */* | *\\*) . $lib ;; 2369c43cc173Smrg *) . ./$lib ;; 2370c43cc173Smrg esac 2371c43cc173Smrg 2372c43cc173Smrg if test "$linkmode,$pass" = "lib,link" || 2373c43cc173Smrg test "$linkmode,$pass" = "prog,scan" || 2374c43cc173Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 2375c43cc173Smrg test -n "$dlopen" && dlfiles="$dlfiles $dlopen" 2376c43cc173Smrg test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" 2377c43cc173Smrg fi 2378c43cc173Smrg 2379c43cc173Smrg if test "$pass" = conv; then 2380c43cc173Smrg # Only check for convenience libraries 2381c43cc173Smrg deplibs="$lib $deplibs" 2382c43cc173Smrg if test -z "$libdir"; then 2383c43cc173Smrg if test -z "$old_library"; then 2384c43cc173Smrg $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 2385c43cc173Smrg exit $EXIT_FAILURE 2386c43cc173Smrg fi 2387c43cc173Smrg # It is a libtool convenience library, so add in its objects. 2388c43cc173Smrg convenience="$convenience $ladir/$objdir/$old_library" 2389c43cc173Smrg old_convenience="$old_convenience $ladir/$objdir/$old_library" 2390c43cc173Smrg tmp_libs= 2391c43cc173Smrg for deplib in $dependency_libs; do 2392c43cc173Smrg deplibs="$deplib $deplibs" 2393c43cc173Smrg if test "X$duplicate_deps" = "Xyes" ; then 2394c43cc173Smrg case "$tmp_libs " in 2395c43cc173Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 2396c43cc173Smrg esac 2397c43cc173Smrg fi 2398c43cc173Smrg tmp_libs="$tmp_libs $deplib" 2399c43cc173Smrg done 2400c43cc173Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 2401c43cc173Smrg $echo "$modename: \`$lib' is not a convenience library" 1>&2 2402c43cc173Smrg exit $EXIT_FAILURE 2403c43cc173Smrg fi 2404c43cc173Smrg continue 2405c43cc173Smrg fi # $pass = conv 2406c43cc173Smrg 2407c43cc173Smrg 2408c43cc173Smrg # Get the name of the library we link against. 2409c43cc173Smrg linklib= 2410c43cc173Smrg for l in $old_library $library_names; do 2411c43cc173Smrg linklib="$l" 2412c43cc173Smrg done 2413c43cc173Smrg if test -z "$linklib"; then 2414c43cc173Smrg $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 2415c43cc173Smrg exit $EXIT_FAILURE 2416c43cc173Smrg fi 2417c43cc173Smrg 2418c43cc173Smrg # This library was specified with -dlopen. 2419c43cc173Smrg if test "$pass" = dlopen; then 2420c43cc173Smrg if test -z "$libdir"; then 2421c43cc173Smrg $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 2422c43cc173Smrg exit $EXIT_FAILURE 2423c43cc173Smrg fi 2424c43cc173Smrg if test -z "$dlname" || 2425c43cc173Smrg test "$dlopen_support" != yes || 2426c43cc173Smrg test "$build_libtool_libs" = no; then 2427c43cc173Smrg # If there is no dlname, no dlopen support or we're linking 2428c43cc173Smrg # statically, we need to preload. We also need to preload any 2429c43cc173Smrg # dependent libraries so libltdl's deplib preloader doesn't 2430c43cc173Smrg # bomb out in the load deplibs phase. 2431c43cc173Smrg dlprefiles="$dlprefiles $lib $dependency_libs" 2432c43cc173Smrg else 2433c43cc173Smrg newdlfiles="$newdlfiles $lib" 2434c43cc173Smrg fi 2435c43cc173Smrg continue 2436c43cc173Smrg fi # $pass = dlopen 2437c43cc173Smrg 2438c43cc173Smrg # We need an absolute path. 2439c43cc173Smrg case $ladir in 2440c43cc173Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 2441c43cc173Smrg *) 2442c43cc173Smrg abs_ladir=`cd "$ladir" && pwd` 2443c43cc173Smrg if test -z "$abs_ladir"; then 2444c43cc173Smrg $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 2445c43cc173Smrg $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 2446c43cc173Smrg abs_ladir="$ladir" 2447c43cc173Smrg fi 2448c43cc173Smrg ;; 2449c43cc173Smrg esac 2450c43cc173Smrg laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` 2451c43cc173Smrg 2452c43cc173Smrg # Find the relevant object directory and library name. 2453c43cc173Smrg if test "X$installed" = Xyes; then 2454c43cc173Smrg if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 2455c43cc173Smrg $echo "$modename: warning: library \`$lib' was moved." 1>&2 2456c43cc173Smrg dir="$ladir" 2457c43cc173Smrg absdir="$abs_ladir" 2458c43cc173Smrg libdir="$abs_ladir" 2459c43cc173Smrg else 2460c43cc173Smrg dir="$libdir" 2461c43cc173Smrg absdir="$libdir" 2462c43cc173Smrg fi 2463c43cc173Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 2464c43cc173Smrg else 2465c43cc173Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 2466c43cc173Smrg dir="$ladir" 2467c43cc173Smrg absdir="$abs_ladir" 2468c43cc173Smrg # Remove this search path later 2469c43cc173Smrg notinst_path="$notinst_path $abs_ladir" 2470c43cc173Smrg else 2471c43cc173Smrg dir="$ladir/$objdir" 2472c43cc173Smrg absdir="$abs_ladir/$objdir" 2473c43cc173Smrg # Remove this search path later 2474c43cc173Smrg notinst_path="$notinst_path $abs_ladir" 2475c43cc173Smrg fi 2476c43cc173Smrg fi # $installed = yes 2477c43cc173Smrg name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` 2478c43cc173Smrg 2479c43cc173Smrg # This library was specified with -dlpreopen. 2480c43cc173Smrg if test "$pass" = dlpreopen; then 2481c43cc173Smrg if test -z "$libdir"; then 2482c43cc173Smrg $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 2483c43cc173Smrg exit $EXIT_FAILURE 2484c43cc173Smrg fi 2485c43cc173Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 2486c43cc173Smrg # are required to link). 2487c43cc173Smrg if test -n "$old_library"; then 2488c43cc173Smrg newdlprefiles="$newdlprefiles $dir/$old_library" 2489c43cc173Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 2490c43cc173Smrg elif test -n "$dlname"; then 2491c43cc173Smrg newdlprefiles="$newdlprefiles $dir/$dlname" 2492c43cc173Smrg else 2493c43cc173Smrg newdlprefiles="$newdlprefiles $dir/$linklib" 2494c43cc173Smrg fi 2495c43cc173Smrg fi # $pass = dlpreopen 2496c43cc173Smrg 2497c43cc173Smrg if test -z "$libdir"; then 2498c43cc173Smrg # Link the convenience library 2499c43cc173Smrg if test "$linkmode" = lib; then 2500c43cc173Smrg deplibs="$dir/$old_library $deplibs" 2501c43cc173Smrg elif test "$linkmode,$pass" = "prog,link"; then 2502c43cc173Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 2503c43cc173Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 2504c43cc173Smrg else 2505c43cc173Smrg deplibs="$lib $deplibs" # used for prog,scan pass 2506c43cc173Smrg fi 2507c43cc173Smrg continue 2508c43cc173Smrg fi 2509c43cc173Smrg 2510c43cc173Smrg 2511c43cc173Smrg if test "$linkmode" = prog && test "$pass" != link; then 2512c43cc173Smrg newlib_search_path="$newlib_search_path $ladir" 2513c43cc173Smrg deplibs="$lib $deplibs" 2514c43cc173Smrg 2515c43cc173Smrg linkalldeplibs=no 2516c43cc173Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 2517c43cc173Smrg test "$build_libtool_libs" = no; then 2518c43cc173Smrg linkalldeplibs=yes 2519c43cc173Smrg fi 2520c43cc173Smrg 2521c43cc173Smrg tmp_libs= 2522c43cc173Smrg for deplib in $dependency_libs; do 2523c43cc173Smrg case $deplib in 2524c43cc173Smrg -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test 2525c43cc173Smrg esac 2526c43cc173Smrg # Need to link against all dependency_libs? 2527c43cc173Smrg if test "$linkalldeplibs" = yes; then 2528c43cc173Smrg deplibs="$deplib $deplibs" 2529c43cc173Smrg else 2530c43cc173Smrg # Need to hardcode shared library paths 2531c43cc173Smrg # or/and link against static libraries 2532c43cc173Smrg newdependency_libs="$deplib $newdependency_libs" 2533c43cc173Smrg fi 2534c43cc173Smrg if test "X$duplicate_deps" = "Xyes" ; then 2535c43cc173Smrg case "$tmp_libs " in 2536c43cc173Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 2537c43cc173Smrg esac 2538c43cc173Smrg fi 2539c43cc173Smrg tmp_libs="$tmp_libs $deplib" 2540c43cc173Smrg done # for deplib 2541c43cc173Smrg continue 2542c43cc173Smrg fi # $linkmode = prog... 2543c43cc173Smrg 2544c43cc173Smrg if test "$linkmode,$pass" = "prog,link"; then 2545c43cc173Smrg if test -n "$library_names" && 2546c43cc173Smrg { test "$prefer_static_libs" = no || test -z "$old_library"; }; then 2547c43cc173Smrg # We need to hardcode the library path 2548c43cc173Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 2549c43cc173Smrg # Make sure the rpath contains only unique directories. 2550c43cc173Smrg case "$temp_rpath " in 2551c43cc173Smrg *" $dir "*) ;; 2552c43cc173Smrg *" $absdir "*) ;; 2553c43cc173Smrg *) temp_rpath="$temp_rpath $absdir" ;; 2554c43cc173Smrg esac 2555c43cc173Smrg fi 2556c43cc173Smrg 2557c43cc173Smrg # Hardcode the library path. 2558c43cc173Smrg # Skip directories that are in the system default run-time 2559c43cc173Smrg # search path. 2560c43cc173Smrg case " $sys_lib_dlsearch_path " in 2561c43cc173Smrg *" $absdir "*) ;; 2562c43cc173Smrg *) 2563c43cc173Smrg case "$compile_rpath " in 2564c43cc173Smrg *" $absdir "*) ;; 2565c43cc173Smrg *) compile_rpath="$compile_rpath $absdir" 2566c43cc173Smrg esac 2567c43cc173Smrg ;; 2568c43cc173Smrg esac 2569c43cc173Smrg case " $sys_lib_dlsearch_path " in 2570c43cc173Smrg *" $libdir "*) ;; 2571c43cc173Smrg *) 2572c43cc173Smrg case "$finalize_rpath " in 2573c43cc173Smrg *" $libdir "*) ;; 2574c43cc173Smrg *) finalize_rpath="$finalize_rpath $libdir" 2575c43cc173Smrg esac 2576c43cc173Smrg ;; 2577c43cc173Smrg esac 2578c43cc173Smrg fi # $linkmode,$pass = prog,link... 2579c43cc173Smrg 2580c43cc173Smrg if test "$alldeplibs" = yes && 2581c43cc173Smrg { test "$deplibs_check_method" = pass_all || 2582c43cc173Smrg { test "$build_libtool_libs" = yes && 2583c43cc173Smrg test -n "$library_names"; }; }; then 2584c43cc173Smrg # We only need to search for static libraries 2585c43cc173Smrg continue 2586c43cc173Smrg fi 2587c43cc173Smrg fi 2588c43cc173Smrg 2589c43cc173Smrg link_static=no # Whether the deplib will be linked statically 2590c43cc173Smrg use_static_libs=$prefer_static_libs 2591c43cc173Smrg if test "$use_static_libs" = built && test "$installed" = yes ; then 2592c43cc173Smrg use_static_libs=no 2593c43cc173Smrg fi 2594c43cc173Smrg if test -n "$library_names" && 2595c43cc173Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 2596c43cc173Smrg if test "$installed" = no; then 2597c43cc173Smrg notinst_deplibs="$notinst_deplibs $lib" 2598c43cc173Smrg need_relink=yes 2599c43cc173Smrg fi 2600c43cc173Smrg # This is a shared library 2601c43cc173Smrg 2602c43cc173Smrg # Warn about portability, can't link against -module's on 2603c43cc173Smrg # some systems (darwin) 2604c43cc173Smrg if test "$shouldnotlink" = yes && test "$pass" = link ; then 2605c43cc173Smrg $echo 2606c43cc173Smrg if test "$linkmode" = prog; then 2607c43cc173Smrg $echo "*** Warning: Linking the executable $output against the loadable module" 2608c43cc173Smrg else 2609c43cc173Smrg $echo "*** Warning: Linking the shared library $output against the loadable module" 2610c43cc173Smrg fi 2611c43cc173Smrg $echo "*** $linklib is not portable!" 2612c43cc173Smrg fi 2613c43cc173Smrg if test "$linkmode" = lib && 2614c43cc173Smrg test "$hardcode_into_libs" = yes; then 2615c43cc173Smrg # Hardcode the library path. 2616c43cc173Smrg # Skip directories that are in the system default run-time 2617c43cc173Smrg # search path. 2618c43cc173Smrg case " $sys_lib_dlsearch_path " in 2619c43cc173Smrg *" $absdir "*) ;; 2620c43cc173Smrg *) 2621c43cc173Smrg case "$compile_rpath " in 2622c43cc173Smrg *" $absdir "*) ;; 2623c43cc173Smrg *) compile_rpath="$compile_rpath $absdir" 2624c43cc173Smrg esac 2625c43cc173Smrg ;; 2626c43cc173Smrg esac 2627c43cc173Smrg case " $sys_lib_dlsearch_path " in 2628c43cc173Smrg *" $libdir "*) ;; 2629c43cc173Smrg *) 2630c43cc173Smrg case "$finalize_rpath " in 2631c43cc173Smrg *" $libdir "*) ;; 2632c43cc173Smrg *) finalize_rpath="$finalize_rpath $libdir" 2633c43cc173Smrg esac 2634c43cc173Smrg ;; 2635c43cc173Smrg esac 2636c43cc173Smrg fi 2637c43cc173Smrg 2638c43cc173Smrg if test -n "$old_archive_from_expsyms_cmds"; then 2639c43cc173Smrg # figure out the soname 2640c43cc173Smrg set dummy $library_names 2641c43cc173Smrg realname="$2" 2642c43cc173Smrg shift; shift 2643c43cc173Smrg libname=`eval \\$echo \"$libname_spec\"` 2644c43cc173Smrg # use dlname if we got it. it's perfectly good, no? 2645c43cc173Smrg if test -n "$dlname"; then 2646c43cc173Smrg soname="$dlname" 2647c43cc173Smrg elif test -n "$soname_spec"; then 2648c43cc173Smrg # bleh windows 2649c43cc173Smrg case $host in 2650c43cc173Smrg *cygwin* | mingw*) 2651c43cc173Smrg major=`expr $current - $age` 2652c43cc173Smrg versuffix="-$major" 2653c43cc173Smrg ;; 2654c43cc173Smrg esac 2655c43cc173Smrg eval soname=\"$soname_spec\" 2656c43cc173Smrg else 2657c43cc173Smrg soname="$realname" 2658c43cc173Smrg fi 2659c43cc173Smrg 2660c43cc173Smrg # Make a new name for the extract_expsyms_cmds to use 2661c43cc173Smrg soroot="$soname" 2662c43cc173Smrg soname=`$echo $soroot | ${SED} -e 's/^.*\///'` 2663c43cc173Smrg newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" 2664c43cc173Smrg 2665c43cc173Smrg # If the library has no export list, then create one now 2666c43cc173Smrg if test -f "$output_objdir/$soname-def"; then : 2667c43cc173Smrg else 2668c43cc173Smrg $show "extracting exported symbol list from \`$soname'" 2669c43cc173Smrg save_ifs="$IFS"; IFS='~' 2670c43cc173Smrg cmds=$extract_expsyms_cmds 2671c43cc173Smrg for cmd in $cmds; do 2672c43cc173Smrg IFS="$save_ifs" 2673c43cc173Smrg eval cmd=\"$cmd\" 2674c43cc173Smrg $show "$cmd" 2675c43cc173Smrg $run eval "$cmd" || exit $? 2676c43cc173Smrg done 2677c43cc173Smrg IFS="$save_ifs" 2678c43cc173Smrg fi 2679c43cc173Smrg 2680c43cc173Smrg # Create $newlib 2681c43cc173Smrg if test -f "$output_objdir/$newlib"; then :; else 2682c43cc173Smrg $show "generating import library for \`$soname'" 2683c43cc173Smrg save_ifs="$IFS"; IFS='~' 2684c43cc173Smrg cmds=$old_archive_from_expsyms_cmds 2685c43cc173Smrg for cmd in $cmds; do 2686c43cc173Smrg IFS="$save_ifs" 2687c43cc173Smrg eval cmd=\"$cmd\" 2688c43cc173Smrg $show "$cmd" 2689c43cc173Smrg $run eval "$cmd" || exit $? 2690c43cc173Smrg done 2691c43cc173Smrg IFS="$save_ifs" 2692c43cc173Smrg fi 2693c43cc173Smrg # make sure the library variables are pointing to the new library 2694c43cc173Smrg dir=$output_objdir 2695c43cc173Smrg linklib=$newlib 2696c43cc173Smrg fi # test -n "$old_archive_from_expsyms_cmds" 2697c43cc173Smrg 2698c43cc173Smrg if test "$linkmode" = prog || test "$mode" != relink; then 2699c43cc173Smrg add_shlibpath= 2700c43cc173Smrg add_dir= 2701c43cc173Smrg add= 2702c43cc173Smrg lib_linked=yes 2703c43cc173Smrg case $hardcode_action in 2704c43cc173Smrg immediate | unsupported) 2705c43cc173Smrg if test "$hardcode_direct" = no; then 2706c43cc173Smrg add="$dir/$linklib" 2707c43cc173Smrg case $host in 2708c43cc173Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 2709c43cc173Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 2710c43cc173Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 2711c43cc173Smrg *-*-unixware7*) add_dir="-L$dir" ;; 2712c43cc173Smrg *-*-darwin* ) 2713c43cc173Smrg # if the lib is a module then we can not link against 2714c43cc173Smrg # it, someone is ignoring the new warnings I added 2715c43cc173Smrg if /usr/bin/file -L $add 2> /dev/null | 2716c43cc173Smrg $EGREP ": [^:]* bundle" >/dev/null ; then 2717c43cc173Smrg $echo "** Warning, lib $linklib is a module, not a shared library" 2718c43cc173Smrg if test -z "$old_library" ; then 2719c43cc173Smrg $echo 2720c43cc173Smrg $echo "** And there doesn't seem to be a static archive available" 2721c43cc173Smrg $echo "** The link will probably fail, sorry" 2722c43cc173Smrg else 2723c43cc173Smrg add="$dir/$old_library" 2724c43cc173Smrg fi 2725c43cc173Smrg fi 2726c43cc173Smrg esac 2727c43cc173Smrg elif test "$hardcode_minus_L" = no; then 2728c43cc173Smrg case $host in 2729c43cc173Smrg *-*-sunos*) add_shlibpath="$dir" ;; 2730c43cc173Smrg esac 2731c43cc173Smrg add_dir="-L$dir" 2732c43cc173Smrg add="-l$name" 2733c43cc173Smrg elif test "$hardcode_shlibpath_var" = no; then 2734c43cc173Smrg add_shlibpath="$dir" 2735c43cc173Smrg add="-l$name" 2736c43cc173Smrg else 2737c43cc173Smrg lib_linked=no 2738c43cc173Smrg fi 2739c43cc173Smrg ;; 2740c43cc173Smrg relink) 2741c43cc173Smrg if test "$hardcode_direct" = yes; then 2742c43cc173Smrg add="$dir/$linklib" 2743c43cc173Smrg elif test "$hardcode_minus_L" = yes; then 2744c43cc173Smrg add_dir="-L$dir" 2745c43cc173Smrg # Try looking first in the location we're being installed to. 2746c43cc173Smrg if test -n "$inst_prefix_dir"; then 2747c43cc173Smrg case $libdir in 2748c43cc173Smrg [\\/]*) 2749c43cc173Smrg add_dir="$add_dir -L$inst_prefix_dir$libdir" 2750c43cc173Smrg ;; 2751c43cc173Smrg esac 2752c43cc173Smrg fi 2753c43cc173Smrg add="-l$name" 2754c43cc173Smrg elif test "$hardcode_shlibpath_var" = yes; then 2755c43cc173Smrg add_shlibpath="$dir" 2756c43cc173Smrg add="-l$name" 2757c43cc173Smrg else 2758c43cc173Smrg lib_linked=no 2759c43cc173Smrg fi 2760c43cc173Smrg ;; 2761c43cc173Smrg *) lib_linked=no ;; 2762c43cc173Smrg esac 2763c43cc173Smrg 2764c43cc173Smrg if test "$lib_linked" != yes; then 2765c43cc173Smrg $echo "$modename: configuration error: unsupported hardcode properties" 2766c43cc173Smrg exit $EXIT_FAILURE 2767c43cc173Smrg fi 2768c43cc173Smrg 2769c43cc173Smrg if test -n "$add_shlibpath"; then 2770c43cc173Smrg case :$compile_shlibpath: in 2771c43cc173Smrg *":$add_shlibpath:"*) ;; 2772c43cc173Smrg *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; 2773c43cc173Smrg esac 2774c43cc173Smrg fi 2775c43cc173Smrg if test "$linkmode" = prog; then 2776c43cc173Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 2777c43cc173Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 2778c43cc173Smrg else 2779c43cc173Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 2780c43cc173Smrg test -n "$add" && deplibs="$add $deplibs" 2781c43cc173Smrg if test "$hardcode_direct" != yes && \ 2782c43cc173Smrg test "$hardcode_minus_L" != yes && \ 2783c43cc173Smrg test "$hardcode_shlibpath_var" = yes; then 2784c43cc173Smrg case :$finalize_shlibpath: in 2785c43cc173Smrg *":$libdir:"*) ;; 2786c43cc173Smrg *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; 2787c43cc173Smrg esac 2788c43cc173Smrg fi 2789c43cc173Smrg fi 2790c43cc173Smrg fi 2791c43cc173Smrg 2792c43cc173Smrg if test "$linkmode" = prog || test "$mode" = relink; then 2793c43cc173Smrg add_shlibpath= 2794c43cc173Smrg add_dir= 2795c43cc173Smrg add= 2796c43cc173Smrg # Finalize command for both is simple: just hardcode it. 2797c43cc173Smrg if test "$hardcode_direct" = yes; then 2798c43cc173Smrg add="$libdir/$linklib" 2799c43cc173Smrg elif test "$hardcode_minus_L" = yes; then 2800c43cc173Smrg add_dir="-L$libdir" 2801c43cc173Smrg add="-l$name" 2802c43cc173Smrg elif test "$hardcode_shlibpath_var" = yes; then 2803c43cc173Smrg case :$finalize_shlibpath: in 2804c43cc173Smrg *":$libdir:"*) ;; 2805c43cc173Smrg *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; 2806c43cc173Smrg esac 2807c43cc173Smrg add="-l$name" 2808c43cc173Smrg elif test "$hardcode_automatic" = yes; then 2809c43cc173Smrg if test -n "$inst_prefix_dir" && 2810c43cc173Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 2811c43cc173Smrg add="$inst_prefix_dir$libdir/$linklib" 2812c43cc173Smrg else 2813c43cc173Smrg add="$libdir/$linklib" 2814c43cc173Smrg fi 2815c43cc173Smrg else 2816c43cc173Smrg # We cannot seem to hardcode it, guess we'll fake it. 2817c43cc173Smrg add_dir="-L$libdir" 2818c43cc173Smrg # Try looking first in the location we're being installed to. 2819c43cc173Smrg if test -n "$inst_prefix_dir"; then 2820c43cc173Smrg case $libdir in 2821c43cc173Smrg [\\/]*) 2822c43cc173Smrg add_dir="$add_dir -L$inst_prefix_dir$libdir" 2823c43cc173Smrg ;; 2824c43cc173Smrg esac 2825c43cc173Smrg fi 2826c43cc173Smrg add="-l$name" 2827c43cc173Smrg fi 2828c43cc173Smrg 2829c43cc173Smrg if test "$linkmode" = prog; then 2830c43cc173Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 2831c43cc173Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 2832c43cc173Smrg else 2833c43cc173Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 2834c43cc173Smrg test -n "$add" && deplibs="$add $deplibs" 2835c43cc173Smrg fi 2836c43cc173Smrg fi 2837c43cc173Smrg elif test "$linkmode" = prog; then 2838c43cc173Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 2839c43cc173Smrg # is not unsupported. This is valid on all known static and 2840c43cc173Smrg # shared platforms. 2841c43cc173Smrg if test "$hardcode_direct" != unsupported; then 2842c43cc173Smrg test -n "$old_library" && linklib="$old_library" 2843c43cc173Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 2844c43cc173Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 2845c43cc173Smrg else 2846c43cc173Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 2847c43cc173Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 2848c43cc173Smrg fi 2849c43cc173Smrg elif test "$build_libtool_libs" = yes; then 2850c43cc173Smrg # Not a shared library 2851c43cc173Smrg if test "$deplibs_check_method" != pass_all; then 2852c43cc173Smrg # We're trying link a shared library against a static one 2853c43cc173Smrg # but the system doesn't support it. 2854c43cc173Smrg 2855c43cc173Smrg # Just print a warning and add the library to dependency_libs so 2856c43cc173Smrg # that the program can be linked against the static library. 2857c43cc173Smrg $echo 2858c43cc173Smrg $echo "*** Warning: This system can not link to static lib archive $lib." 2859c43cc173Smrg $echo "*** I have the capability to make that library automatically link in when" 2860c43cc173Smrg $echo "*** you link to this library. But I can only do this if you have a" 2861c43cc173Smrg $echo "*** shared version of the library, which you do not appear to have." 2862c43cc173Smrg if test "$module" = yes; then 2863c43cc173Smrg $echo "*** But as you try to build a module library, libtool will still create " 2864c43cc173Smrg $echo "*** a static module, that should work as long as the dlopening application" 2865c43cc173Smrg $echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 2866c43cc173Smrg if test -z "$global_symbol_pipe"; then 2867c43cc173Smrg $echo 2868c43cc173Smrg $echo "*** However, this would only work if libtool was able to extract symbol" 2869c43cc173Smrg $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 2870c43cc173Smrg $echo "*** not find such a program. So, this module is probably useless." 2871c43cc173Smrg $echo "*** \`nm' from GNU binutils and a full rebuild may help." 2872c43cc173Smrg fi 2873c43cc173Smrg if test "$build_old_libs" = no; then 2874c43cc173Smrg build_libtool_libs=module 2875c43cc173Smrg build_old_libs=yes 2876c43cc173Smrg else 2877c43cc173Smrg build_libtool_libs=no 2878c43cc173Smrg fi 2879c43cc173Smrg fi 2880c43cc173Smrg else 2881c43cc173Smrg deplibs="$dir/$old_library $deplibs" 2882c43cc173Smrg link_static=yes 2883c43cc173Smrg fi 2884c43cc173Smrg fi # link shared/static library? 2885c43cc173Smrg 2886c43cc173Smrg if test "$linkmode" = lib; then 2887c43cc173Smrg if test -n "$dependency_libs" && 2888c43cc173Smrg { test "$hardcode_into_libs" != yes || 2889c43cc173Smrg test "$build_old_libs" = yes || 2890c43cc173Smrg test "$link_static" = yes; }; then 2891c43cc173Smrg # Extract -R from dependency_libs 2892c43cc173Smrg temp_deplibs= 2893c43cc173Smrg for libdir in $dependency_libs; do 2894c43cc173Smrg case $libdir in 2895c43cc173Smrg -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` 2896c43cc173Smrg case " $xrpath " in 2897c43cc173Smrg *" $temp_xrpath "*) ;; 2898c43cc173Smrg *) xrpath="$xrpath $temp_xrpath";; 2899c43cc173Smrg esac;; 2900c43cc173Smrg *) temp_deplibs="$temp_deplibs $libdir";; 2901c43cc173Smrg esac 2902c43cc173Smrg done 2903c43cc173Smrg dependency_libs="$temp_deplibs" 2904c43cc173Smrg fi 2905c43cc173Smrg 2906c43cc173Smrg newlib_search_path="$newlib_search_path $absdir" 2907c43cc173Smrg # Link against this library 2908c43cc173Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 2909c43cc173Smrg # ... and its dependency_libs 2910c43cc173Smrg tmp_libs= 2911c43cc173Smrg for deplib in $dependency_libs; do 2912c43cc173Smrg newdependency_libs="$deplib $newdependency_libs" 2913c43cc173Smrg if test "X$duplicate_deps" = "Xyes" ; then 2914c43cc173Smrg case "$tmp_libs " in 2915c43cc173Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 2916c43cc173Smrg esac 2917c43cc173Smrg fi 2918c43cc173Smrg tmp_libs="$tmp_libs $deplib" 2919c43cc173Smrg done 2920c43cc173Smrg 2921c43cc173Smrg if test "$link_all_deplibs" != no; then 2922c43cc173Smrg # Add the search paths of all dependency libraries 2923c43cc173Smrg for deplib in $dependency_libs; do 2924c43cc173Smrg case $deplib in 2925c43cc173Smrg -L*) path="$deplib" ;; 2926c43cc173Smrg *.la) 2927c43cc173Smrg dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` 2928c43cc173Smrg test "X$dir" = "X$deplib" && dir="." 2929c43cc173Smrg # We need an absolute path. 2930c43cc173Smrg case $dir in 2931c43cc173Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 2932c43cc173Smrg *) 2933c43cc173Smrg absdir=`cd "$dir" && pwd` 2934c43cc173Smrg if test -z "$absdir"; then 2935c43cc173Smrg $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 2936c43cc173Smrg absdir="$dir" 2937c43cc173Smrg fi 2938c43cc173Smrg ;; 2939c43cc173Smrg esac 2940c43cc173Smrg if grep "^installed=no" $deplib > /dev/null; then 2941c43cc173Smrg path="$absdir/$objdir" 2942c43cc173Smrg else 2943c43cc173Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 2944c43cc173Smrg if test -z "$libdir"; then 2945c43cc173Smrg $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 2946c43cc173Smrg exit $EXIT_FAILURE 2947c43cc173Smrg fi 2948c43cc173Smrg if test "$absdir" != "$libdir"; then 2949c43cc173Smrg $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 2950c43cc173Smrg fi 2951c43cc173Smrg path="$absdir" 2952c43cc173Smrg fi 2953c43cc173Smrg depdepl= 2954c43cc173Smrg case $host in 2955c43cc173Smrg *-*-darwin*) 2956c43cc173Smrg # we do not want to link against static libs, 2957c43cc173Smrg # but need to link against shared 2958c43cc173Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 2959c43cc173Smrg if test -n "$deplibrary_names" ; then 2960c43cc173Smrg for tmp in $deplibrary_names ; do 2961c43cc173Smrg depdepl=$tmp 2962c43cc173Smrg done 2963c43cc173Smrg if test -f "$path/$depdepl" ; then 2964c43cc173Smrg depdepl="$path/$depdepl" 2965c43cc173Smrg fi 2966c43cc173Smrg # do not add paths which are already there 2967c43cc173Smrg case " $newlib_search_path " in 2968c43cc173Smrg *" $path "*) ;; 2969c43cc173Smrg *) newlib_search_path="$newlib_search_path $path";; 2970c43cc173Smrg esac 2971c43cc173Smrg fi 2972c43cc173Smrg path="" 2973c43cc173Smrg ;; 2974c43cc173Smrg *) 2975c43cc173Smrg path="-L$path" 2976c43cc173Smrg ;; 2977c43cc173Smrg esac 2978c43cc173Smrg ;; 2979c43cc173Smrg -l*) 2980c43cc173Smrg case $host in 2981c43cc173Smrg *-*-darwin*) 2982c43cc173Smrg # Again, we only want to link against shared libraries 2983c43cc173Smrg eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"` 2984c43cc173Smrg for tmp in $newlib_search_path ; do 2985c43cc173Smrg if test -f "$tmp/lib$tmp_libs.dylib" ; then 2986c43cc173Smrg eval depdepl="$tmp/lib$tmp_libs.dylib" 2987c43cc173Smrg break 2988c43cc173Smrg fi 2989c43cc173Smrg done 2990c43cc173Smrg path="" 2991c43cc173Smrg ;; 2992c43cc173Smrg *) continue ;; 2993c43cc173Smrg esac 2994c43cc173Smrg ;; 2995c43cc173Smrg *) continue ;; 2996c43cc173Smrg esac 2997c43cc173Smrg case " $deplibs " in 2998c43cc173Smrg *" $path "*) ;; 2999c43cc173Smrg *) deplibs="$path $deplibs" ;; 3000c43cc173Smrg esac 3001c43cc173Smrg case " $deplibs " in 3002c43cc173Smrg *" $depdepl "*) ;; 3003c43cc173Smrg *) deplibs="$depdepl $deplibs" ;; 3004c43cc173Smrg esac 3005c43cc173Smrg done 3006c43cc173Smrg fi # link_all_deplibs != no 3007c43cc173Smrg fi # linkmode = lib 3008c43cc173Smrg done # for deplib in $libs 3009c43cc173Smrg dependency_libs="$newdependency_libs" 3010c43cc173Smrg if test "$pass" = dlpreopen; then 3011c43cc173Smrg # Link the dlpreopened libraries before other libraries 3012c43cc173Smrg for deplib in $save_deplibs; do 3013c43cc173Smrg deplibs="$deplib $deplibs" 3014c43cc173Smrg done 3015c43cc173Smrg fi 3016c43cc173Smrg if test "$pass" != dlopen; then 3017c43cc173Smrg if test "$pass" != conv; then 3018c43cc173Smrg # Make sure lib_search_path contains only unique directories. 3019c43cc173Smrg lib_search_path= 3020c43cc173Smrg for dir in $newlib_search_path; do 3021c43cc173Smrg case "$lib_search_path " in 3022c43cc173Smrg *" $dir "*) ;; 3023c43cc173Smrg *) lib_search_path="$lib_search_path $dir" ;; 3024c43cc173Smrg esac 3025c43cc173Smrg done 3026c43cc173Smrg newlib_search_path= 3027c43cc173Smrg fi 3028c43cc173Smrg 3029c43cc173Smrg if test "$linkmode,$pass" != "prog,link"; then 3030c43cc173Smrg vars="deplibs" 3031c43cc173Smrg else 3032c43cc173Smrg vars="compile_deplibs finalize_deplibs" 3033c43cc173Smrg fi 3034c43cc173Smrg for var in $vars dependency_libs; do 3035c43cc173Smrg # Add libraries to $var in reverse order 3036c43cc173Smrg eval tmp_libs=\"\$$var\" 3037c43cc173Smrg new_libs= 3038c43cc173Smrg for deplib in $tmp_libs; do 3039c43cc173Smrg # FIXME: Pedantically, this is the right thing to do, so 3040c43cc173Smrg # that some nasty dependency loop isn't accidentally 3041c43cc173Smrg # broken: 3042c43cc173Smrg #new_libs="$deplib $new_libs" 3043c43cc173Smrg # Pragmatically, this seems to cause very few problems in 3044c43cc173Smrg # practice: 3045c43cc173Smrg case $deplib in 3046c43cc173Smrg -L*) new_libs="$deplib $new_libs" ;; 3047c43cc173Smrg -R*) ;; 3048c43cc173Smrg *) 3049c43cc173Smrg # And here is the reason: when a library appears more 3050c43cc173Smrg # than once as an explicit dependence of a library, or 3051c43cc173Smrg # is implicitly linked in more than once by the 3052c43cc173Smrg # compiler, it is considered special, and multiple 3053c43cc173Smrg # occurrences thereof are not removed. Compare this 3054c43cc173Smrg # with having the same library being listed as a 3055c43cc173Smrg # dependency of multiple other libraries: in this case, 3056c43cc173Smrg # we know (pedantically, we assume) the library does not 3057c43cc173Smrg # need to be listed more than once, so we keep only the 3058c43cc173Smrg # last copy. This is not always right, but it is rare 3059c43cc173Smrg # enough that we require users that really mean to play 3060c43cc173Smrg # such unportable linking tricks to link the library 3061c43cc173Smrg # using -Wl,-lname, so that libtool does not consider it 3062c43cc173Smrg # for duplicate removal. 3063c43cc173Smrg case " $specialdeplibs " in 3064c43cc173Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 3065c43cc173Smrg *) 3066c43cc173Smrg case " $new_libs " in 3067c43cc173Smrg *" $deplib "*) ;; 3068c43cc173Smrg *) new_libs="$deplib $new_libs" ;; 3069c43cc173Smrg esac 3070c43cc173Smrg ;; 3071c43cc173Smrg esac 3072c43cc173Smrg ;; 3073c43cc173Smrg esac 3074c43cc173Smrg done 3075c43cc173Smrg tmp_libs= 3076c43cc173Smrg for deplib in $new_libs; do 3077c43cc173Smrg case $deplib in 3078c43cc173Smrg -L*) 3079c43cc173Smrg case " $tmp_libs " in 3080c43cc173Smrg *" $deplib "*) ;; 3081c43cc173Smrg *) tmp_libs="$tmp_libs $deplib" ;; 3082c43cc173Smrg esac 3083c43cc173Smrg ;; 3084c43cc173Smrg *) tmp_libs="$tmp_libs $deplib" ;; 3085c43cc173Smrg esac 3086c43cc173Smrg done 3087c43cc173Smrg eval $var=\"$tmp_libs\" 3088c43cc173Smrg done # for var 3089c43cc173Smrg fi 3090c43cc173Smrg # Last step: remove runtime libs from dependency_libs 3091c43cc173Smrg # (they stay in deplibs) 3092c43cc173Smrg tmp_libs= 3093c43cc173Smrg for i in $dependency_libs ; do 3094c43cc173Smrg case " $predeps $postdeps $compiler_lib_search_path " in 3095c43cc173Smrg *" $i "*) 3096c43cc173Smrg i="" 3097c43cc173Smrg ;; 3098c43cc173Smrg esac 3099c43cc173Smrg if test -n "$i" ; then 3100c43cc173Smrg tmp_libs="$tmp_libs $i" 3101c43cc173Smrg fi 3102c43cc173Smrg done 3103c43cc173Smrg dependency_libs=$tmp_libs 3104c43cc173Smrg done # for pass 3105c43cc173Smrg if test "$linkmode" = prog; then 3106c43cc173Smrg dlfiles="$newdlfiles" 3107c43cc173Smrg dlprefiles="$newdlprefiles" 3108c43cc173Smrg fi 3109c43cc173Smrg 3110c43cc173Smrg case $linkmode in 3111c43cc173Smrg oldlib) 3112c43cc173Smrg if test -n "$deplibs"; then 3113c43cc173Smrg $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 3114c43cc173Smrg fi 3115c43cc173Smrg 3116c43cc173Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 3117c43cc173Smrg $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 3118c43cc173Smrg fi 3119c43cc173Smrg 3120c43cc173Smrg if test -n "$rpath"; then 3121c43cc173Smrg $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 3122c43cc173Smrg fi 3123c43cc173Smrg 3124c43cc173Smrg if test -n "$xrpath"; then 3125c43cc173Smrg $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 3126c43cc173Smrg fi 3127c43cc173Smrg 3128c43cc173Smrg if test -n "$vinfo"; then 3129c43cc173Smrg $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2 3130c43cc173Smrg fi 3131c43cc173Smrg 3132c43cc173Smrg if test -n "$release"; then 3133c43cc173Smrg $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 3134c43cc173Smrg fi 3135c43cc173Smrg 3136c43cc173Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 3137c43cc173Smrg $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 3138c43cc173Smrg fi 3139c43cc173Smrg 3140c43cc173Smrg # Now set the variables for building old libraries. 3141c43cc173Smrg build_libtool_libs=no 3142c43cc173Smrg oldlibs="$output" 3143c43cc173Smrg objs="$objs$old_deplibs" 3144c43cc173Smrg ;; 3145c43cc173Smrg 3146c43cc173Smrg lib) 3147c43cc173Smrg # Make sure we only generate libraries of the form `libNAME.la'. 3148c43cc173Smrg case $outputname in 3149c43cc173Smrg lib*) 3150c43cc173Smrg name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` 3151c43cc173Smrg eval shared_ext=\"$shrext_cmds\" 3152c43cc173Smrg eval libname=\"$libname_spec\" 3153c43cc173Smrg ;; 3154c43cc173Smrg *) 3155c43cc173Smrg if test "$module" = no; then 3156c43cc173Smrg $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 3157c43cc173Smrg $echo "$help" 1>&2 3158c43cc173Smrg exit $EXIT_FAILURE 3159c43cc173Smrg fi 3160c43cc173Smrg if test "$need_lib_prefix" != no; then 3161c43cc173Smrg # Add the "lib" prefix for modules if required 3162c43cc173Smrg name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` 3163c43cc173Smrg eval shared_ext=\"$shrext_cmds\" 3164c43cc173Smrg eval libname=\"$libname_spec\" 3165c43cc173Smrg else 3166c43cc173Smrg libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` 3167c43cc173Smrg fi 3168c43cc173Smrg ;; 3169c43cc173Smrg esac 3170c43cc173Smrg 3171c43cc173Smrg if test -n "$objs"; then 3172c43cc173Smrg if test "$deplibs_check_method" != pass_all; then 3173c43cc173Smrg $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 3174c43cc173Smrg exit $EXIT_FAILURE 3175c43cc173Smrg else 3176c43cc173Smrg $echo 3177c43cc173Smrg $echo "*** Warning: Linking the shared library $output against the non-libtool" 3178c43cc173Smrg $echo "*** objects $objs is not portable!" 3179c43cc173Smrg libobjs="$libobjs $objs" 3180c43cc173Smrg fi 3181c43cc173Smrg fi 3182c43cc173Smrg 3183c43cc173Smrg if test "$dlself" != no; then 3184c43cc173Smrg $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 3185c43cc173Smrg fi 3186c43cc173Smrg 3187c43cc173Smrg set dummy $rpath 3188c43cc173Smrg if test "$#" -gt 2; then 3189c43cc173Smrg $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 3190c43cc173Smrg fi 3191c43cc173Smrg install_libdir="$2" 3192c43cc173Smrg 3193c43cc173Smrg oldlibs= 3194c43cc173Smrg if test -z "$rpath"; then 3195c43cc173Smrg if test "$build_libtool_libs" = yes; then 3196c43cc173Smrg # Building a libtool convenience library. 3197c43cc173Smrg # Some compilers have problems with a `.al' extension so 3198c43cc173Smrg # convenience libraries should have the same extension an 3199c43cc173Smrg # archive normally would. 3200c43cc173Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 3201c43cc173Smrg build_libtool_libs=convenience 3202c43cc173Smrg build_old_libs=yes 3203c43cc173Smrg fi 3204c43cc173Smrg 3205c43cc173Smrg if test -n "$vinfo"; then 3206c43cc173Smrg $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2 3207c43cc173Smrg fi 3208c43cc173Smrg 3209c43cc173Smrg if test -n "$release"; then 3210c43cc173Smrg $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 3211c43cc173Smrg fi 3212c43cc173Smrg else 3213c43cc173Smrg 3214c43cc173Smrg # Parse the version information argument. 3215c43cc173Smrg save_ifs="$IFS"; IFS=':' 3216c43cc173Smrg set dummy $vinfo 0 0 0 3217c43cc173Smrg IFS="$save_ifs" 3218c43cc173Smrg 3219c43cc173Smrg if test -n "$8"; then 3220c43cc173Smrg $echo "$modename: too many parameters to \`-version-info'" 1>&2 3221c43cc173Smrg $echo "$help" 1>&2 3222c43cc173Smrg exit $EXIT_FAILURE 3223c43cc173Smrg fi 3224c43cc173Smrg 3225c43cc173Smrg # convert absolute version numbers to libtool ages 3226c43cc173Smrg # this retains compatibility with .la files and attempts 3227c43cc173Smrg # to make the code below a bit more comprehensible 3228c43cc173Smrg 3229c43cc173Smrg case $vinfo_number in 3230c43cc173Smrg yes) 3231c43cc173Smrg number_major="$2" 3232c43cc173Smrg number_minor="$3" 3233c43cc173Smrg number_revision="$4" 3234c43cc173Smrg # 3235c43cc173Smrg # There are really only two kinds -- those that 3236c43cc173Smrg # use the current revision as the major version 3237c43cc173Smrg # and those that subtract age and use age as 3238c43cc173Smrg # a minor version. But, then there is irix 3239c43cc173Smrg # which has an extra 1 added just for fun 3240c43cc173Smrg # 3241c43cc173Smrg case $version_type in 3242c43cc173Smrg darwin|linux|osf|windows) 3243c43cc173Smrg current=`expr $number_major + $number_minor` 3244c43cc173Smrg age="$number_minor" 3245c43cc173Smrg revision="$number_revision" 3246c43cc173Smrg ;; 3247c43cc173Smrg freebsd-aout|freebsd-elf|sunos) 3248c43cc173Smrg current="$number_major" 3249c43cc173Smrg revision="$number_minor" 3250c43cc173Smrg age="0" 3251c43cc173Smrg ;; 3252c43cc173Smrg irix|nonstopux) 3253c43cc173Smrg current=`expr $number_major + $number_minor - 1` 3254c43cc173Smrg age="$number_minor" 3255c43cc173Smrg revision="$number_minor" 3256c43cc173Smrg ;; 3257c43cc173Smrg esac 3258c43cc173Smrg ;; 3259c43cc173Smrg no) 3260c43cc173Smrg current="$2" 3261c43cc173Smrg revision="$3" 3262c43cc173Smrg age="$4" 3263c43cc173Smrg ;; 3264c43cc173Smrg esac 3265c43cc173Smrg 3266c43cc173Smrg # Check that each of the things are valid numbers. 3267c43cc173Smrg case $current in 3268c43cc173Smrg 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]) ;; 3269c43cc173Smrg *) 3270c43cc173Smrg $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2 3271c43cc173Smrg $echo "$modename: \`$vinfo' is not valid version information" 1>&2 3272c43cc173Smrg exit $EXIT_FAILURE 3273c43cc173Smrg ;; 3274c43cc173Smrg esac 3275c43cc173Smrg 3276c43cc173Smrg case $revision in 3277c43cc173Smrg 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]) ;; 3278c43cc173Smrg *) 3279c43cc173Smrg $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2 3280c43cc173Smrg $echo "$modename: \`$vinfo' is not valid version information" 1>&2 3281c43cc173Smrg exit $EXIT_FAILURE 3282c43cc173Smrg ;; 3283c43cc173Smrg esac 3284c43cc173Smrg 3285c43cc173Smrg case $age in 3286c43cc173Smrg 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]) ;; 3287c43cc173Smrg *) 3288c43cc173Smrg $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2 3289c43cc173Smrg $echo "$modename: \`$vinfo' is not valid version information" 1>&2 3290c43cc173Smrg exit $EXIT_FAILURE 3291c43cc173Smrg ;; 3292c43cc173Smrg esac 3293c43cc173Smrg 3294c43cc173Smrg if test "$age" -gt "$current"; then 3295c43cc173Smrg $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 3296c43cc173Smrg $echo "$modename: \`$vinfo' is not valid version information" 1>&2 3297c43cc173Smrg exit $EXIT_FAILURE 3298c43cc173Smrg fi 3299c43cc173Smrg 3300c43cc173Smrg # Calculate the version variables. 3301c43cc173Smrg major= 3302c43cc173Smrg versuffix= 3303c43cc173Smrg verstring= 3304c43cc173Smrg case $version_type in 3305c43cc173Smrg none) ;; 3306c43cc173Smrg 3307c43cc173Smrg darwin) 3308c43cc173Smrg # Like Linux, but with the current version available in 3309c43cc173Smrg # verstring for coding it into the library header 3310c43cc173Smrg major=.`expr $current - $age` 3311c43cc173Smrg versuffix="$major.$age.$revision" 3312c43cc173Smrg # Darwin ld doesn't like 0 for these options... 3313c43cc173Smrg minor_current=`expr $current + 1` 3314c43cc173Smrg verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 3315c43cc173Smrg ;; 3316c43cc173Smrg 3317c43cc173Smrg freebsd-aout) 3318c43cc173Smrg major=".$current" 3319c43cc173Smrg versuffix=".$current.$revision"; 3320c43cc173Smrg ;; 3321c43cc173Smrg 3322c43cc173Smrg freebsd-elf) 3323c43cc173Smrg major=".$current" 3324c43cc173Smrg versuffix=".$current"; 3325c43cc173Smrg ;; 3326c43cc173Smrg 3327c43cc173Smrg irix | nonstopux) 3328c43cc173Smrg major=`expr $current - $age + 1` 3329c43cc173Smrg 3330c43cc173Smrg case $version_type in 3331c43cc173Smrg nonstopux) verstring_prefix=nonstopux ;; 3332c43cc173Smrg *) verstring_prefix=sgi ;; 3333c43cc173Smrg esac 3334c43cc173Smrg verstring="$verstring_prefix$major.$revision" 3335c43cc173Smrg 3336c43cc173Smrg # Add in all the interfaces that we are compatible with. 3337c43cc173Smrg loop=$revision 3338c43cc173Smrg while test "$loop" -ne 0; do 3339c43cc173Smrg iface=`expr $revision - $loop` 3340c43cc173Smrg loop=`expr $loop - 1` 3341c43cc173Smrg verstring="$verstring_prefix$major.$iface:$verstring" 3342c43cc173Smrg done 3343c43cc173Smrg 3344c43cc173Smrg # Before this point, $major must not contain `.'. 3345c43cc173Smrg major=.$major 3346c43cc173Smrg versuffix="$major.$revision" 3347c43cc173Smrg ;; 3348c43cc173Smrg 3349c43cc173Smrg linux) 3350c43cc173Smrg major=.`expr $current - $age` 3351c43cc173Smrg versuffix="$major.$age.$revision" 3352c43cc173Smrg ;; 3353c43cc173Smrg 3354c43cc173Smrg osf) 3355c43cc173Smrg major=.`expr $current - $age` 3356c43cc173Smrg versuffix=".$current.$age.$revision" 3357c43cc173Smrg verstring="$current.$age.$revision" 3358c43cc173Smrg 3359c43cc173Smrg # Add in all the interfaces that we are compatible with. 3360c43cc173Smrg loop=$age 3361c43cc173Smrg while test "$loop" -ne 0; do 3362c43cc173Smrg iface=`expr $current - $loop` 3363c43cc173Smrg loop=`expr $loop - 1` 3364c43cc173Smrg verstring="$verstring:${iface}.0" 3365c43cc173Smrg done 3366c43cc173Smrg 3367c43cc173Smrg # Make executables depend on our current version. 3368c43cc173Smrg verstring="$verstring:${current}.0" 3369c43cc173Smrg ;; 3370c43cc173Smrg 3371c43cc173Smrg sunos) 3372c43cc173Smrg major=".$current" 3373c43cc173Smrg versuffix=".$current.$revision" 3374c43cc173Smrg ;; 3375c43cc173Smrg 3376c43cc173Smrg windows) 3377c43cc173Smrg # Use '-' rather than '.', since we only want one 3378c43cc173Smrg # extension on DOS 8.3 filesystems. 3379c43cc173Smrg major=`expr $current - $age` 3380c43cc173Smrg versuffix="-$major" 3381c43cc173Smrg ;; 3382c43cc173Smrg 3383c43cc173Smrg *) 3384c43cc173Smrg $echo "$modename: unknown library version type \`$version_type'" 1>&2 3385c43cc173Smrg $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 3386c43cc173Smrg exit $EXIT_FAILURE 3387c43cc173Smrg ;; 3388c43cc173Smrg esac 3389c43cc173Smrg 3390c43cc173Smrg # Clear the version info if we defaulted, and they specified a release. 3391c43cc173Smrg if test -z "$vinfo" && test -n "$release"; then 3392c43cc173Smrg major= 3393c43cc173Smrg case $version_type in 3394c43cc173Smrg darwin) 3395c43cc173Smrg # we can't check for "0.0" in archive_cmds due to quoting 3396c43cc173Smrg # problems, so we reset it completely 3397c43cc173Smrg verstring= 3398c43cc173Smrg ;; 3399c43cc173Smrg *) 3400c43cc173Smrg verstring="0.0" 3401c43cc173Smrg ;; 3402c43cc173Smrg esac 3403c43cc173Smrg if test "$need_version" = no; then 3404c43cc173Smrg versuffix= 3405c43cc173Smrg else 3406c43cc173Smrg versuffix=".0.0" 3407c43cc173Smrg fi 3408c43cc173Smrg fi 3409c43cc173Smrg 3410c43cc173Smrg # Remove version info from name if versioning should be avoided 3411c43cc173Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 3412c43cc173Smrg major= 3413c43cc173Smrg versuffix= 3414c43cc173Smrg verstring="" 3415c43cc173Smrg fi 3416c43cc173Smrg 3417c43cc173Smrg # Check to see if the archive will have undefined symbols. 3418c43cc173Smrg if test "$allow_undefined" = yes; then 3419c43cc173Smrg if test "$allow_undefined_flag" = unsupported; then 3420c43cc173Smrg $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 3421c43cc173Smrg build_libtool_libs=no 3422c43cc173Smrg build_old_libs=yes 3423c43cc173Smrg fi 3424c43cc173Smrg else 3425c43cc173Smrg # Don't allow undefined symbols. 3426c43cc173Smrg allow_undefined_flag="$no_undefined_flag" 3427c43cc173Smrg fi 3428c43cc173Smrg fi 3429c43cc173Smrg 3430c43cc173Smrg if test "$mode" != relink; then 3431c43cc173Smrg # Remove our outputs, but don't remove object files since they 3432c43cc173Smrg # may have been created when compiling PIC objects. 3433c43cc173Smrg removelist= 3434c43cc173Smrg tempremovelist=`$echo "$output_objdir/*"` 3435c43cc173Smrg for p in $tempremovelist; do 3436c43cc173Smrg case $p in 3437c43cc173Smrg *.$objext) 3438c43cc173Smrg ;; 3439c43cc173Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 3440c43cc173Smrg if test "X$precious_files_regex" != "X"; then 3441c43cc173Smrg if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 3442c43cc173Smrg then 3443c43cc173Smrg continue 3444c43cc173Smrg fi 3445c43cc173Smrg fi 3446c43cc173Smrg removelist="$removelist $p" 3447c43cc173Smrg ;; 3448c43cc173Smrg *) ;; 3449c43cc173Smrg esac 3450c43cc173Smrg done 3451c43cc173Smrg if test -n "$removelist"; then 3452c43cc173Smrg $show "${rm}r $removelist" 3453c43cc173Smrg $run ${rm}r $removelist 3454c43cc173Smrg fi 3455c43cc173Smrg fi 3456c43cc173Smrg 3457c43cc173Smrg # Now set the variables for building old libraries. 3458c43cc173Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 3459c43cc173Smrg oldlibs="$oldlibs $output_objdir/$libname.$libext" 3460c43cc173Smrg 3461c43cc173Smrg # Transform .lo files to .o files. 3462c43cc173Smrg oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` 3463c43cc173Smrg fi 3464c43cc173Smrg 3465c43cc173Smrg # Eliminate all temporary directories. 3466c43cc173Smrg for path in $notinst_path; do 3467c43cc173Smrg lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"` 3468c43cc173Smrg deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"` 3469c43cc173Smrg dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"` 3470c43cc173Smrg done 3471c43cc173Smrg 3472c43cc173Smrg if test -n "$xrpath"; then 3473c43cc173Smrg # If the user specified any rpath flags, then add them. 3474c43cc173Smrg temp_xrpath= 3475c43cc173Smrg for libdir in $xrpath; do 3476c43cc173Smrg temp_xrpath="$temp_xrpath -R$libdir" 3477c43cc173Smrg case "$finalize_rpath " in 3478c43cc173Smrg *" $libdir "*) ;; 3479c43cc173Smrg *) finalize_rpath="$finalize_rpath $libdir" ;; 3480c43cc173Smrg esac 3481c43cc173Smrg done 3482c43cc173Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 3483c43cc173Smrg dependency_libs="$temp_xrpath $dependency_libs" 3484c43cc173Smrg fi 3485c43cc173Smrg fi 3486c43cc173Smrg 3487c43cc173Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 3488c43cc173Smrg old_dlfiles="$dlfiles" 3489c43cc173Smrg dlfiles= 3490c43cc173Smrg for lib in $old_dlfiles; do 3491c43cc173Smrg case " $dlprefiles $dlfiles " in 3492c43cc173Smrg *" $lib "*) ;; 3493c43cc173Smrg *) dlfiles="$dlfiles $lib" ;; 3494c43cc173Smrg esac 3495c43cc173Smrg done 3496c43cc173Smrg 3497c43cc173Smrg # Make sure dlprefiles contains only unique files 3498c43cc173Smrg old_dlprefiles="$dlprefiles" 3499c43cc173Smrg dlprefiles= 3500c43cc173Smrg for lib in $old_dlprefiles; do 3501c43cc173Smrg case "$dlprefiles " in 3502c43cc173Smrg *" $lib "*) ;; 3503c43cc173Smrg *) dlprefiles="$dlprefiles $lib" ;; 3504c43cc173Smrg esac 3505c43cc173Smrg done 3506c43cc173Smrg 3507c43cc173Smrg if test "$build_libtool_libs" = yes; then 3508c43cc173Smrg if test -n "$rpath"; then 3509c43cc173Smrg case $host in 3510c43cc173Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) 3511c43cc173Smrg # these systems don't actually have a c library (as such)! 3512c43cc173Smrg ;; 3513c43cc173Smrg *-*-rhapsody* | *-*-darwin1.[012]) 3514c43cc173Smrg # Rhapsody C library is in the System framework 3515c43cc173Smrg deplibs="$deplibs -framework System" 3516c43cc173Smrg ;; 3517c43cc173Smrg *-*-netbsd*) 3518c43cc173Smrg # Don't link with libc until the a.out ld.so is fixed. 3519c43cc173Smrg ;; 3520c43cc173Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 3521c43cc173Smrg # Do not include libc due to us having libc/libc_r. 3522c43cc173Smrg ;; 3523c43cc173Smrg *-*-sco3.2v5* | *-*-sco5v6*) 3524c43cc173Smrg # Causes problems with __ctype 3525c43cc173Smrg ;; 3526c43cc173Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 3527c43cc173Smrg # Compiler inserts libc in the correct place for threads to work 3528c43cc173Smrg ;; 3529c43cc173Smrg *) 3530c43cc173Smrg # Add libc to deplibs on all other systems if necessary. 3531c43cc173Smrg if test "$build_libtool_need_lc" = "yes"; then 3532c43cc173Smrg deplibs="$deplibs -lc" 3533c43cc173Smrg fi 3534c43cc173Smrg ;; 3535c43cc173Smrg esac 3536c43cc173Smrg fi 3537c43cc173Smrg 3538c43cc173Smrg # Transform deplibs into only deplibs that can be linked in shared. 3539c43cc173Smrg name_save=$name 3540c43cc173Smrg libname_save=$libname 3541c43cc173Smrg release_save=$release 3542c43cc173Smrg versuffix_save=$versuffix 3543c43cc173Smrg major_save=$major 3544c43cc173Smrg # I'm not sure if I'm treating the release correctly. I think 3545c43cc173Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 3546c43cc173Smrg # add it in twice. Is that correct? 3547c43cc173Smrg release="" 3548c43cc173Smrg versuffix="" 3549c43cc173Smrg major="" 3550c43cc173Smrg newdeplibs= 3551c43cc173Smrg droppeddeps=no 3552c43cc173Smrg case $deplibs_check_method in 3553c43cc173Smrg pass_all) 3554c43cc173Smrg # Don't check for shared/static. Everything works. 3555c43cc173Smrg # This might be a little naive. We might want to check 3556c43cc173Smrg # whether the library exists or not. But this is on 3557c43cc173Smrg # osf3 & osf4 and I'm not really sure... Just 3558c43cc173Smrg # implementing what was already the behavior. 3559c43cc173Smrg newdeplibs=$deplibs 3560c43cc173Smrg ;; 3561c43cc173Smrg test_compile) 3562c43cc173Smrg # This code stresses the "libraries are programs" paradigm to its 3563c43cc173Smrg # limits. Maybe even breaks it. We compile a program, linking it 3564c43cc173Smrg # against the deplibs as a proxy for the library. Then we can check 3565c43cc173Smrg # whether they linked in statically or dynamically with ldd. 3566c43cc173Smrg $rm conftest.c 3567c43cc173Smrg cat > conftest.c <<EOF 3568c43cc173Smrg int main() { return 0; } 3569c43cc173SmrgEOF 3570c43cc173Smrg $rm conftest 3571c43cc173Smrg $LTCC $LTCFLAGS -o conftest conftest.c $deplibs 3572c43cc173Smrg if test "$?" -eq 0 ; then 3573c43cc173Smrg ldd_output=`ldd conftest` 3574c43cc173Smrg for i in $deplibs; do 3575c43cc173Smrg name=`expr $i : '-l\(.*\)'` 3576c43cc173Smrg # If $name is empty we are operating on a -L argument. 3577c43cc173Smrg if test "$name" != "" && test "$name" -ne "0"; then 3578c43cc173Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 3579c43cc173Smrg case " $predeps $postdeps " in 3580c43cc173Smrg *" $i "*) 3581c43cc173Smrg newdeplibs="$newdeplibs $i" 3582c43cc173Smrg i="" 3583c43cc173Smrg ;; 3584c43cc173Smrg esac 3585c43cc173Smrg fi 3586c43cc173Smrg if test -n "$i" ; then 3587c43cc173Smrg libname=`eval \\$echo \"$libname_spec\"` 3588c43cc173Smrg deplib_matches=`eval \\$echo \"$library_names_spec\"` 3589c43cc173Smrg set dummy $deplib_matches 3590c43cc173Smrg deplib_match=$2 3591c43cc173Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 3592c43cc173Smrg newdeplibs="$newdeplibs $i" 3593c43cc173Smrg else 3594c43cc173Smrg droppeddeps=yes 3595c43cc173Smrg $echo 3596c43cc173Smrg $echo "*** Warning: dynamic linker does not accept needed library $i." 3597c43cc173Smrg $echo "*** I have the capability to make that library automatically link in when" 3598c43cc173Smrg $echo "*** you link to this library. But I can only do this if you have a" 3599c43cc173Smrg $echo "*** shared version of the library, which I believe you do not have" 3600c43cc173Smrg $echo "*** because a test_compile did reveal that the linker did not use it for" 3601c43cc173Smrg $echo "*** its dynamic dependency list that programs get resolved with at runtime." 3602c43cc173Smrg fi 3603c43cc173Smrg fi 3604c43cc173Smrg else 3605c43cc173Smrg newdeplibs="$newdeplibs $i" 3606c43cc173Smrg fi 3607c43cc173Smrg done 3608c43cc173Smrg else 3609c43cc173Smrg # Error occurred in the first compile. Let's try to salvage 3610c43cc173Smrg # the situation: Compile a separate program for each library. 3611c43cc173Smrg for i in $deplibs; do 3612c43cc173Smrg name=`expr $i : '-l\(.*\)'` 3613c43cc173Smrg # If $name is empty we are operating on a -L argument. 3614c43cc173Smrg if test "$name" != "" && test "$name" != "0"; then 3615c43cc173Smrg $rm conftest 3616c43cc173Smrg $LTCC $LTCFLAGS -o conftest conftest.c $i 3617c43cc173Smrg # Did it work? 3618c43cc173Smrg if test "$?" -eq 0 ; then 3619c43cc173Smrg ldd_output=`ldd conftest` 3620c43cc173Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 3621c43cc173Smrg case " $predeps $postdeps " in 3622c43cc173Smrg *" $i "*) 3623c43cc173Smrg newdeplibs="$newdeplibs $i" 3624c43cc173Smrg i="" 3625c43cc173Smrg ;; 3626c43cc173Smrg esac 3627c43cc173Smrg fi 3628c43cc173Smrg if test -n "$i" ; then 3629c43cc173Smrg libname=`eval \\$echo \"$libname_spec\"` 3630c43cc173Smrg deplib_matches=`eval \\$echo \"$library_names_spec\"` 3631c43cc173Smrg set dummy $deplib_matches 3632c43cc173Smrg deplib_match=$2 3633c43cc173Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 3634c43cc173Smrg newdeplibs="$newdeplibs $i" 3635c43cc173Smrg else 3636c43cc173Smrg droppeddeps=yes 3637c43cc173Smrg $echo 3638c43cc173Smrg $echo "*** Warning: dynamic linker does not accept needed library $i." 3639c43cc173Smrg $echo "*** I have the capability to make that library automatically link in when" 3640c43cc173Smrg $echo "*** you link to this library. But I can only do this if you have a" 3641c43cc173Smrg $echo "*** shared version of the library, which you do not appear to have" 3642c43cc173Smrg $echo "*** because a test_compile did reveal that the linker did not use this one" 3643c43cc173Smrg $echo "*** as a dynamic dependency that programs can get resolved with at runtime." 3644c43cc173Smrg fi 3645c43cc173Smrg fi 3646c43cc173Smrg else 3647c43cc173Smrg droppeddeps=yes 3648c43cc173Smrg $echo 3649c43cc173Smrg $echo "*** Warning! Library $i is needed by this library but I was not able to" 3650c43cc173Smrg $echo "*** make it link in! You will probably need to install it or some" 3651c43cc173Smrg $echo "*** library that it depends on before this library will be fully" 3652c43cc173Smrg $echo "*** functional. Installing it before continuing would be even better." 3653c43cc173Smrg fi 3654c43cc173Smrg else 3655c43cc173Smrg newdeplibs="$newdeplibs $i" 3656c43cc173Smrg fi 3657c43cc173Smrg done 3658c43cc173Smrg fi 3659c43cc173Smrg ;; 3660c43cc173Smrg file_magic*) 3661c43cc173Smrg set dummy $deplibs_check_method 3662c43cc173Smrg file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` 3663c43cc173Smrg for a_deplib in $deplibs; do 3664c43cc173Smrg name=`expr $a_deplib : '-l\(.*\)'` 3665c43cc173Smrg # If $name is empty we are operating on a -L argument. 3666c43cc173Smrg if test "$name" != "" && test "$name" != "0"; then 3667c43cc173Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 3668c43cc173Smrg case " $predeps $postdeps " in 3669c43cc173Smrg *" $a_deplib "*) 3670c43cc173Smrg newdeplibs="$newdeplibs $a_deplib" 3671c43cc173Smrg a_deplib="" 3672c43cc173Smrg ;; 3673c43cc173Smrg esac 3674c43cc173Smrg fi 3675c43cc173Smrg if test -n "$a_deplib" ; then 3676c43cc173Smrg libname=`eval \\$echo \"$libname_spec\"` 3677c43cc173Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 3678c43cc173Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 3679c43cc173Smrg for potent_lib in $potential_libs; do 3680c43cc173Smrg # Follow soft links. 3681c43cc173Smrg if ls -lLd "$potent_lib" 2>/dev/null \ 3682c43cc173Smrg | grep " -> " >/dev/null; then 3683c43cc173Smrg continue 3684c43cc173Smrg fi 3685c43cc173Smrg # The statement above tries to avoid entering an 3686c43cc173Smrg # endless loop below, in case of cyclic links. 3687c43cc173Smrg # We might still enter an endless loop, since a link 3688c43cc173Smrg # loop can be closed while we follow links, 3689c43cc173Smrg # but so what? 3690c43cc173Smrg potlib="$potent_lib" 3691c43cc173Smrg while test -h "$potlib" 2>/dev/null; do 3692c43cc173Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 3693c43cc173Smrg case $potliblink in 3694c43cc173Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 3695c43cc173Smrg *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; 3696c43cc173Smrg esac 3697c43cc173Smrg done 3698c43cc173Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ 3699c43cc173Smrg | ${SED} 10q \ 3700c43cc173Smrg | $EGREP "$file_magic_regex" > /dev/null; then 3701c43cc173Smrg newdeplibs="$newdeplibs $a_deplib" 3702c43cc173Smrg a_deplib="" 3703c43cc173Smrg break 2 3704c43cc173Smrg fi 3705c43cc173Smrg done 3706c43cc173Smrg done 3707c43cc173Smrg fi 3708c43cc173Smrg if test -n "$a_deplib" ; then 3709c43cc173Smrg droppeddeps=yes 3710c43cc173Smrg $echo 3711c43cc173Smrg $echo "*** Warning: linker path does not have real file for library $a_deplib." 3712c43cc173Smrg $echo "*** I have the capability to make that library automatically link in when" 3713c43cc173Smrg $echo "*** you link to this library. But I can only do this if you have a" 3714c43cc173Smrg $echo "*** shared version of the library, which you do not appear to have" 3715c43cc173Smrg $echo "*** because I did check the linker path looking for a file starting" 3716c43cc173Smrg if test -z "$potlib" ; then 3717c43cc173Smrg $echo "*** with $libname but no candidates were found. (...for file magic test)" 3718c43cc173Smrg else 3719c43cc173Smrg $echo "*** with $libname and none of the candidates passed a file format test" 3720c43cc173Smrg $echo "*** using a file magic. Last file checked: $potlib" 3721c43cc173Smrg fi 3722c43cc173Smrg fi 3723c43cc173Smrg else 3724c43cc173Smrg # Add a -L argument. 3725c43cc173Smrg newdeplibs="$newdeplibs $a_deplib" 3726c43cc173Smrg fi 3727c43cc173Smrg done # Gone through all deplibs. 3728c43cc173Smrg ;; 3729c43cc173Smrg match_pattern*) 3730c43cc173Smrg set dummy $deplibs_check_method 3731c43cc173Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` 3732c43cc173Smrg for a_deplib in $deplibs; do 3733c43cc173Smrg name=`expr $a_deplib : '-l\(.*\)'` 3734c43cc173Smrg # If $name is empty we are operating on a -L argument. 3735c43cc173Smrg if test -n "$name" && test "$name" != "0"; then 3736c43cc173Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 3737c43cc173Smrg case " $predeps $postdeps " in 3738c43cc173Smrg *" $a_deplib "*) 3739c43cc173Smrg newdeplibs="$newdeplibs $a_deplib" 3740c43cc173Smrg a_deplib="" 3741c43cc173Smrg ;; 3742c43cc173Smrg esac 3743c43cc173Smrg fi 3744c43cc173Smrg if test -n "$a_deplib" ; then 3745c43cc173Smrg libname=`eval \\$echo \"$libname_spec\"` 3746c43cc173Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 3747c43cc173Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 3748c43cc173Smrg for potent_lib in $potential_libs; do 3749c43cc173Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 3750c43cc173Smrg if eval $echo \"$potent_lib\" 2>/dev/null \ 3751c43cc173Smrg | ${SED} 10q \ 3752c43cc173Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 3753c43cc173Smrg newdeplibs="$newdeplibs $a_deplib" 3754c43cc173Smrg a_deplib="" 3755c43cc173Smrg break 2 3756c43cc173Smrg fi 3757c43cc173Smrg done 3758c43cc173Smrg done 3759c43cc173Smrg fi 3760c43cc173Smrg if test -n "$a_deplib" ; then 3761c43cc173Smrg droppeddeps=yes 3762c43cc173Smrg $echo 3763c43cc173Smrg $echo "*** Warning: linker path does not have real file for library $a_deplib." 3764c43cc173Smrg $echo "*** I have the capability to make that library automatically link in when" 3765c43cc173Smrg $echo "*** you link to this library. But I can only do this if you have a" 3766c43cc173Smrg $echo "*** shared version of the library, which you do not appear to have" 3767c43cc173Smrg $echo "*** because I did check the linker path looking for a file starting" 3768c43cc173Smrg if test -z "$potlib" ; then 3769c43cc173Smrg $echo "*** with $libname but no candidates were found. (...for regex pattern test)" 3770c43cc173Smrg else 3771c43cc173Smrg $echo "*** with $libname and none of the candidates passed a file format test" 3772c43cc173Smrg $echo "*** using a regex pattern. Last file checked: $potlib" 3773c43cc173Smrg fi 3774c43cc173Smrg fi 3775c43cc173Smrg else 3776c43cc173Smrg # Add a -L argument. 3777c43cc173Smrg newdeplibs="$newdeplibs $a_deplib" 3778c43cc173Smrg fi 3779c43cc173Smrg done # Gone through all deplibs. 3780c43cc173Smrg ;; 3781c43cc173Smrg none | unknown | *) 3782c43cc173Smrg newdeplibs="" 3783c43cc173Smrg tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ 3784c43cc173Smrg -e 's/ -[LR][^ ]*//g'` 3785c43cc173Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 3786c43cc173Smrg for i in $predeps $postdeps ; do 3787c43cc173Smrg # can't use Xsed below, because $i might contain '/' 3788c43cc173Smrg tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` 3789c43cc173Smrg done 3790c43cc173Smrg fi 3791c43cc173Smrg if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ 3792c43cc173Smrg | grep . >/dev/null; then 3793c43cc173Smrg $echo 3794c43cc173Smrg if test "X$deplibs_check_method" = "Xnone"; then 3795c43cc173Smrg $echo "*** Warning: inter-library dependencies are not supported in this platform." 3796c43cc173Smrg else 3797c43cc173Smrg $echo "*** Warning: inter-library dependencies are not known to be supported." 3798c43cc173Smrg fi 3799c43cc173Smrg $echo "*** All declared inter-library dependencies are being dropped." 3800c43cc173Smrg droppeddeps=yes 3801c43cc173Smrg fi 3802c43cc173Smrg ;; 3803c43cc173Smrg esac 3804c43cc173Smrg versuffix=$versuffix_save 3805c43cc173Smrg major=$major_save 3806c43cc173Smrg release=$release_save 3807c43cc173Smrg libname=$libname_save 3808c43cc173Smrg name=$name_save 3809c43cc173Smrg 3810c43cc173Smrg case $host in 3811c43cc173Smrg *-*-rhapsody* | *-*-darwin1.[012]) 3812c43cc173Smrg # On Rhapsody replace the C library is the System framework 3813c43cc173Smrg newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` 3814c43cc173Smrg ;; 3815c43cc173Smrg esac 3816c43cc173Smrg 3817c43cc173Smrg if test "$droppeddeps" = yes; then 3818c43cc173Smrg if test "$module" = yes; then 3819c43cc173Smrg $echo 3820c43cc173Smrg $echo "*** Warning: libtool could not satisfy all declared inter-library" 3821c43cc173Smrg $echo "*** dependencies of module $libname. Therefore, libtool will create" 3822c43cc173Smrg $echo "*** a static module, that should work as long as the dlopening" 3823c43cc173Smrg $echo "*** application is linked with the -dlopen flag." 3824c43cc173Smrg if test -z "$global_symbol_pipe"; then 3825c43cc173Smrg $echo 3826c43cc173Smrg $echo "*** However, this would only work if libtool was able to extract symbol" 3827c43cc173Smrg $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 3828c43cc173Smrg $echo "*** not find such a program. So, this module is probably useless." 3829c43cc173Smrg $echo "*** \`nm' from GNU binutils and a full rebuild may help." 3830c43cc173Smrg fi 3831c43cc173Smrg if test "$build_old_libs" = no; then 3832c43cc173Smrg oldlibs="$output_objdir/$libname.$libext" 3833c43cc173Smrg build_libtool_libs=module 3834c43cc173Smrg build_old_libs=yes 3835c43cc173Smrg else 3836c43cc173Smrg build_libtool_libs=no 3837c43cc173Smrg fi 3838c43cc173Smrg else 3839c43cc173Smrg $echo "*** The inter-library dependencies that have been dropped here will be" 3840c43cc173Smrg $echo "*** automatically added whenever a program is linked with this library" 3841c43cc173Smrg $echo "*** or is declared to -dlopen it." 3842c43cc173Smrg 3843c43cc173Smrg if test "$allow_undefined" = no; then 3844c43cc173Smrg $echo 3845c43cc173Smrg $echo "*** Since this library must not contain undefined symbols," 3846c43cc173Smrg $echo "*** because either the platform does not support them or" 3847c43cc173Smrg $echo "*** it was explicitly requested with -no-undefined," 3848c43cc173Smrg $echo "*** libtool will only create a static version of it." 3849c43cc173Smrg if test "$build_old_libs" = no; then 3850c43cc173Smrg oldlibs="$output_objdir/$libname.$libext" 3851c43cc173Smrg build_libtool_libs=module 3852c43cc173Smrg build_old_libs=yes 3853c43cc173Smrg else 3854c43cc173Smrg build_libtool_libs=no 3855c43cc173Smrg fi 3856c43cc173Smrg fi 3857c43cc173Smrg fi 3858c43cc173Smrg fi 3859c43cc173Smrg # Done checking deplibs! 3860c43cc173Smrg deplibs=$newdeplibs 3861c43cc173Smrg fi 3862c43cc173Smrg 3863c43cc173Smrg 3864c43cc173Smrg # move library search paths that coincide with paths to not yet 3865c43cc173Smrg # installed libraries to the beginning of the library search list 3866c43cc173Smrg new_libs= 3867c43cc173Smrg for path in $notinst_path; do 3868c43cc173Smrg case " $new_libs " in 3869c43cc173Smrg *" -L$path/$objdir "*) ;; 3870c43cc173Smrg *) 3871c43cc173Smrg case " $deplibs " in 3872c43cc173Smrg *" -L$path/$objdir "*) 3873c43cc173Smrg new_libs="$new_libs -L$path/$objdir" ;; 3874c43cc173Smrg esac 3875c43cc173Smrg ;; 3876c43cc173Smrg esac 3877c43cc173Smrg done 3878c43cc173Smrg for deplib in $deplibs; do 3879c43cc173Smrg case $deplib in 3880c43cc173Smrg -L*) 3881c43cc173Smrg case " $new_libs " in 3882c43cc173Smrg *" $deplib "*) ;; 3883c43cc173Smrg *) new_libs="$new_libs $deplib" ;; 3884c43cc173Smrg esac 3885c43cc173Smrg ;; 3886c43cc173Smrg *) new_libs="$new_libs $deplib" ;; 3887c43cc173Smrg esac 3888c43cc173Smrg done 3889c43cc173Smrg deplibs="$new_libs" 3890c43cc173Smrg 3891c43cc173Smrg 3892c43cc173Smrg # All the library-specific variables (install_libdir is set above). 3893c43cc173Smrg library_names= 3894c43cc173Smrg old_library= 3895c43cc173Smrg dlname= 3896c43cc173Smrg 3897c43cc173Smrg # Test again, we may have decided not to build it any more 3898c43cc173Smrg if test "$build_libtool_libs" = yes; then 3899c43cc173Smrg if test "$hardcode_into_libs" = yes; then 3900c43cc173Smrg # Hardcode the library paths 3901c43cc173Smrg hardcode_libdirs= 3902c43cc173Smrg dep_rpath= 3903c43cc173Smrg rpath="$finalize_rpath" 3904c43cc173Smrg test "$mode" != relink && rpath="$compile_rpath$rpath" 3905c43cc173Smrg for libdir in $rpath; do 3906c43cc173Smrg if test -n "$hardcode_libdir_flag_spec"; then 3907c43cc173Smrg if test -n "$hardcode_libdir_separator"; then 3908c43cc173Smrg if test -z "$hardcode_libdirs"; then 3909c43cc173Smrg hardcode_libdirs="$libdir" 3910c43cc173Smrg else 3911c43cc173Smrg # Just accumulate the unique libdirs. 3912c43cc173Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 3913c43cc173Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 3914c43cc173Smrg ;; 3915c43cc173Smrg *) 3916c43cc173Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 3917c43cc173Smrg ;; 3918c43cc173Smrg esac 3919c43cc173Smrg fi 3920c43cc173Smrg else 3921c43cc173Smrg eval flag=\"$hardcode_libdir_flag_spec\" 3922c43cc173Smrg dep_rpath="$dep_rpath $flag" 3923c43cc173Smrg fi 3924c43cc173Smrg elif test -n "$runpath_var"; then 3925c43cc173Smrg case "$perm_rpath " in 3926c43cc173Smrg *" $libdir "*) ;; 3927c43cc173Smrg *) perm_rpath="$perm_rpath $libdir" ;; 3928c43cc173Smrg esac 3929c43cc173Smrg fi 3930c43cc173Smrg done 3931c43cc173Smrg # Substitute the hardcoded libdirs into the rpath. 3932c43cc173Smrg if test -n "$hardcode_libdir_separator" && 3933c43cc173Smrg test -n "$hardcode_libdirs"; then 3934c43cc173Smrg libdir="$hardcode_libdirs" 3935c43cc173Smrg if test -n "$hardcode_libdir_flag_spec_ld"; then 3936c43cc173Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" 3937c43cc173Smrg else 3938c43cc173Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec\" 3939c43cc173Smrg fi 3940c43cc173Smrg fi 3941c43cc173Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 3942c43cc173Smrg # We should set the runpath_var. 3943c43cc173Smrg rpath= 3944c43cc173Smrg for dir in $perm_rpath; do 3945c43cc173Smrg rpath="$rpath$dir:" 3946c43cc173Smrg done 3947c43cc173Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 3948c43cc173Smrg fi 3949c43cc173Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 3950c43cc173Smrg fi 3951c43cc173Smrg 3952c43cc173Smrg shlibpath="$finalize_shlibpath" 3953c43cc173Smrg test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 3954c43cc173Smrg if test -n "$shlibpath"; then 3955c43cc173Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 3956c43cc173Smrg fi 3957c43cc173Smrg 3958c43cc173Smrg # Get the real and link names of the library. 3959c43cc173Smrg eval shared_ext=\"$shrext_cmds\" 3960c43cc173Smrg eval library_names=\"$library_names_spec\" 3961c43cc173Smrg set dummy $library_names 3962c43cc173Smrg realname="$2" 3963c43cc173Smrg shift; shift 3964c43cc173Smrg 3965c43cc173Smrg if test -n "$soname_spec"; then 3966c43cc173Smrg eval soname=\"$soname_spec\" 3967c43cc173Smrg else 3968c43cc173Smrg soname="$realname" 3969c43cc173Smrg fi 3970c43cc173Smrg if test -z "$dlname"; then 3971c43cc173Smrg dlname=$soname 3972c43cc173Smrg fi 3973c43cc173Smrg 3974c43cc173Smrg lib="$output_objdir/$realname" 3975c43cc173Smrg linknames= 3976c43cc173Smrg for link 3977c43cc173Smrg do 3978c43cc173Smrg linknames="$linknames $link" 3979c43cc173Smrg done 3980c43cc173Smrg 3981c43cc173Smrg # Use standard objects if they are pic 3982c43cc173Smrg test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` 3983c43cc173Smrg 3984c43cc173Smrg # Prepare the list of exported symbols 3985c43cc173Smrg if test -z "$export_symbols"; then 3986c43cc173Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 3987c43cc173Smrg $show "generating symbol list for \`$libname.la'" 3988c43cc173Smrg export_symbols="$output_objdir/$libname.exp" 3989c43cc173Smrg $run $rm $export_symbols 3990c43cc173Smrg cmds=$export_symbols_cmds 3991c43cc173Smrg save_ifs="$IFS"; IFS='~' 3992c43cc173Smrg for cmd in $cmds; do 3993c43cc173Smrg IFS="$save_ifs" 3994c43cc173Smrg eval cmd=\"$cmd\" 3995c43cc173Smrg if len=`expr "X$cmd" : ".*"` && 3996c43cc173Smrg test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then 3997c43cc173Smrg $show "$cmd" 3998c43cc173Smrg $run eval "$cmd" || exit $? 3999c43cc173Smrg skipped_export=false 4000c43cc173Smrg else 4001c43cc173Smrg # The command line is too long to execute in one step. 4002c43cc173Smrg $show "using reloadable object file for export list..." 4003c43cc173Smrg skipped_export=: 4004c43cc173Smrg # Break out early, otherwise skipped_export may be 4005c43cc173Smrg # set to false by a later but shorter cmd. 4006c43cc173Smrg break 4007c43cc173Smrg fi 4008c43cc173Smrg done 4009c43cc173Smrg IFS="$save_ifs" 4010c43cc173Smrg if test -n "$export_symbols_regex"; then 4011c43cc173Smrg $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" 4012c43cc173Smrg $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 4013c43cc173Smrg $show "$mv \"${export_symbols}T\" \"$export_symbols\"" 4014c43cc173Smrg $run eval '$mv "${export_symbols}T" "$export_symbols"' 4015c43cc173Smrg fi 4016c43cc173Smrg fi 4017c43cc173Smrg fi 4018c43cc173Smrg 4019c43cc173Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 4020c43cc173Smrg $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' 4021c43cc173Smrg fi 4022c43cc173Smrg 4023c43cc173Smrg tmp_deplibs= 4024c43cc173Smrg for test_deplib in $deplibs; do 4025c43cc173Smrg case " $convenience " in 4026c43cc173Smrg *" $test_deplib "*) ;; 4027c43cc173Smrg *) 4028c43cc173Smrg tmp_deplibs="$tmp_deplibs $test_deplib" 4029c43cc173Smrg ;; 4030c43cc173Smrg esac 4031c43cc173Smrg done 4032c43cc173Smrg deplibs="$tmp_deplibs" 4033c43cc173Smrg 4034c43cc173Smrg if test -n "$convenience"; then 4035c43cc173Smrg if test -n "$whole_archive_flag_spec"; then 4036c43cc173Smrg save_libobjs=$libobjs 4037c43cc173Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 4038c43cc173Smrg else 4039c43cc173Smrg gentop="$output_objdir/${outputname}x" 4040c43cc173Smrg generated="$generated $gentop" 4041c43cc173Smrg 4042c43cc173Smrg func_extract_archives $gentop $convenience 4043c43cc173Smrg libobjs="$libobjs $func_extract_archives_result" 4044c43cc173Smrg fi 4045c43cc173Smrg fi 4046c43cc173Smrg 4047c43cc173Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 4048c43cc173Smrg eval flag=\"$thread_safe_flag_spec\" 4049c43cc173Smrg linker_flags="$linker_flags $flag" 4050c43cc173Smrg fi 4051c43cc173Smrg 4052c43cc173Smrg # Make a backup of the uninstalled library when relinking 4053c43cc173Smrg if test "$mode" = relink; then 4054c43cc173Smrg $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? 4055c43cc173Smrg fi 4056c43cc173Smrg 4057c43cc173Smrg # Do each of the archive commands. 4058c43cc173Smrg if test "$module" = yes && test -n "$module_cmds" ; then 4059c43cc173Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 4060c43cc173Smrg eval test_cmds=\"$module_expsym_cmds\" 4061c43cc173Smrg cmds=$module_expsym_cmds 4062c43cc173Smrg else 4063c43cc173Smrg eval test_cmds=\"$module_cmds\" 4064c43cc173Smrg cmds=$module_cmds 4065c43cc173Smrg fi 4066c43cc173Smrg else 4067c43cc173Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 4068c43cc173Smrg eval test_cmds=\"$archive_expsym_cmds\" 4069c43cc173Smrg cmds=$archive_expsym_cmds 4070c43cc173Smrg else 4071c43cc173Smrg eval test_cmds=\"$archive_cmds\" 4072c43cc173Smrg cmds=$archive_cmds 4073c43cc173Smrg fi 4074c43cc173Smrg fi 4075c43cc173Smrg 4076c43cc173Smrg if test "X$skipped_export" != "X:" && 4077c43cc173Smrg len=`expr "X$test_cmds" : ".*" 2>/dev/null` && 4078c43cc173Smrg test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then 4079c43cc173Smrg : 4080c43cc173Smrg else 4081c43cc173Smrg # The command line is too long to link in one step, link piecewise. 4082c43cc173Smrg $echo "creating reloadable object files..." 4083c43cc173Smrg 4084c43cc173Smrg # Save the value of $output and $libobjs because we want to 4085c43cc173Smrg # use them later. If we have whole_archive_flag_spec, we 4086c43cc173Smrg # want to use save_libobjs as it was before 4087c43cc173Smrg # whole_archive_flag_spec was expanded, because we can't 4088c43cc173Smrg # assume the linker understands whole_archive_flag_spec. 4089c43cc173Smrg # This may have to be revisited, in case too many 4090c43cc173Smrg # convenience libraries get linked in and end up exceeding 4091c43cc173Smrg # the spec. 4092c43cc173Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 4093c43cc173Smrg save_libobjs=$libobjs 4094c43cc173Smrg fi 4095c43cc173Smrg save_output=$output 4096c43cc173Smrg output_la=`$echo "X$output" | $Xsed -e "$basename"` 4097c43cc173Smrg 4098c43cc173Smrg # Clear the reloadable object creation command queue and 4099c43cc173Smrg # initialize k to one. 4100c43cc173Smrg test_cmds= 4101c43cc173Smrg concat_cmds= 4102c43cc173Smrg objlist= 4103c43cc173Smrg delfiles= 4104c43cc173Smrg last_robj= 4105c43cc173Smrg k=1 4106c43cc173Smrg output=$output_objdir/$output_la-${k}.$objext 4107c43cc173Smrg # Loop over the list of objects to be linked. 4108c43cc173Smrg for obj in $save_libobjs 4109c43cc173Smrg do 4110c43cc173Smrg eval test_cmds=\"$reload_cmds $objlist $last_robj\" 4111c43cc173Smrg if test "X$objlist" = X || 4112c43cc173Smrg { len=`expr "X$test_cmds" : ".*" 2>/dev/null` && 4113c43cc173Smrg test "$len" -le "$max_cmd_len"; }; then 4114c43cc173Smrg objlist="$objlist $obj" 4115c43cc173Smrg else 4116c43cc173Smrg # The command $test_cmds is almost too long, add a 4117c43cc173Smrg # command to the queue. 4118c43cc173Smrg if test "$k" -eq 1 ; then 4119c43cc173Smrg # The first file doesn't have a previous command to add. 4120c43cc173Smrg eval concat_cmds=\"$reload_cmds $objlist $last_robj\" 4121c43cc173Smrg else 4122c43cc173Smrg # All subsequent reloadable object files will link in 4123c43cc173Smrg # the last one created. 4124c43cc173Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" 4125c43cc173Smrg fi 4126c43cc173Smrg last_robj=$output_objdir/$output_la-${k}.$objext 4127c43cc173Smrg k=`expr $k + 1` 4128c43cc173Smrg output=$output_objdir/$output_la-${k}.$objext 4129c43cc173Smrg objlist=$obj 4130c43cc173Smrg len=1 4131c43cc173Smrg fi 4132c43cc173Smrg done 4133c43cc173Smrg # Handle the remaining objects by creating one last 4134c43cc173Smrg # reloadable object file. All subsequent reloadable object 4135c43cc173Smrg # files will link in the last one created. 4136c43cc173Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 4137c43cc173Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" 4138c43cc173Smrg 4139c43cc173Smrg if ${skipped_export-false}; then 4140c43cc173Smrg $show "generating symbol list for \`$libname.la'" 4141c43cc173Smrg export_symbols="$output_objdir/$libname.exp" 4142c43cc173Smrg $run $rm $export_symbols 4143c43cc173Smrg libobjs=$output 4144c43cc173Smrg # Append the command to create the export file. 4145c43cc173Smrg eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" 4146c43cc173Smrg fi 4147c43cc173Smrg 4148c43cc173Smrg # Set up a command to remove the reloadable object files 4149c43cc173Smrg # after they are used. 4150c43cc173Smrg i=0 4151c43cc173Smrg while test "$i" -lt "$k" 4152c43cc173Smrg do 4153c43cc173Smrg i=`expr $i + 1` 4154c43cc173Smrg delfiles="$delfiles $output_objdir/$output_la-${i}.$objext" 4155c43cc173Smrg done 4156c43cc173Smrg 4157c43cc173Smrg $echo "creating a temporary reloadable object file: $output" 4158c43cc173Smrg 4159c43cc173Smrg # Loop through the commands generated above and execute them. 4160c43cc173Smrg save_ifs="$IFS"; IFS='~' 4161c43cc173Smrg for cmd in $concat_cmds; do 4162c43cc173Smrg IFS="$save_ifs" 4163c43cc173Smrg $show "$cmd" 4164c43cc173Smrg $run eval "$cmd" || exit $? 4165c43cc173Smrg done 4166c43cc173Smrg IFS="$save_ifs" 4167c43cc173Smrg 4168c43cc173Smrg libobjs=$output 4169c43cc173Smrg # Restore the value of output. 4170c43cc173Smrg output=$save_output 4171c43cc173Smrg 4172c43cc173Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 4173c43cc173Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 4174c43cc173Smrg fi 4175c43cc173Smrg # Expand the library linking commands again to reset the 4176c43cc173Smrg # value of $libobjs for piecewise linking. 4177c43cc173Smrg 4178c43cc173Smrg # Do each of the archive commands. 4179c43cc173Smrg if test "$module" = yes && test -n "$module_cmds" ; then 4180c43cc173Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 4181c43cc173Smrg cmds=$module_expsym_cmds 4182c43cc173Smrg else 4183c43cc173Smrg cmds=$module_cmds 4184c43cc173Smrg fi 4185c43cc173Smrg else 4186c43cc173Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 4187c43cc173Smrg cmds=$archive_expsym_cmds 4188c43cc173Smrg else 4189c43cc173Smrg cmds=$archive_cmds 4190c43cc173Smrg fi 4191c43cc173Smrg fi 4192c43cc173Smrg 4193c43cc173Smrg # Append the command to remove the reloadable object files 4194c43cc173Smrg # to the just-reset $cmds. 4195c43cc173Smrg eval cmds=\"\$cmds~\$rm $delfiles\" 4196c43cc173Smrg fi 4197c43cc173Smrg save_ifs="$IFS"; IFS='~' 4198c43cc173Smrg for cmd in $cmds; do 4199c43cc173Smrg IFS="$save_ifs" 4200c43cc173Smrg eval cmd=\"$cmd\" 4201c43cc173Smrg $show "$cmd" 4202c43cc173Smrg $run eval "$cmd" || { 4203c43cc173Smrg lt_exit=$? 4204c43cc173Smrg 4205c43cc173Smrg # Restore the uninstalled library and exit 4206c43cc173Smrg if test "$mode" = relink; then 4207c43cc173Smrg $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' 4208c43cc173Smrg fi 4209c43cc173Smrg 4210c43cc173Smrg exit $lt_exit 4211c43cc173Smrg } 4212c43cc173Smrg done 4213c43cc173Smrg IFS="$save_ifs" 4214c43cc173Smrg 4215c43cc173Smrg # Restore the uninstalled library and exit 4216c43cc173Smrg if test "$mode" = relink; then 4217c43cc173Smrg $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? 4218c43cc173Smrg 4219c43cc173Smrg if test -n "$convenience"; then 4220c43cc173Smrg if test -z "$whole_archive_flag_spec"; then 4221c43cc173Smrg $show "${rm}r $gentop" 4222c43cc173Smrg $run ${rm}r "$gentop" 4223c43cc173Smrg fi 4224c43cc173Smrg fi 4225c43cc173Smrg 4226c43cc173Smrg exit $EXIT_SUCCESS 4227c43cc173Smrg fi 4228c43cc173Smrg 4229c43cc173Smrg # Create links to the real library. 4230c43cc173Smrg for linkname in $linknames; do 4231c43cc173Smrg if test "$realname" != "$linkname"; then 4232c43cc173Smrg $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" 4233c43cc173Smrg $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? 4234c43cc173Smrg fi 4235c43cc173Smrg done 4236c43cc173Smrg 4237c43cc173Smrg # If -module or -export-dynamic was specified, set the dlname. 4238c43cc173Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 4239c43cc173Smrg # On all known operating systems, these are identical. 4240c43cc173Smrg dlname="$soname" 4241c43cc173Smrg fi 4242c43cc173Smrg fi 4243c43cc173Smrg ;; 4244c43cc173Smrg 4245c43cc173Smrg obj) 4246c43cc173Smrg if test -n "$deplibs"; then 4247c43cc173Smrg $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 4248c43cc173Smrg fi 4249c43cc173Smrg 4250c43cc173Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 4251c43cc173Smrg $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 4252c43cc173Smrg fi 4253c43cc173Smrg 4254c43cc173Smrg if test -n "$rpath"; then 4255c43cc173Smrg $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 4256c43cc173Smrg fi 4257c43cc173Smrg 4258c43cc173Smrg if test -n "$xrpath"; then 4259c43cc173Smrg $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 4260c43cc173Smrg fi 4261c43cc173Smrg 4262c43cc173Smrg if test -n "$vinfo"; then 4263c43cc173Smrg $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 4264c43cc173Smrg fi 4265c43cc173Smrg 4266c43cc173Smrg if test -n "$release"; then 4267c43cc173Smrg $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 4268c43cc173Smrg fi 4269c43cc173Smrg 4270c43cc173Smrg case $output in 4271c43cc173Smrg *.lo) 4272c43cc173Smrg if test -n "$objs$old_deplibs"; then 4273c43cc173Smrg $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 4274c43cc173Smrg exit $EXIT_FAILURE 4275c43cc173Smrg fi 4276c43cc173Smrg libobj="$output" 4277c43cc173Smrg obj=`$echo "X$output" | $Xsed -e "$lo2o"` 4278c43cc173Smrg ;; 4279c43cc173Smrg *) 4280c43cc173Smrg libobj= 4281c43cc173Smrg obj="$output" 4282c43cc173Smrg ;; 4283c43cc173Smrg esac 4284c43cc173Smrg 4285c43cc173Smrg # Delete the old objects. 4286c43cc173Smrg $run $rm $obj $libobj 4287c43cc173Smrg 4288c43cc173Smrg # Objects from convenience libraries. This assumes 4289c43cc173Smrg # single-version convenience libraries. Whenever we create 4290c43cc173Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 4291c43cc173Smrg # the extraction. 4292c43cc173Smrg reload_conv_objs= 4293c43cc173Smrg gentop= 4294c43cc173Smrg # reload_cmds runs $LD directly, so let us get rid of 4295c43cc173Smrg # -Wl from whole_archive_flag_spec 4296c43cc173Smrg wl= 4297c43cc173Smrg 4298c43cc173Smrg if test -n "$convenience"; then 4299c43cc173Smrg if test -n "$whole_archive_flag_spec"; then 4300c43cc173Smrg eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" 4301c43cc173Smrg else 4302c43cc173Smrg gentop="$output_objdir/${obj}x" 4303c43cc173Smrg generated="$generated $gentop" 4304c43cc173Smrg 4305c43cc173Smrg func_extract_archives $gentop $convenience 4306c43cc173Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 4307c43cc173Smrg fi 4308c43cc173Smrg fi 4309c43cc173Smrg 4310c43cc173Smrg # Create the old-style object. 4311c43cc173Smrg reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 4312c43cc173Smrg 4313c43cc173Smrg output="$obj" 4314c43cc173Smrg cmds=$reload_cmds 4315c43cc173Smrg save_ifs="$IFS"; IFS='~' 4316c43cc173Smrg for cmd in $cmds; do 4317c43cc173Smrg IFS="$save_ifs" 4318c43cc173Smrg eval cmd=\"$cmd\" 4319c43cc173Smrg $show "$cmd" 4320c43cc173Smrg $run eval "$cmd" || exit $? 4321c43cc173Smrg done 4322c43cc173Smrg IFS="$save_ifs" 4323c43cc173Smrg 4324c43cc173Smrg # Exit if we aren't doing a library object file. 4325c43cc173Smrg if test -z "$libobj"; then 4326c43cc173Smrg if test -n "$gentop"; then 4327c43cc173Smrg $show "${rm}r $gentop" 4328c43cc173Smrg $run ${rm}r $gentop 4329c43cc173Smrg fi 4330c43cc173Smrg 4331c43cc173Smrg exit $EXIT_SUCCESS 4332c43cc173Smrg fi 4333c43cc173Smrg 4334c43cc173Smrg if test "$build_libtool_libs" != yes; then 4335c43cc173Smrg if test -n "$gentop"; then 4336c43cc173Smrg $show "${rm}r $gentop" 4337c43cc173Smrg $run ${rm}r $gentop 4338c43cc173Smrg fi 4339c43cc173Smrg 4340c43cc173Smrg # Create an invalid libtool object if no PIC, so that we don't 4341c43cc173Smrg # accidentally link it into a program. 4342c43cc173Smrg # $show "echo timestamp > $libobj" 4343c43cc173Smrg # $run eval "echo timestamp > $libobj" || exit $? 4344c43cc173Smrg exit $EXIT_SUCCESS 4345c43cc173Smrg fi 4346c43cc173Smrg 4347c43cc173Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 4348c43cc173Smrg # Only do commands if we really have different PIC objects. 4349c43cc173Smrg reload_objs="$libobjs $reload_conv_objs" 4350c43cc173Smrg output="$libobj" 4351c43cc173Smrg cmds=$reload_cmds 4352c43cc173Smrg save_ifs="$IFS"; IFS='~' 4353c43cc173Smrg for cmd in $cmds; do 4354c43cc173Smrg IFS="$save_ifs" 4355c43cc173Smrg eval cmd=\"$cmd\" 4356c43cc173Smrg $show "$cmd" 4357c43cc173Smrg $run eval "$cmd" || exit $? 4358c43cc173Smrg done 4359c43cc173Smrg IFS="$save_ifs" 4360c43cc173Smrg fi 4361c43cc173Smrg 4362c43cc173Smrg if test -n "$gentop"; then 4363c43cc173Smrg $show "${rm}r $gentop" 4364c43cc173Smrg $run ${rm}r $gentop 4365c43cc173Smrg fi 4366c43cc173Smrg 4367c43cc173Smrg exit $EXIT_SUCCESS 4368c43cc173Smrg ;; 4369c43cc173Smrg 4370c43cc173Smrg prog) 4371c43cc173Smrg case $host in 4372c43cc173Smrg *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; 4373c43cc173Smrg esac 4374c43cc173Smrg if test -n "$vinfo"; then 4375c43cc173Smrg $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 4376c43cc173Smrg fi 4377c43cc173Smrg 4378c43cc173Smrg if test -n "$release"; then 4379c43cc173Smrg $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 4380c43cc173Smrg fi 4381c43cc173Smrg 4382c43cc173Smrg if test "$preload" = yes; then 4383c43cc173Smrg if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && 4384c43cc173Smrg test "$dlopen_self_static" = unknown; then 4385c43cc173Smrg $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." 4386c43cc173Smrg fi 4387c43cc173Smrg fi 4388c43cc173Smrg 4389c43cc173Smrg case $host in 4390c43cc173Smrg *-*-rhapsody* | *-*-darwin1.[012]) 4391c43cc173Smrg # On Rhapsody replace the C library is the System framework 4392c43cc173Smrg compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` 4393c43cc173Smrg finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` 4394c43cc173Smrg ;; 4395c43cc173Smrg esac 4396c43cc173Smrg 4397c43cc173Smrg case $host in 4398c43cc173Smrg *darwin*) 4399c43cc173Smrg # Don't allow lazy linking, it breaks C++ global constructors 4400c43cc173Smrg if test "$tagname" = CXX ; then 4401c43cc173Smrg compile_command="$compile_command ${wl}-bind_at_load" 4402c43cc173Smrg finalize_command="$finalize_command ${wl}-bind_at_load" 4403c43cc173Smrg fi 4404c43cc173Smrg ;; 4405c43cc173Smrg esac 4406c43cc173Smrg 4407c43cc173Smrg 4408c43cc173Smrg # move library search paths that coincide with paths to not yet 4409c43cc173Smrg # installed libraries to the beginning of the library search list 4410c43cc173Smrg new_libs= 4411c43cc173Smrg for path in $notinst_path; do 4412c43cc173Smrg case " $new_libs " in 4413c43cc173Smrg *" -L$path/$objdir "*) ;; 4414c43cc173Smrg *) 4415c43cc173Smrg case " $compile_deplibs " in 4416c43cc173Smrg *" -L$path/$objdir "*) 4417c43cc173Smrg new_libs="$new_libs -L$path/$objdir" ;; 4418c43cc173Smrg esac 4419c43cc173Smrg ;; 4420c43cc173Smrg esac 4421c43cc173Smrg done 4422c43cc173Smrg for deplib in $compile_deplibs; do 4423c43cc173Smrg case $deplib in 4424c43cc173Smrg -L*) 4425c43cc173Smrg case " $new_libs " in 4426c43cc173Smrg *" $deplib "*) ;; 4427c43cc173Smrg *) new_libs="$new_libs $deplib" ;; 4428c43cc173Smrg esac 4429c43cc173Smrg ;; 4430c43cc173Smrg *) new_libs="$new_libs $deplib" ;; 4431c43cc173Smrg esac 4432c43cc173Smrg done 4433c43cc173Smrg compile_deplibs="$new_libs" 4434c43cc173Smrg 4435c43cc173Smrg 4436c43cc173Smrg compile_command="$compile_command $compile_deplibs" 4437c43cc173Smrg finalize_command="$finalize_command $finalize_deplibs" 4438c43cc173Smrg 4439c43cc173Smrg if test -n "$rpath$xrpath"; then 4440c43cc173Smrg # If the user specified any rpath flags, then add them. 4441c43cc173Smrg for libdir in $rpath $xrpath; do 4442c43cc173Smrg # This is the magic to use -rpath. 4443c43cc173Smrg case "$finalize_rpath " in 4444c43cc173Smrg *" $libdir "*) ;; 4445c43cc173Smrg *) finalize_rpath="$finalize_rpath $libdir" ;; 4446c43cc173Smrg esac 4447c43cc173Smrg done 4448c43cc173Smrg fi 4449c43cc173Smrg 4450c43cc173Smrg # Now hardcode the library paths 4451c43cc173Smrg rpath= 4452c43cc173Smrg hardcode_libdirs= 4453c43cc173Smrg for libdir in $compile_rpath $finalize_rpath; do 4454c43cc173Smrg if test -n "$hardcode_libdir_flag_spec"; then 4455c43cc173Smrg if test -n "$hardcode_libdir_separator"; then 4456c43cc173Smrg if test -z "$hardcode_libdirs"; then 4457c43cc173Smrg hardcode_libdirs="$libdir" 4458c43cc173Smrg else 4459c43cc173Smrg # Just accumulate the unique libdirs. 4460c43cc173Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 4461c43cc173Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 4462c43cc173Smrg ;; 4463c43cc173Smrg *) 4464c43cc173Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 4465c43cc173Smrg ;; 4466c43cc173Smrg esac 4467c43cc173Smrg fi 4468c43cc173Smrg else 4469c43cc173Smrg eval flag=\"$hardcode_libdir_flag_spec\" 4470c43cc173Smrg rpath="$rpath $flag" 4471c43cc173Smrg fi 4472c43cc173Smrg elif test -n "$runpath_var"; then 4473c43cc173Smrg case "$perm_rpath " in 4474c43cc173Smrg *" $libdir "*) ;; 4475c43cc173Smrg *) perm_rpath="$perm_rpath $libdir" ;; 4476c43cc173Smrg esac 4477c43cc173Smrg fi 4478c43cc173Smrg case $host in 4479c43cc173Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) 4480c43cc173Smrg testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'` 4481c43cc173Smrg case :$dllsearchpath: in 4482c43cc173Smrg *":$libdir:"*) ;; 4483c43cc173Smrg *) dllsearchpath="$dllsearchpath:$libdir";; 4484c43cc173Smrg esac 4485c43cc173Smrg case :$dllsearchpath: in 4486c43cc173Smrg *":$testbindir:"*) ;; 4487c43cc173Smrg *) dllsearchpath="$dllsearchpath:$testbindir";; 4488c43cc173Smrg esac 4489c43cc173Smrg ;; 4490c43cc173Smrg esac 4491c43cc173Smrg done 4492c43cc173Smrg # Substitute the hardcoded libdirs into the rpath. 4493c43cc173Smrg if test -n "$hardcode_libdir_separator" && 4494c43cc173Smrg test -n "$hardcode_libdirs"; then 4495c43cc173Smrg libdir="$hardcode_libdirs" 4496c43cc173Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 4497c43cc173Smrg fi 4498c43cc173Smrg compile_rpath="$rpath" 4499c43cc173Smrg 4500c43cc173Smrg rpath= 4501c43cc173Smrg hardcode_libdirs= 4502c43cc173Smrg for libdir in $finalize_rpath; do 4503c43cc173Smrg if test -n "$hardcode_libdir_flag_spec"; then 4504c43cc173Smrg if test -n "$hardcode_libdir_separator"; then 4505c43cc173Smrg if test -z "$hardcode_libdirs"; then 4506c43cc173Smrg hardcode_libdirs="$libdir" 4507c43cc173Smrg else 4508c43cc173Smrg # Just accumulate the unique libdirs. 4509c43cc173Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 4510c43cc173Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 4511c43cc173Smrg ;; 4512c43cc173Smrg *) 4513c43cc173Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 4514c43cc173Smrg ;; 4515c43cc173Smrg esac 4516c43cc173Smrg fi 4517c43cc173Smrg else 4518c43cc173Smrg eval flag=\"$hardcode_libdir_flag_spec\" 4519c43cc173Smrg rpath="$rpath $flag" 4520c43cc173Smrg fi 4521c43cc173Smrg elif test -n "$runpath_var"; then 4522c43cc173Smrg case "$finalize_perm_rpath " in 4523c43cc173Smrg *" $libdir "*) ;; 4524c43cc173Smrg *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; 4525c43cc173Smrg esac 4526c43cc173Smrg fi 4527c43cc173Smrg done 4528c43cc173Smrg # Substitute the hardcoded libdirs into the rpath. 4529c43cc173Smrg if test -n "$hardcode_libdir_separator" && 4530c43cc173Smrg test -n "$hardcode_libdirs"; then 4531c43cc173Smrg libdir="$hardcode_libdirs" 4532c43cc173Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 4533c43cc173Smrg fi 4534c43cc173Smrg finalize_rpath="$rpath" 4535c43cc173Smrg 4536c43cc173Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 4537c43cc173Smrg # Transform all the library objects into standard objects. 4538c43cc173Smrg compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` 4539c43cc173Smrg finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` 4540c43cc173Smrg fi 4541c43cc173Smrg 4542c43cc173Smrg dlsyms= 4543c43cc173Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 4544c43cc173Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4545c43cc173Smrg dlsyms="${outputname}S.c" 4546c43cc173Smrg else 4547c43cc173Smrg $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 4548c43cc173Smrg fi 4549c43cc173Smrg fi 4550c43cc173Smrg 4551c43cc173Smrg if test -n "$dlsyms"; then 4552c43cc173Smrg case $dlsyms in 4553c43cc173Smrg "") ;; 4554c43cc173Smrg *.c) 4555c43cc173Smrg # Discover the nlist of each of the dlfiles. 4556c43cc173Smrg nlist="$output_objdir/${outputname}.nm" 4557c43cc173Smrg 4558c43cc173Smrg $show "$rm $nlist ${nlist}S ${nlist}T" 4559c43cc173Smrg $run $rm "$nlist" "${nlist}S" "${nlist}T" 4560c43cc173Smrg 4561c43cc173Smrg # Parse the name list into a source file. 4562c43cc173Smrg $show "creating $output_objdir/$dlsyms" 4563c43cc173Smrg 4564c43cc173Smrg test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ 4565c43cc173Smrg/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ 4566c43cc173Smrg/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ 4567c43cc173Smrg 4568c43cc173Smrg#ifdef __cplusplus 4569c43cc173Smrgextern \"C\" { 4570c43cc173Smrg#endif 4571c43cc173Smrg 4572c43cc173Smrg/* Prevent the only kind of declaration conflicts we can make. */ 4573c43cc173Smrg#define lt_preloaded_symbols some_other_symbol 4574c43cc173Smrg 4575c43cc173Smrg/* External symbol declarations for the compiler. */\ 4576c43cc173Smrg" 4577c43cc173Smrg 4578c43cc173Smrg if test "$dlself" = yes; then 4579c43cc173Smrg $show "generating symbol list for \`$output'" 4580c43cc173Smrg 4581c43cc173Smrg test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" 4582c43cc173Smrg 4583c43cc173Smrg # Add our own program objects to the symbol list. 4584c43cc173Smrg progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` 4585c43cc173Smrg for arg in $progfiles; do 4586c43cc173Smrg $show "extracting global C symbols from \`$arg'" 4587c43cc173Smrg $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" 4588c43cc173Smrg done 4589c43cc173Smrg 4590c43cc173Smrg if test -n "$exclude_expsyms"; then 4591c43cc173Smrg $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4592c43cc173Smrg $run eval '$mv "$nlist"T "$nlist"' 4593c43cc173Smrg fi 4594c43cc173Smrg 4595c43cc173Smrg if test -n "$export_symbols_regex"; then 4596c43cc173Smrg $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4597c43cc173Smrg $run eval '$mv "$nlist"T "$nlist"' 4598c43cc173Smrg fi 4599c43cc173Smrg 4600c43cc173Smrg # Prepare the list of exported symbols 4601c43cc173Smrg if test -z "$export_symbols"; then 4602c43cc173Smrg export_symbols="$output_objdir/$outputname.exp" 4603c43cc173Smrg $run $rm $export_symbols 4604c43cc173Smrg $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4605c43cc173Smrg case $host in 4606c43cc173Smrg *cygwin* | *mingw* ) 4607c43cc173Smrg $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4608c43cc173Smrg $run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4609c43cc173Smrg ;; 4610c43cc173Smrg esac 4611c43cc173Smrg else 4612c43cc173Smrg $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4613c43cc173Smrg $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4614c43cc173Smrg $run eval 'mv "$nlist"T "$nlist"' 4615c43cc173Smrg case $host in 4616c43cc173Smrg *cygwin* | *mingw* ) 4617c43cc173Smrg $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4618c43cc173Smrg $run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4619c43cc173Smrg ;; 4620c43cc173Smrg esac 4621c43cc173Smrg fi 4622c43cc173Smrg fi 4623c43cc173Smrg 4624c43cc173Smrg for arg in $dlprefiles; do 4625c43cc173Smrg $show "extracting global C symbols from \`$arg'" 4626c43cc173Smrg name=`$echo "$arg" | ${SED} -e 's%^.*/%%'` 4627c43cc173Smrg $run eval '$echo ": $name " >> "$nlist"' 4628c43cc173Smrg $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" 4629c43cc173Smrg done 4630c43cc173Smrg 4631c43cc173Smrg if test -z "$run"; then 4632c43cc173Smrg # Make sure we have at least an empty file. 4633c43cc173Smrg test -f "$nlist" || : > "$nlist" 4634c43cc173Smrg 4635c43cc173Smrg if test -n "$exclude_expsyms"; then 4636c43cc173Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4637c43cc173Smrg $mv "$nlist"T "$nlist" 4638c43cc173Smrg fi 4639c43cc173Smrg 4640c43cc173Smrg # Try sorting and uniquifying the output. 4641c43cc173Smrg if grep -v "^: " < "$nlist" | 4642c43cc173Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4643c43cc173Smrg sort -k 3 4644c43cc173Smrg else 4645c43cc173Smrg sort +2 4646c43cc173Smrg fi | 4647c43cc173Smrg uniq > "$nlist"S; then 4648c43cc173Smrg : 4649c43cc173Smrg else 4650c43cc173Smrg grep -v "^: " < "$nlist" > "$nlist"S 4651c43cc173Smrg fi 4652c43cc173Smrg 4653c43cc173Smrg if test -f "$nlist"S; then 4654c43cc173Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' 4655c43cc173Smrg else 4656c43cc173Smrg $echo '/* NONE */' >> "$output_objdir/$dlsyms" 4657c43cc173Smrg fi 4658c43cc173Smrg 4659c43cc173Smrg $echo >> "$output_objdir/$dlsyms" "\ 4660c43cc173Smrg 4661c43cc173Smrg#undef lt_preloaded_symbols 4662c43cc173Smrg 4663c43cc173Smrg#if defined (__STDC__) && __STDC__ 4664c43cc173Smrg# define lt_ptr void * 4665c43cc173Smrg#else 4666c43cc173Smrg# define lt_ptr char * 4667c43cc173Smrg# define const 4668c43cc173Smrg#endif 4669c43cc173Smrg 4670c43cc173Smrg/* The mapping between symbol names and symbols. */ 4671c43cc173Smrg" 4672c43cc173Smrg 4673c43cc173Smrg case $host in 4674c43cc173Smrg *cygwin* | *mingw* ) 4675c43cc173Smrg $echo >> "$output_objdir/$dlsyms" "\ 4676c43cc173Smrg/* DATA imports from DLLs on WIN32 can't be const, because 4677c43cc173Smrg runtime relocations are performed -- see ld's documentation 4678c43cc173Smrg on pseudo-relocs */ 4679c43cc173Smrgstruct { 4680c43cc173Smrg" 4681c43cc173Smrg ;; 4682c43cc173Smrg * ) 4683c43cc173Smrg $echo >> "$output_objdir/$dlsyms" "\ 4684c43cc173Smrgconst struct { 4685c43cc173Smrg" 4686c43cc173Smrg ;; 4687c43cc173Smrg esac 4688c43cc173Smrg 4689c43cc173Smrg 4690c43cc173Smrg $echo >> "$output_objdir/$dlsyms" "\ 4691c43cc173Smrg const char *name; 4692c43cc173Smrg lt_ptr address; 4693c43cc173Smrg} 4694c43cc173Smrglt_preloaded_symbols[] = 4695c43cc173Smrg{\ 4696c43cc173Smrg" 4697c43cc173Smrg 4698c43cc173Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" 4699c43cc173Smrg 4700c43cc173Smrg $echo >> "$output_objdir/$dlsyms" "\ 4701c43cc173Smrg {0, (lt_ptr) 0} 4702c43cc173Smrg}; 4703c43cc173Smrg 4704c43cc173Smrg/* This works around a problem in FreeBSD linker */ 4705c43cc173Smrg#ifdef FREEBSD_WORKAROUND 4706c43cc173Smrgstatic const void *lt_preloaded_setup() { 4707c43cc173Smrg return lt_preloaded_symbols; 4708c43cc173Smrg} 4709c43cc173Smrg#endif 4710c43cc173Smrg 4711c43cc173Smrg#ifdef __cplusplus 4712c43cc173Smrg} 4713c43cc173Smrg#endif\ 4714c43cc173Smrg" 4715c43cc173Smrg fi 4716c43cc173Smrg 4717c43cc173Smrg pic_flag_for_symtable= 4718c43cc173Smrg case $host in 4719c43cc173Smrg # compiling the symbol table file with pic_flag works around 4720c43cc173Smrg # a FreeBSD bug that causes programs to crash when -lm is 4721c43cc173Smrg # linked before any other PIC object. But we must not use 4722c43cc173Smrg # pic_flag when linking with -static. The problem exists in 4723c43cc173Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4724c43cc173Smrg *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4725c43cc173Smrg case "$compile_command " in 4726c43cc173Smrg *" -static "*) ;; 4727c43cc173Smrg *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";; 4728c43cc173Smrg esac;; 4729c43cc173Smrg *-*-hpux*) 4730c43cc173Smrg case "$compile_command " in 4731c43cc173Smrg *" -static "*) ;; 4732c43cc173Smrg *) pic_flag_for_symtable=" $pic_flag";; 4733c43cc173Smrg esac 4734c43cc173Smrg esac 4735c43cc173Smrg 4736c43cc173Smrg # Now compile the dynamic symbol file. 4737c43cc173Smrg $show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" 4738c43cc173Smrg $run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? 4739c43cc173Smrg 4740c43cc173Smrg # Clean up the generated files. 4741c43cc173Smrg $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" 4742c43cc173Smrg $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" 4743c43cc173Smrg 4744c43cc173Smrg # Transform the symbol file into the correct name. 4745c43cc173Smrg case $host in 4746c43cc173Smrg *cygwin* | *mingw* ) 4747c43cc173Smrg if test -f "$output_objdir/${outputname}.def" ; then 4748c43cc173Smrg compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"` 4749c43cc173Smrg finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"` 4750c43cc173Smrg else 4751c43cc173Smrg compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` 4752c43cc173Smrg finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` 4753c43cc173Smrg fi 4754c43cc173Smrg ;; 4755c43cc173Smrg * ) 4756c43cc173Smrg compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` 4757c43cc173Smrg finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` 4758c43cc173Smrg ;; 4759c43cc173Smrg esac 4760c43cc173Smrg ;; 4761c43cc173Smrg *-*-freebsd*) 4762c43cc173Smrg # FreeBSD doesn't need this... 4763c43cc173Smrg ;; 4764c43cc173Smrg *) 4765c43cc173Smrg $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 4766c43cc173Smrg exit $EXIT_FAILURE 4767c43cc173Smrg ;; 4768c43cc173Smrg esac 4769c43cc173Smrg else 4770c43cc173Smrg # We keep going just in case the user didn't refer to 4771c43cc173Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4772c43cc173Smrg # really was required. 4773c43cc173Smrg 4774c43cc173Smrg # Nullify the symbol file. 4775c43cc173Smrg compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` 4776c43cc173Smrg finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` 4777c43cc173Smrg fi 4778c43cc173Smrg 4779c43cc173Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 4780c43cc173Smrg # Replace the output file specification. 4781c43cc173Smrg compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` 4782c43cc173Smrg link_command="$compile_command$compile_rpath" 4783c43cc173Smrg 4784c43cc173Smrg # We have no uninstalled library dependencies, so finalize right now. 4785c43cc173Smrg $show "$link_command" 4786c43cc173Smrg $run eval "$link_command" 4787c43cc173Smrg exit_status=$? 4788c43cc173Smrg 4789c43cc173Smrg # Delete the generated files. 4790c43cc173Smrg if test -n "$dlsyms"; then 4791c43cc173Smrg $show "$rm $output_objdir/${outputname}S.${objext}" 4792c43cc173Smrg $run $rm "$output_objdir/${outputname}S.${objext}" 4793c43cc173Smrg fi 4794c43cc173Smrg 4795c43cc173Smrg exit $exit_status 4796c43cc173Smrg fi 4797c43cc173Smrg 4798c43cc173Smrg if test -n "$shlibpath_var"; then 4799c43cc173Smrg # We should set the shlibpath_var 4800c43cc173Smrg rpath= 4801c43cc173Smrg for dir in $temp_rpath; do 4802c43cc173Smrg case $dir in 4803c43cc173Smrg [\\/]* | [A-Za-z]:[\\/]*) 4804c43cc173Smrg # Absolute path. 4805c43cc173Smrg rpath="$rpath$dir:" 4806c43cc173Smrg ;; 4807c43cc173Smrg *) 4808c43cc173Smrg # Relative path: add a thisdir entry. 4809c43cc173Smrg rpath="$rpath\$thisdir/$dir:" 4810c43cc173Smrg ;; 4811c43cc173Smrg esac 4812c43cc173Smrg done 4813c43cc173Smrg temp_rpath="$rpath" 4814c43cc173Smrg fi 4815c43cc173Smrg 4816c43cc173Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 4817c43cc173Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 4818c43cc173Smrg fi 4819c43cc173Smrg if test -n "$finalize_shlibpath"; then 4820c43cc173Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 4821c43cc173Smrg fi 4822c43cc173Smrg 4823c43cc173Smrg compile_var= 4824c43cc173Smrg finalize_var= 4825c43cc173Smrg if test -n "$runpath_var"; then 4826c43cc173Smrg if test -n "$perm_rpath"; then 4827c43cc173Smrg # We should set the runpath_var. 4828c43cc173Smrg rpath= 4829c43cc173Smrg for dir in $perm_rpath; do 4830c43cc173Smrg rpath="$rpath$dir:" 4831c43cc173Smrg done 4832c43cc173Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 4833c43cc173Smrg fi 4834c43cc173Smrg if test -n "$finalize_perm_rpath"; then 4835c43cc173Smrg # We should set the runpath_var. 4836c43cc173Smrg rpath= 4837c43cc173Smrg for dir in $finalize_perm_rpath; do 4838c43cc173Smrg rpath="$rpath$dir:" 4839c43cc173Smrg done 4840c43cc173Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 4841c43cc173Smrg fi 4842c43cc173Smrg fi 4843c43cc173Smrg 4844c43cc173Smrg if test "$no_install" = yes; then 4845c43cc173Smrg # We don't need to create a wrapper script. 4846c43cc173Smrg link_command="$compile_var$compile_command$compile_rpath" 4847c43cc173Smrg # Replace the output file specification. 4848c43cc173Smrg link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` 4849c43cc173Smrg # Delete the old output file. 4850c43cc173Smrg $run $rm $output 4851c43cc173Smrg # Link the executable and exit 4852c43cc173Smrg $show "$link_command" 4853c43cc173Smrg $run eval "$link_command" || exit $? 4854c43cc173Smrg exit $EXIT_SUCCESS 4855c43cc173Smrg fi 4856c43cc173Smrg 4857c43cc173Smrg if test "$hardcode_action" = relink; then 4858c43cc173Smrg # Fast installation is not supported 4859c43cc173Smrg link_command="$compile_var$compile_command$compile_rpath" 4860c43cc173Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 4861c43cc173Smrg 4862c43cc173Smrg $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 4863c43cc173Smrg $echo "$modename: \`$output' will be relinked during installation" 1>&2 4864c43cc173Smrg else 4865c43cc173Smrg if test "$fast_install" != no; then 4866c43cc173Smrg link_command="$finalize_var$compile_command$finalize_rpath" 4867c43cc173Smrg if test "$fast_install" = yes; then 4868c43cc173Smrg relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` 4869c43cc173Smrg else 4870c43cc173Smrg # fast_install is set to needless 4871c43cc173Smrg relink_command= 4872c43cc173Smrg fi 4873c43cc173Smrg else 4874c43cc173Smrg link_command="$compile_var$compile_command$compile_rpath" 4875c43cc173Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 4876c43cc173Smrg fi 4877c43cc173Smrg fi 4878c43cc173Smrg 4879c43cc173Smrg # Replace the output file specification. 4880c43cc173Smrg link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 4881c43cc173Smrg 4882c43cc173Smrg # Delete the old output files. 4883c43cc173Smrg $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname 4884c43cc173Smrg 4885c43cc173Smrg $show "$link_command" 4886c43cc173Smrg $run eval "$link_command" || exit $? 4887c43cc173Smrg 4888c43cc173Smrg # Now create the wrapper script. 4889c43cc173Smrg $show "creating $output" 4890c43cc173Smrg 4891c43cc173Smrg # Quote the relink command for shipping. 4892c43cc173Smrg if test -n "$relink_command"; then 4893c43cc173Smrg # Preserve any variables that may affect compiler behavior 4894c43cc173Smrg for var in $variables_saved_for_relink; do 4895c43cc173Smrg if eval test -z \"\${$var+set}\"; then 4896c43cc173Smrg relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" 4897c43cc173Smrg elif eval var_value=\$$var; test -z "$var_value"; then 4898c43cc173Smrg relink_command="$var=; export $var; $relink_command" 4899c43cc173Smrg else 4900c43cc173Smrg var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` 4901c43cc173Smrg relink_command="$var=\"$var_value\"; export $var; $relink_command" 4902c43cc173Smrg fi 4903c43cc173Smrg done 4904c43cc173Smrg relink_command="(cd `pwd`; $relink_command)" 4905c43cc173Smrg relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` 4906c43cc173Smrg fi 4907c43cc173Smrg 4908c43cc173Smrg # Quote $echo for shipping. 4909c43cc173Smrg if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then 4910c43cc173Smrg case $progpath in 4911c43cc173Smrg [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; 4912c43cc173Smrg *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; 4913c43cc173Smrg esac 4914c43cc173Smrg qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` 4915c43cc173Smrg else 4916c43cc173Smrg qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` 4917c43cc173Smrg fi 4918c43cc173Smrg 4919c43cc173Smrg # Only actually do things if our run command is non-null. 4920c43cc173Smrg if test -z "$run"; then 4921c43cc173Smrg # win32 will think the script is a binary if it has 4922c43cc173Smrg # a .exe suffix, so we strip it off here. 4923c43cc173Smrg case $output in 4924c43cc173Smrg *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;; 4925c43cc173Smrg esac 4926c43cc173Smrg # test for cygwin because mv fails w/o .exe extensions 4927c43cc173Smrg case $host in 4928c43cc173Smrg *cygwin*) 4929c43cc173Smrg exeext=.exe 4930c43cc173Smrg outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;; 4931c43cc173Smrg *) exeext= ;; 4932c43cc173Smrg esac 4933c43cc173Smrg case $host in 4934c43cc173Smrg *cygwin* | *mingw* ) 4935c43cc173Smrg output_name=`basename $output` 4936c43cc173Smrg output_path=`dirname $output` 4937c43cc173Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 4938c43cc173Smrg cwrapper="$output_path/$output_name.exe" 4939c43cc173Smrg $rm $cwrappersource $cwrapper 4940c43cc173Smrg trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 4941c43cc173Smrg 4942c43cc173Smrg cat > $cwrappersource <<EOF 4943c43cc173Smrg 4944c43cc173Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 4945c43cc173Smrg Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP 4946c43cc173Smrg 4947c43cc173Smrg The $output program cannot be directly executed until all the libtool 4948c43cc173Smrg libraries that it depends on are installed. 4949c43cc173Smrg 4950c43cc173Smrg This wrapper executable should never be moved out of the build directory. 4951c43cc173Smrg If it is, it will not operate correctly. 4952c43cc173Smrg 4953c43cc173Smrg Currently, it simply execs the wrapper *script* "/bin/sh $output", 4954c43cc173Smrg but could eventually absorb all of the scripts functionality and 4955c43cc173Smrg exec $objdir/$outputname directly. 4956c43cc173Smrg*/ 4957c43cc173SmrgEOF 4958c43cc173Smrg cat >> $cwrappersource<<"EOF" 4959c43cc173Smrg#include <stdio.h> 4960c43cc173Smrg#include <stdlib.h> 4961c43cc173Smrg#include <unistd.h> 4962c43cc173Smrg#include <malloc.h> 4963c43cc173Smrg#include <stdarg.h> 4964c43cc173Smrg#include <assert.h> 4965c43cc173Smrg#include <string.h> 4966c43cc173Smrg#include <ctype.h> 4967c43cc173Smrg#include <sys/stat.h> 4968c43cc173Smrg 4969c43cc173Smrg#if defined(PATH_MAX) 4970c43cc173Smrg# define LT_PATHMAX PATH_MAX 4971c43cc173Smrg#elif defined(MAXPATHLEN) 4972c43cc173Smrg# define LT_PATHMAX MAXPATHLEN 4973c43cc173Smrg#else 4974c43cc173Smrg# define LT_PATHMAX 1024 4975c43cc173Smrg#endif 4976c43cc173Smrg 4977c43cc173Smrg#ifndef DIR_SEPARATOR 4978c43cc173Smrg# define DIR_SEPARATOR '/' 4979c43cc173Smrg# define PATH_SEPARATOR ':' 4980c43cc173Smrg#endif 4981c43cc173Smrg 4982c43cc173Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 4983c43cc173Smrg defined (__OS2__) 4984c43cc173Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 4985c43cc173Smrg# ifndef DIR_SEPARATOR_2 4986c43cc173Smrg# define DIR_SEPARATOR_2 '\\' 4987c43cc173Smrg# endif 4988c43cc173Smrg# ifndef PATH_SEPARATOR_2 4989c43cc173Smrg# define PATH_SEPARATOR_2 ';' 4990c43cc173Smrg# endif 4991c43cc173Smrg#endif 4992c43cc173Smrg 4993c43cc173Smrg#ifndef DIR_SEPARATOR_2 4994c43cc173Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 4995c43cc173Smrg#else /* DIR_SEPARATOR_2 */ 4996c43cc173Smrg# define IS_DIR_SEPARATOR(ch) \ 4997c43cc173Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 4998c43cc173Smrg#endif /* DIR_SEPARATOR_2 */ 4999c43cc173Smrg 5000c43cc173Smrg#ifndef PATH_SEPARATOR_2 5001c43cc173Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5002c43cc173Smrg#else /* PATH_SEPARATOR_2 */ 5003c43cc173Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5004c43cc173Smrg#endif /* PATH_SEPARATOR_2 */ 5005c43cc173Smrg 5006c43cc173Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5007c43cc173Smrg#define XFREE(stale) do { \ 5008c43cc173Smrg if (stale) { free ((void *) stale); stale = 0; } \ 5009c43cc173Smrg} while (0) 5010c43cc173Smrg 5011c43cc173Smrg/* -DDEBUG is fairly common in CFLAGS. */ 5012c43cc173Smrg#undef DEBUG 5013c43cc173Smrg#if defined DEBUGWRAPPER 5014c43cc173Smrg# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__) 5015c43cc173Smrg#else 5016c43cc173Smrg# define DEBUG(format, ...) 5017c43cc173Smrg#endif 5018c43cc173Smrg 5019c43cc173Smrgconst char *program_name = NULL; 5020c43cc173Smrg 5021c43cc173Smrgvoid * xmalloc (size_t num); 5022c43cc173Smrgchar * xstrdup (const char *string); 5023c43cc173Smrgconst char * base_name (const char *name); 5024c43cc173Smrgchar * find_executable(const char *wrapper); 5025c43cc173Smrgint check_executable(const char *path); 5026c43cc173Smrgchar * strendzap(char *str, const char *pat); 5027c43cc173Smrgvoid lt_fatal (const char *message, ...); 5028c43cc173Smrg 5029c43cc173Smrgint 5030c43cc173Smrgmain (int argc, char *argv[]) 5031c43cc173Smrg{ 5032c43cc173Smrg char **newargz; 5033c43cc173Smrg int i; 5034c43cc173Smrg 5035c43cc173Smrg program_name = (char *) xstrdup (base_name (argv[0])); 5036c43cc173Smrg DEBUG("(main) argv[0] : %s\n",argv[0]); 5037c43cc173Smrg DEBUG("(main) program_name : %s\n",program_name); 5038c43cc173Smrg newargz = XMALLOC(char *, argc+2); 5039c43cc173SmrgEOF 5040c43cc173Smrg 5041c43cc173Smrg cat >> $cwrappersource <<EOF 5042c43cc173Smrg newargz[0] = (char *) xstrdup("$SHELL"); 5043c43cc173SmrgEOF 5044c43cc173Smrg 5045c43cc173Smrg cat >> $cwrappersource <<"EOF" 5046c43cc173Smrg newargz[1] = find_executable(argv[0]); 5047c43cc173Smrg if (newargz[1] == NULL) 5048c43cc173Smrg lt_fatal("Couldn't find %s", argv[0]); 5049c43cc173Smrg DEBUG("(main) found exe at : %s\n",newargz[1]); 5050c43cc173Smrg /* we know the script has the same name, without the .exe */ 5051c43cc173Smrg /* so make sure newargz[1] doesn't end in .exe */ 5052c43cc173Smrg strendzap(newargz[1],".exe"); 5053c43cc173Smrg for (i = 1; i < argc; i++) 5054c43cc173Smrg newargz[i+1] = xstrdup(argv[i]); 5055c43cc173Smrg newargz[argc+1] = NULL; 5056c43cc173Smrg 5057c43cc173Smrg for (i=0; i<argc+1; i++) 5058c43cc173Smrg { 5059c43cc173Smrg DEBUG("(main) newargz[%d] : %s\n",i,newargz[i]); 5060c43cc173Smrg ; 5061c43cc173Smrg } 5062c43cc173Smrg 5063c43cc173SmrgEOF 5064c43cc173Smrg 5065c43cc173Smrg case $host_os in 5066c43cc173Smrg mingw*) 5067c43cc173Smrg cat >> $cwrappersource <<EOF 5068c43cc173Smrg execv("$SHELL",(char const **)newargz); 5069c43cc173SmrgEOF 5070c43cc173Smrg ;; 5071c43cc173Smrg *) 5072c43cc173Smrg cat >> $cwrappersource <<EOF 5073c43cc173Smrg execv("$SHELL",newargz); 5074c43cc173SmrgEOF 5075c43cc173Smrg ;; 5076c43cc173Smrg esac 5077c43cc173Smrg 5078c43cc173Smrg cat >> $cwrappersource <<"EOF" 5079c43cc173Smrg return 127; 5080c43cc173Smrg} 5081c43cc173Smrg 5082c43cc173Smrgvoid * 5083c43cc173Smrgxmalloc (size_t num) 5084c43cc173Smrg{ 5085c43cc173Smrg void * p = (void *) malloc (num); 5086c43cc173Smrg if (!p) 5087c43cc173Smrg lt_fatal ("Memory exhausted"); 5088c43cc173Smrg 5089c43cc173Smrg return p; 5090c43cc173Smrg} 5091c43cc173Smrg 5092c43cc173Smrgchar * 5093c43cc173Smrgxstrdup (const char *string) 5094c43cc173Smrg{ 5095c43cc173Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL 5096c43cc173Smrg; 5097c43cc173Smrg} 5098c43cc173Smrg 5099c43cc173Smrgconst char * 5100c43cc173Smrgbase_name (const char *name) 5101c43cc173Smrg{ 5102c43cc173Smrg const char *base; 5103c43cc173Smrg 5104c43cc173Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 5105c43cc173Smrg /* Skip over the disk name in MSDOS pathnames. */ 5106c43cc173Smrg if (isalpha ((unsigned char)name[0]) && name[1] == ':') 5107c43cc173Smrg name += 2; 5108c43cc173Smrg#endif 5109c43cc173Smrg 5110c43cc173Smrg for (base = name; *name; name++) 5111c43cc173Smrg if (IS_DIR_SEPARATOR (*name)) 5112c43cc173Smrg base = name + 1; 5113c43cc173Smrg return base; 5114c43cc173Smrg} 5115c43cc173Smrg 5116c43cc173Smrgint 5117c43cc173Smrgcheck_executable(const char * path) 5118c43cc173Smrg{ 5119c43cc173Smrg struct stat st; 5120c43cc173Smrg 5121c43cc173Smrg DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!"); 5122c43cc173Smrg if ((!path) || (!*path)) 5123c43cc173Smrg return 0; 5124c43cc173Smrg 5125c43cc173Smrg if ((stat (path, &st) >= 0) && 5126c43cc173Smrg ( 5127c43cc173Smrg /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */ 5128c43cc173Smrg#if defined (S_IXOTH) 5129c43cc173Smrg ((st.st_mode & S_IXOTH) == S_IXOTH) || 5130c43cc173Smrg#endif 5131c43cc173Smrg#if defined (S_IXGRP) 5132c43cc173Smrg ((st.st_mode & S_IXGRP) == S_IXGRP) || 5133c43cc173Smrg#endif 5134c43cc173Smrg ((st.st_mode & S_IXUSR) == S_IXUSR)) 5135c43cc173Smrg ) 5136c43cc173Smrg return 1; 5137c43cc173Smrg else 5138c43cc173Smrg return 0; 5139c43cc173Smrg} 5140c43cc173Smrg 5141c43cc173Smrg/* Searches for the full path of the wrapper. Returns 5142c43cc173Smrg newly allocated full path name if found, NULL otherwise */ 5143c43cc173Smrgchar * 5144c43cc173Smrgfind_executable (const char* wrapper) 5145c43cc173Smrg{ 5146c43cc173Smrg int has_slash = 0; 5147c43cc173Smrg const char* p; 5148c43cc173Smrg const char* p_next; 5149c43cc173Smrg /* static buffer for getcwd */ 5150c43cc173Smrg char tmp[LT_PATHMAX + 1]; 5151c43cc173Smrg int tmp_len; 5152c43cc173Smrg char* concat_name; 5153c43cc173Smrg 5154c43cc173Smrg DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"); 5155c43cc173Smrg 5156c43cc173Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 5157c43cc173Smrg return NULL; 5158c43cc173Smrg 5159c43cc173Smrg /* Absolute path? */ 5160c43cc173Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 5161c43cc173Smrg if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':') 5162c43cc173Smrg { 5163c43cc173Smrg concat_name = xstrdup (wrapper); 5164c43cc173Smrg if (check_executable(concat_name)) 5165c43cc173Smrg return concat_name; 5166c43cc173Smrg XFREE(concat_name); 5167c43cc173Smrg } 5168c43cc173Smrg else 5169c43cc173Smrg { 5170c43cc173Smrg#endif 5171c43cc173Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 5172c43cc173Smrg { 5173c43cc173Smrg concat_name = xstrdup (wrapper); 5174c43cc173Smrg if (check_executable(concat_name)) 5175c43cc173Smrg return concat_name; 5176c43cc173Smrg XFREE(concat_name); 5177c43cc173Smrg } 5178c43cc173Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 5179c43cc173Smrg } 5180c43cc173Smrg#endif 5181c43cc173Smrg 5182c43cc173Smrg for (p = wrapper; *p; p++) 5183c43cc173Smrg if (*p == '/') 5184c43cc173Smrg { 5185c43cc173Smrg has_slash = 1; 5186c43cc173Smrg break; 5187c43cc173Smrg } 5188c43cc173Smrg if (!has_slash) 5189c43cc173Smrg { 5190c43cc173Smrg /* no slashes; search PATH */ 5191c43cc173Smrg const char* path = getenv ("PATH"); 5192c43cc173Smrg if (path != NULL) 5193c43cc173Smrg { 5194c43cc173Smrg for (p = path; *p; p = p_next) 5195c43cc173Smrg { 5196c43cc173Smrg const char* q; 5197c43cc173Smrg size_t p_len; 5198c43cc173Smrg for (q = p; *q; q++) 5199c43cc173Smrg if (IS_PATH_SEPARATOR(*q)) 5200c43cc173Smrg break; 5201c43cc173Smrg p_len = q - p; 5202c43cc173Smrg p_next = (*q == '\0' ? q : q + 1); 5203c43cc173Smrg if (p_len == 0) 5204c43cc173Smrg { 5205c43cc173Smrg /* empty path: current directory */ 5206c43cc173Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 5207c43cc173Smrg lt_fatal ("getcwd failed"); 5208c43cc173Smrg tmp_len = strlen(tmp); 5209c43cc173Smrg concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1); 5210c43cc173Smrg memcpy (concat_name, tmp, tmp_len); 5211c43cc173Smrg concat_name[tmp_len] = '/'; 5212c43cc173Smrg strcpy (concat_name + tmp_len + 1, wrapper); 5213c43cc173Smrg } 5214c43cc173Smrg else 5215c43cc173Smrg { 5216c43cc173Smrg concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1); 5217c43cc173Smrg memcpy (concat_name, p, p_len); 5218c43cc173Smrg concat_name[p_len] = '/'; 5219c43cc173Smrg strcpy (concat_name + p_len + 1, wrapper); 5220c43cc173Smrg } 5221c43cc173Smrg if (check_executable(concat_name)) 5222c43cc173Smrg return concat_name; 5223c43cc173Smrg XFREE(concat_name); 5224c43cc173Smrg } 5225c43cc173Smrg } 5226c43cc173Smrg /* not found in PATH; assume curdir */ 5227c43cc173Smrg } 5228c43cc173Smrg /* Relative path | not found in path: prepend cwd */ 5229c43cc173Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 5230c43cc173Smrg lt_fatal ("getcwd failed"); 5231c43cc173Smrg tmp_len = strlen(tmp); 5232c43cc173Smrg concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1); 5233c43cc173Smrg memcpy (concat_name, tmp, tmp_len); 5234c43cc173Smrg concat_name[tmp_len] = '/'; 5235c43cc173Smrg strcpy (concat_name + tmp_len + 1, wrapper); 5236c43cc173Smrg 5237c43cc173Smrg if (check_executable(concat_name)) 5238c43cc173Smrg return concat_name; 5239c43cc173Smrg XFREE(concat_name); 5240c43cc173Smrg return NULL; 5241c43cc173Smrg} 5242c43cc173Smrg 5243c43cc173Smrgchar * 5244c43cc173Smrgstrendzap(char *str, const char *pat) 5245c43cc173Smrg{ 5246c43cc173Smrg size_t len, patlen; 5247c43cc173Smrg 5248c43cc173Smrg assert(str != NULL); 5249c43cc173Smrg assert(pat != NULL); 5250c43cc173Smrg 5251c43cc173Smrg len = strlen(str); 5252c43cc173Smrg patlen = strlen(pat); 5253c43cc173Smrg 5254c43cc173Smrg if (patlen <= len) 5255c43cc173Smrg { 5256c43cc173Smrg str += len - patlen; 5257c43cc173Smrg if (strcmp(str, pat) == 0) 5258c43cc173Smrg *str = '\0'; 5259c43cc173Smrg } 5260c43cc173Smrg return str; 5261c43cc173Smrg} 5262c43cc173Smrg 5263c43cc173Smrgstatic void 5264c43cc173Smrglt_error_core (int exit_status, const char * mode, 5265c43cc173Smrg const char * message, va_list ap) 5266c43cc173Smrg{ 5267c43cc173Smrg fprintf (stderr, "%s: %s: ", program_name, mode); 5268c43cc173Smrg vfprintf (stderr, message, ap); 5269c43cc173Smrg fprintf (stderr, ".\n"); 5270c43cc173Smrg 5271c43cc173Smrg if (exit_status >= 0) 5272c43cc173Smrg exit (exit_status); 5273c43cc173Smrg} 5274c43cc173Smrg 5275c43cc173Smrgvoid 5276c43cc173Smrglt_fatal (const char *message, ...) 5277c43cc173Smrg{ 5278c43cc173Smrg va_list ap; 5279c43cc173Smrg va_start (ap, message); 5280c43cc173Smrg lt_error_core (EXIT_FAILURE, "FATAL", message, ap); 5281c43cc173Smrg va_end (ap); 5282c43cc173Smrg} 5283c43cc173SmrgEOF 5284c43cc173Smrg # we should really use a build-platform specific compiler 5285c43cc173Smrg # here, but OTOH, the wrappers (shell script and this C one) 5286c43cc173Smrg # are only useful if you want to execute the "real" binary. 5287c43cc173Smrg # Since the "real" binary is built for $host, then this 5288c43cc173Smrg # wrapper might as well be built for $host, too. 5289c43cc173Smrg $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource 5290c43cc173Smrg ;; 5291c43cc173Smrg esac 5292c43cc173Smrg $rm $output 5293c43cc173Smrg trap "$rm $output; exit $EXIT_FAILURE" 1 2 15 5294c43cc173Smrg 5295c43cc173Smrg $echo > $output "\ 5296c43cc173Smrg#! $SHELL 5297c43cc173Smrg 5298c43cc173Smrg# $output - temporary wrapper script for $objdir/$outputname 5299c43cc173Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP 5300c43cc173Smrg# 5301c43cc173Smrg# The $output program cannot be directly executed until all the libtool 5302c43cc173Smrg# libraries that it depends on are installed. 5303c43cc173Smrg# 5304c43cc173Smrg# This wrapper script should never be moved out of the build directory. 5305c43cc173Smrg# If it is, it will not operate correctly. 5306c43cc173Smrg 5307c43cc173Smrg# Sed substitution that helps us do robust quoting. It backslashifies 5308c43cc173Smrg# metacharacters that are still active within double-quoted strings. 5309c43cc173SmrgXsed='${SED} -e 1s/^X//' 5310c43cc173Smrgsed_quote_subst='$sed_quote_subst' 5311c43cc173Smrg 5312c43cc173Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5313c43cc173Smrg# if CDPATH is set. 5314c43cc173Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5315c43cc173Smrg 5316c43cc173Smrgrelink_command=\"$relink_command\" 5317c43cc173Smrg 5318c43cc173Smrg# This environment variable determines our operation mode. 5319c43cc173Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5320c43cc173Smrg # install mode needs the following variable: 5321c43cc173Smrg notinst_deplibs='$notinst_deplibs' 5322c43cc173Smrgelse 5323c43cc173Smrg # When we are sourced in execute mode, \$file and \$echo are already set. 5324c43cc173Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5325c43cc173Smrg echo=\"$qecho\" 5326c43cc173Smrg file=\"\$0\" 5327c43cc173Smrg # Make sure echo works. 5328c43cc173Smrg if test \"X\$1\" = X--no-reexec; then 5329c43cc173Smrg # Discard the --no-reexec flag, and continue. 5330c43cc173Smrg shift 5331c43cc173Smrg elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then 5332c43cc173Smrg # Yippee, \$echo works! 5333c43cc173Smrg : 5334c43cc173Smrg else 5335c43cc173Smrg # Restart under the correct shell, and then maybe \$echo will work. 5336c43cc173Smrg exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} 5337c43cc173Smrg fi 5338c43cc173Smrg fi\ 5339c43cc173Smrg" 5340c43cc173Smrg $echo >> $output "\ 5341c43cc173Smrg 5342c43cc173Smrg # Find the directory that this script lives in. 5343c43cc173Smrg thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` 5344c43cc173Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5345c43cc173Smrg 5346c43cc173Smrg # Follow symbolic links until we get to the real thisdir. 5347c43cc173Smrg file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` 5348c43cc173Smrg while test -n \"\$file\"; do 5349c43cc173Smrg destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` 5350c43cc173Smrg 5351c43cc173Smrg # If there was a directory component, then change thisdir. 5352c43cc173Smrg if test \"x\$destdir\" != \"x\$file\"; then 5353c43cc173Smrg case \"\$destdir\" in 5354c43cc173Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5355c43cc173Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5356c43cc173Smrg esac 5357c43cc173Smrg fi 5358c43cc173Smrg 5359c43cc173Smrg file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` 5360c43cc173Smrg file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` 5361c43cc173Smrg done 5362c43cc173Smrg 5363c43cc173Smrg # Try to get the absolute directory name. 5364c43cc173Smrg absdir=\`cd \"\$thisdir\" && pwd\` 5365c43cc173Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5366c43cc173Smrg" 5367c43cc173Smrg 5368c43cc173Smrg if test "$fast_install" = yes; then 5369c43cc173Smrg $echo >> $output "\ 5370c43cc173Smrg program=lt-'$outputname'$exeext 5371c43cc173Smrg progdir=\"\$thisdir/$objdir\" 5372c43cc173Smrg 5373c43cc173Smrg if test ! -f \"\$progdir/\$program\" || \\ 5374c43cc173Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 5375c43cc173Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5376c43cc173Smrg 5377c43cc173Smrg file=\"\$\$-\$program\" 5378c43cc173Smrg 5379c43cc173Smrg if test ! -d \"\$progdir\"; then 5380c43cc173Smrg $mkdir \"\$progdir\" 5381c43cc173Smrg else 5382c43cc173Smrg $rm \"\$progdir/\$file\" 5383c43cc173Smrg fi" 5384c43cc173Smrg 5385c43cc173Smrg $echo >> $output "\ 5386c43cc173Smrg 5387c43cc173Smrg # relink executable if necessary 5388c43cc173Smrg if test -n \"\$relink_command\"; then 5389c43cc173Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5390c43cc173Smrg else 5391c43cc173Smrg $echo \"\$relink_command_output\" >&2 5392c43cc173Smrg $rm \"\$progdir/\$file\" 5393c43cc173Smrg exit $EXIT_FAILURE 5394c43cc173Smrg fi 5395c43cc173Smrg fi 5396c43cc173Smrg 5397c43cc173Smrg $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5398c43cc173Smrg { $rm \"\$progdir/\$program\"; 5399c43cc173Smrg $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5400c43cc173Smrg $rm \"\$progdir/\$file\" 5401c43cc173Smrg fi" 5402c43cc173Smrg else 5403c43cc173Smrg $echo >> $output "\ 5404c43cc173Smrg program='$outputname' 5405c43cc173Smrg progdir=\"\$thisdir/$objdir\" 5406c43cc173Smrg" 5407c43cc173Smrg fi 5408c43cc173Smrg 5409c43cc173Smrg $echo >> $output "\ 5410c43cc173Smrg 5411c43cc173Smrg if test -f \"\$progdir/\$program\"; then" 5412c43cc173Smrg 5413c43cc173Smrg # Export our shlibpath_var if we have one. 5414c43cc173Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5415c43cc173Smrg $echo >> $output "\ 5416c43cc173Smrg # Add our own library path to $shlibpath_var 5417c43cc173Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5418c43cc173Smrg 5419c43cc173Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 5420c43cc173Smrg # The second colon is a workaround for a bug in BeOS R4 sed 5421c43cc173Smrg $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` 5422c43cc173Smrg 5423c43cc173Smrg export $shlibpath_var 5424c43cc173Smrg" 5425c43cc173Smrg fi 5426c43cc173Smrg 5427c43cc173Smrg # fixup the dll searchpath if we need to. 5428c43cc173Smrg if test -n "$dllsearchpath"; then 5429c43cc173Smrg $echo >> $output "\ 5430c43cc173Smrg # Add the dll search path components to the executable PATH 5431c43cc173Smrg PATH=$dllsearchpath:\$PATH 5432c43cc173Smrg" 5433c43cc173Smrg fi 5434c43cc173Smrg 5435c43cc173Smrg $echo >> $output "\ 5436c43cc173Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5437c43cc173Smrg # Run the actual program with our arguments. 5438c43cc173Smrg" 5439c43cc173Smrg case $host in 5440c43cc173Smrg # Backslashes separate directories on plain windows 5441c43cc173Smrg *-*-mingw | *-*-os2*) 5442c43cc173Smrg $echo >> $output "\ 5443c43cc173Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5444c43cc173Smrg" 5445c43cc173Smrg ;; 5446c43cc173Smrg 5447c43cc173Smrg *) 5448c43cc173Smrg $echo >> $output "\ 5449c43cc173Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5450c43cc173Smrg" 5451c43cc173Smrg ;; 5452c43cc173Smrg esac 5453c43cc173Smrg $echo >> $output "\ 5454c43cc173Smrg \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" 5455c43cc173Smrg exit $EXIT_FAILURE 5456c43cc173Smrg fi 5457c43cc173Smrg else 5458c43cc173Smrg # The program doesn't exist. 5459c43cc173Smrg \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 5460c43cc173Smrg \$echo \"This script is just a wrapper for \$program.\" 1>&2 5461c43cc173Smrg $echo \"See the $PACKAGE documentation for more information.\" 1>&2 5462c43cc173Smrg exit $EXIT_FAILURE 5463c43cc173Smrg fi 5464c43cc173Smrgfi\ 5465c43cc173Smrg" 5466c43cc173Smrg chmod +x $output 5467c43cc173Smrg fi 5468c43cc173Smrg exit $EXIT_SUCCESS 5469c43cc173Smrg ;; 5470c43cc173Smrg esac 5471c43cc173Smrg 5472c43cc173Smrg # See if we need to build an old-fashioned archive. 5473c43cc173Smrg for oldlib in $oldlibs; do 5474c43cc173Smrg 5475c43cc173Smrg if test "$build_libtool_libs" = convenience; then 5476c43cc173Smrg oldobjs="$libobjs_save" 5477c43cc173Smrg addlibs="$convenience" 5478c43cc173Smrg build_libtool_libs=no 5479c43cc173Smrg else 5480c43cc173Smrg if test "$build_libtool_libs" = module; then 5481c43cc173Smrg oldobjs="$libobjs_save" 5482c43cc173Smrg build_libtool_libs=no 5483c43cc173Smrg else 5484c43cc173Smrg oldobjs="$old_deplibs $non_pic_objects" 5485c43cc173Smrg fi 5486c43cc173Smrg addlibs="$old_convenience" 5487c43cc173Smrg fi 5488c43cc173Smrg 5489c43cc173Smrg if test -n "$addlibs"; then 5490c43cc173Smrg gentop="$output_objdir/${outputname}x" 5491c43cc173Smrg generated="$generated $gentop" 5492c43cc173Smrg 5493c43cc173Smrg func_extract_archives $gentop $addlibs 5494c43cc173Smrg oldobjs="$oldobjs $func_extract_archives_result" 5495c43cc173Smrg fi 5496c43cc173Smrg 5497c43cc173Smrg # Do each command in the archive commands. 5498c43cc173Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 5499c43cc173Smrg cmds=$old_archive_from_new_cmds 5500c43cc173Smrg else 5501c43cc173Smrg # POSIX demands no paths to be encoded in archives. We have 5502c43cc173Smrg # to avoid creating archives with duplicate basenames if we 5503c43cc173Smrg # might have to extract them afterwards, e.g., when creating a 5504c43cc173Smrg # static archive out of a convenience library, or when linking 5505c43cc173Smrg # the entirety of a libtool archive into another (currently 5506c43cc173Smrg # not supported by libtool). 5507c43cc173Smrg if (for obj in $oldobjs 5508c43cc173Smrg do 5509c43cc173Smrg $echo "X$obj" | $Xsed -e 's%^.*/%%' 5510c43cc173Smrg done | sort | sort -uc >/dev/null 2>&1); then 5511c43cc173Smrg : 5512c43cc173Smrg else 5513c43cc173Smrg $echo "copying selected object files to avoid basename conflicts..." 5514c43cc173Smrg 5515c43cc173Smrg if test -z "$gentop"; then 5516c43cc173Smrg gentop="$output_objdir/${outputname}x" 5517c43cc173Smrg generated="$generated $gentop" 5518c43cc173Smrg 5519c43cc173Smrg $show "${rm}r $gentop" 5520c43cc173Smrg $run ${rm}r "$gentop" 5521c43cc173Smrg $show "$mkdir $gentop" 5522c43cc173Smrg $run $mkdir "$gentop" 5523c43cc173Smrg exit_status=$? 5524c43cc173Smrg if test "$exit_status" -ne 0 && test ! -d "$gentop"; then 5525c43cc173Smrg exit $exit_status 5526c43cc173Smrg fi 5527c43cc173Smrg fi 5528c43cc173Smrg 5529c43cc173Smrg save_oldobjs=$oldobjs 5530c43cc173Smrg oldobjs= 5531c43cc173Smrg counter=1 5532c43cc173Smrg for obj in $save_oldobjs 5533c43cc173Smrg do 5534c43cc173Smrg objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` 5535c43cc173Smrg case " $oldobjs " in 5536c43cc173Smrg " ") oldobjs=$obj ;; 5537c43cc173Smrg *[\ /]"$objbase "*) 5538c43cc173Smrg while :; do 5539c43cc173Smrg # Make sure we don't pick an alternate name that also 5540c43cc173Smrg # overlaps. 5541c43cc173Smrg newobj=lt$counter-$objbase 5542c43cc173Smrg counter=`expr $counter + 1` 5543c43cc173Smrg case " $oldobjs " in 5544c43cc173Smrg *[\ /]"$newobj "*) ;; 5545c43cc173Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 5546c43cc173Smrg esac 5547c43cc173Smrg done 5548c43cc173Smrg $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 5549c43cc173Smrg $run ln "$obj" "$gentop/$newobj" || 5550c43cc173Smrg $run cp "$obj" "$gentop/$newobj" 5551c43cc173Smrg oldobjs="$oldobjs $gentop/$newobj" 5552c43cc173Smrg ;; 5553c43cc173Smrg *) oldobjs="$oldobjs $obj" ;; 5554c43cc173Smrg esac 5555c43cc173Smrg done 5556c43cc173Smrg fi 5557c43cc173Smrg 5558c43cc173Smrg eval cmds=\"$old_archive_cmds\" 5559c43cc173Smrg 5560c43cc173Smrg if len=`expr "X$cmds" : ".*"` && 5561c43cc173Smrg test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then 5562c43cc173Smrg cmds=$old_archive_cmds 5563c43cc173Smrg else 5564c43cc173Smrg # the command line is too long to link in one step, link in parts 5565c43cc173Smrg $echo "using piecewise archive linking..." 5566c43cc173Smrg save_RANLIB=$RANLIB 5567c43cc173Smrg RANLIB=: 5568c43cc173Smrg objlist= 5569c43cc173Smrg concat_cmds= 5570c43cc173Smrg save_oldobjs=$oldobjs 5571c43cc173Smrg 5572c43cc173Smrg # Is there a better way of finding the last object in the list? 5573c43cc173Smrg for obj in $save_oldobjs 5574c43cc173Smrg do 5575c43cc173Smrg last_oldobj=$obj 5576c43cc173Smrg done 5577c43cc173Smrg for obj in $save_oldobjs 5578c43cc173Smrg do 5579c43cc173Smrg oldobjs="$objlist $obj" 5580c43cc173Smrg objlist="$objlist $obj" 5581c43cc173Smrg eval test_cmds=\"$old_archive_cmds\" 5582c43cc173Smrg if len=`expr "X$test_cmds" : ".*" 2>/dev/null` && 5583c43cc173Smrg test "$len" -le "$max_cmd_len"; then 5584c43cc173Smrg : 5585c43cc173Smrg else 5586c43cc173Smrg # the above command should be used before it gets too long 5587c43cc173Smrg oldobjs=$objlist 5588c43cc173Smrg if test "$obj" = "$last_oldobj" ; then 5589c43cc173Smrg RANLIB=$save_RANLIB 5590c43cc173Smrg fi 5591c43cc173Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 5592c43cc173Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 5593c43cc173Smrg objlist= 5594c43cc173Smrg fi 5595c43cc173Smrg done 5596c43cc173Smrg RANLIB=$save_RANLIB 5597c43cc173Smrg oldobjs=$objlist 5598c43cc173Smrg if test "X$oldobjs" = "X" ; then 5599c43cc173Smrg eval cmds=\"\$concat_cmds\" 5600c43cc173Smrg else 5601c43cc173Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 5602c43cc173Smrg fi 5603c43cc173Smrg fi 5604c43cc173Smrg fi 5605c43cc173Smrg save_ifs="$IFS"; IFS='~' 5606c43cc173Smrg for cmd in $cmds; do 5607c43cc173Smrg eval cmd=\"$cmd\" 5608c43cc173Smrg IFS="$save_ifs" 5609c43cc173Smrg $show "$cmd" 5610c43cc173Smrg $run eval "$cmd" || exit $? 5611c43cc173Smrg done 5612c43cc173Smrg IFS="$save_ifs" 5613c43cc173Smrg done 5614c43cc173Smrg 5615c43cc173Smrg if test -n "$generated"; then 5616c43cc173Smrg $show "${rm}r$generated" 5617c43cc173Smrg $run ${rm}r$generated 5618c43cc173Smrg fi 5619c43cc173Smrg 5620c43cc173Smrg # Now create the libtool archive. 5621c43cc173Smrg case $output in 5622c43cc173Smrg *.la) 5623c43cc173Smrg old_library= 5624c43cc173Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 5625c43cc173Smrg $show "creating $output" 5626c43cc173Smrg 5627c43cc173Smrg # Preserve any variables that may affect compiler behavior 5628c43cc173Smrg for var in $variables_saved_for_relink; do 5629c43cc173Smrg if eval test -z \"\${$var+set}\"; then 5630c43cc173Smrg relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" 5631c43cc173Smrg elif eval var_value=\$$var; test -z "$var_value"; then 5632c43cc173Smrg relink_command="$var=; export $var; $relink_command" 5633c43cc173Smrg else 5634c43cc173Smrg var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` 5635c43cc173Smrg relink_command="$var=\"$var_value\"; export $var; $relink_command" 5636c43cc173Smrg fi 5637c43cc173Smrg done 5638c43cc173Smrg # Quote the link command for shipping. 5639c43cc173Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 5640c43cc173Smrg relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` 5641c43cc173Smrg if test "$hardcode_automatic" = yes ; then 5642c43cc173Smrg relink_command= 5643c43cc173Smrg fi 5644c43cc173Smrg 5645c43cc173Smrg 5646c43cc173Smrg # Only create the output if not a dry run. 5647c43cc173Smrg if test -z "$run"; then 5648c43cc173Smrg for installed in no yes; do 5649c43cc173Smrg if test "$installed" = yes; then 5650c43cc173Smrg if test -z "$install_libdir"; then 5651c43cc173Smrg break 5652c43cc173Smrg fi 5653c43cc173Smrg output="$output_objdir/$outputname"i 5654c43cc173Smrg # Replace all uninstalled libtool libraries with the installed ones 5655c43cc173Smrg newdependency_libs= 5656c43cc173Smrg for deplib in $dependency_libs; do 5657c43cc173Smrg case $deplib in 5658c43cc173Smrg *.la) 5659c43cc173Smrg name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` 5660c43cc173Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 5661c43cc173Smrg if test -z "$libdir"; then 5662c43cc173Smrg $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 5663c43cc173Smrg exit $EXIT_FAILURE 5664c43cc173Smrg fi 5665c43cc173Smrg newdependency_libs="$newdependency_libs $libdir/$name" 5666c43cc173Smrg ;; 5667c43cc173Smrg *) newdependency_libs="$newdependency_libs $deplib" ;; 5668c43cc173Smrg esac 5669c43cc173Smrg done 5670c43cc173Smrg dependency_libs="$newdependency_libs" 5671c43cc173Smrg newdlfiles= 5672c43cc173Smrg for lib in $dlfiles; do 5673c43cc173Smrg name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` 5674c43cc173Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 5675c43cc173Smrg if test -z "$libdir"; then 5676c43cc173Smrg $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 5677c43cc173Smrg exit $EXIT_FAILURE 5678c43cc173Smrg fi 5679c43cc173Smrg newdlfiles="$newdlfiles $libdir/$name" 5680c43cc173Smrg done 5681c43cc173Smrg dlfiles="$newdlfiles" 5682c43cc173Smrg newdlprefiles= 5683c43cc173Smrg for lib in $dlprefiles; do 5684c43cc173Smrg name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` 5685c43cc173Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 5686c43cc173Smrg if test -z "$libdir"; then 5687c43cc173Smrg $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 5688c43cc173Smrg exit $EXIT_FAILURE 5689c43cc173Smrg fi 5690c43cc173Smrg newdlprefiles="$newdlprefiles $libdir/$name" 5691c43cc173Smrg done 5692c43cc173Smrg dlprefiles="$newdlprefiles" 5693c43cc173Smrg else 5694c43cc173Smrg newdlfiles= 5695c43cc173Smrg for lib in $dlfiles; do 5696c43cc173Smrg case $lib in 5697c43cc173Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 5698c43cc173Smrg *) abs=`pwd`"/$lib" ;; 5699c43cc173Smrg esac 5700c43cc173Smrg newdlfiles="$newdlfiles $abs" 5701c43cc173Smrg done 5702c43cc173Smrg dlfiles="$newdlfiles" 5703c43cc173Smrg newdlprefiles= 5704c43cc173Smrg for lib in $dlprefiles; do 5705c43cc173Smrg case $lib in 5706c43cc173Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 5707c43cc173Smrg *) abs=`pwd`"/$lib" ;; 5708c43cc173Smrg esac 5709c43cc173Smrg newdlprefiles="$newdlprefiles $abs" 5710c43cc173Smrg done 5711c43cc173Smrg dlprefiles="$newdlprefiles" 5712c43cc173Smrg fi 5713c43cc173Smrg $rm $output 5714c43cc173Smrg # place dlname in correct position for cygwin 5715c43cc173Smrg tdlname=$dlname 5716c43cc173Smrg case $host,$output,$installed,$module,$dlname in 5717c43cc173Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; 5718c43cc173Smrg esac 5719c43cc173Smrg $echo > $output "\ 5720c43cc173Smrg# $outputname - a libtool library file 5721c43cc173Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP 5722c43cc173Smrg# 5723c43cc173Smrg# Please DO NOT delete this file! 5724c43cc173Smrg# It is necessary for linking the library. 5725c43cc173Smrg 5726c43cc173Smrg# The name that we can dlopen(3). 5727c43cc173Smrgdlname='$tdlname' 5728c43cc173Smrg 5729c43cc173Smrg# Names of this library. 5730c43cc173Smrglibrary_names='$library_names' 5731c43cc173Smrg 5732c43cc173Smrg# The name of the static archive. 5733c43cc173Smrgold_library='$old_library' 5734c43cc173Smrg 5735c43cc173Smrg# Libraries that this one depends upon. 5736c43cc173Smrgdependency_libs='$dependency_libs' 5737c43cc173Smrg 5738c43cc173Smrg# Version information for $libname. 5739c43cc173Smrgcurrent=$current 5740c43cc173Smrgage=$age 5741c43cc173Smrgrevision=$revision 5742c43cc173Smrg 5743c43cc173Smrg# Is this an already installed library? 5744c43cc173Smrginstalled=$installed 5745c43cc173Smrg 5746c43cc173Smrg# Should we warn about portability when linking against -modules? 5747c43cc173Smrgshouldnotlink=$module 5748c43cc173Smrg 5749c43cc173Smrg# Files to dlopen/dlpreopen 5750c43cc173Smrgdlopen='$dlfiles' 5751c43cc173Smrgdlpreopen='$dlprefiles' 5752c43cc173Smrg 5753c43cc173Smrg# Directory that this library needs to be installed in: 5754c43cc173Smrglibdir='$install_libdir'" 5755c43cc173Smrg if test "$installed" = no && test "$need_relink" = yes; then 5756c43cc173Smrg $echo >> $output "\ 5757c43cc173Smrgrelink_command=\"$relink_command\"" 5758c43cc173Smrg fi 5759c43cc173Smrg done 5760c43cc173Smrg fi 5761c43cc173Smrg 5762c43cc173Smrg # Do a symbolic link so that the libtool archive can be found in 5763c43cc173Smrg # LD_LIBRARY_PATH before the program is installed. 5764c43cc173Smrg $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" 5765c43cc173Smrg $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? 5766c43cc173Smrg ;; 5767c43cc173Smrg esac 5768c43cc173Smrg exit $EXIT_SUCCESS 5769c43cc173Smrg ;; 5770c43cc173Smrg 5771c43cc173Smrg # libtool install mode 5772c43cc173Smrg install) 5773c43cc173Smrg modename="$modename: install" 5774c43cc173Smrg 5775c43cc173Smrg # There may be an optional sh(1) argument at the beginning of 5776c43cc173Smrg # install_prog (especially on Windows NT). 5777c43cc173Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 5778c43cc173Smrg # Allow the use of GNU shtool's install command. 5779c43cc173Smrg $echo "X$nonopt" | grep shtool > /dev/null; then 5780c43cc173Smrg # Aesthetically quote it. 5781c43cc173Smrg arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` 5782c43cc173Smrg case $arg in 5783c43cc173Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 5784c43cc173Smrg arg="\"$arg\"" 5785c43cc173Smrg ;; 5786c43cc173Smrg esac 5787c43cc173Smrg install_prog="$arg " 5788c43cc173Smrg arg="$1" 5789c43cc173Smrg shift 5790c43cc173Smrg else 5791c43cc173Smrg install_prog= 5792c43cc173Smrg arg=$nonopt 5793c43cc173Smrg fi 5794c43cc173Smrg 5795c43cc173Smrg # The real first argument should be the name of the installation program. 5796c43cc173Smrg # Aesthetically quote it. 5797c43cc173Smrg arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` 5798c43cc173Smrg case $arg in 5799c43cc173Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 5800c43cc173Smrg arg="\"$arg\"" 5801c43cc173Smrg ;; 5802c43cc173Smrg esac 5803c43cc173Smrg install_prog="$install_prog$arg" 5804c43cc173Smrg 5805c43cc173Smrg # We need to accept at least all the BSD install flags. 5806c43cc173Smrg dest= 5807c43cc173Smrg files= 5808c43cc173Smrg opts= 5809c43cc173Smrg prev= 5810c43cc173Smrg install_type= 5811c43cc173Smrg isdir=no 5812c43cc173Smrg stripme= 5813c43cc173Smrg for arg 5814c43cc173Smrg do 5815c43cc173Smrg if test -n "$dest"; then 5816c43cc173Smrg files="$files $dest" 5817c43cc173Smrg dest=$arg 5818c43cc173Smrg continue 5819c43cc173Smrg fi 5820c43cc173Smrg 5821c43cc173Smrg case $arg in 5822c43cc173Smrg -d) isdir=yes ;; 5823c43cc173Smrg -f) 5824c43cc173Smrg case " $install_prog " in 5825c43cc173Smrg *[\\\ /]cp\ *) ;; 5826c43cc173Smrg *) prev=$arg ;; 5827c43cc173Smrg esac 5828c43cc173Smrg ;; 5829c43cc173Smrg -g | -m | -o) prev=$arg ;; 5830c43cc173Smrg -s) 5831c43cc173Smrg stripme=" -s" 5832c43cc173Smrg continue 5833c43cc173Smrg ;; 5834c43cc173Smrg -*) 5835c43cc173Smrg ;; 5836c43cc173Smrg *) 5837c43cc173Smrg # If the previous option needed an argument, then skip it. 5838c43cc173Smrg if test -n "$prev"; then 5839c43cc173Smrg prev= 5840c43cc173Smrg else 5841c43cc173Smrg dest=$arg 5842c43cc173Smrg continue 5843c43cc173Smrg fi 5844c43cc173Smrg ;; 5845c43cc173Smrg esac 5846c43cc173Smrg 5847c43cc173Smrg # Aesthetically quote the argument. 5848c43cc173Smrg arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` 5849c43cc173Smrg case $arg in 5850c43cc173Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 5851c43cc173Smrg arg="\"$arg\"" 5852c43cc173Smrg ;; 5853c43cc173Smrg esac 5854c43cc173Smrg install_prog="$install_prog $arg" 5855c43cc173Smrg done 5856c43cc173Smrg 5857c43cc173Smrg if test -z "$install_prog"; then 5858c43cc173Smrg $echo "$modename: you must specify an install program" 1>&2 5859c43cc173Smrg $echo "$help" 1>&2 5860c43cc173Smrg exit $EXIT_FAILURE 5861c43cc173Smrg fi 5862c43cc173Smrg 5863c43cc173Smrg if test -n "$prev"; then 5864c43cc173Smrg $echo "$modename: the \`$prev' option requires an argument" 1>&2 5865c43cc173Smrg $echo "$help" 1>&2 5866c43cc173Smrg exit $EXIT_FAILURE 5867c43cc173Smrg fi 5868c43cc173Smrg 5869c43cc173Smrg if test -z "$files"; then 5870c43cc173Smrg if test -z "$dest"; then 5871c43cc173Smrg $echo "$modename: no file or destination specified" 1>&2 5872c43cc173Smrg else 5873c43cc173Smrg $echo "$modename: you must specify a destination" 1>&2 5874c43cc173Smrg fi 5875c43cc173Smrg $echo "$help" 1>&2 5876c43cc173Smrg exit $EXIT_FAILURE 5877c43cc173Smrg fi 5878c43cc173Smrg 5879c43cc173Smrg # Strip any trailing slash from the destination. 5880c43cc173Smrg dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` 5881c43cc173Smrg 5882c43cc173Smrg # Check to see that the destination is a directory. 5883c43cc173Smrg test -d "$dest" && isdir=yes 5884c43cc173Smrg if test "$isdir" = yes; then 5885c43cc173Smrg destdir="$dest" 5886c43cc173Smrg destname= 5887c43cc173Smrg else 5888c43cc173Smrg destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` 5889c43cc173Smrg test "X$destdir" = "X$dest" && destdir=. 5890c43cc173Smrg destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` 5891c43cc173Smrg 5892c43cc173Smrg # Not a directory, so check to see that there is only one file specified. 5893c43cc173Smrg set dummy $files 5894c43cc173Smrg if test "$#" -gt 2; then 5895c43cc173Smrg $echo "$modename: \`$dest' is not a directory" 1>&2 5896c43cc173Smrg $echo "$help" 1>&2 5897c43cc173Smrg exit $EXIT_FAILURE 5898c43cc173Smrg fi 5899c43cc173Smrg fi 5900c43cc173Smrg case $destdir in 5901c43cc173Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5902c43cc173Smrg *) 5903c43cc173Smrg for file in $files; do 5904c43cc173Smrg case $file in 5905c43cc173Smrg *.lo) ;; 5906c43cc173Smrg *) 5907c43cc173Smrg $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 5908c43cc173Smrg $echo "$help" 1>&2 5909c43cc173Smrg exit $EXIT_FAILURE 5910c43cc173Smrg ;; 5911c43cc173Smrg esac 5912c43cc173Smrg done 5913c43cc173Smrg ;; 5914c43cc173Smrg esac 5915c43cc173Smrg 5916c43cc173Smrg # This variable tells wrapper scripts just to set variables rather 5917c43cc173Smrg # than running their programs. 5918c43cc173Smrg libtool_install_magic="$magic" 5919c43cc173Smrg 5920c43cc173Smrg staticlibs= 5921c43cc173Smrg future_libdirs= 5922c43cc173Smrg current_libdirs= 5923c43cc173Smrg for file in $files; do 5924c43cc173Smrg 5925c43cc173Smrg # Do each installation. 5926c43cc173Smrg case $file in 5927c43cc173Smrg *.$libext) 5928c43cc173Smrg # Do the static libraries later. 5929c43cc173Smrg staticlibs="$staticlibs $file" 5930c43cc173Smrg ;; 5931c43cc173Smrg 5932c43cc173Smrg *.la) 5933c43cc173Smrg # Check to see that this really is a libtool archive. 5934c43cc173Smrg if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : 5935c43cc173Smrg else 5936c43cc173Smrg $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 5937c43cc173Smrg $echo "$help" 1>&2 5938c43cc173Smrg exit $EXIT_FAILURE 5939c43cc173Smrg fi 5940c43cc173Smrg 5941c43cc173Smrg library_names= 5942c43cc173Smrg old_library= 5943c43cc173Smrg relink_command= 5944c43cc173Smrg # If there is no directory component, then add one. 5945c43cc173Smrg case $file in 5946c43cc173Smrg */* | *\\*) . $file ;; 5947c43cc173Smrg *) . ./$file ;; 5948c43cc173Smrg esac 5949c43cc173Smrg 5950c43cc173Smrg # Add the libdir to current_libdirs if it is the destination. 5951c43cc173Smrg if test "X$destdir" = "X$libdir"; then 5952c43cc173Smrg case "$current_libdirs " in 5953c43cc173Smrg *" $libdir "*) ;; 5954c43cc173Smrg *) current_libdirs="$current_libdirs $libdir" ;; 5955c43cc173Smrg esac 5956c43cc173Smrg else 5957c43cc173Smrg # Note the libdir as a future libdir. 5958c43cc173Smrg case "$future_libdirs " in 5959c43cc173Smrg *" $libdir "*) ;; 5960c43cc173Smrg *) future_libdirs="$future_libdirs $libdir" ;; 5961c43cc173Smrg esac 5962c43cc173Smrg fi 5963c43cc173Smrg 5964c43cc173Smrg dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ 5965c43cc173Smrg test "X$dir" = "X$file/" && dir= 5966c43cc173Smrg dir="$dir$objdir" 5967c43cc173Smrg 5968c43cc173Smrg if test -n "$relink_command"; then 5969c43cc173Smrg # Determine the prefix the user has applied to our future dir. 5970c43cc173Smrg inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"` 5971c43cc173Smrg 5972c43cc173Smrg # Don't allow the user to place us outside of our expected 5973c43cc173Smrg # location b/c this prevents finding dependent libraries that 5974c43cc173Smrg # are installed to the same prefix. 5975c43cc173Smrg # At present, this check doesn't affect windows .dll's that 5976c43cc173Smrg # are installed into $libdir/../bin (currently, that works fine) 5977c43cc173Smrg # but it's something to keep an eye on. 5978c43cc173Smrg if test "$inst_prefix_dir" = "$destdir"; then 5979c43cc173Smrg $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 5980c43cc173Smrg exit $EXIT_FAILURE 5981c43cc173Smrg fi 5982c43cc173Smrg 5983c43cc173Smrg if test -n "$inst_prefix_dir"; then 5984c43cc173Smrg # Stick the inst_prefix_dir data into the link command. 5985c43cc173Smrg relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 5986c43cc173Smrg else 5987c43cc173Smrg relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 5988c43cc173Smrg fi 5989c43cc173Smrg 5990c43cc173Smrg $echo "$modename: warning: relinking \`$file'" 1>&2 5991c43cc173Smrg $show "$relink_command" 5992c43cc173Smrg if $run eval "$relink_command"; then : 5993c43cc173Smrg else 5994c43cc173Smrg $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 5995c43cc173Smrg exit $EXIT_FAILURE 5996c43cc173Smrg fi 5997c43cc173Smrg fi 5998c43cc173Smrg 5999c43cc173Smrg # See the names of the shared library. 6000c43cc173Smrg set dummy $library_names 6001c43cc173Smrg if test -n "$2"; then 6002c43cc173Smrg realname="$2" 6003c43cc173Smrg shift 6004c43cc173Smrg shift 6005c43cc173Smrg 6006c43cc173Smrg srcname="$realname" 6007c43cc173Smrg test -n "$relink_command" && srcname="$realname"T 6008c43cc173Smrg 6009c43cc173Smrg # Install the shared library and build the symlinks. 6010c43cc173Smrg $show "$install_prog $dir/$srcname $destdir/$realname" 6011c43cc173Smrg $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? 6012c43cc173Smrg if test -n "$stripme" && test -n "$striplib"; then 6013c43cc173Smrg $show "$striplib $destdir/$realname" 6014c43cc173Smrg $run eval "$striplib $destdir/$realname" || exit $? 6015c43cc173Smrg fi 6016c43cc173Smrg 6017c43cc173Smrg if test "$#" -gt 0; then 6018c43cc173Smrg # Delete the old symlinks, and create new ones. 6019c43cc173Smrg # Try `ln -sf' first, because the `ln' binary might depend on 6020c43cc173Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 6021c43cc173Smrg # so we also need to try rm && ln -s. 6022c43cc173Smrg for linkname 6023c43cc173Smrg do 6024c43cc173Smrg if test "$linkname" != "$realname"; then 6025c43cc173Smrg $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" 6026c43cc173Smrg $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" 6027c43cc173Smrg fi 6028c43cc173Smrg done 6029c43cc173Smrg fi 6030c43cc173Smrg 6031c43cc173Smrg # Do each command in the postinstall commands. 6032c43cc173Smrg lib="$destdir/$realname" 6033c43cc173Smrg cmds=$postinstall_cmds 6034c43cc173Smrg save_ifs="$IFS"; IFS='~' 6035c43cc173Smrg for cmd in $cmds; do 6036c43cc173Smrg IFS="$save_ifs" 6037c43cc173Smrg eval cmd=\"$cmd\" 6038c43cc173Smrg $show "$cmd" 6039c43cc173Smrg $run eval "$cmd" || { 6040c43cc173Smrg lt_exit=$? 6041c43cc173Smrg 6042c43cc173Smrg # Restore the uninstalled library and exit 6043c43cc173Smrg if test "$mode" = relink; then 6044c43cc173Smrg $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' 6045c43cc173Smrg fi 6046c43cc173Smrg 6047c43cc173Smrg exit $lt_exit 6048c43cc173Smrg } 6049c43cc173Smrg done 6050c43cc173Smrg IFS="$save_ifs" 6051c43cc173Smrg fi 6052c43cc173Smrg 6053c43cc173Smrg # Install the pseudo-library for information purposes. 6054c43cc173Smrg name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` 6055c43cc173Smrg instname="$dir/$name"i 6056c43cc173Smrg $show "$install_prog $instname $destdir/$name" 6057c43cc173Smrg $run eval "$install_prog $instname $destdir/$name" || exit $? 6058c43cc173Smrg 6059c43cc173Smrg # Maybe install the static library, too. 6060c43cc173Smrg test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" 6061c43cc173Smrg ;; 6062c43cc173Smrg 6063c43cc173Smrg *.lo) 6064c43cc173Smrg # Install (i.e. copy) a libtool object. 6065c43cc173Smrg 6066c43cc173Smrg # Figure out destination file name, if it wasn't already specified. 6067c43cc173Smrg if test -n "$destname"; then 6068c43cc173Smrg destfile="$destdir/$destname" 6069c43cc173Smrg else 6070c43cc173Smrg destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` 6071c43cc173Smrg destfile="$destdir/$destfile" 6072c43cc173Smrg fi 6073c43cc173Smrg 6074c43cc173Smrg # Deduce the name of the destination old-style object file. 6075c43cc173Smrg case $destfile in 6076c43cc173Smrg *.lo) 6077c43cc173Smrg staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` 6078c43cc173Smrg ;; 6079c43cc173Smrg *.$objext) 6080c43cc173Smrg staticdest="$destfile" 6081c43cc173Smrg destfile= 6082c43cc173Smrg ;; 6083c43cc173Smrg *) 6084c43cc173Smrg $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 6085c43cc173Smrg $echo "$help" 1>&2 6086c43cc173Smrg exit $EXIT_FAILURE 6087c43cc173Smrg ;; 6088c43cc173Smrg esac 6089c43cc173Smrg 6090c43cc173Smrg # Install the libtool object if requested. 6091c43cc173Smrg if test -n "$destfile"; then 6092c43cc173Smrg $show "$install_prog $file $destfile" 6093c43cc173Smrg $run eval "$install_prog $file $destfile" || exit $? 6094c43cc173Smrg fi 6095c43cc173Smrg 6096c43cc173Smrg # Install the old object if enabled. 6097c43cc173Smrg if test "$build_old_libs" = yes; then 6098c43cc173Smrg # Deduce the name of the old-style object file. 6099c43cc173Smrg staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` 6100c43cc173Smrg 6101c43cc173Smrg $show "$install_prog $staticobj $staticdest" 6102c43cc173Smrg $run eval "$install_prog \$staticobj \$staticdest" || exit $? 6103c43cc173Smrg fi 6104c43cc173Smrg exit $EXIT_SUCCESS 6105c43cc173Smrg ;; 6106c43cc173Smrg 6107c43cc173Smrg *) 6108c43cc173Smrg # Figure out destination file name, if it wasn't already specified. 6109c43cc173Smrg if test -n "$destname"; then 6110c43cc173Smrg destfile="$destdir/$destname" 6111c43cc173Smrg else 6112c43cc173Smrg destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` 6113c43cc173Smrg destfile="$destdir/$destfile" 6114c43cc173Smrg fi 6115c43cc173Smrg 6116c43cc173Smrg # If the file is missing, and there is a .exe on the end, strip it 6117c43cc173Smrg # because it is most likely a libtool script we actually want to 6118c43cc173Smrg # install 6119c43cc173Smrg stripped_ext="" 6120c43cc173Smrg case $file in 6121c43cc173Smrg *.exe) 6122c43cc173Smrg if test ! -f "$file"; then 6123c43cc173Smrg file=`$echo $file|${SED} 's,.exe$,,'` 6124c43cc173Smrg stripped_ext=".exe" 6125c43cc173Smrg fi 6126c43cc173Smrg ;; 6127c43cc173Smrg esac 6128c43cc173Smrg 6129c43cc173Smrg # Do a test to see if this is really a libtool program. 6130c43cc173Smrg case $host in 6131c43cc173Smrg *cygwin*|*mingw*) 6132c43cc173Smrg wrapper=`$echo $file | ${SED} -e 's,.exe$,,'` 6133c43cc173Smrg ;; 6134c43cc173Smrg *) 6135c43cc173Smrg wrapper=$file 6136c43cc173Smrg ;; 6137c43cc173Smrg esac 6138c43cc173Smrg if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then 6139c43cc173Smrg notinst_deplibs= 6140c43cc173Smrg relink_command= 6141c43cc173Smrg 6142c43cc173Smrg # Note that it is not necessary on cygwin/mingw to append a dot to 6143c43cc173Smrg # foo even if both foo and FILE.exe exist: automatic-append-.exe 6144c43cc173Smrg # behavior happens only for exec(3), not for open(2)! Also, sourcing 6145c43cc173Smrg # `FILE.' does not work on cygwin managed mounts. 6146c43cc173Smrg # 6147c43cc173Smrg # If there is no directory component, then add one. 6148c43cc173Smrg case $wrapper in 6149c43cc173Smrg */* | *\\*) . ${wrapper} ;; 6150c43cc173Smrg *) . ./${wrapper} ;; 6151c43cc173Smrg esac 6152c43cc173Smrg 6153c43cc173Smrg # Check the variables that should have been set. 6154c43cc173Smrg if test -z "$notinst_deplibs"; then 6155c43cc173Smrg $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 6156c43cc173Smrg exit $EXIT_FAILURE 6157c43cc173Smrg fi 6158c43cc173Smrg 6159c43cc173Smrg finalize=yes 6160c43cc173Smrg for lib in $notinst_deplibs; do 6161c43cc173Smrg # Check to see that each library is installed. 6162c43cc173Smrg libdir= 6163c43cc173Smrg if test -f "$lib"; then 6164c43cc173Smrg # If there is no directory component, then add one. 6165c43cc173Smrg case $lib in 6166c43cc173Smrg */* | *\\*) . $lib ;; 6167c43cc173Smrg *) . ./$lib ;; 6168c43cc173Smrg esac 6169c43cc173Smrg fi 6170c43cc173Smrg libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test 6171c43cc173Smrg if test -n "$libdir" && test ! -f "$libfile"; then 6172c43cc173Smrg $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 6173c43cc173Smrg finalize=no 6174c43cc173Smrg fi 6175c43cc173Smrg done 6176c43cc173Smrg 6177c43cc173Smrg relink_command= 6178c43cc173Smrg # Note that it is not necessary on cygwin/mingw to append a dot to 6179c43cc173Smrg # foo even if both foo and FILE.exe exist: automatic-append-.exe 6180c43cc173Smrg # behavior happens only for exec(3), not for open(2)! Also, sourcing 6181c43cc173Smrg # `FILE.' does not work on cygwin managed mounts. 6182c43cc173Smrg # 6183c43cc173Smrg # If there is no directory component, then add one. 6184c43cc173Smrg case $wrapper in 6185c43cc173Smrg */* | *\\*) . ${wrapper} ;; 6186c43cc173Smrg *) . ./${wrapper} ;; 6187c43cc173Smrg esac 6188c43cc173Smrg 6189c43cc173Smrg outputname= 6190c43cc173Smrg if test "$fast_install" = no && test -n "$relink_command"; then 6191c43cc173Smrg if test "$finalize" = yes && test -z "$run"; then 6192c43cc173Smrg tmpdir=`func_mktempdir` 6193c43cc173Smrg file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` 6194c43cc173Smrg outputname="$tmpdir/$file" 6195c43cc173Smrg # Replace the output file specification. 6196c43cc173Smrg relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` 6197c43cc173Smrg 6198c43cc173Smrg $show "$relink_command" 6199c43cc173Smrg if $run eval "$relink_command"; then : 6200c43cc173Smrg else 6201c43cc173Smrg $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 6202c43cc173Smrg ${rm}r "$tmpdir" 6203c43cc173Smrg continue 6204c43cc173Smrg fi 6205c43cc173Smrg file="$outputname" 6206c43cc173Smrg else 6207c43cc173Smrg $echo "$modename: warning: cannot relink \`$file'" 1>&2 6208c43cc173Smrg fi 6209c43cc173Smrg else 6210c43cc173Smrg # Install the binary that we compiled earlier. 6211c43cc173Smrg file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` 6212c43cc173Smrg fi 6213c43cc173Smrg fi 6214c43cc173Smrg 6215c43cc173Smrg # remove .exe since cygwin /usr/bin/install will append another 6216c43cc173Smrg # one anyway 6217c43cc173Smrg case $install_prog,$host in 6218c43cc173Smrg */usr/bin/install*,*cygwin*) 6219c43cc173Smrg case $file:$destfile in 6220c43cc173Smrg *.exe:*.exe) 6221c43cc173Smrg # this is ok 6222c43cc173Smrg ;; 6223c43cc173Smrg *.exe:*) 6224c43cc173Smrg destfile=$destfile.exe 6225c43cc173Smrg ;; 6226c43cc173Smrg *:*.exe) 6227c43cc173Smrg destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'` 6228c43cc173Smrg ;; 6229c43cc173Smrg esac 6230c43cc173Smrg ;; 6231c43cc173Smrg esac 6232c43cc173Smrg $show "$install_prog$stripme $file $destfile" 6233c43cc173Smrg $run eval "$install_prog\$stripme \$file \$destfile" || exit $? 6234c43cc173Smrg test -n "$outputname" && ${rm}r "$tmpdir" 6235c43cc173Smrg ;; 6236c43cc173Smrg esac 6237c43cc173Smrg done 6238c43cc173Smrg 6239c43cc173Smrg for file in $staticlibs; do 6240c43cc173Smrg name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` 6241c43cc173Smrg 6242c43cc173Smrg # Set up the ranlib parameters. 6243c43cc173Smrg oldlib="$destdir/$name" 6244c43cc173Smrg 6245c43cc173Smrg $show "$install_prog $file $oldlib" 6246c43cc173Smrg $run eval "$install_prog \$file \$oldlib" || exit $? 6247c43cc173Smrg 6248c43cc173Smrg if test -n "$stripme" && test -n "$old_striplib"; then 6249c43cc173Smrg $show "$old_striplib $oldlib" 6250c43cc173Smrg $run eval "$old_striplib $oldlib" || exit $? 6251c43cc173Smrg fi 6252c43cc173Smrg 6253c43cc173Smrg # Do each command in the postinstall commands. 6254c43cc173Smrg cmds=$old_postinstall_cmds 6255c43cc173Smrg save_ifs="$IFS"; IFS='~' 6256c43cc173Smrg for cmd in $cmds; do 6257c43cc173Smrg IFS="$save_ifs" 6258c43cc173Smrg eval cmd=\"$cmd\" 6259c43cc173Smrg $show "$cmd" 6260c43cc173Smrg $run eval "$cmd" || exit $? 6261c43cc173Smrg done 6262c43cc173Smrg IFS="$save_ifs" 6263c43cc173Smrg done 6264c43cc173Smrg 6265c43cc173Smrg if test -n "$future_libdirs"; then 6266c43cc173Smrg $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 6267c43cc173Smrg fi 6268c43cc173Smrg 6269c43cc173Smrg if test -n "$current_libdirs"; then 6270c43cc173Smrg # Maybe just do a dry run. 6271c43cc173Smrg test -n "$run" && current_libdirs=" -n$current_libdirs" 6272c43cc173Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 6273c43cc173Smrg else 6274c43cc173Smrg exit $EXIT_SUCCESS 6275c43cc173Smrg fi 6276c43cc173Smrg ;; 6277c43cc173Smrg 6278c43cc173Smrg # libtool finish mode 6279c43cc173Smrg finish) 6280c43cc173Smrg modename="$modename: finish" 6281c43cc173Smrg libdirs="$nonopt" 6282c43cc173Smrg admincmds= 6283c43cc173Smrg 6284c43cc173Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 6285c43cc173Smrg for dir 6286c43cc173Smrg do 6287c43cc173Smrg libdirs="$libdirs $dir" 6288c43cc173Smrg done 6289c43cc173Smrg 6290c43cc173Smrg for libdir in $libdirs; do 6291c43cc173Smrg if test -n "$finish_cmds"; then 6292c43cc173Smrg # Do each command in the finish commands. 6293c43cc173Smrg cmds=$finish_cmds 6294c43cc173Smrg save_ifs="$IFS"; IFS='~' 6295c43cc173Smrg for cmd in $cmds; do 6296c43cc173Smrg IFS="$save_ifs" 6297c43cc173Smrg eval cmd=\"$cmd\" 6298c43cc173Smrg $show "$cmd" 6299c43cc173Smrg $run eval "$cmd" || admincmds="$admincmds 6300c43cc173Smrg $cmd" 6301c43cc173Smrg done 6302c43cc173Smrg IFS="$save_ifs" 6303c43cc173Smrg fi 6304c43cc173Smrg if test -n "$finish_eval"; then 6305c43cc173Smrg # Do the single finish_eval. 6306c43cc173Smrg eval cmds=\"$finish_eval\" 6307c43cc173Smrg $run eval "$cmds" || admincmds="$admincmds 6308c43cc173Smrg $cmds" 6309c43cc173Smrg fi 6310c43cc173Smrg done 6311c43cc173Smrg fi 6312c43cc173Smrg 6313c43cc173Smrg # Exit here if they wanted silent mode. 6314c43cc173Smrg test "$show" = : && exit $EXIT_SUCCESS 6315c43cc173Smrg 6316c43cc173Smrg $echo "X----------------------------------------------------------------------" | $Xsed 6317c43cc173Smrg $echo "Libraries have been installed in:" 6318c43cc173Smrg for libdir in $libdirs; do 6319c43cc173Smrg $echo " $libdir" 6320c43cc173Smrg done 6321c43cc173Smrg $echo 6322c43cc173Smrg $echo "If you ever happen to want to link against installed libraries" 6323c43cc173Smrg $echo "in a given directory, LIBDIR, you must either use libtool, and" 6324c43cc173Smrg $echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 6325c43cc173Smrg $echo "flag during linking and do at least one of the following:" 6326c43cc173Smrg if test -n "$shlibpath_var"; then 6327c43cc173Smrg $echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 6328c43cc173Smrg $echo " during execution" 6329c43cc173Smrg fi 6330c43cc173Smrg if test -n "$runpath_var"; then 6331c43cc173Smrg $echo " - add LIBDIR to the \`$runpath_var' environment variable" 6332c43cc173Smrg $echo " during linking" 6333c43cc173Smrg fi 6334c43cc173Smrg if test -n "$hardcode_libdir_flag_spec"; then 6335c43cc173Smrg libdir=LIBDIR 6336c43cc173Smrg eval flag=\"$hardcode_libdir_flag_spec\" 6337c43cc173Smrg 6338c43cc173Smrg $echo " - use the \`$flag' linker flag" 6339c43cc173Smrg fi 6340c43cc173Smrg if test -n "$admincmds"; then 6341c43cc173Smrg $echo " - have your system administrator run these commands:$admincmds" 6342c43cc173Smrg fi 6343c43cc173Smrg if test -f /etc/ld.so.conf; then 6344c43cc173Smrg $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 6345c43cc173Smrg fi 6346c43cc173Smrg $echo 6347c43cc173Smrg $echo "See any operating system documentation about shared libraries for" 6348c43cc173Smrg $echo "more information, such as the ld(1) and ld.so(8) manual pages." 6349c43cc173Smrg $echo "X----------------------------------------------------------------------" | $Xsed 6350c43cc173Smrg exit $EXIT_SUCCESS 6351c43cc173Smrg ;; 6352c43cc173Smrg 6353c43cc173Smrg # libtool execute mode 6354c43cc173Smrg execute) 6355c43cc173Smrg modename="$modename: execute" 6356c43cc173Smrg 6357c43cc173Smrg # The first argument is the command name. 6358c43cc173Smrg cmd="$nonopt" 6359c43cc173Smrg if test -z "$cmd"; then 6360c43cc173Smrg $echo "$modename: you must specify a COMMAND" 1>&2 6361c43cc173Smrg $echo "$help" 6362c43cc173Smrg exit $EXIT_FAILURE 6363c43cc173Smrg fi 6364c43cc173Smrg 6365c43cc173Smrg # Handle -dlopen flags immediately. 6366c43cc173Smrg for file in $execute_dlfiles; do 6367c43cc173Smrg if test ! -f "$file"; then 6368c43cc173Smrg $echo "$modename: \`$file' is not a file" 1>&2 6369c43cc173Smrg $echo "$help" 1>&2 6370c43cc173Smrg exit $EXIT_FAILURE 6371c43cc173Smrg fi 6372c43cc173Smrg 6373c43cc173Smrg dir= 6374c43cc173Smrg case $file in 6375c43cc173Smrg *.la) 6376c43cc173Smrg # Check to see that this really is a libtool archive. 6377c43cc173Smrg if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : 6378c43cc173Smrg else 6379c43cc173Smrg $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 6380c43cc173Smrg $echo "$help" 1>&2 6381c43cc173Smrg exit $EXIT_FAILURE 6382c43cc173Smrg fi 6383c43cc173Smrg 6384c43cc173Smrg # Read the libtool library. 6385c43cc173Smrg dlname= 6386c43cc173Smrg library_names= 6387c43cc173Smrg 6388c43cc173Smrg # If there is no directory component, then add one. 6389c43cc173Smrg case $file in 6390c43cc173Smrg */* | *\\*) . $file ;; 6391c43cc173Smrg *) . ./$file ;; 6392c43cc173Smrg esac 6393c43cc173Smrg 6394c43cc173Smrg # Skip this library if it cannot be dlopened. 6395c43cc173Smrg if test -z "$dlname"; then 6396c43cc173Smrg # Warn if it was a shared library. 6397c43cc173Smrg test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" 6398c43cc173Smrg continue 6399c43cc173Smrg fi 6400c43cc173Smrg 6401c43cc173Smrg dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` 6402c43cc173Smrg test "X$dir" = "X$file" && dir=. 6403c43cc173Smrg 6404c43cc173Smrg if test -f "$dir/$objdir/$dlname"; then 6405c43cc173Smrg dir="$dir/$objdir" 6406c43cc173Smrg else 6407c43cc173Smrg $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 6408c43cc173Smrg exit $EXIT_FAILURE 6409c43cc173Smrg fi 6410c43cc173Smrg ;; 6411c43cc173Smrg 6412c43cc173Smrg *.lo) 6413c43cc173Smrg # Just add the directory containing the .lo file. 6414c43cc173Smrg dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` 6415c43cc173Smrg test "X$dir" = "X$file" && dir=. 6416c43cc173Smrg ;; 6417c43cc173Smrg 6418c43cc173Smrg *) 6419c43cc173Smrg $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 6420c43cc173Smrg continue 6421c43cc173Smrg ;; 6422c43cc173Smrg esac 6423c43cc173Smrg 6424c43cc173Smrg # Get the absolute pathname. 6425c43cc173Smrg absdir=`cd "$dir" && pwd` 6426c43cc173Smrg test -n "$absdir" && dir="$absdir" 6427c43cc173Smrg 6428c43cc173Smrg # Now add the directory to shlibpath_var. 6429c43cc173Smrg if eval "test -z \"\$$shlibpath_var\""; then 6430c43cc173Smrg eval "$shlibpath_var=\"\$dir\"" 6431c43cc173Smrg else 6432c43cc173Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 6433c43cc173Smrg fi 6434c43cc173Smrg done 6435c43cc173Smrg 6436c43cc173Smrg # This variable tells wrapper scripts just to set shlibpath_var 6437c43cc173Smrg # rather than running their programs. 6438c43cc173Smrg libtool_execute_magic="$magic" 6439c43cc173Smrg 6440c43cc173Smrg # Check if any of the arguments is a wrapper script. 6441c43cc173Smrg args= 6442c43cc173Smrg for file 6443c43cc173Smrg do 6444c43cc173Smrg case $file in 6445c43cc173Smrg -*) ;; 6446c43cc173Smrg *) 6447c43cc173Smrg # Do a test to see if this is really a libtool program. 6448c43cc173Smrg if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then 6449c43cc173Smrg # If there is no directory component, then add one. 6450c43cc173Smrg case $file in 6451c43cc173Smrg */* | *\\*) . $file ;; 6452c43cc173Smrg *) . ./$file ;; 6453c43cc173Smrg esac 6454c43cc173Smrg 6455c43cc173Smrg # Transform arg to wrapped name. 6456c43cc173Smrg file="$progdir/$program" 6457c43cc173Smrg fi 6458c43cc173Smrg ;; 6459c43cc173Smrg esac 6460c43cc173Smrg # Quote arguments (to preserve shell metacharacters). 6461c43cc173Smrg file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` 6462c43cc173Smrg args="$args \"$file\"" 6463c43cc173Smrg done 6464c43cc173Smrg 6465c43cc173Smrg if test -z "$run"; then 6466c43cc173Smrg if test -n "$shlibpath_var"; then 6467c43cc173Smrg # Export the shlibpath_var. 6468c43cc173Smrg eval "export $shlibpath_var" 6469c43cc173Smrg fi 6470c43cc173Smrg 6471c43cc173Smrg # Restore saved environment variables 6472c43cc173Smrg if test "${save_LC_ALL+set}" = set; then 6473c43cc173Smrg LC_ALL="$save_LC_ALL"; export LC_ALL 6474c43cc173Smrg fi 6475c43cc173Smrg if test "${save_LANG+set}" = set; then 6476c43cc173Smrg LANG="$save_LANG"; export LANG 6477c43cc173Smrg fi 6478c43cc173Smrg 6479c43cc173Smrg # Now prepare to actually exec the command. 6480c43cc173Smrg exec_cmd="\$cmd$args" 6481c43cc173Smrg else 6482c43cc173Smrg # Display what would be done. 6483c43cc173Smrg if test -n "$shlibpath_var"; then 6484c43cc173Smrg eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" 6485c43cc173Smrg $echo "export $shlibpath_var" 6486c43cc173Smrg fi 6487c43cc173Smrg $echo "$cmd$args" 6488c43cc173Smrg exit $EXIT_SUCCESS 6489c43cc173Smrg fi 6490c43cc173Smrg ;; 6491c43cc173Smrg 6492c43cc173Smrg # libtool clean and uninstall mode 6493c43cc173Smrg clean | uninstall) 6494c43cc173Smrg modename="$modename: $mode" 6495c43cc173Smrg rm="$nonopt" 6496c43cc173Smrg files= 6497c43cc173Smrg rmforce= 6498c43cc173Smrg exit_status=0 6499c43cc173Smrg 6500c43cc173Smrg # This variable tells wrapper scripts just to set variables rather 6501c43cc173Smrg # than running their programs. 6502c43cc173Smrg libtool_install_magic="$magic" 6503c43cc173Smrg 6504c43cc173Smrg for arg 6505c43cc173Smrg do 6506c43cc173Smrg case $arg in 6507c43cc173Smrg -f) rm="$rm $arg"; rmforce=yes ;; 6508c43cc173Smrg -*) rm="$rm $arg" ;; 6509c43cc173Smrg *) files="$files $arg" ;; 6510c43cc173Smrg esac 6511c43cc173Smrg done 6512c43cc173Smrg 6513c43cc173Smrg if test -z "$rm"; then 6514c43cc173Smrg $echo "$modename: you must specify an RM program" 1>&2 6515c43cc173Smrg $echo "$help" 1>&2 6516c43cc173Smrg exit $EXIT_FAILURE 6517c43cc173Smrg fi 6518c43cc173Smrg 6519c43cc173Smrg rmdirs= 6520c43cc173Smrg 6521c43cc173Smrg origobjdir="$objdir" 6522c43cc173Smrg for file in $files; do 6523c43cc173Smrg dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` 6524c43cc173Smrg if test "X$dir" = "X$file"; then 6525c43cc173Smrg dir=. 6526c43cc173Smrg objdir="$origobjdir" 6527c43cc173Smrg else 6528c43cc173Smrg objdir="$dir/$origobjdir" 6529c43cc173Smrg fi 6530c43cc173Smrg name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` 6531c43cc173Smrg test "$mode" = uninstall && objdir="$dir" 6532c43cc173Smrg 6533c43cc173Smrg # Remember objdir for removal later, being careful to avoid duplicates 6534c43cc173Smrg if test "$mode" = clean; then 6535c43cc173Smrg case " $rmdirs " in 6536c43cc173Smrg *" $objdir "*) ;; 6537c43cc173Smrg *) rmdirs="$rmdirs $objdir" ;; 6538c43cc173Smrg esac 6539c43cc173Smrg fi 6540c43cc173Smrg 6541c43cc173Smrg # Don't error if the file doesn't exist and rm -f was used. 6542c43cc173Smrg if (test -L "$file") >/dev/null 2>&1 \ 6543c43cc173Smrg || (test -h "$file") >/dev/null 2>&1 \ 6544c43cc173Smrg || test -f "$file"; then 6545c43cc173Smrg : 6546c43cc173Smrg elif test -d "$file"; then 6547c43cc173Smrg exit_status=1 6548c43cc173Smrg continue 6549c43cc173Smrg elif test "$rmforce" = yes; then 6550c43cc173Smrg continue 6551c43cc173Smrg fi 6552c43cc173Smrg 6553c43cc173Smrg rmfiles="$file" 6554c43cc173Smrg 6555c43cc173Smrg case $name in 6556c43cc173Smrg *.la) 6557c43cc173Smrg # Possibly a libtool archive, so verify it. 6558c43cc173Smrg if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then 6559c43cc173Smrg . $dir/$name 6560c43cc173Smrg 6561c43cc173Smrg # Delete the libtool libraries and symlinks. 6562c43cc173Smrg for n in $library_names; do 6563c43cc173Smrg rmfiles="$rmfiles $objdir/$n" 6564c43cc173Smrg done 6565c43cc173Smrg test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" 6566c43cc173Smrg 6567c43cc173Smrg case "$mode" in 6568c43cc173Smrg clean) 6569c43cc173Smrg case " $library_names " in 6570c43cc173Smrg # " " in the beginning catches empty $dlname 6571c43cc173Smrg *" $dlname "*) ;; 6572c43cc173Smrg *) rmfiles="$rmfiles $objdir/$dlname" ;; 6573c43cc173Smrg esac 6574c43cc173Smrg test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" 6575c43cc173Smrg ;; 6576c43cc173Smrg uninstall) 6577c43cc173Smrg if test -n "$library_names"; then 6578c43cc173Smrg # Do each command in the postuninstall commands. 6579c43cc173Smrg cmds=$postuninstall_cmds 6580c43cc173Smrg save_ifs="$IFS"; IFS='~' 6581c43cc173Smrg for cmd in $cmds; do 6582c43cc173Smrg IFS="$save_ifs" 6583c43cc173Smrg eval cmd=\"$cmd\" 6584c43cc173Smrg $show "$cmd" 6585c43cc173Smrg $run eval "$cmd" 6586c43cc173Smrg if test "$?" -ne 0 && test "$rmforce" != yes; then 6587c43cc173Smrg exit_status=1 6588c43cc173Smrg fi 6589c43cc173Smrg done 6590c43cc173Smrg IFS="$save_ifs" 6591c43cc173Smrg fi 6592c43cc173Smrg 6593c43cc173Smrg if test -n "$old_library"; then 6594c43cc173Smrg # Do each command in the old_postuninstall commands. 6595c43cc173Smrg cmds=$old_postuninstall_cmds 6596c43cc173Smrg save_ifs="$IFS"; IFS='~' 6597c43cc173Smrg for cmd in $cmds; do 6598c43cc173Smrg IFS="$save_ifs" 6599c43cc173Smrg eval cmd=\"$cmd\" 6600c43cc173Smrg $show "$cmd" 6601c43cc173Smrg $run eval "$cmd" 6602c43cc173Smrg if test "$?" -ne 0 && test "$rmforce" != yes; then 6603c43cc173Smrg exit_status=1 6604c43cc173Smrg fi 6605c43cc173Smrg done 6606c43cc173Smrg IFS="$save_ifs" 6607c43cc173Smrg fi 6608c43cc173Smrg # FIXME: should reinstall the best remaining shared library. 6609c43cc173Smrg ;; 6610c43cc173Smrg esac 6611c43cc173Smrg fi 6612c43cc173Smrg ;; 6613c43cc173Smrg 6614c43cc173Smrg *.lo) 6615c43cc173Smrg # Possibly a libtool object, so verify it. 6616c43cc173Smrg if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then 6617c43cc173Smrg 6618c43cc173Smrg # Read the .lo file 6619c43cc173Smrg . $dir/$name 6620c43cc173Smrg 6621c43cc173Smrg # Add PIC object to the list of files to remove. 6622c43cc173Smrg if test -n "$pic_object" \ 6623c43cc173Smrg && test "$pic_object" != none; then 6624c43cc173Smrg rmfiles="$rmfiles $dir/$pic_object" 6625c43cc173Smrg fi 6626c43cc173Smrg 6627c43cc173Smrg # Add non-PIC object to the list of files to remove. 6628c43cc173Smrg if test -n "$non_pic_object" \ 6629c43cc173Smrg && test "$non_pic_object" != none; then 6630c43cc173Smrg rmfiles="$rmfiles $dir/$non_pic_object" 6631c43cc173Smrg fi 6632c43cc173Smrg fi 6633c43cc173Smrg ;; 6634c43cc173Smrg 6635c43cc173Smrg *) 6636c43cc173Smrg if test "$mode" = clean ; then 6637c43cc173Smrg noexename=$name 6638c43cc173Smrg case $file in 6639c43cc173Smrg *.exe) 6640c43cc173Smrg file=`$echo $file|${SED} 's,.exe$,,'` 6641c43cc173Smrg noexename=`$echo $name|${SED} 's,.exe$,,'` 6642c43cc173Smrg # $file with .exe has already been added to rmfiles, 6643c43cc173Smrg # add $file without .exe 6644c43cc173Smrg rmfiles="$rmfiles $file" 6645c43cc173Smrg ;; 6646c43cc173Smrg esac 6647c43cc173Smrg # Do a test to see if this is a libtool program. 6648c43cc173Smrg if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then 6649c43cc173Smrg relink_command= 6650c43cc173Smrg . $dir/$noexename 6651c43cc173Smrg 6652c43cc173Smrg # note $name still contains .exe if it was in $file originally 6653c43cc173Smrg # as does the version of $file that was added into $rmfiles 6654c43cc173Smrg rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" 6655c43cc173Smrg if test "$fast_install" = yes && test -n "$relink_command"; then 6656c43cc173Smrg rmfiles="$rmfiles $objdir/lt-$name" 6657c43cc173Smrg fi 6658c43cc173Smrg if test "X$noexename" != "X$name" ; then 6659c43cc173Smrg rmfiles="$rmfiles $objdir/lt-${noexename}.c" 6660c43cc173Smrg fi 6661c43cc173Smrg fi 6662c43cc173Smrg fi 6663c43cc173Smrg ;; 6664c43cc173Smrg esac 6665c43cc173Smrg $show "$rm $rmfiles" 6666c43cc173Smrg $run $rm $rmfiles || exit_status=1 6667c43cc173Smrg done 6668c43cc173Smrg objdir="$origobjdir" 6669c43cc173Smrg 6670c43cc173Smrg # Try to remove the ${objdir}s in the directories where we deleted files 6671c43cc173Smrg for dir in $rmdirs; do 6672c43cc173Smrg if test -d "$dir"; then 6673c43cc173Smrg $show "rmdir $dir" 6674c43cc173Smrg $run rmdir $dir >/dev/null 2>&1 6675c43cc173Smrg fi 6676c43cc173Smrg done 6677c43cc173Smrg 6678c43cc173Smrg exit $exit_status 6679c43cc173Smrg ;; 6680c43cc173Smrg 6681c43cc173Smrg "") 6682c43cc173Smrg $echo "$modename: you must specify a MODE" 1>&2 6683c43cc173Smrg $echo "$generic_help" 1>&2 6684c43cc173Smrg exit $EXIT_FAILURE 6685c43cc173Smrg ;; 6686c43cc173Smrg esac 6687c43cc173Smrg 6688c43cc173Smrg if test -z "$exec_cmd"; then 6689c43cc173Smrg $echo "$modename: invalid operation mode \`$mode'" 1>&2 6690c43cc173Smrg $echo "$generic_help" 1>&2 6691c43cc173Smrg exit $EXIT_FAILURE 6692c43cc173Smrg fi 6693c43cc173Smrgfi # test -z "$show_help" 6694c43cc173Smrg 6695c43cc173Smrgif test -n "$exec_cmd"; then 6696c43cc173Smrg eval exec $exec_cmd 6697c43cc173Smrg exit $EXIT_FAILURE 6698c43cc173Smrgfi 6699c43cc173Smrg 6700c43cc173Smrg# We need to display help for each of the modes. 6701c43cc173Smrgcase $mode in 6702c43cc173Smrg"") $echo \ 6703c43cc173Smrg"Usage: $modename [OPTION]... [MODE-ARG]... 6704c43cc173Smrg 6705c43cc173SmrgProvide generalized library-building support services. 6706c43cc173Smrg 6707c43cc173Smrg --config show all configuration variables 6708c43cc173Smrg --debug enable verbose shell tracing 6709c43cc173Smrg-n, --dry-run display commands without modifying any files 6710c43cc173Smrg --features display basic configuration information and exit 6711c43cc173Smrg --finish same as \`--mode=finish' 6712c43cc173Smrg --help display this help message and exit 6713c43cc173Smrg --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] 6714c43cc173Smrg --quiet same as \`--silent' 6715c43cc173Smrg --silent don't print informational messages 6716c43cc173Smrg --tag=TAG use configuration variables from tag TAG 6717c43cc173Smrg --version print version information 6718c43cc173Smrg 6719c43cc173SmrgMODE must be one of the following: 6720c43cc173Smrg 6721c43cc173Smrg clean remove files from the build directory 6722c43cc173Smrg compile compile a source file into a libtool object 6723c43cc173Smrg execute automatically set library path, then run a program 6724c43cc173Smrg finish complete the installation of libtool libraries 6725c43cc173Smrg install install libraries or executables 6726c43cc173Smrg link create a library or an executable 6727c43cc173Smrg uninstall remove libraries from an installed directory 6728c43cc173Smrg 6729c43cc173SmrgMODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for 6730c43cc173Smrga more detailed description of MODE. 6731c43cc173Smrg 6732c43cc173SmrgReport bugs to <bug-libtool@gnu.org>." 6733c43cc173Smrg exit $EXIT_SUCCESS 6734c43cc173Smrg ;; 6735c43cc173Smrg 6736c43cc173Smrgclean) 6737c43cc173Smrg $echo \ 6738c43cc173Smrg"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 6739c43cc173Smrg 6740c43cc173SmrgRemove files from the build directory. 6741c43cc173Smrg 6742c43cc173SmrgRM is the name of the program to use to delete files associated with each FILE 6743c43cc173Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 6744c43cc173Smrgto RM. 6745c43cc173Smrg 6746c43cc173SmrgIf FILE is a libtool library, object or program, all the files associated 6747c43cc173Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 6748c43cc173Smrg ;; 6749c43cc173Smrg 6750c43cc173Smrgcompile) 6751c43cc173Smrg $echo \ 6752c43cc173Smrg"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 6753c43cc173Smrg 6754c43cc173SmrgCompile a source file into a libtool library object. 6755c43cc173Smrg 6756c43cc173SmrgThis mode accepts the following additional options: 6757c43cc173Smrg 6758c43cc173Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 6759c43cc173Smrg -prefer-pic try to building PIC objects only 6760c43cc173Smrg -prefer-non-pic try to building non-PIC objects only 6761c43cc173Smrg -static always build a \`.o' file suitable for static linking 6762c43cc173Smrg 6763c43cc173SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 6764c43cc173Smrgfrom the given SOURCEFILE. 6765c43cc173Smrg 6766c43cc173SmrgThe output file name is determined by removing the directory component from 6767c43cc173SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 6768c43cc173Smrglibrary object suffix, \`.lo'." 6769c43cc173Smrg ;; 6770c43cc173Smrg 6771c43cc173Smrgexecute) 6772c43cc173Smrg $echo \ 6773c43cc173Smrg"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... 6774c43cc173Smrg 6775c43cc173SmrgAutomatically set library path, then run a program. 6776c43cc173Smrg 6777c43cc173SmrgThis mode accepts the following additional options: 6778c43cc173Smrg 6779c43cc173Smrg -dlopen FILE add the directory containing FILE to the library path 6780c43cc173Smrg 6781c43cc173SmrgThis mode sets the library path environment variable according to \`-dlopen' 6782c43cc173Smrgflags. 6783c43cc173Smrg 6784c43cc173SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 6785c43cc173Smrginto their corresponding uninstalled binary, and any of their required library 6786c43cc173Smrgdirectories are added to the library path. 6787c43cc173Smrg 6788c43cc173SmrgThen, COMMAND is executed, with ARGS as arguments." 6789c43cc173Smrg ;; 6790c43cc173Smrg 6791c43cc173Smrgfinish) 6792c43cc173Smrg $echo \ 6793c43cc173Smrg"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... 6794c43cc173Smrg 6795c43cc173SmrgComplete the installation of libtool libraries. 6796c43cc173Smrg 6797c43cc173SmrgEach LIBDIR is a directory that contains libtool libraries. 6798c43cc173Smrg 6799c43cc173SmrgThe commands that this mode executes may require superuser privileges. Use 6800c43cc173Smrgthe \`--dry-run' option if you just want to see what would be executed." 6801c43cc173Smrg ;; 6802c43cc173Smrg 6803c43cc173Smrginstall) 6804c43cc173Smrg $echo \ 6805c43cc173Smrg"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... 6806c43cc173Smrg 6807c43cc173SmrgInstall executables or libraries. 6808c43cc173Smrg 6809c43cc173SmrgINSTALL-COMMAND is the installation command. The first component should be 6810c43cc173Smrgeither the \`install' or \`cp' program. 6811c43cc173Smrg 6812c43cc173SmrgThe rest of the components are interpreted as arguments to that command (only 6813c43cc173SmrgBSD-compatible install options are recognized)." 6814c43cc173Smrg ;; 6815c43cc173Smrg 6816c43cc173Smrglink) 6817c43cc173Smrg $echo \ 6818c43cc173Smrg"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... 6819c43cc173Smrg 6820c43cc173SmrgLink object files or libraries together to form another library, or to 6821c43cc173Smrgcreate an executable program. 6822c43cc173Smrg 6823c43cc173SmrgLINK-COMMAND is a command using the C compiler that you would use to create 6824c43cc173Smrga program from several object files. 6825c43cc173Smrg 6826c43cc173SmrgThe following components of LINK-COMMAND are treated specially: 6827c43cc173Smrg 6828c43cc173Smrg -all-static do not do any dynamic linking at all 6829c43cc173Smrg -avoid-version do not add a version suffix if possible 6830c43cc173Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 6831c43cc173Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 6832c43cc173Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 6833c43cc173Smrg -export-symbols SYMFILE 6834c43cc173Smrg try to export only the symbols listed in SYMFILE 6835c43cc173Smrg -export-symbols-regex REGEX 6836c43cc173Smrg try to export only the symbols matching REGEX 6837c43cc173Smrg -LLIBDIR search LIBDIR for required installed libraries 6838c43cc173Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 6839c43cc173Smrg -module build a library that can dlopened 6840c43cc173Smrg -no-fast-install disable the fast-install mode 6841c43cc173Smrg -no-install link a not-installable executable 6842c43cc173Smrg -no-undefined declare that a library does not refer to external symbols 6843c43cc173Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 6844c43cc173Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 6845c43cc173Smrg -precious-files-regex REGEX 6846c43cc173Smrg don't remove output files matching REGEX 6847c43cc173Smrg -release RELEASE specify package release information 6848c43cc173Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 6849c43cc173Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 6850c43cc173Smrg -static do not do any dynamic linking of libtool libraries 6851c43cc173Smrg -version-info CURRENT[:REVISION[:AGE]] 6852c43cc173Smrg specify library version info [each variable defaults to 0] 6853c43cc173Smrg 6854c43cc173SmrgAll other options (arguments beginning with \`-') are ignored. 6855c43cc173Smrg 6856c43cc173SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 6857c43cc173Smrgtreated as uninstalled libtool libraries, other files are standard or library 6858c43cc173Smrgobject files. 6859c43cc173Smrg 6860c43cc173SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 6861c43cc173Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 6862c43cc173Smrgrequired, except when creating a convenience library. 6863c43cc173Smrg 6864c43cc173SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 6865c43cc173Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 6866c43cc173Smrg 6867c43cc173SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 6868c43cc173Smrgis created, otherwise an executable program is created." 6869c43cc173Smrg ;; 6870c43cc173Smrg 6871c43cc173Smrguninstall) 6872c43cc173Smrg $echo \ 6873c43cc173Smrg"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 6874c43cc173Smrg 6875c43cc173SmrgRemove libraries from an installation directory. 6876c43cc173Smrg 6877c43cc173SmrgRM is the name of the program to use to delete files associated with each FILE 6878c43cc173Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 6879c43cc173Smrgto RM. 6880c43cc173Smrg 6881c43cc173SmrgIf FILE is a libtool library, all the files associated with it are deleted. 6882c43cc173SmrgOtherwise, only FILE itself is deleted using RM." 6883c43cc173Smrg ;; 6884c43cc173Smrg 6885c43cc173Smrg*) 6886c43cc173Smrg $echo "$modename: invalid operation mode \`$mode'" 1>&2 6887c43cc173Smrg $echo "$help" 1>&2 6888c43cc173Smrg exit $EXIT_FAILURE 6889c43cc173Smrg ;; 6890c43cc173Smrgesac 6891c43cc173Smrg 6892c43cc173Smrg$echo 6893c43cc173Smrg$echo "Try \`$modename --help' for more information about other modes." 6894c43cc173Smrg 6895c43cc173Smrgexit $? 6896c43cc173Smrg 6897c43cc173Smrg# The TAGs below are defined such that we never get into a situation 6898c43cc173Smrg# in which we disable both kinds of libraries. Given conflicting 6899c43cc173Smrg# choices, we go for a static library, that is the most portable, 6900c43cc173Smrg# since we can't tell whether shared libraries were disabled because 6901c43cc173Smrg# the user asked for that or because the platform doesn't support 6902c43cc173Smrg# them. This is particularly important on AIX, because we don't 6903c43cc173Smrg# support having both static and shared libraries enabled at the same 6904c43cc173Smrg# time on that platform, so we default to a shared-only configuration. 6905c43cc173Smrg# If a disable-shared tag is given, we'll fallback to a static-only 6906c43cc173Smrg# configuration. But we'll never go from static-only to shared-only. 6907c43cc173Smrg 6908c43cc173Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 6909c43cc173Smrgdisable_libs=shared 6910c43cc173Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 6911c43cc173Smrg 6912c43cc173Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 6913c43cc173Smrgdisable_libs=static 6914c43cc173Smrg# ### END LIBTOOL TAG CONFIG: disable-static 6915c43cc173Smrg 6916c43cc173Smrg# Local Variables: 6917c43cc173Smrg# mode:shell-script 6918c43cc173Smrg# sh-indentation:2 6919c43cc173Smrg# End: 6920