63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# libtool (GNU libtool) 2.4.2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# This is free software; see the source for copying conditions. There is NO
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# GNU Libtool is free software; you can redistribute it and/or modify
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley# it under the terms of the GNU General Public License as published by
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley# the Free Software Foundation; either version 2 of the License, or
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley# (at your option) any later version.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# As a special exception to the GNU General Public License,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# if you distribute this file as part of a program or library that
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# is built using GNU Libtool, you may include this file under the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# same distribution terms that you use for the rest of that program.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# GNU Libtool is distributed in the hope that it will be useful, but
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley# WITHOUT ANY WARRANTY; without even the implied warranty of
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley# General Public License for more details.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley#
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley# You should have received a copy of the GNU General Public License
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# along with GNU Libtool; see the file COPYING. If not, a copy
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# can be downloaded from http://www.gnu.org/licenses/gpl.html,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# or obtained by writing to the Free Software Foundation, Inc.,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Usage: $progname [OPTION]... [MODE-ARG]...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Provide generalized library-building support services.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# --config show all configuration variables
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# --debug enable verbose shell tracing
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# -n, --dry-run display commands without modifying any files
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# --features display basic configuration information and exit
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# --mode=MODE use operation mode MODE
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# --preserve-dup-deps don't remove duplicate dependency libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# --quiet, --silent don't print informational messages
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# --no-quiet, --no-silent
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# print informational messages (default)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# --no-warn don't display warning messages
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# --tag=TAG use configuration variables from tag TAG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# -v, --verbose print more informational messages than default
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# --no-verbose don't print the extra informational messages
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# --version print version information
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# -h, --help, --help-all print short, long, or detailed help message
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# MODE must be one of the following:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# clean remove files from the build directory
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# compile compile a source file into a libtool object
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# execute automatically set library path, then run a program
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# finish complete the installation of libtool libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# install install libraries or executables
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# link create a library or an executable
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# uninstall remove libraries from an installed directory
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# MODE-ARGS vary depending on the MODE. When passed as first option,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# When reporting a bug, please describe a test case to reproduce it and
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# include the following information:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# host-triplet: $host
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# shell: $SHELL
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# compiler: $LTCC
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# compiler flags: $LTCFLAGS
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# linker: $LD (gnu? $with_gnu_ld)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# $progname: (GNU libtool) 2.4.2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# automake: $automake_version
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# autoconf: $autoconf_version
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Report bugs to <bug-libtool@gnu.org>.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# General help using GNU software: <http://www.gnu.org/gethelp/>.
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsPROGRAM=libtool
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark AndrewsPACKAGE=libtool
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsVERSION=2.4.2
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsTIMESTAMP=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewspackage_revision=1.3337
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Be Bourne compatible
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrewsif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews emulate sh
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews NULLCMD=:
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews # is contrary to our usage. Disable this feature.
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews alias -g '${1+"$@"}'='"$@"'
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews setopt NO_GLOB_SUBST
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrewselse
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrewsfi
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark AndrewsBIN_SH=xpg4; export BIN_SH # for Tru64
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark AndrewsDUALCASE=1; export DUALCASE # for MKS sh
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# A function that is used when there is no print builtin or printf.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_fallback_echo ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval 'cat <<_LTECHO_EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews$1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews_LTECHO_EOF'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# NLS nuisances: We save the old values to restore during execute mode.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslt_user_locale=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslt_safe_locale=
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrewsfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrewsdo
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews eval "if test \"\${$lt_var+set}\" = set; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_$lt_var=\$$lt_var
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $lt_var=C
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews export $lt_var
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews fi"
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrewsdone
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsLC_ALL=C
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsLANGUAGE=C
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsexport LANGUAGE LC_ALL
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews$lt_unset CDPATH
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# is ksh but when the shell is invoked as "sh" and the current value of
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# the _XPG environment variable is not equal to 1 (one), the special
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# positional parameter $0, within a function call, is the name of the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# function.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsprogpath="$0"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews: ${CP="cp -f"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewstest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews: ${MAKE="make"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews: ${MKDIR="mkdir"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews: ${MV="mv -f"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews: ${RM="rm -f"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews: ${Xsed="$SED -e 1s/^X//"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Global variables:
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEXIT_SUCCESS=0
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEXIT_FAILURE=1
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsexit_status=$EXIT_SUCCESS
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
0bd1b2fbfed4aa489e9d5fcbc7f48acb96ba7248Mark Andrews# Make sure IFS has a sensible default
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrewslt_nl='
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews'
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark AndrewsIFS=" $lt_nl"
0bd1b2fbfed4aa489e9d5fcbc7f48acb96ba7248Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsdirname="s,/[^/]*$,,"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsbasename="s,^.*/,,"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_dirname file append nondir_replacement
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Compute the dirname of FILE. If nonempty, add APPEND to the result,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# otherwise set result to NONDIR_REPLACEMENT.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_dirname ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$func_dirname_result" = "X${1}"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname_result="${3}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname_result="$func_dirname_result${2}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews} # func_dirname may be replaced by extended shell implementation
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_basename file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_basename ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename_result=`$ECHO "${1}" | $SED "$basename"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews} # func_basename may be replaced by extended shell implementation
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_dirname_and_basename file append nondir_replacement
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# perform func_basename and func_dirname in a single function
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# call:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# dirname: Compute the dirname of FILE. If nonempty,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# add APPEND to the result, otherwise set result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# to NONDIR_REPLACEMENT.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# value returned in "$func_dirname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# basename: Compute filename of FILE.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# value retuned in "$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Implementation must be kept synchronized with func_dirname
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# and func_basename. For efficiency, we do not delegate to
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# those functions but instead duplicate the functionality here.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_dirname_and_basename ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Extract subdirectory from the argument.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$func_dirname_result" = "X${1}"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname_result="${3}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname_result="$func_dirname_result${2}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews} # func_dirname_and_basename may be replaced by extended shell implementation
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_stripname prefix suffix name
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# strip PREFIX and SUFFIX off of NAME.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# PREFIX and SUFFIX must not contain globbing or regex special
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# characters, hashes, percent signs, but SUFFIX may contain a leading
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# dot (in which case that matches only a dot).
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_strip_suffix prefix name
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_stripname ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case ${2} in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews} # func_stripname may be replaced by extended shell implementation
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# These SED scripts presuppose an absolute path with a trailing slash.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewspathcar='s,^/\([^/]*\).*$,\1,'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewspathcdr='s,^/[^/]*,,'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsremovedotparts=':dotsl
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s@/\./@/@g
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews t dotsl
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s,/\.$,/,'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewscollapseslashes='s@/\{1,\}@/@g'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfinalslash='s,/*$,/,'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_normal_abspath PATH
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Remove doubled-up and trailing slashes, "." path components,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# and cancel out any ".." path components in PATH after making
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# it an absolute path.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# value returned in "$func_normal_abspath_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_normal_abspath ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Start from root dir and reassemble the path.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_normal_abspath_result=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_normal_abspath_tpath=$1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_normal_abspath_altnamespace=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $func_normal_abspath_tpath in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "")
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Empty path, that just means $cwd.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '' '/' "`pwd`"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_normal_abspath_result=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The next three entries are used to spot a run of precisely
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # two leading slashes without using negated character classes;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # we take advantage of case's first-match behaviour.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ///*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Unusual form of absolute path, do nothing.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews //*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Not necessarily an ordinary path; POSIX reserves leading '//'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # and for example Cygwin uses it to access remote file shares
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # over CIFS/SMB, so we conserve a leading double slash if found.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_normal_abspath_altnamespace=/
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Absolute path, do nothing.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Relative path, prepend $cwd.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Cancel out all the simple stuff to save iterations. We also want
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # the path to end with a slash for ease of parsing, so make sure
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # there is one (and only one) here.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while :; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Processed it all yet?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$func_normal_abspath_tpath" = / ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If we ascended to the root using ".." the result may be empty now.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$func_normal_abspath_result" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_normal_abspath_result=/
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -e "$pathcar"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -e "$pathcdr"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Figure out what to do with it
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $func_normal_abspath_tcomponent in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "")
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Trailing empty path component, ignore it.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ..)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Parent dir; strip last assembled component from result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname "$func_normal_abspath_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_normal_abspath_result=$func_dirname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Actual path component, append it.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Restore leading double-slash if one was found on entry.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_relative_path SRCDIR DSTDIR
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# generates a relative path from SRCDIR to DSTDIR, with a trailing
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# slash if non-empty, suitable for immediately appending a filename
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# without needing to append a separator.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# value returned in "$func_relative_path_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_relative_path ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_relative_path_result=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_normal_abspath "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_relative_path_tlibdir=$func_normal_abspath_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_normal_abspath "$2"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_relative_path_tbindir=$func_normal_abspath_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Ascend the tree starting from libdir
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while :; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # check if we have found a prefix of bindir
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $func_relative_path_tbindir in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $func_relative_path_tlibdir)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # found an exact match
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_relative_path_tcancelled=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $func_relative_path_tlibdir*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # found a matching prefix
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_relative_path_tcancelled=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$func_relative_path_result"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_relative_path_result=.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname $func_relative_path_tlibdir
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_relative_path_tlibdir=${func_dirname_result}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "x$func_relative_path_tlibdir" = x ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Have to descend all the way to the root!
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_relative_path_result=../$func_relative_path_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_relative_path_tcancelled=$func_relative_path_tbindir
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_relative_path_result=../$func_relative_path_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Now calculate path; take care to avoid doubling-up slashes.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '' '/' "$func_relative_path_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_relative_path_result=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '/' '/' "$func_relative_path_tcancelled"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "x$func_stripname_result" != x ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Normalisation. If bindir is libdir, return empty string,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # else relative path ending with a slash; either way, target
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # file name can be directly appended.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test ! -z "$func_relative_path_result"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname './' '' "$func_relative_path_result/"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_relative_path_result=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# The name of this program:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_dirname_and_basename "$progpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsprogname=$func_basename_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Make sure we have an absolute path for reexecution:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewscase $progpath in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [\\/]*|[A-Za-z]:\\*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *[\\/]*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews progdir=$func_dirname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews progdir=`cd "$progdir" && pwd`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews progpath="$progdir/$progname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_IFS="$IFS"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS=${PATH_SEPARATOR-:}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for progdir in $PATH; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS="$save_IFS"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -x "$progdir/$progname" && break
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS="$save_IFS"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$progdir" || progdir=`pwd`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews progpath="$progdir/$progname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsesac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Sed substitution that helps us do robust quoting. It backslashifies
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# metacharacters that are still active within double-quoted strings.
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsXsed="${SED}"' -e 1s/^X//'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewssed_quote_subst='s/\([`"$\\]\)/\\\1/g'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Same as above, but do not quote variable references.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Sed substitution that turns a string into a regex matching for the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# string literally.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewssed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Sed substitution that converts a w32 file name or path
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# which contains forward slashes, into one that contains
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# (escaped) backslashes. A very naive implementation.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Re-`\' parameter expansions in output of double_quote_subst that were
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# `\'-ed in input to the same. If an odd number of `\' preceded a '$'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# in input to double_quote_subst, that '$' was protected from expansion.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Since each input `\' is now two `\'s, look for any number of runs of
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# four `\'s followed by two `\'s and then a '$'. `\' that '$'.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsbs='\\'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsbs2='\\\\'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsbs4='\\\\\\\\'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsdollar='\$'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewssed_double_backslash="\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/$bs4/&\\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/g
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/^$bs2$dollar/$bs&/
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/\n//g"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Standard options:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_dry_run=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_help=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_quiet=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_verbose=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_warning=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_echo arg...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Echo program name prefixed message, along with the current mode
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# name if it has been set yet.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_echo ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_verbose arg...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Echo program name prefixed message in verbose mode only.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_verbose ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_verbose && func_echo ${1+"$@"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # A bug in bash halts the script if the last line of a function
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # fails when set -e is in force, so we need another command to
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # work around that:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews :
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_echo_all arg...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Invoke $ECHO with all args, space-separated.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_echo_all ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "$*"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_error arg...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Echo program name prefixed message to standard error.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_error ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_warning arg...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Echo program name prefixed warning message to standard error.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_warning ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # bash bug again:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews :
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_fatal_error arg...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Echo program name prefixed message to standard error, and exit.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_fatal_error ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error ${1+"$@"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $EXIT_FAILURE
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_fatal_help arg...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Echo program name prefixed message to standard error, followed by
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# a help hint, and exit.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_fatal_help ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error ${1+"$@"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "$help"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewshelp="Try \`$progname --help' for more information." ## default
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_grep expression filename
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Check whether EXPRESSION matches any line of FILENAME, without output.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_grep ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $GREP "$1" "$2" >/dev/null 2>&1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_mkdir_p directory-path
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Make sure the entire path to DIRECTORY-PATH is available.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_mkdir_p ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_directory_path="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_dir_list=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Protect directory names starting with `-'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $my_directory_path in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -*) my_directory_path="./$my_directory_path" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # While some portion of DIR does not yet exist...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while test ! -d "$my_directory_path"; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # ...make a list in topmost first order. Use a colon delimited
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # list incase some portion of path contains whitespace.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_dir_list="$my_directory_path:$my_dir_list"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If the last portion added has no slash in it, the list is done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $my_directory_path in */*) ;; *) break ;; esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # ...otherwise throw away the child directory and loop
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_mkdir_p_IFS="$IFS"; IFS=':'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for my_dir in $my_dir_list; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS="$save_mkdir_p_IFS"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # mkdir can fail with a `File exist' error if two processes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # try to create one of the directories concurrently. Don't
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # stop in that case!
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $MKDIR "$my_dir" 2>/dev/null || :
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS="$save_mkdir_p_IFS"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Bail out if we (or some other process) failed to create a directory.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -d "$my_directory_path" || \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "Failed to create \`$1'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews# func_mktempdir [string]
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews# Make a temporary directory that won't clash with other running
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews# libtool processes, and avoids race conditions if possible. If
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews# given, STRING is the basename for that directory.
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrewsfunc_mktempdir ()
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews{
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews my_template="${TMPDIR-/tmp}/${1-$progname}"
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$opt_dry_run" = ":"; then
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews # Return a directory name, but don't create it in dry-run mode
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews my_tmpdir="${my_template}-$$"
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews else
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews # If mktemp works, use that first and foremost
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews if test ! -d "$my_tmpdir"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Failing that, at least try and use $RANDOM to avoid a race
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_tmpdir="${my_template}-${RANDOM-0}$$"
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_mktempdir_umask=`umask`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews umask 0077
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $MKDIR "$my_tmpdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews umask $save_mktempdir_umask
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews fi
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews # If we're not in dry-run mode, bomb out on failure
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -d "$my_tmpdir" || \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews fi
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "$my_tmpdir"
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews}
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_quote_for_eval arg
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Aesthetically quote ARG to be evaled later.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# is double-quoted, suitable for a subsequent eval, whereas
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# which are still active within double quotes backslashified.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_quote_for_eval ()
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $1 in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *[\\\`\"\$]*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval_unquoted_result="$1" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $func_quote_for_eval_unquoted_result in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Double-quote args containing shell metacharacters to delay
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # word splitting, command substitution and and variable
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # expansion for a subsequent eval.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Many Bourne shells cannot handle close brackets correctly
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # in scan sets, so we specify it separately.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_quote_for_expand arg
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Aesthetically quote ARG to be evaled later; same as above,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# but do not quote variable references.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_quote_for_expand ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $1 in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *[\\\`\"]*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_arg=`$ECHO "$1" | $SED \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_arg="$1" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $my_arg in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Double-quote args containing shell metacharacters to delay
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # word splitting and command substitution for a subsequent eval.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Many Bourne shells cannot handle close brackets correctly
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # in scan sets, so we specify it separately.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_arg="\"$my_arg\""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_expand_result="$my_arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_show_eval cmd [fail_exp]
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# is given, then evaluate it.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_show_eval ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_cmd="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_fail_exp="${2-:}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ${opt_silent-false} || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_expand "$my_cmd"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "func_echo $func_quote_for_expand_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if ${opt_dry_run-false}; then :; else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "$my_cmd"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_status=$?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$my_status" -eq 0; then :; else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "(exit $my_status); $my_fail_exp"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_show_eval_locale cmd [fail_exp]
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# is given, then evaluate it. Use the saved locale for evaluation.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_show_eval_locale ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_cmd="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_fail_exp="${2-:}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ${opt_silent-false} || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_expand "$my_cmd"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "func_echo $func_quote_for_expand_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if ${opt_dry_run-false}; then :; else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "$lt_user_locale
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $my_cmd"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_status=$?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "$lt_safe_locale"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$my_status" -eq 0; then :; else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "(exit $my_status); $my_fail_exp"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_tr_sh
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Turn $1 into a string suitable for a shell variable name.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Result is stored in $func_tr_sh_result. All characters
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# if $1 begins with a digit, a '_' is prepended as well.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_tr_sh ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $1 in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [0-9]* | *[!a-zA-Z0-9_]*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews * )
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_tr_sh_result=$1
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews esac
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews}
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_version
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Echo version message to standard output and exit.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_version ()
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED -n '/(C)/!b go
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews :more
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /\./!{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews N
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/\n# / /
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews b more
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews :go
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /^# '$PROGRAM' (GNU /,/# warranty; / {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/^# //
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/^# *$//
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews p
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }' < "$progpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_usage
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Echo short help message to standard output and exit.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_usage ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED -n '/^# Usage:/,/^# *.*--help/ {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/^# //
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/^# *$//
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/\$progname/'$progname'/
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews p
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }' < "$progpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "run \`$progname --help | more' for full usage"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_help [NOEXIT]
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Echo long help message to standard output and exit,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# unless 'noexit' is passed as argument.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_help ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED -n '/^# Usage:/,/# Report bugs to/ {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews :print
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/^# //
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/^# *$//
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s*\$progname*'$progname'*
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s*\$host*'"$host"'*
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s*\$SHELL*'"$SHELL"'*
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s*\$LTCC*'"$LTCC"'*
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s*\$LTCFLAGS*'"$LTCFLAGS"'*
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s*\$LD*'"$LD"'*
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/\$with_gnu_ld/'"$with_gnu_ld"'/
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews p
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews d
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /^# .* home page:/b print
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /^# General help using/b print
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ' < "$progpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ret=$?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$1"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $ret
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_missing_arg argname
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Echo program name prefixed message to standard error and set global
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# exit_cmd.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_missing_arg ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error "missing argument for $1."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit_cmd=exit
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_split_short_opt shortopt
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Set func_split_short_opt_name and func_split_short_opt_arg shell
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# variables after splitting SHORTOPT after the 2nd character.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_split_short_opt ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_sed_short_opt='1s/^\(..\).*$/\1/;q'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews} # func_split_short_opt may be replaced by extended shell implementation
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_split_long_opt longopt
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Set func_split_long_opt_name and func_split_long_opt_arg shell
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# variables after splitting LONGOPT at the `=' sign.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_split_long_opt ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_sed_long_arg='1s/^--[^=]*=//'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews} # func_split_long_opt may be replaced by extended shell implementation
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsexit_cmd=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsmagic="%%%MAGIC variable%%%"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsmagic_exe="%%%MAGIC EXE variable%%%"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Global variables.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsnonopt=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewspreserve_args=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslo2o="s/\\.lo\$/.${objext}/"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewso2lo="s/\\.${objext}\$/.lo/"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsextracted_archives=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsextracted_serial=0
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# If this variable is set in any of the actions, the command in it
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# will be execed at the end. This prevents here-documents from being
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# left over by shells.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsexec_cmd=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_append var value
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Append VALUE to the end of shell variable VAR.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_append ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "${1}=\$${1}\${2}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews} # func_append may be replaced by extended shell implementation
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_append_quoted var value
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Quote VALUE and append to the end of shell variable VAR, separated
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# by a space.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_append_quoted ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "${2}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews} # func_append_quoted may be replaced by extended shell implementation
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_arith arithmetic-term...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_arith ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith_result=`expr "${@}"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews} # func_arith may be replaced by extended shell implementation
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_len string
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# STRING may not start with a hyphen.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_len ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews} # func_len may be replaced by extended shell implementation
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_lo2o object
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_lo2o ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews} # func_lo2o may be replaced by extended shell implementation
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_xform libobj-or-source
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_xform ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews} # func_xform may be replaced by extended shell implementation
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_fatal_configuration arg...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Echo program name prefixed message to standard error, followed by
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# a configuration failure hint, and exit.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_fatal_configuration ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error ${1+"$@"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error "See the $PACKAGE documentation for more information."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "Fatal configuration error."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_config
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Display the configuration for all the tags in this script.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_config ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews re_begincf='^# ### BEGIN LIBTOOL'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews re_endcf='^# ### END LIBTOOL'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Default configuration.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Now print the configurations for the tags.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for tagname in $taglist; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_features
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Display the features supported by this script.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_features ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "host: $host"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_libtool_libs" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "enable shared libraries"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "disable shared libraries"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_old_libs" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "enable static libraries"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "disable static libraries"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_enable_tag tagname
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Verify that TAGNAME is valid, and either flag an error and exit, or
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# enable the TAGNAME tag. We also add TAGNAME to the global $taglist
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# variable here.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_enable_tag ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Global variable:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tagname="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews sed_extractcf="/$re_begincf/,/$re_endcf/p"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Validate tagname.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $tagname in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *[!-_A-Za-z0-9,/]*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "invalid tag name: $tagname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Don't test for the "default" C tag, as we know it's
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # there but not specially marked.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $tagname in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews CC) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews taglist="$taglist $tagname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Evaluate the configuration. Be careful to quote the path
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # and the sed script, to avoid splitting on whitespace, but
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # also don't use non-portable quotes within backquotes within
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # quotes we have to do it in 2 steps:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "$extractedcf"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error "ignoring unknown tag $tagname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_check_version_match
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Ensure that we are using m4 macros, and libtool script from the same
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# release of libtool.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_check_version_match ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$package_revision" != "$macro_revision"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$VERSION" != "$macro_version"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$macro_version"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat >&2 <<_LT_EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews$progname: Version mismatch error. This is $PACKAGE $VERSION, but the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews$progname: definition of this LT_INIT comes from an older release.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews$progname: and run autoconf again.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews_LT_EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat >&2 <<_LT_EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews$progname: Version mismatch error. This is $PACKAGE $VERSION, but the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews$progname: and run autoconf again.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews_LT_EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat >&2 <<_LT_EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews$progname: but the definition of this LT_INIT comes from revision $macro_revision.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews$progname: You should recreate aclocal.m4 with macros from revision $package_revision
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews$progname: of $PACKAGE $VERSION and run autoconf again.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews_LT_EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $EXIT_MISMATCH
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Shorthand for --mode=foo, only valid as the first argument
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewscase $1 in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsclean|clea|cle|cl)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift; set dummy --mode clean ${1+"$@"}; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewscompile|compil|compi|comp|com|co|c)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift; set dummy --mode compile ${1+"$@"}; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsexecute|execut|execu|exec|exe|ex|e)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift; set dummy --mode execute ${1+"$@"}; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfinish|finis|fini|fin|fi|f)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift; set dummy --mode finish ${1+"$@"}; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsinstall|instal|insta|inst|ins|in|i)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift; set dummy --mode install ${1+"$@"}; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslink|lin|li|l)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift; set dummy --mode link ${1+"$@"}; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsuninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift; set dummy --mode uninstall ${1+"$@"}; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsesac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Option defaults:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_debug=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_dry_run=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_config=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_preserve_dup_deps=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_features=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_finish=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_help=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_help_all=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_silent=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_warning=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_verbose=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_silent=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_verbose=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Parse options once, thoroughly. This comes as soon as possible in the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# script to make things like `--version' happen as quickly as we can.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # this just eases exit handling
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while test $# -gt 0; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $opt in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --debug|-x) opt_debug='set -x'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_echo "enabling shell trace mode"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --dry-run|--dryrun|-n)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_dry_run=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --config)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_config=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_config
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --dlopen|-dlopen)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews optarg="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_dlopen="${opt_dlopen+$opt_dlopen
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}$optarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --preserve-dup-deps)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_preserve_dup_deps=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --features)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_features=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_features
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --finish)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_finish=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsset dummy --mode finish ${1+"$@"}; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --help)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_help=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --help-all)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_help_all=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_help=': help-all'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --mode)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test $# = 0 && func_missing_arg $opt && break
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews optarg="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_mode="$optarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewscase $optarg in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Valid mode arguments:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews clean|compile|execute|finish|install|link|relink|uninstall) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Catch anything else as an error
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_error "invalid argument for $opt"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit_cmd=exit
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsesac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --no-silent|--no-quiet)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_silent=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_append preserve_args " $opt"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --no-warning|--no-warn)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_warning=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_append preserve_args " $opt"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --no-verbose)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_verbose=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_append preserve_args " $opt"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --silent|--quiet)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_silent=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_append preserve_args " $opt"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_verbose=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --verbose|-v)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_verbose=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_append preserve_args " $opt"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsopt_silent=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --tag)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test $# = 0 && func_missing_arg $opt && break
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews optarg="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_tag="$optarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_append preserve_args " $opt $optarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_enable_tag "$optarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -\?|-h) func_usage ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --help) func_help ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --version) func_version ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Separate optargs to long options:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --*=*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_split_long_opt "$opt"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Separate non-argument short options:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -\?*|-h*|-n*|-v*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_split_short_opt "$opt"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --) break ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -*) func_fatal_help "unrecognized option \`$opt'" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) set dummy "$opt" ${1+"$@"}; shift; break ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Validate options:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # save first non-option argument
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$#" -gt 0; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews nonopt="$opt"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # preserve --debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$opt_debug" = : || func_append preserve_args " --debug"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *cygwin* | *mingw* | *pw32* | *cegcc*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # don't eliminate duplications in $postdeps and $predeps
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_duplicate_compiler_generated_deps=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_help || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Sanity checks first:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_check_version_match
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_configuration "not configured to build any kind of library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Darwin sucks
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval std_shrext=\"$shrext_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Only execute mode is allowed to have -dlopen flags.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error "unrecognized option \`-dlopen'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "$help" 1>&2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $EXIT_FAILURE
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Change the help message to a mode-specific one.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews generic_help="$help"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews help="Try \`$progname --help --mode=$opt_mode' for more information."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Bail if the options were screwed
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $exit_cmd $EXIT_FAILURE
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews## ----------- ##
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews## Main. ##
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews## ----------- ##
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_lalib_p file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# True iff FILE is a libtool `.la' library or `.lo' object file.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# This function is only a basic sanity check; it will hardly flush out
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# determined imposters.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_lalib_p ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -f "$1" &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED -e 4q "$1" 2>/dev/null \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_lalib_unsafe_p file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# True iff FILE is a libtool `.la' library or `.lo' object file.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# This function implements the same check as func_lalib_p without
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# resorting to external programs. To this end, it redirects stdin and
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# closes it afterwards, without saving the original file descriptor.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# As a safety measure, use it only where a negative result would be
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# fatal anyway. Works if `file' does not exist.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_lalib_unsafe_p ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lalib_p=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for lalib_p_l in 1 2 3 4
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews read lalib_p_line
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$lalib_p_line" in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exec 0<&5 5<&-
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$lalib_p" = yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_ltwrapper_script_p file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# True iff FILE is a libtool wrapper script
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# This function is only a basic sanity check; it will hardly flush out
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# determined imposters.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_ltwrapper_script_p ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_lalib_p "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_ltwrapper_executable_p file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# True iff FILE is a libtool wrapper executable
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# This function is only a basic sanity check; it will hardly flush out
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# determined imposters.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_ltwrapper_executable_p ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_ltwrapper_exec_suffix=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $1 in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.exe) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_ltwrapper_exec_suffix=.exe ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_ltwrapper_scriptname file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Assumes file is an ltwrapper_executable
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# uses $file to determine the appropriate filename for a
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# temporary ltwrapper_script.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_ltwrapper_scriptname ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname_and_basename "$1" "" "."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '' '.exe' "$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_ltwrapper_p file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# True iff FILE is a libtool wrapper script or wrapper executable
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# This function is only a basic sanity check; it will hardly flush out
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# determined imposters.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_ltwrapper_p ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_execute_cmds commands fail_cmd
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Execute tilde-delimited COMMANDS.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# If FAIL_CMD is given, eval that upon failure.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# FAIL_CMD may read-access the current command in variable CMD!
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_execute_cmds ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_ifs=$IFS; IFS='~'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for cmd in $1; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS=$save_ifs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval cmd=\"$cmd\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$cmd" "${2-:}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS=$save_ifs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_source file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Source FILE, adding directory component if necessary.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Note that it is not necessary on cygwin/mingw to append a dot to
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# behavior happens only for exec(3), not for open(2)! Also, sourcing
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# `FILE.' does not work on cygwin managed mounts.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_source ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $1 in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews */* | *\\*) . "$1" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) . "./$1" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_resolve_sysroot PATH
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Replace a leading = in PATH with a sysroot. Store the result into
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_resolve_sysroot_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_resolve_sysroot ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_resolve_sysroot_result=$1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $func_resolve_sysroot_result in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews =*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '=' '' "$func_resolve_sysroot_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_replace_sysroot PATH
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# If PATH begins with the sysroot, replace it with = and
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# store the result into func_replace_sysroot_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_replace_sysroot ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$lt_sysroot:$1" in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ?*:"$lt_sysroot"*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname "$lt_sysroot" '' "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_replace_sysroot_result="=$func_stripname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Including no sysroot.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_replace_sysroot_result=$1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_infer_tag arg
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Infer tagged configuration to use if any are available and
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# if one wasn't chosen via the "--tag" command line option.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Only attempt this if the compiler in the base compile
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# command doesn't match the default compiler.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# arg is usually of the form 'gcc ...'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_infer_tag ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # FreeBSD-specific: where we install compilers with non-standard names
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tag_compilers_CC="*cc cc* *gcc gcc* clang"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tag_compilers_CXX="*c++ c++* *g++ g++* clang++"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews base_compiler=`set -- "$@"; echo $1`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If $tagname isn't set, then try to infer if the default "CC" tag applies
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$tagname"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for zp in $tag_compilers_CC; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $base_compiler in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $zp) tagname="CC"; break;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews if test -n "$available_tags" && test -z "$tagname"; then
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews CC_quoted=
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews for arg in $CC; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append_quoted CC_quoted "$arg"
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews CC_expanded=`func_echo_all $CC`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews CC_quoted_expanded=`func_echo_all $CC_quoted`
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews case $@ in
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews # Blanks in the command may have been stripped by the calling shell,
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews # but not from the CC environment variable when configure was run.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews # Blanks at the start of $base_compile will cause this to fail
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews # if we don't check for them as well.
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews *)
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews for z in $available_tags; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews # Evaluate the configuration.
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews CC_quoted=
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews for arg in $CC; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Double-quote args containing other shell metacharacters.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append_quoted CC_quoted "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews CC_expanded=`func_echo_all $CC`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews CC_quoted_expanded=`func_echo_all $CC_quoted`
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews case "$@ " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews # The compiler in the base compile command matches
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews # the one in the tagged configuration.
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews # Assume this is the tagged configuration we want.
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews tagname=$z
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews break
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews ;;
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews esac
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews # FreeBSD-specific: try compilers based on inferred tag
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews if test -z "$tagname"; then
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews eval "tag_compilers=\$tag_compilers_${z}"
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews if test -n "$tag_compilers"; then
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews for zp in $tag_compilers; do
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews case $base_compiler in
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews $zp) tagname=$z; break;;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews esac
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews done
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews if test -n "$tagname"; then
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews break
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews fi
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews fi
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews fi
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews fi
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews done
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews # If $tagname still isn't set, then no tagged configuration
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews # was found and let the user know that the "--tag" command
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews # line option must be used.
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews if test -z "$tagname"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_echo "unable to infer tagged configuration"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "specify a tag with \`--tag'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_verbose "using $tagname tagged configuration"
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews fi
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews ;;
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews esac
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews fi
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews}
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_write_libtool_object output_name pic_name nonpic_name
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Create a libtool object file (analogous to a ".la" file),
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# but don't create it if we're doing a dry run.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_write_libtool_object ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews write_libobj=${1}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_libtool_libs" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews write_lobj=\'${2}\'
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews write_lobj=none
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_old_libs" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews write_oldobj=\'${3}\'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews write_oldobj=none
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat >${write_libobj}T <<EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# $write_libobj - a libtool object file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Please DO NOT delete this file!
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# It is necessary for linking the library.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Name of the PIC object.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewspic_object=$write_lobj
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Name of the non-PIC object
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsnon_pic_object=$write_oldobj
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $MV "${write_libobj}T" "${write_libobj}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews}
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews##################################################
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews##################################################
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_core_file_wine_to_w32 ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Helper function used by file name conversion functions when $build is *nix,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# and $host is mingw, cygwin, or some other w32 environment. Relies on a
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# correctly configured wine environment available, with the winepath program
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# in $build's $PATH.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# ARG is the $build file name to be converted to w32 format.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Result is available in $func_convert_core_file_wine_to_w32_result, and will
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# be empty on error (or when ARG is empty)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_core_file_wine_to_w32 ()
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_file_wine_to_w32_result="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$1"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Unfortunately, winepath does not exit with a non-zero error code, so we
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # are forced to check the contents of stdout. On the other hand, if the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # command is not found, the shell will set an exit code of 127 and print
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # *an error message* to stdout. So we must check for both error code of
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # zero AND non-empty stdout, which explains the odd construction:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED -e "$lt_sed_naive_backslashify"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_file_wine_to_w32_result=
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end: func_convert_core_file_wine_to_w32
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_core_path_wine_to_w32 ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Helper function used by path conversion functions when $build is *nix, and
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# configured wine environment available, with the winepath program in $build's
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# $PATH. Assumes ARG has no leading or trailing path separator characters.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# ARG is path to be converted from $build format to win32.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Result is available in $func_convert_core_path_wine_to_w32_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Unconvertible file (directory) names in ARG are skipped; if no directory names
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# are convertible, then the result may be empty.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_core_path_wine_to_w32 ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # unfortunately, winepath doesn't convert paths, only file names
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_path_wine_to_w32_result=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$1"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldIFS=$IFS
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for func_convert_core_path_wine_to_w32_f in $1; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS=$oldIFS
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$func_convert_core_file_wine_to_w32_result" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$func_convert_core_path_wine_to_w32_result"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews fi
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS=$oldIFS
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end: func_convert_core_path_wine_to_w32
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_cygpath ARGS...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# (2), returns the Cygwin file name or path in func_cygpath_result (input
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# file name or path is assumed to be in w32 format, as previously converted
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# from $build's *nix or MSYS format). In case (3), returns the w32 file name
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# or path in func_cygpath_result (input file name or path is assumed to be in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Cygwin format). Returns an empty string on error.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# ARGS are passed to cygpath, with the last one being the file name or path to
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# be converted.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# environment variable; do not put it in $PATH.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_cygpath ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$?" -ne 0; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # on failure, ensure result is empty
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_cygpath_result=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_cygpath_result=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#end: func_cygpath
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_core_msys_to_w32 ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Convert file name or path ARG from MSYS format to w32 format. Return
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# result in func_convert_core_msys_to_w32_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_core_msys_to_w32 ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # awkward: cmd appends spaces to result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#end: func_convert_core_msys_to_w32
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_file_check ARG1 ARG2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Verify that ARG1 (a file name in $build format) was converted to $host
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# format in ARG2. Otherwise, emit an error message, but continue (resetting
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_to_host_file_result to ARG1).
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_file_check ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$2" && test -n "$1" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error "Could not determine host file name corresponding to"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error " \`$1'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error "Continuing, but uninstalled executables may not work."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Fallback:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_file_result="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_convert_file_check
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Verify that FROM_PATH (a path in $build format) was converted to $host
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_to_host_file_result to a simplistic fallback value (see below).
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_path_check ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$4" && test -n "$3"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error "Could not determine the host path corresponding to"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error " \`$3'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error "Continuing, but uninstalled executables may not work."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Fallback. This is a deliberately simplistic "conversion" and
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # should not be "improved". See libtool.info.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "x$1" != "x$2"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_replace_pathsep_chars="s|$1|$2|g"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_result=`echo "$3" |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED -e "$lt_replace_pathsep_chars"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_result="$3"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_convert_path_check
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# and appending REPL if ORIG matches BACKPAT.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_path_front_back_pathsep ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $4 in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $1 ) func_to_host_path_result="$3$func_to_host_path_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $4 in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $2 ) func_append func_to_host_path_result "$3"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_convert_path_front_back_pathsep
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews##################################################
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# $build to $host FILE NAME CONVERSION FUNCTIONS #
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews##################################################
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# invoked via `$to_host_file_cmd ARG'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# In each case, ARG is the path to be converted from $build to $host format.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Result will be available in $func_to_host_file_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_to_host_file ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Converts the file name ARG from $build format to $host format. Return result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# in func_to_host_file_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_to_host_file ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $to_host_file_cmd "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_to_host_file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_to_tool_file ARG LAZY
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# converts the file name ARG from $build format to toolchain format. Return
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# result in func_to_tool_file_result. If the conversion in use is listed
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# in (the comma separated) LAZY, no conversion takes place.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_to_tool_file ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case ,$2, in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *,"$to_tool_file_cmd",*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file_result=$1
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $to_tool_file_cmd "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file_result=$func_to_host_file_result
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_to_tool_file
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_file_noop ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Copy ARG to func_to_host_file_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_file_noop ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_file_result="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_convert_file_noop
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_file_msys_to_w32 ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# conversion to w32 is not available inside the cwrapper. Returns result in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_to_host_file_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_file_msys_to_w32 ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_file_result="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$1"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_msys_to_w32 "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_file_result="$func_convert_core_msys_to_w32_result"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_file_check "$1" "$func_to_host_file_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_convert_file_msys_to_w32
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_file_cygwin_to_w32 ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Convert file name ARG from Cygwin to w32 format. Returns result in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_to_host_file_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_file_cygwin_to_w32 ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_file_result="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$1"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # LT_CYGPATH in this case.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_file_result=`cygpath -m "$1"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_file_check "$1" "$func_to_host_file_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_convert_file_cygwin_to_w32
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_file_nix_to_w32 ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Convert file name ARG from *nix to w32 format. Requires a wine environment
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# and a working winepath. Returns result in func_to_host_file_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_file_nix_to_w32 ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_file_result="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$1"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_file_wine_to_w32 "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_file_check "$1" "$func_to_host_file_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_convert_file_nix_to_w32
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_file_msys_to_cygwin ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Returns result in func_to_host_file_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_file_msys_to_cygwin ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_file_result="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$1"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_msys_to_w32 "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_cygpath -u "$func_convert_core_msys_to_w32_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_file_result="$func_cygpath_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_file_check "$1" "$func_to_host_file_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_convert_file_msys_to_cygwin
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_file_nix_to_cygwin ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# in a wine environment, working winepath, and LT_CYGPATH set. Returns result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# in func_to_host_file_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_file_nix_to_cygwin ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_file_result="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$1"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_file_wine_to_w32 "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_file_result="$func_cygpath_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_file_check "$1" "$func_to_host_file_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_convert_file_nix_to_cygwin
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#############################################
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# $build to $host PATH CONVERSION FUNCTIONS #
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#############################################
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# invoked via `$to_host_path_cmd ARG'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# In each case, ARG is the path to be converted from $build to $host format.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# The result will be available in $func_to_host_path_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Path separators are also converted from $build format to $host format. If
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# ARG begins or ends with a path separator character, it is preserved (but
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# converted to $host format) on output.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# All path conversion functions are named using the following convention:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# file name conversion function : func_convert_file_X_to_Y ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# path conversion function : func_convert_path_X_to_Y ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# where, for any given $build/$host combination the 'X_to_Y' value is the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# same. If conversion functions are added for new $build/$host combinations,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# the two new functions must follow this pattern, or func_init_to_host_path_cmd
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# will break.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_init_to_host_path_cmd
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Ensures that function "pointer" variable $to_host_path_cmd is set to the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# appropriate value, based on the value of $to_host_file_cmd.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsto_host_path_cmd=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_init_to_host_path_cmd ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$to_host_path_cmd"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews to_host_path_cmd="func_convert_path_${func_stripname_result}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_to_host_path ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Converts the path ARG from $build format to $host format. Return result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# in func_to_host_path_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_to_host_path ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_init_to_host_path_cmd
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $to_host_path_cmd "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_to_host_path
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_path_noop ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Copy ARG to func_to_host_path_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_path_noop ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_result="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_convert_path_noop
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_path_msys_to_w32 ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# conversion to w32 is not available inside the cwrapper. Returns result in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_to_host_path_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_path_msys_to_w32 ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_result="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$1"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Remove leading and trailing path separator characters from ARG. MSYS
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # and winepath ignores them completely.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname : : "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_tmp1=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_result="$func_convert_core_msys_to_w32_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_path_check : ";" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "$func_to_host_path_tmp1" "$func_to_host_path_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_convert_path_msys_to_w32
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_path_cygwin_to_w32 ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Convert path ARG from Cygwin to w32 format. Returns result in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_to_host_file_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_path_cygwin_to_w32 ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_result="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$1"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # See func_convert_path_msys_to_w32:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname : : "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_tmp1=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_path_check : ";" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "$func_to_host_path_tmp1" "$func_to_host_path_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_convert_path_cygwin_to_w32
0bd1b2fbfed4aa489e9d5fcbc7f48acb96ba7248Mark Andrews
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_path_nix_to_w32 ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Convert path ARG from *nix to w32 format. Requires a wine environment and
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# a working winepath. Returns result in func_to_host_file_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_path_nix_to_w32 ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_result="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$1"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # See func_convert_path_msys_to_w32:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname : : "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_tmp1=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_path_check : ";" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "$func_to_host_path_tmp1" "$func_to_host_path_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_convert_path_nix_to_w32
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_path_msys_to_cygwin ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Returns result in func_to_host_file_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_path_msys_to_cygwin ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_result="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$1"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # See func_convert_path_msys_to_w32:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname : : "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_tmp1=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_result="$func_cygpath_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_path_check : : \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "$func_to_host_path_tmp1" "$func_to_host_path_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_path_front_back_pathsep ":*" "*:" : "$1"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_convert_path_msys_to_cygwin
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_convert_path_nix_to_cygwin ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# a wine environment, working winepath, and LT_CYGPATH set. Returns result in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_to_host_file_result.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_convert_path_nix_to_cygwin ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_result="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$1"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Remove leading and trailing path separator characters from
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # ARG. msys behavior is inconsistent here, cygpath turns them
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # into '.;' and ';.', and winepath ignores them completely.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname : : "$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_tmp1=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path_result="$func_cygpath_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_path_check : : \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "$func_to_host_path_tmp1" "$func_to_host_path_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_convert_path_front_back_pathsep ":*" "*:" : "$1"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end func_convert_path_nix_to_cygwin
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_mode_compile arg...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_mode_compile ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # Get the compilation command and the source file.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley base_compile=
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews srcfile="$nonopt" # always keep a non-empty value in "srcfile"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews suppress_opt=yes
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley suppress_output=
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews arg_mode=normal
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews libobj=
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews later=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews pie_flag=
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley for arg
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley do
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews case $arg_mode in
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews arg )
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # do not "continue". Instead, add this to base_compile
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews lastarg="$arg"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews arg_mode=normal
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews target )
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews libobj="$arg"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews arg_mode=normal
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington continue
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews normal )
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # Accept any command-line options.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews case $arg in
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews -o)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$libobj" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "you cannot specify \`-o' more than once"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews arg_mode=target
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews continue
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -pie | -fpie | -fPIE)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append pie_flag " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -shared | -static | -prefer-pic | -prefer-non-pic)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append later " $arg"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews continue
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews -no-suppress)
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews suppress_opt=no
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews continue
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews -Xcompiler)
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews arg_mode=arg # the next one goes into the "base_compile" arg list
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews continue # The current "srcfile" will either be retained or
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;; # replaced later. I would guess that would be a bug.
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews -Wc,*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '-Wc,' '' "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews args=$func_stripname_result
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews lastarg=
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews save_ifs="$IFS"; IFS=','
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for arg in $args; do
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews IFS="$save_ifs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append_quoted lastarg "$arg"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews done
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington IFS="$save_ifs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname ' ' '' "$lastarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lastarg=$func_stripname_result
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # Add the arguments to base_compile.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append base_compile " $lastarg"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews continue
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # Accept the current argument as the source file.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # The previous "srcfile" becomes the current argument.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews #
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews lastarg="$srcfile"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews srcfile="$arg"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews esac # case $arg
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews esac # case $arg_mode
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # Aesthetically quote the previous argument.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append_quoted base_compile "$lastarg"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews done # for arg
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews case $arg_mode in
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews arg)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "you must specify an argument for -Xcompile"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews target)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "you must specify a target with \`-o'"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews *)
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # Get the name of the library object.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$libobj" && {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$srcfile"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libobj="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # Recognize several different file suffixes.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # If the user specifies -o file.o, it is replaced with file.lo
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington case $libobj in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.[cCFSifmso] | \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.ada | *.adb | *.ads | *.asm | \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_xform "$libobj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libobj=$func_xform_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington case $libobj in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "cannot determine name of library object from \`$libobj'"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews func_infer_tag $base_compile
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews for arg in $later; do
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews case $arg in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -shared)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$build_libtool_libs" != yes && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_configuration "can not build a shared library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_old_libs=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews -static)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_libtool_libs=no
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews build_old_libs=yes
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews continue
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews -prefer-pic)
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews pic_mode=yes
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews continue
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews -prefer-non-pic)
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews pic_mode=no
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews continue
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews esac
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews done
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$libobj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "X$libobj" != "X$func_quote_for_eval_result" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews && func_warning "libobj name \`$libobj' may not contain shell special characters."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname_and_basename "$obj" "/" ""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews objname="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews xdir="$func_dirname_result"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews lobj=${xdir}$objdir/$objname
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$base_compile" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "you must specify a compilation command"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # Delete any leftover library objects.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley if test "$build_old_libs" = yes; then
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews removelist="$obj $lobj $libobj ${libobj}T"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley else
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews removelist="$lobj $libobj ${libobj}T"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington # On Cygwin there's no "real" PIC flag so we must build both object types
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington case $host_os in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cygwin* | mingw* | pw32* | os2* | cegcc*)
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington pic_mode=default
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington esac
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington # non-PIC code in shared libraries is not supported
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington pic_mode=default
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # Calculate the filename of the output object if compiler does
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # not support -o with -c
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley if test "$compiler_c_o" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley lockfile="$output_obj.lock"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley else
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews output_obj=
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley need_locks=no
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley lockfile=
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # Lock this critical section if it is needed
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # We use this script file to make the link, it avoids creating a new file
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley if test "$need_locks" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_echo "Waiting for $lockfile to be removed"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley sleep 2
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley done
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley elif test "$need_locks" = warn; then
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley if test -f "$lockfile"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "\
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley*** ERROR, $lockfile exists and contains:
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley`cat $lockfile 2>/dev/null`
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob HalleyThis indicates that another process is trying to use the same
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleytemporary object file, and libtool could not work around it because
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleyyour compiler does not support \`-c' and \`-o' together. If you
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleyrepeat this compilation, it may succeed, by chance, but you had better
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleyavoid parallel builds (make -j) in this platform, or get a better
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleycompiler."
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $RM $removelist
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews exit $EXIT_FAILURE
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append removelist " $output_obj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "$srcfile" > "$lockfile"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $RM $removelist
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append removelist " $lockfile"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews srcfile=$func_to_tool_file_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$srcfile"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews qsrcfile=$func_quote_for_eval_result
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # Only build a PIC object if we are building libtool libraries.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley if test "$build_libtool_libs" = yes; then
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # Without this assignment, base_compile gets emptied.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fbsd_hideous_sh_bug=$base_compile
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington if test "$pic_mode" != no; then
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews command="$base_compile $qsrcfile $pic_flag"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington else
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington # Don't build PIC code
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews command="$base_compile $qsrcfile"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_mkdir_p "$xdir$objdir"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews if test -z "$output_obj"; then
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # Place PIC objects in $objdir
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append command " -o $lobj"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval_locale "$command" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley if test "$need_locks" = warn &&
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "\
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley*** ERROR, $lockfile contains:
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley`cat $lockfile 2>/dev/null`
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleybut it should contain:
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley$srcfile
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob HalleyThis indicates that another process is trying to use the same
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleytemporary object file, and libtool could not work around it because
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleyyour compiler does not support \`-c' and \`-o' together. If you
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleyrepeat this compilation, it may succeed, by chance, but you had better
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleyavoid parallel builds (make -j) in this platform, or get a better
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleycompiler."
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $RM $removelist
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews exit $EXIT_FAILURE
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # Just move the object if needed, then go on to compile the next one
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval '$MV "$output_obj" "$lobj"' \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # Allow error messages only from the first compilation.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews if test "$suppress_opt" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews suppress_output=' >/dev/null 2>&1'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # Only build a position-dependent object if we build old libraries.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley if test "$build_old_libs" = yes; then
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington if test "$pic_mode" != yes; then
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington # Don't build PIC code
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews command="$base_compile $qsrcfile$pie_flag"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington else
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews command="$base_compile $qsrcfile $pic_flag"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley if test "$compiler_c_o" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append command " -o $obj"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # Suppress compiler output if we already did a PIC compilation.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append command "$suppress_output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval_locale "$command" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley if test "$need_locks" = warn &&
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "\
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley*** ERROR, $lockfile contains:
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley`cat $lockfile 2>/dev/null`
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleybut it should contain:
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley$srcfile
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob HalleyThis indicates that another process is trying to use the same
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleytemporary object file, and libtool could not work around it because
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleyyour compiler does not support \`-c' and \`-o' together. If you
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleyrepeat this compilation, it may succeed, by chance, but you had better
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleyavoid parallel builds (make -j) in this platform, or get a better
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleycompiler."
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $RM $removelist
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews exit $EXIT_FAILURE
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # Just move the object if needed
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval '$MV "$output_obj" "$obj"' \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Unlock the critical section if it was locked
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$need_locks" != no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews removelist=$lockfile
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $RM "$lockfile"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews exit $EXIT_SUCCESS
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews$opt_help || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_mode_help ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We need to display help for each of the modes.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $opt_mode in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "")
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Generic help is extracted from the usage comments
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # at the start of this file.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_help
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews clean)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsRemove files from the build directory.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsRM is the name of the program to use to delete files associated with each FILE
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsto RM.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsIf FILE is a libtool library, object or program, all the files associated
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewswith it are deleted. Otherwise, only FILE itself is deleted using RM."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsCompile a source file into a libtool library object.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsThis mode accepts the following additional options:
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -o OUTPUT-FILE set the output file name to OUTPUT-FILE
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -no-suppress do not suppress compiler output for multiple passes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -prefer-pic try to build PIC objects only
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -prefer-non-pic try to build non-PIC objects only
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -shared do not build a \`.o' file suitable for static linking
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -static only build a \`.o' file suitable for static linking
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -Wc,FLAG pass FLAG directly to the compiler
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfrom the given SOURCEFILE.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsThe output file name is determined by removing the directory component from
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsSOURCEFILE, then substituting the C source code suffix \`.c' with the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslibrary object suffix, \`.lo'."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews execute)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsAutomatically set library path, then run a program.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsThis mode accepts the following additional options:
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -dlopen FILE add the directory containing FILE to the library path
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsThis mode sets the library path environment variable according to \`-dlopen'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsflags.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsIf any of the ARGS are libtool executable wrappers, then they are translated
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsinto their corresponding uninstalled binary, and any of their required library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsdirectories are added to the library path.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsThen, COMMAND is executed, with ARGS as arguments."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finish)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsComplete the installation of libtool libraries.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEach LIBDIR is a directory that contains libtool libraries.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsThe commands that this mode executes may require superuser privileges. Use
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsthe \`--dry-run' option if you just want to see what would be executed."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews install)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsInstall executables or libraries.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsINSTALL-COMMAND is the installation command. The first component should be
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewseither the \`install' or \`cp' program.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsThe following components of INSTALL-COMMAND are treated specially:
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsThe rest of the components are interpreted as arguments to that command (only
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsBSD-compatible install options are recognized)."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews link)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsLink object files or libraries together to form another library, or to
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewscreate an executable program.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsLINK-COMMAND is a command using the C compiler that you would use to create
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsa program from several object files.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsThe following components of LINK-COMMAND are treated specially:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -all-static do not do any dynamic linking at all
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -avoid-version do not add a version suffix if possible
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -bindir BINDIR specify path to binaries directory (for systems where
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libraries must be found in the PATH setting at runtime)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -export-symbols SYMFILE
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews try to export only the symbols listed in SYMFILE
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -export-symbols-regex REGEX
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews try to export only the symbols matching REGEX
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -LLIBDIR search LIBDIR for required installed libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -lNAME OUTPUT-FILE requires the installed library libNAME
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -module build a library that can dlopened
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -no-fast-install disable the fast-install mode
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -no-install link a not-installable executable
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -no-undefined declare that a library does not refer to external symbols
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -objectlist FILE Use a list of object files found in FILE to specify objects
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -precious-files-regex REGEX
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews don't remove output files matching REGEX
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -release RELEASE specify package release information
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -rpath LIBDIR the created library will eventually be installed in LIBDIR
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -shared only do dynamic linking of libtool libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -shrext SUFFIX override the standard shared library file extension
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -static do not do any dynamic linking of uninstalled libtool libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -static-libtool-libs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do not do any dynamic linking of libtool libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -version-info CURRENT[:REVISION[:AGE]]
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews specify library version info [each variable defaults to 0]
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -weak LIBNAME declare that the target provides the LIBNAME interface
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -Wc,FLAG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -Wl,FLAG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -Xlinker FLAG pass linker-specific FLAG directly to the linker
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsAll other options (arguments beginning with \`-') are ignored.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEvery other argument is treated as a filename. Files ending in \`.la' are
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewstreated as uninstalled libtool libraries, other files are standard or library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsobject files.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsonly library objects (\`.lo' files) may be specified, and \`-rpath' is
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsrequired, except when creating a convenience library.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsusing \`ar' and \`ranlib', or on Windows using \`lib'.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsis created, otherwise an executable program is created."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews uninstall)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsRemove libraries from an installation directory.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsRM is the name of the program to use to delete files associated with each FILE
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsto RM.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsIf FILE is a libtool library, all the files associated with it are deleted.
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsOtherwise, only FILE itself is deleted using RM."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "invalid operation mode \`$opt_mode'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "Try \`$progname --help' for more information about other modes."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Now that we've collected a possible --mode arg, show help if necessary
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsif $opt_help; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$opt_help" = :; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_mode_help
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_help noexit
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for opt_mode in compile link execute install finish uninstall clean; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_mode_help
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews } | sed -n '1p; 2,$s/^Usage:/ or: /p'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_help noexit
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for opt_mode in compile link execute install finish uninstall clean; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_mode_help
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews } |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews sed '1d
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /^When reporting/,/^Report/{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews H
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews d
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $x
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /information about other modes/d
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /more detailed .*MODE/d
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_mode_execute arg...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_mode_execute ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The first argument is the command name.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cmd="$nonopt"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$cmd" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "you must specify a COMMAND"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Handle -dlopen flags immediately.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for file in $opt_dlopen; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -f "$file" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews || func_fatal_help "\`$file' is not a file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $file in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.la)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_resolve_sysroot "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file=$func_resolve_sysroot_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Check to see that this really is a libtool archive.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_lalib_unsafe_p "$file" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews || func_fatal_help "\`$lib' is not a valid libtool archive"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Read the libtool library.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlname=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews library_names=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_source "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Skip this library if it cannot be dlopened.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$dlname"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Warn if it was a shared library.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$library_names" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`$file' was not linked with \`-export-dynamic'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname "$file" "" "."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir="$func_dirname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -f "$dir/$objdir/$dlname"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append dir "/$objdir"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test ! -f "$dir/$dlname"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.lo)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Just add the directory containing the .lo file.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname "$file" "" "."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir="$func_dirname_result"
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews ;;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews continue
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Get the absolute pathname.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews absdir=`cd "$dir" && pwd`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$absdir" && dir="$absdir"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Now add the directory to shlibpath_var.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if eval "test -z \"\$$shlibpath_var\""; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "$shlibpath_var=\"\$dir\""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # This variable tells wrapper scripts just to set shlibpath_var
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # rather than running their programs.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libtool_execute_magic="$magic"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Check if any of the arguments is a wrapper script.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews args=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $file in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -* | *.la | *.lo ) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do a test to see if this is really a libtool program.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if func_ltwrapper_script_p "$file"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_source "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Transform arg to wrapped name.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file="$progdir/$program"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif func_ltwrapper_executable_p "$file"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_ltwrapper_scriptname "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_source "$func_ltwrapper_scriptname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Transform arg to wrapped name.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file="$progdir/$program"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Quote arguments (to preserve shell metacharacters).
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append_quoted args "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$opt_dry_run" = Xfalse; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$shlibpath_var"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Export the shlibpath_var.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "export $shlibpath_var"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Restore saved environment variables
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "if test \"\${save_$lt_var+set}\" = set; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $lt_var=\$save_$lt_var; export $lt_var
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $lt_unset $lt_var
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Now prepare to actually exec the command.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exec_cmd="\$cmd$args"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Display what would be done.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$shlibpath_var"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "export $shlibpath_var"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "$cmd$args"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $EXIT_SUCCESS
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewstest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_mode_finish arg...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_mode_finish ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libdirs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews admincmds=
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for opt in "$nonopt" ${1+"$@"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -d "$opt"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append libdirs " $opt"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test -f "$opt"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if func_lalib_unsafe_p "$opt"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append libs " $opt"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`$opt' is not a valid libtool archive"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "invalid argument \`$opt'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$libs"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$lt_sysroot"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews sysroot_cmd=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Remove sysroot references
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $opt_dry_run; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for lib in $libs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmpdir=`func_mktempdir`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for lib in $libs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews > $tmpdir/tmp-la
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews mv -f $tmpdir/tmp-la $lib
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ${RM}r "$tmpdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for libdir in $libdirs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$finish_cmds"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do each command in the finish commands.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews'"$cmd"'"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$finish_eval"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do the single finish_eval.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval cmds=\"$finish_eval\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || eval "$cmds" || func_append admincmds "
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $cmds"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Exit here if they wanted silent mode.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_silent && exit $EXIT_SUCCESS
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "----------------------------------------------------------------------"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "Libraries have been installed in:"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for libdir in $libdirs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO " $libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "If you ever happen to want to link against installed libraries"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "in a given directory, LIBDIR, you must either use libtool, and"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "flag during linking and do at least one of the following:"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$shlibpath_var"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo " during execution"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$runpath_var"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo " - add LIBDIR to the \`$runpath_var' environment variable"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo " during linking"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$hardcode_libdir_flag_spec"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libdir=LIBDIR
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval flag=\"$hardcode_libdir_flag_spec\"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO " - use the \`$flag' linker flag"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$admincmds"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO " - have your system administrator run these commands:$admincmds"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -f /etc/ld.so.conf; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "See any operating system documentation about shared libraries for"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews solaris2.[6789]|solaris2.1[0-9])
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "pages."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "more information, such as the ld(1) and ld.so(8) manual pages."
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "----------------------------------------------------------------------"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $EXIT_SUCCESS
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewstest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_mode_install arg...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_mode_install ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # There may be an optional sh(1) argument at the beginning of
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # install_prog (especially on Windows NT).
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Allow the use of GNU shtool's install command.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $nonopt in *shtool*) :;; *) false;; esac; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Aesthetically quote it.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$nonopt"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews install_prog="$func_quote_for_eval_result "
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg=$1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews install_prog=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg=$nonopt
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The real first argument should be the name of the installation program.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Aesthetically quote it.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append install_prog "$func_quote_for_eval_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews install_shared_prog=$install_prog
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $install_prog " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *[\\\ /]cp\ *) install_cp=: ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) install_cp=false ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We need to accept at least all the BSD install flags.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dest=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews files=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews opts=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews install_type=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews isdir=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews stripme=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews no_mode=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for arg
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg2=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$dest"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append files " $dest"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dest=$arg
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $arg in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -d) isdir=yes ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -f)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $install_cp; then :; else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=$arg
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -g | -m | -o)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=$arg
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -s)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews stripme=" -s"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews continue
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -*)
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If the previous option needed an argument, then skip it.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$prev"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "x$prev" = x-m && test -n "$install_override_mode"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg2=$install_override_mode
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews no_mode=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dest=$arg
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Aesthetically quote the argument.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append install_prog " $func_quote_for_eval_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$arg2"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$arg2"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append install_shared_prog " $func_quote_for_eval_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$install_prog" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "you must specify an install program"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$prev" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "the \`$prev' option requires an argument"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$install_override_mode" && $no_mode; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $install_cp; then :; else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$install_override_mode"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append install_shared_prog " -m $func_quote_for_eval_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$files"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$dest"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "no file or destination specified"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "you must specify a destination"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Strip any trailing slash from the destination.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '' '/' "$dest"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dest=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Check to see that the destination is a directory.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -d "$dest" && isdir=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$isdir" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews destdir="$dest"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews destname=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname_and_basename "$dest" "" "."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews destdir="$func_dirname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews destname="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Not a directory, so check to see that there is only one file specified.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews set dummy $files; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$#" -gt 1 && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "\`$dest' is not a directory"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $destdir in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [\\/]* | [A-Za-z]:[\\/]*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for file in $files; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $file in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.lo) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "\`$destdir' must be an absolute directory name"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # This variable tells wrapper scripts just to set variables rather
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # than running their programs.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libtool_install_magic="$magic"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews staticlibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews future_libdirs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews current_libdirs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for file in $files; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do each installation.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $file in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.$libext)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do the static libraries later.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append staticlibs " $file"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.la)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_resolve_sysroot "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file=$func_resolve_sysroot_result
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Check to see that this really is a libtool archive.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_lalib_unsafe_p "$file" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews || func_fatal_help "\`$file' is not a valid libtool archive"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews library_names=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews old_library=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_source "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Add the libdir to current_libdirs if it is the destination.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$destdir" = "X$libdir"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$current_libdirs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $libdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append current_libdirs " $libdir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Note the libdir as a future libdir.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$future_libdirs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $libdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append future_libdirs " $libdir" ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname "$file" "/" ""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir="$func_dirname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append dir "$objdir"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$relink_command"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Determine the prefix the user has applied to our future dir.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Don't allow the user to place us outside of our expected
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # location b/c this prevents finding dependent libraries that
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # are installed to the same prefix.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # At present, this check doesn't affect windows .dll's that
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # are installed into $libdir/../bin (currently, that works fine)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # but it's something to keep an eye on.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$inst_prefix_dir" = "$destdir" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$inst_prefix_dir"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Stick the inst_prefix_dir data into the link command.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "relinking \`$file'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$relink_command" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # See the names of the shared library.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews set dummy $library_names; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$1"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews realname="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews srcname="$realname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$relink_command" && srcname="$realname"T
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Install the shared library and build the symlinks.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tstripme="$stripme"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host_os in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cygwin* | mingw* | pw32* | cegcc*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $realname in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.dll.a)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tstripme=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$tstripme" && test -n "$striplib"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$striplib $destdir/$realname" 'exit $?'
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$#" -gt 0; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Delete the old symlinks, and create new ones.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Try `ln -sf' first, because the `ln' binary might depend on
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # the symlink we replace! Solaris /bin/ln does not understand -f,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # so we also need to try rm && ln -s.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for linkname
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$linkname" != "$realname" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do each command in the postinstall commands.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib="$destdir/$realname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_execute_cmds "$postinstall_cmds" 'exit $?'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Install the pseudo-library for information purposes.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews instname="$dir/$name"i
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Maybe install the static library, too.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$old_library" && func_append staticlibs " $dir/$old_library"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.lo)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Install (i.e. copy) a libtool object.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Figure out destination file name, if it wasn't already specified.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$destname"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews destfile="$destdir/$destname"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews destfile="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews destfile="$destdir/$destfile"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Deduce the name of the destination old-style object file.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $destfile in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.lo)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_lo2o "$destfile"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews staticdest=$func_lo2o_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.$objext)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews staticdest="$destfile"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews destfile=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "cannot copy a libtool object to \`$destfile'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Install the libtool object if requested.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$destfile" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$install_prog $file $destfile" 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Install the old object if enabled.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_old_libs" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Deduce the name of the old-style object file.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_lo2o "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews staticobj=$func_lo2o_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $EXIT_SUCCESS
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Figure out destination file name, if it wasn't already specified.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$destname"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews destfile="$destdir/$destname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews destfile="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews destfile="$destdir/$destfile"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If the file is missing, and there is a .exe on the end, strip it
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # because it is most likely a libtool script we actually want to
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # install
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews stripped_ext=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $file in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.exe)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test ! -f "$file"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '' '.exe' "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews stripped_ext=".exe"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do a test to see if this is really a libtool program.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *cygwin* | *mingw*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if func_ltwrapper_executable_p "$file"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_ltwrapper_scriptname "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews wrapper=$func_ltwrapper_scriptname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '' '.exe' "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews wrapper=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews wrapper=$file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if func_ltwrapper_script_p "$wrapper"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews notinst_deplibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_source "$wrapper"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Check the variables that should have been set.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$generated_by_libtool_version" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "invalid libtool wrapper script \`$wrapper'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for lib in $notinst_deplibs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Check to see that each library is installed.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libdir=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -f "$lib"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_source "$lib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$libdir" && test ! -f "$libfile"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`$lib' has not been installed in \`$libdir'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_source "$wrapper"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews outputname=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$fast_install" = no && test -n "$relink_command"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$finalize" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmpdir=`func_mktempdir`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$file$stripped_ext"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews outputname="$tmpdir/$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Replace the output file specification.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_silent || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_expand "$relink_command"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "func_echo $func_quote_for_expand_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if eval "$relink_command"; then :
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error "error: relink \`$file' with the above command before installing it"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || ${RM}r "$tmpdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file="$outputname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "cannot relink \`$file'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Install the binary that we compiled earlier.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # remove .exe since cygwin /usr/bin/install will append another
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # one anyway
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $install_prog,$host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews */usr/bin/install*,*cygwin*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $file:$destfile in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.exe:*.exe)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # this is ok
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.exe:*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews destfile=$destfile.exe
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *:*.exe)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '' '.exe' "$destfile"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews destfile=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || if test -n "$outputname"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ${RM}r "$tmpdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for file in $staticlibs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name="$func_basename_result"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Set up the ranlib parameters.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldlib="$destdir/$name"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tool_oldlib=$func_to_tool_file_result
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$stripme" && test -n "$old_striplib"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do each command in the postinstall commands.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_execute_cmds "$old_postinstall_cmds" 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$future_libdirs" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "remember to run \`$progname --finish$future_libdirs'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$current_libdirs"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Maybe just do a dry run.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run && current_libdirs=" -n$current_libdirs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $EXIT_SUCCESS
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewstest "$opt_mode" = install && func_mode_install ${1+"$@"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_generate_dlsyms outputname originator pic_p
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Extract symbols from dlprefiles and create ${outputname}S.o with
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# a dlpreopen symbol table.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_generate_dlsyms ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_outputname="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_originator="$2"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_pic_p="${3-no}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_dlsyms=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$NM" && test -n "$global_symbol_pipe"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_dlsyms="${my_outputname}S.c"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error "not configured to extract global symbols from dlpreopened files"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$my_dlsyms"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $my_dlsyms in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "") ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.c)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Discover the nlist of each of the dlfiles.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews nlist="$output_objdir/${my_outputname}.nm"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Parse the name list into a source file.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "creating $output_objdir/$my_dlsyms"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#ifdef __cplusplus
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsextern \"C\" {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* DATA imports from DLLs on WIN32 con't be const, because runtime
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relocations are performed -- see ld's documentation on pseudo-relocs. */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define LT_DLSYM_CONST
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#elif defined(__osf__)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* This system does not cope well with relocations in const data. */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define LT_DLSYM_CONST
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define LT_DLSYM_CONST const
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* External symbol declarations for the compiler. */\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$dlself" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "generating symbol list for \`$output'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Add our own program objects to the symbol list.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for progfile in $progfiles; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$progfile" func_convert_file_msys_to_w32
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$exclude_expsyms"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval '$MV "$nlist"T "$nlist"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$export_symbols_regex"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval '$MV "$nlist"T "$nlist"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Prepare the list of exported symbols
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$export_symbols"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export_symbols="$output_objdir/$outputname.exp"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $RM $export_symbols
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *cygwin* | *mingw* | *cegcc* )
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval '$MV "$nlist"T "$nlist"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *cygwin* | *mingw* | *cegcc* )
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for dlprefile in $dlprefiles; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "extracting global C symbols from \`$dlprefile'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$dlprefile"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *cygwin* | *mingw* | *cegcc* )
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # if an import library, we need to obtain dlname
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if func_win32_import_lib_p "$dlprefile"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_tr_sh "$dlprefile"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "curr_lafile=\$libfile_$func_tr_sh_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlprefile_dlbasename=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Use subshell, to avoid clobbering current variable values
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$dlprefile_dlname" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$dlprefile_dlname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlprefile_dlbasename="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # no lafile. user explicitly requested -dlpreopen <import library>.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $sharedlib_from_linklib_cmd "$dlprefile"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlprefile_dlbasename=$sharedlib_from_linklib_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$dlprefile_dlbasename" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "Could not compute DLL name from $name"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval '$ECHO ": $name " >> "$nlist"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else # not an import lib
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval '$ECHO ": $name " >> "$nlist"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval '$ECHO ": $name " >> "$nlist"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews done
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Make sure we have at least an empty file.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -f "$nlist" || : > "$nlist"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$exclude_expsyms"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $MV "$nlist"T "$nlist"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Try sorting and uniquifying the output.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $GREP -v "^: " < "$nlist" |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if sort -k 3 </dev/null >/dev/null 2>&1; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews sort -k 3
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews sort +2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews uniq > "$nlist"S; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews :
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $GREP -v "^: " < "$nlist" > "$nlist"S
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -f "$nlist"S; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo >> "$output_objdir/$my_dlsyms" "\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* The mapping between symbol names and symbols. */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewstypedef struct {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews const char *name;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews void *address;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews} lt_dlsymlist;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsextern LT_DLSYM_CONST lt_dlsymlist
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslt_${my_prefix}_LTX_preloaded_symbols[];
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsLT_DLSYM_CONST lt_dlsymlist
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslt_${my_prefix}_LTX_preloaded_symbols[] =
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews { \"$my_originator\", (void *) 0 },"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $need_lib_prefix in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews no)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo >> "$output_objdir/$my_dlsyms" "\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {0, (void *) 0}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews};
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* This works around a problem in FreeBSD linker */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#ifdef FREEBSD_WORKAROUND
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsstatic const void *lt_preloaded_setup() {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return lt_${my_prefix}_LTX_preloaded_symbols;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#ifdef __cplusplus
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews } # !$opt_dry_run
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews pic_flag_for_symtable=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$compile_command " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" -static "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # compiling the symbol table file with pic_flag works around
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # a FreeBSD bug that causes programs to crash when -lm is
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # linked before any other PIC object. But we must not use
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # pic_flag when linking with -static. The problem exists in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-hpux*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews pic_flag_for_symtable=" $pic_flag" ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$my_pic_p" != Xno; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews pic_flag_for_symtable=" $pic_flag"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews symtab_cflags=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for arg in $LTCFLAGS; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $arg in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -pie | -fpie | -fPIE) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append symtab_cflags " $arg" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Now compile the dynamic symbol file.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Clean up the generated files.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Transform the symbol file into the correct name.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews symfileobj="$output_objdir/${my_outputname}S.$objext"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *cygwin* | *mingw* | *cegcc* )
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -f "$output_objdir/$my_outputname.def"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-freebsd*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # FreeBSD doesn't need this...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "unknown suffix for \`$my_dlsyms'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We keep going just in case the user didn't refer to
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # really was required.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Nullify the symbol file.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_win32_libid arg
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# return the library type of file 'arg'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Need a lot of goo to handle *both* DLLs and import libs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Has to be a shell function in order to 'eat' the argument
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# that is supplied when $file_magic_command is called.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Despite the name, also deal with 64 bit binaries.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_win32_libid ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews win32_libid_type="unknown"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews win32_fileres=`file -L $1 2>/dev/null`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $win32_fileres in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *ar\ archive\ import\ library*) # definitely import
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews win32_libid_type="x86 archive import"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *ar\ archive*) # could be an import, or static
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$1" func_convert_file_msys_to_w32
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED -n -e '
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews 1,100{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews / I /{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s,.*,import,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews p
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews q
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $win32_nmres in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews import*) win32_libid_type="x86 archive import";;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) win32_libid_type="x86 archive static";;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *DLL*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews win32_libid_type="x86 DLL"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *executable*) # but shell scripts are "executable" too...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $win32_fileres in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *MS\ Windows\ PE\ Intel*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews win32_libid_type="x86 DLL"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "$win32_libid_type"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_cygming_dll_for_implib ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Platform-specific function to extract the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# name of the DLL associated with the specified
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# import library ARG.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Invoked by eval'ing the libtool variable
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# $sharedlib_from_linklib_cmd
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Result is available in the variable
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# $sharedlib_from_linklib_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_cygming_dll_for_implib ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# The is the core of a fallback implementation of a
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# platform-specific function to extract the name of the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# DLL associated with the specified import library LIBNAME.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# SECTION_NAME is either .idata$6 or .idata$7, depending
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# on the platform and compiler that created the implib.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Echos the name of the DLL associated with the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# specified import library.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_cygming_dll_for_implib_fallback_core ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED '/^Contents of section '"$match_literal"':/{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Place marker at beginning of archive member dllname section
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/.*/====MARK====/
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews p
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews d
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # These lines can sometimes be longer than 43 characters, but
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # are always uninteresting
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /:[ ]*file format pe[i]\{,1\}-/d
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /^In archive [^:]*:/d
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Ensure marker is printed
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /^====MARK====/p
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Remove all lines with less than 43 characters
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /^.\{43\}/!d
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # From remaining lines, remove first 43 characters
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/^.\{43\}//' |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED -n '
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Join marker and all lines until next marker into a single line
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /^====MARK====/ b para
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews H
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ b para
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews b
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews :para
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews x
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/\n//g
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Remove the marker
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/^====MARK====//
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Remove trailing dots and whitespace
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews s/[\. \t]*$//
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Print
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /./p' |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # we now have a list, one entry per line, of the stringified
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # contents of the appropriate section of all members of the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # archive which possess that section. Heuristic: eliminate
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # all those which have a first or second character that is
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # a '.' (that is, objdump's representation of an unprintable
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # character.) This should work for all archives with less than
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # 0x302f exports -- but will fail for DLLs whose name actually
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # begins with a literal '.' or a single character followed by
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # a '.'.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews #
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Of those that remain, print the first one.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED -e '/^\./d;/^.\./d;q'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_cygming_gnu_implib_p ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# This predicate returns with zero status (TRUE) if
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# ARG is a GNU/binutils-style import library. Returns
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# with nonzero status (FALSE) otherwise.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_cygming_gnu_implib_p ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$1" func_convert_file_msys_to_w32
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$func_cygming_gnu_implib_tmp"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_cygming_ms_implib_p ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# This predicate returns with zero status (TRUE) if
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# ARG is an MS-style import library. Returns
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# with nonzero status (FALSE) otherwise.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_cygming_ms_implib_p ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$1" func_convert_file_msys_to_w32
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$func_cygming_ms_implib_tmp"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_cygming_dll_for_implib_fallback ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Platform-specific function to extract the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# name of the DLL associated with the specified
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# import library ARG.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# This fallback implementation is for use when $DLLTOOL
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# does not support the --identify-strict option.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Invoked by eval'ing the libtool variable
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# $sharedlib_from_linklib_cmd
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Result is available in the variable
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# $sharedlib_from_linklib_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_cygming_dll_for_implib_fallback ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if func_cygming_gnu_implib_p "$1" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # binutils import library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif func_cygming_ms_implib_p "$1" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # ms-generated import library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # unknown
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews sharedlib_from_linklib_result=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_extract_an_archive dir oldlib
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_extract_an_archive ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews f_ex_an_ar_dir="$1"; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews f_ex_an_ar_oldlib="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$lock_old_archive_extraction" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lockfile=$f_ex_an_ar_oldlib.lock
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_echo "Waiting for $lockfile to be removed"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews sleep 2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews 'stat=$?; rm -f "$lockfile"; exit $stat'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$lock_old_archive_extraction" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || rm -f "$lockfile"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews :
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_extract_archives gentop oldlib ...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_extract_archives ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_gentop="$1"; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_oldlibs=${1+"$@"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_oldobjs=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_xlib=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_xabs=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_xdir=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for my_xlib in $my_oldlibs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Extract the objects.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $my_xlib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) my_xabs=`pwd`"/$my_xlib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$my_xlib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_xlib="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_xlib_u=$my_xlib
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while :; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $extracted_archives " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $my_xlib_u "*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $extracted_serial + 1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews extracted_serial=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_xlib_u=lt$extracted_serial-$my_xlib ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) break ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews extracted_archives="$extracted_archives $my_xlib_u"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_xdir="$my_gentop/$my_xlib_u"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_mkdir_p "$my_xdir"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-darwin*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "Extracting $my_xabs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do not bother doing anything if just a dry run
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin_orig_dir=`pwd`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cd $my_xdir || exit $?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin_archive=$my_xabs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin_curdir=`pwd`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin_base_archive=`basename "$darwin_archive"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$darwin_arches"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin_arch=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for darwin_arch in $darwin_arches ; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_extract_an_archive "`pwd`" "${darwin_base_archive}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cd "$darwin_curdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done # $darwin_arches
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ## Okay now we've a bunch of thin objects, gotta fatten them up :)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin_file=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin_files=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for darwin_file in $darwin_filelist; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $LIPO -create -output "$darwin_file" $darwin_files
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done # $darwin_filelist
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $RM -rf unfat-$$
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cd "$darwin_orig_dir"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cd $darwin_orig_dir
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_extract_an_archive "$my_xdir" "$my_xabs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi # $darwin_arches
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews } # !$opt_dry_run
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_extract_an_archive "$my_xdir" "$my_xabs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_extract_archives_result="$my_oldobjs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_emit_wrapper [arg=no]
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Emit a libtool wrapper script on stdout.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Don't directly open a file because we may want to
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# incorporate the script contents within a cygwin/mingw
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# wrapper executable. Must ONLY be called from within
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_mode_link because it depends on a number of variables
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# set therein.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# variable will take. If 'yes', then the emitted script
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# will assume that the directory in which it is stored is
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# the $objdir directory. This is a cygwin/mingw-specific
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# behavior.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_emit_wrapper ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_emit_wrapper_arg1=${1-no}
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#! $SHELL
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# $output - temporary wrapper script for $objdir/$outputname
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# The $output program cannot be directly executed until all the libtool
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# libraries that it depends on are installed.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# This wrapper script should never be moved out of the build directory.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# If it is, it will not operate correctly.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Sed substitution that helps us do robust quoting. It backslashifies
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# metacharacters that are still active within double-quoted strings.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewssed_quote_subst='$sed_quote_subst'
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Be Bourne compatible
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews emulate sh
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews NULLCMD=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # is contrary to our usage. Disable this feature.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews alias -g '\${1+\"\$@\"}'='\"\$@\"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews setopt NO_GLOB_SUBST
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewselse
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfi
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsBIN_SH=xpg4; export BIN_SH # for Tru64
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsDUALCASE=1; export DUALCASE # for MKS sh
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# The HP-UX ksh and POSIX shell print the target directory to stdout
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# if CDPATH is set.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsrelink_command=\"$relink_command\"
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# This environment variable determines our operation mode.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsif test \"\$libtool_install_magic\" = \"$magic\"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # install mode needs the following variables:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews generated_by_libtool_version='$macro_version'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews notinst_deplibs='$notinst_deplibs'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewselse
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # When we are sourced in execute mode, \$file and \$ECHO are already set.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test \"\$libtool_execute_magic\" != \"$magic\"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file=\"\$0\""
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "\
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# A function that is used when there is no print builtin or printf.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_fallback_echo ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval 'cat <<_LTECHO_EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews\$1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews_LTECHO_EOF'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ECHO=\"$qECHO\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Very basic option parsing. These options are (a) specific to
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# the libtool wrapper, (b) are identical between the wrapper
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# /script/ and the wrapper /executable/ which is used only on
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# windows platforms, and (c) all begin with the string "--lt-"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# (application programs are unlikely to have options which match
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# this pattern).
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# There are only two supported options: --lt-debug and
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# --lt-dump-script. There is, deliberately, no --lt-help.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# The first argument to this parsing function should be the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# script's $0 value, followed by "$@".
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslt_option_debug=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_parse_lt_options ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_script_arg0=\$0
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for lt_opt
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case \"\$lt_opt\" in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --lt-debug) lt_option_debug=1 ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --lt-dump-script)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat \"\$lt_dump_D/\$lt_dump_F\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit 0
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --lt-*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit 1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Print the debug banner immediately:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n \"\$lt_option_debug\"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Used when --lt-debug. Prints its arguments to stdout
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# (redirection is the responsibility of the caller)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_lt_dump_args ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_dump_args_N=1;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for lt_arg
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Core function for launching the target application
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_exec_program_core ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Backslashes separate directories on plain windows
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-mingw | *-*-os2* | *-cegcc*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n \"\$lt_option_debug\"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_lt_dump_args \${1+\"\$@\"} 1>&2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n \"\$lt_option_debug\"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_lt_dump_args \${1+\"\$@\"} 1>&2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exec \"\$progdir/\$program\" \${1+\"\$@\"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit 1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# A function to encapsulate launching the target application
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Strips options in the --lt-* namespace from \$@ and
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# launches target application with the remaining arguments.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_exec_program ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case \" \$* \" in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *\\ --lt-*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for lt_wr_arg
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case \$lt_wr_arg in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews --lt-*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_exec_program_core \${1+\"\$@\"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Parse options
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_parse_lt_options \"\$0\" \${1+\"\$@\"}
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Find the directory that this script lives in.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test \"x\$thisdir\" = \"x\$file\" && thisdir=.
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Follow symbolic links until we get to the real thisdir.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while test -n \"\$file\"; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If there was a directory component, then change thisdir.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test \"x\$destdir\" != \"x\$file\"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case \"\$destdir\" in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) thisdir=\"\$thisdir/\$destdir\" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Usually 'no', except on cygwin/mingw when embedded into
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # the cwrapper.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # special case for '.'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test \"\$thisdir\" = \".\"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews thisdir=\`pwd\`
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # remove .libs from thisdir
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case \"\$thisdir\" in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $objdir ) thisdir=. ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Try to get the absolute directory name.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews absdir=\`cd \"\$thisdir\" && pwd\`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n \"\$absdir\" && thisdir=\"\$absdir\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$fast_install" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews program=lt-'$outputname'$exeext
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews progdir=\"\$thisdir/$objdir\"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test ! -f \"\$progdir/\$program\" ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test \"X\$file\" != \"X\$progdir/\$program\"; }; then
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file=\"\$\$-\$program\"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test ! -d \"\$progdir\"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $MKDIR \"\$progdir\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $RM \"\$progdir/\$file\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "\
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # relink executable if necessary
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n \"\$relink_command\"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if relink_command_output=\`eval \$relink_command 2>&1\`; then :
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO \"\$relink_command_output\" >&2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $RM \"\$progdir/\$file\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit 1
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews { $RM \"\$progdir/\$program\";
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $RM \"\$progdir/\$file\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews program='$outputname'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews progdir=\"\$thisdir/$objdir\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "\
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -f \"\$progdir/\$program\"; then"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # fixup the dll searchpath if we need to.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews #
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Fix the DLL searchpath if we need to. Do this before prepending
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # to shlibpath, because on Windows, both are PATH and uninstalled
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # libraries must come first.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$dllsearchpath"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Add the dll search path components to the executable PATH
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews PATH=$dllsearchpath:\$PATH
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Export our shlibpath_var if we have one.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Add our own library path to $shlibpath_var
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Some systems cannot cope with colon-terminated $shlibpath_var
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The second colon is a workaround for a bug in BeOS R4 sed
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export $shlibpath_var
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test \"\$libtool_execute_magic\" != \"$magic\"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Run the actual program with our arguments.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_exec_program \${1+\"\$@\"}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The program doesn't exist.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit 1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfi\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_emit_cwrapperexe_src
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# emit the source code for a wrapper executable on stdout
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Must ONLY be called from within func_mode_link because
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# it depends on a number of variable set therein.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_emit_cwrapperexe_src ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<EOF
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews The $output program cannot be directly executed until all the libtool
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libraries that it depends on are installed.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews This wrapper executable should never be moved out of the build directory.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews If it is, it will not operate correctly.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews*/
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<"EOF"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#ifdef _MSC_VER
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define _CRT_SECURE_NO_DEPRECATE 1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#include <stdio.h>
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#include <stdlib.h>
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#ifdef _MSC_VER
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# include <direct.h>
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# include <process.h>
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# include <io.h>
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# include <unistd.h>
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# include <stdint.h>
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# ifdef __CYGWIN__
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# include <io.h>
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#include <malloc.h>
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#include <stdarg.h>
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#include <assert.h>
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#include <string.h>
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#include <ctype.h>
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#include <errno.h>
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#include <fcntl.h>
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#include <sys/stat.h>
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* declarations of non-ANSI functions */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#if defined(__MINGW32__)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# ifdef __STRICT_ANSI__
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsint _putenv (const char *);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#elif defined(__CYGWIN__)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# ifdef __STRICT_ANSI__
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewschar *realpath (const char *, char *);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsint putenv (char *);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsint setenv (const char *, const char *, int);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* #elif defined (other platforms) ... */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* portability defines, excluding path handling macros */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#if defined(_MSC_VER)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define setmode _setmode
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define stat _stat
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define chmod _chmod
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define getcwd _getcwd
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define putenv _putenv
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define S_IXUSR _S_IEXEC
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# ifndef _INTPTR_T_DEFINED
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define _INTPTR_T_DEFINED
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define intptr_t int
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#elif defined(__MINGW32__)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define setmode _setmode
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define stat _stat
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define chmod _chmod
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define getcwd _getcwd
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define putenv _putenv
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#elif defined(__CYGWIN__)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define HAVE_SETENV
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define FOPEN_WB "wb"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* #elif defined (other platforms) ... */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#if defined(PATH_MAX)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define LT_PATHMAX PATH_MAX
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#elif defined(MAXPATHLEN)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define LT_PATHMAX MAXPATHLEN
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define LT_PATHMAX 1024
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#ifndef S_IXOTH
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define S_IXOTH 0
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#ifndef S_IXGRP
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define S_IXGRP 0
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* path handling portability macros */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#ifndef DIR_SEPARATOR
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define DIR_SEPARATOR '/'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define PATH_SEPARATOR ':'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews defined (__OS2__)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define HAVE_DOS_BASED_FILE_SYSTEM
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define FOPEN_WB "wb"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# ifndef DIR_SEPARATOR_2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define DIR_SEPARATOR_2 '\\'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# ifndef PATH_SEPARATOR_2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define PATH_SEPARATOR_2 ';'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#ifndef DIR_SEPARATOR_2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#else /* DIR_SEPARATOR_2 */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define IS_DIR_SEPARATOR(ch) \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif /* DIR_SEPARATOR_2 */
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#ifndef PATH_SEPARATOR_2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#else /* PATH_SEPARATOR_2 */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif /* PATH_SEPARATOR_2 */
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#ifndef FOPEN_WB
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define FOPEN_WB "w"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#ifndef _O_BINARY
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# define _O_BINARY 0
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#define XFREE(stale) do { \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (stale) { free ((void *) stale); stale = 0; } \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews} while (0)
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#if defined(LT_DEBUGWRAPPER)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsstatic int lt_debug = 1;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsstatic int lt_debug = 0;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsvoid *xmalloc (size_t num);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewschar *xstrdup (const char *string);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsconst char *base_name (const char *name);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewschar *find_executable (const char *wrapper);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewschar *chase_symlinks (const char *pathspec);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsint make_executable (const char *path);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsint check_executable (const char *path);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewschar *strendzap (char *str, const char *pat);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsvoid lt_fatal (const char *file, int line, const char *message, ...);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsstatic const char *nonnull (const char *s);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsstatic const char *nonempty (const char *s);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsvoid lt_setenv (const char *name, const char *value);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewschar *lt_extend_str (const char *orig_value, const char *add, int to_end);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsvoid lt_update_exe_path (const char *name, const char *value);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsvoid lt_update_lib_path (const char *name, const char *value);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewschar **prepare_spawn (char **argv);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsvoid lt_dump_script (FILE *f);
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsvolatile const char * MAGIC_EXE = "$magic_exe";
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsconst char * LIB_PATH_VARNAME = "$shlibpath_var";
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path "$temp_rpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsconst char * LIB_PATH_VALUE = "$func_to_host_path_result";
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<"EOF"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsconst char * LIB_PATH_VALUE = "";
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$dllsearchpath"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_host_path "$dllsearchpath:"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsconst char * EXE_PATH_VARNAME = "PATH";
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsconst char * EXE_PATH_VALUE = "$func_to_host_path_result";
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<"EOF"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsconst char * EXE_PATH_VARNAME = "";
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsconst char * EXE_PATH_VALUE = "";
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$fast_install" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<"EOF"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#define LTWRAPPER_OPTION_PREFIX "--lt-"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsint
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsmain (int argc, char *argv[])
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char **newargz;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews int newargc;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char *tmp_pathspec;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char *actual_cwrapper_path;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char *actual_cwrapper_name;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char *target_name;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char *lt_argv_zero;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews intptr_t rval = 127;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews int i;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews program_name = (char *) xstrdup (base_name (argv[0]));
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newargz = XMALLOC (char *, argc + 1);
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* very simple arg parsing; don't want to rely on getopt
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews * also, copy all non cwrapper options to newargz, except
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews * argz[0], which is handled differently
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newargc=0;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for (i = 1; i < argc; i++)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (strcmp (argv[i], dumpscript_opt) == 0)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$host" in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *mingw* | *cygwin* )
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # make stdout use "unix" line endings
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo " setmode(1,_O_BINARY);"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<"EOF"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_dump_script (stdout);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return 0;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (strcmp (argv[i], debug_opt) == 0)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debug = 1;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews namespace, but it is not one of the ones we know about and
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews have already dealt with, above (inluding dump-script), then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews report an error. Otherwise, targets might begin to believe
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews namespace. The first time any user complains about this, we'll
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews need to make LTWRAPPER_OPTION_PREFIX a configure-time option
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews or a configure.ac-settable value.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_fatal (__FILE__, __LINE__,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "unrecognized %s option: '%s'",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ltwrapper_option_prefix, argv[i]);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* otherwise ... */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newargz[++newargc] = xstrdup (argv[i]);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newargz[++newargc] = NULL;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* The GNU banner must be the first non-error debug message */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<"EOF"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_pathspec = find_executable (argv[0]);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (tmp_pathspec == NULL)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "(main) found exe (before symlink chase) at: %s\n",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_pathspec);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews actual_cwrapper_path = chase_symlinks (tmp_pathspec);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "(main) found exe (after symlink chase) at: %s\n",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews actual_cwrapper_path);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XFREE (tmp_pathspec);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews strendzap (actual_cwrapper_path, actual_cwrapper_name);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* wrapper name transforms */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews strendzap (actual_cwrapper_name, ".exe");
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XFREE (actual_cwrapper_name);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews actual_cwrapper_name = tmp_pathspec;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_pathspec = 0;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* target_name transforms -- use actual target program name; might have lt- prefix */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews strendzap (target_name, ".exe");
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XFREE (target_name);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews target_name = tmp_pathspec;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_pathspec = 0;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "(main) libtool target name: %s\n",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews target_name);
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newargz[0] =
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XMALLOC (char, (strlen (actual_cwrapper_path) +
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews strcpy (newargz[0], actual_cwrapper_path);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews strcat (newargz[0], "$objdir");
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews strcat (newargz[0], "/");
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<"EOF"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* stop here, and copy so we don't have to do this twice */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_pathspec = xstrdup (newargz[0]);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews strcat (newargz[0], actual_cwrapper_name);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* DO want the lt- prefix here if it exists, so use target_name */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XFREE (tmp_pathspec);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_pathspec = NULL;
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host_os in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews mingw*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<"EOF"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char* p;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while ((p = strchr (newargz[0], '\\')) != NULL)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *p = '/';
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while ((p = strchr (lt_argv_zero, '\\')) != NULL)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *p = '/';
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<"EOF"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XFREE (target_name);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XFREE (actual_cwrapper_path);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XFREE (actual_cwrapper_name);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_setenv ("DUALCASE", "1"); /* for MSK sh */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews because on Windows, both *_VARNAMEs are PATH but uninstalled
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libraries must come first. */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews nonnull (lt_argv_zero));
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for (i = 0; i < newargc; i++)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews i, nonnull (newargz[i]));
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob HalleyEOF
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host_os in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews mingw*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<"EOF"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* execv doesn't actually work on mingw as expected on unix */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newargz = prepare_spawn (newargz);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (rval == -1)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* failed to start process */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "(main) failed to launch target \"%s\": %s\n",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_argv_zero, nonnull (strerror (errno)));
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return 127;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return rval;
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<"EOF"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews execv (lt_argv_zero, newargz);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return rval; /* =127, but avoids unused variable warning */
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<"EOF"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsvoid *
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsxmalloc (size_t num)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews void *p = (void *) malloc (num);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (!p)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_fatal (__FILE__, __LINE__, "memory exhausted");
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return p;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewschar *
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsxstrdup (const char *string)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews string) : NULL;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsconst char *
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsbase_name (const char *name)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews const char *base;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* Skip over the disk name in MSDOS pathnames. */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (isalpha ((unsigned char) name[0]) && name[1] == ':')
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name += 2;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for (base = name; *name; name++)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (IS_DIR_SEPARATOR (*name))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews base = name + 1;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return base;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsint
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewscheck_executable (const char *path)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews struct stat st;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews nonempty (path));
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if ((!path) || (!*path))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return 0;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if ((stat (path, &st) >= 0)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return 1;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return 0;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsint
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsmake_executable (const char *path)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews int rval = 0;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews struct stat st;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews nonempty (path));
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if ((!path) || (!*path))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return 0;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (stat (path, &st) >= 0)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return rval;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* Searches for the full path of the wrapper. Returns
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newly allocated full path name if found, NULL otherwise
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews Does not chase symlinks, even on platforms that support them.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews*/
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewschar *
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfind_executable (const char *wrapper)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews int has_slash = 0;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews const char *p;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews const char *p_next;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* static buffer for getcwd */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char tmp[LT_PATHMAX + 1];
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews int tmp_len;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char *concat_name;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews nonempty (wrapper));
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if ((wrapper == NULL) || (*wrapper == '\0'))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return NULL;
b4e3e004e4b0b3b903be68db73a21dbea7fe3ac4Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* Absolute path? */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews concat_name = xstrdup (wrapper);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (check_executable (concat_name))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return concat_name;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XFREE (concat_name);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (IS_DIR_SEPARATOR (wrapper[0]))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews concat_name = xstrdup (wrapper);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (check_executable (concat_name))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return concat_name;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XFREE (concat_name);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for (p = wrapper; *p; p++)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (*p == '/')
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews has_slash = 1;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (!has_slash)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* no slashes; search PATH */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews const char *path = getenv ("PATH");
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (path != NULL)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for (p = path; *p; p = p_next)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews const char *q;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews size_t p_len;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for (q = p; *q; q++)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (IS_PATH_SEPARATOR (*q))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews p_len = q - p;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews p_next = (*q == '\0' ? q : q + 1);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (p_len == 0)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* empty path: current directory */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (getcwd (tmp, LT_PATHMAX) == NULL)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews nonnull (strerror (errno)));
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_len = strlen (tmp);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews concat_name =
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews memcpy (concat_name, tmp, tmp_len);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews concat_name[tmp_len] = '/';
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews strcpy (concat_name + tmp_len + 1, wrapper);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews concat_name =
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews memcpy (concat_name, p, p_len);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews concat_name[p_len] = '/';
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews strcpy (concat_name + p_len + 1, wrapper);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (check_executable (concat_name))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return concat_name;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XFREE (concat_name);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* not found in PATH; assume curdir */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* Relative path | not found in path: prepend cwd */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (getcwd (tmp, LT_PATHMAX) == NULL)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews nonnull (strerror (errno)));
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_len = strlen (tmp);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews memcpy (concat_name, tmp, tmp_len);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews concat_name[tmp_len] = '/';
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews strcpy (concat_name + tmp_len + 1, wrapper);
b4e3e004e4b0b3b903be68db73a21dbea7fe3ac4Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (check_executable (concat_name))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return concat_name;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XFREE (concat_name);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return NULL;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewschar *
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewschase_symlinks (const char *pathspec)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#ifndef S_ISLNK
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return xstrdup (pathspec);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char buf[LT_PATHMAX];
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews struct stat s;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char *tmp_pathspec = xstrdup (pathspec);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char *p;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews int has_symlinks = 0;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while (strlen (tmp_pathspec) && !has_symlinks)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "checking path component for symlinks: %s\n",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_pathspec);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (lstat (tmp_pathspec, &s) == 0)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (S_ISLNK (s.st_mode) != 0)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews has_symlinks = 1;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* search backwards for last DIR_SEPARATOR */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews p = tmp_pathspec + strlen (tmp_pathspec) - 1;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews p--;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* no more DIR_SEPARATORS left */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *p = '\0';
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_fatal (__FILE__, __LINE__,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "error accessing file \"%s\": %s",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_pathspec, nonnull (strerror (errno)));
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XFREE (tmp_pathspec);
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (!has_symlinks)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return xstrdup (pathspec);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_pathspec = realpath (pathspec, buf);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (tmp_pathspec == 0)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_fatal (__FILE__, __LINE__,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "could not follow symlinks for %s", pathspec);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return xstrdup (tmp_pathspec);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewschar *
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsstrendzap (char *str, const char *pat)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews size_t len, patlen;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews assert (str != NULL);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews assert (pat != NULL);
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews len = strlen (str);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews patlen = strlen (pat);
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (patlen <= len)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews str += len - patlen;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (strcmp (str, pat) == 0)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *str = '\0';
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return str;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsvoid
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslt_debugprintf (const char *file, int line, const char *fmt, ...)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews va_list args;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (lt_debug)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews va_start (args, fmt);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews (void) vfprintf (stderr, fmt, args);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews va_end (args);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsstatic void
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslt_error_core (int exit_status, const char *file,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews int line, const char *mode,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews const char *message, va_list ap)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews vfprintf (stderr, message, ap);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fprintf (stderr, ".\n");
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (exit_status >= 0)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit (exit_status);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsvoid
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslt_fatal (const char *file, int line, const char *message, ...)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews va_list ap;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews va_start (ap, message);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews va_end (ap);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsstatic const char *
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsnonnull (const char *s)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return s ? s : "(null)";
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsstatic const char *
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsnonempty (const char *s)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return (s && !*s) ? "(empty)" : nonnull (s);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsvoid
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslt_setenv (const char *name, const char *value)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "(lt_setenv) setting '%s' to '%s'\n",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews nonnull (name), nonnull (value));
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#ifdef HAVE_SETENV
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* always make a copy, for consistency with !HAVE_SETENV */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char *str = xstrdup (value);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews setenv (name, str, 1);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews int len = strlen (name) + 1 + strlen (value) + 1;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char *str = XMALLOC (char, len);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews sprintf (str, "%s=%s", name, value);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (putenv (str) != EXIT_SUCCESS)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XFREE (str);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#endif
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewschar *
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslt_extend_str (const char *orig_value, const char *add, int to_end)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char *new_value;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (orig_value && *orig_value)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews int orig_value_len = strlen (orig_value);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews int add_len = strlen (add);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews new_value = XMALLOC (char, add_len + orig_value_len + 1);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (to_end)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews strcpy (new_value, orig_value);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews strcpy (new_value + orig_value_len, add);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews strcpy (new_value, add);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews strcpy (new_value + add_len, orig_value);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews new_value = xstrdup (add);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return new_value;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsvoid
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslt_update_exe_path (const char *name, const char *value)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews nonnull (name), nonnull (value));
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (name && *name && value && *value)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char *new_value = lt_extend_str (getenv (name), value, 0);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* some systems can't cope with a ':'-terminated path #' */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews int len = strlen (new_value);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews new_value[len-1] = '\0';
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_setenv (name, new_value);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XFREE (new_value);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsvoid
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslt_update_lib_path (const char *name, const char *value)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_debugprintf (__FILE__, __LINE__,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews nonnull (name), nonnull (value));
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (name && *name && value && *value)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char *new_value = lt_extend_str (getenv (name), value, 0);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_setenv (name, new_value);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews XFREE (new_value);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
b4e3e004e4b0b3b903be68db73a21dbea7fe3ac4Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host_os in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews mingw*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<"EOF"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews/* Prepares an argument vector before calling spawn().
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews Note that spawn() does not by itself call the command interpreter
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews GetVersionEx(&v);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews v.dwPlatformId == VER_PLATFORM_WIN32_NT;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }) ? "cmd.exe" : "command.com").
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews Instead it simply concatenates the arguments, separated by ' ', and calls
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews CreateProcess(). We must quote the arguments since Win32 CreateProcess()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews special way:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews - Space and tab are interpreted as delimiters. They are not treated as
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews delimiters if they are surrounded by double quotes: "...".
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews - Unescaped double quotes are removed from the input. Their only effect is
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews that within double quotes, space and tab are treated like normal
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews characters.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews - Backslashes not followed by double quotes are not special.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews - But 2*n+1 backslashes followed by a double quote become
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews n backslashes followed by a double quote (n >= 0):
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews \" -> "
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews \\\" -> \"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews \\\\\" -> \\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewschar **
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsprepare_spawn (char **argv)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews size_t argc;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char **new_argv;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews size_t i;
b4e3e004e4b0b3b903be68db73a21dbea7fe3ac4Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* Count number of arguments. */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for (argc = 0; argv[argc] != NULL; argc++)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* Allocate new argument vector. */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews new_argv = XMALLOC (char *, argc + 1);
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews /* Put quoted arguments into the new argument vector. */
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for (i = 0; i < argc; i++)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews const char *string = argv[i];
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (string[0] == '\0')
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews new_argv[i] = xstrdup ("\"\"");
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews size_t length;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews unsigned int backslashes;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews const char *s;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char *quoted_string;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char *p;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews length = 0;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews backslashes = 0;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (quote_around)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews length++;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for (s = string; *s != '\0'; s++)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char c = *s;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (c == '"')
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews length += backslashes + 1;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews length++;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (c == '\\')
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews backslashes++;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews backslashes = 0;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (quote_around)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews length += backslashes + 1;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews quoted_string = XMALLOC (char, length + 1);
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews p = quoted_string;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews backslashes = 0;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (quote_around)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *p++ = '"';
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for (s = string; *s != '\0'; s++)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews char c = *s;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (c == '"')
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews unsigned int j;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for (j = backslashes + 1; j > 0; j--)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *p++ = '\\';
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *p++ = c;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (c == '\\')
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews backslashes++;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews backslashes = 0;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (quote_around)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews unsigned int j;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for (j = backslashes; j > 0; j--)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *p++ = '\\';
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *p++ = '"';
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *p = '\0';
b4e3e004e4b0b3b903be68db73a21dbea7fe3ac4Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews new_argv[i] = quoted_string;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews new_argv[i] = (char *) string;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews new_argv[argc] = NULL;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews return new_argv;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
b4e3e004e4b0b3b903be68db73a21dbea7fe3ac4Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<"EOF"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsvoid lt_dump_script (FILE* f)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_emit_wrapper yes |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED -n -e '
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewss/^\(.\{79\}\)\(..*\)/\1\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews\2/
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsh
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewss/\([\\"]\)/\\\1/g
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewss/$/\\n/
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewss/\([^\n]*\).*/ fputs ("\1", f);/p
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsg
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsD'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat <<"EOF"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# end: func_emit_cwrapperexe_src
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_win32_import_lib_p ARG
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# True if ARG is an import lib, as indicated by $file_magic_cmd
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_win32_import_lib_p ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *import*) : ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) false ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_mode_link arg...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_mode_link ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # It is impossible to link a dll without this setting, and
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # we shouldn't force the makefile maintainer to figure out
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # which system we are compiling for in order to pass an extra
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # flag for every libtool invocation.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # allow_undefined=no
b4e3e004e4b0b3b903be68db73a21dbea7fe3ac4Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # FIXME: Unfortunately, there are problems with the above when trying
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # to make a dll which has undefined symbols, in which case not
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # even a static library is built. For now, we need to specify
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # -no-undefined on the libtool link line when we can be certain
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # that all symbols are satisfied, otherwise we get a static library.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews allow_undefined=yes
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews allow_undefined=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libtool_args=$nonopt
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews base_compile="$nonopt $@"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_command=$nonopt
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_command=$nonopt
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_rpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_rpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_shlibpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_shlibpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews convenience=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews old_convenience=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews old_deplibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compiler_flags=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews linker_flags=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dllsearchpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib_search_path=`pwd`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews inst_prefix_dir=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews new_inherited_linker_flags=
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews avoid_version=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews bindir=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlfiles=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlprefiles=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlself=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export_dynamic=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export_symbols=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export_symbols_regex=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews generated=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libobjs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ltlibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews module=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews no_install=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews objs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews non_pic_objects=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews precious_files_regex=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prefer_static_libs=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews preload=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prevarg=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews release=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews rpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews xrpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews perm_rpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews temp_rpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews thread_safe=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews vinfo=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews vinfo_number=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews weak_libs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews single_module="${wl}-single_module"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_infer_tag $base_compile
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We need to know -static, to get the right output filenames.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for arg
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $arg in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -shared)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$build_libtool_libs" != yes && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_configuration "can not build a shared library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_old_libs=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -all-static | -static | -static-libtool-libs)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $arg in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -all-static)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "complete static linking is impossible in this configuration"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$link_static_flag"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlopen_self=$dlopen_self_static
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prefer_static_libs=yes
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -static)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$pic_flag" && test -n "$link_static_flag"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlopen_self=$dlopen_self_static
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prefer_static_libs=built
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -static-libtool-libs)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$pic_flag" && test -n "$link_static_flag"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlopen_self=$dlopen_self_static
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prefer_static_libs=yes
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews ;;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_libtool_libs=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_old_libs=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # See if our shared archives depend on static archives.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$old_archive_from_new_cmds" && build_old_libs=yes
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Go through the arguments, transforming them on the way.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while test "$#" -gt 0; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews qarg=$func_quote_for_eval_unquoted_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append libtool_args " $func_quote_for_eval_result"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If the previous option needs an argument, assign it.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$prev"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $prev in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compile_command " @OUTPUT@"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append finalize_command " @OUTPUT@"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $prev in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews bindir)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews bindir="$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlfiles|dlprefiles)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$preload" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Add the symbol object into the linking commands.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compile_command " @SYMFILE@"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append finalize_command " @SYMFILE@"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews preload=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $arg in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.la | *.lo) ;; # We handle these cases below.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews force)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$dlself" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlself=needless
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export_dynamic=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews self)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$prev" = dlprefiles; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlself=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlself=yes
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlself=needless
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export_dynamic=yes
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$prev" = dlfiles; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append dlfiles " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append dlprefiles " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews esac
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews expsyms)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export_symbols="$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -f "$arg" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews || func_fatal_error "symbol file \`$arg' does not exist"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews expsyms_regex)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export_symbols_regex="$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews framework)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-darwin*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$deplibs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $qarg.ltframework "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append deplibs " $qarg.ltframework" # this is fixed later
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews inst_prefix)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews inst_prefix_dir="$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews objectlist)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -f "$arg"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_arg=$arg
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews moreargs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for fil in `cat "$save_arg"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_append moreargs " $fil"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg=$fil
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # A libtool-controlled object.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Check to see that this really is a libtool object.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if func_lalib_unsafe_p "$arg"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews pic_object=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews non_pic_object=
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Read the .lo file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_source "$arg"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$pic_object" ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$non_pic_object" ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$pic_object" = none &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$non_pic_object" = none; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "cannot find name of object for \`$arg'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Extract subdirectory from the argument.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname "$arg" "/" ""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews xdir="$func_dirname_result"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pic_object" != none; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Prepend the subdirectory the object is found in.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews pic_object="$xdir$pic_object"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$prev" = dlfiles; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append dlfiles " $pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If libtool objects are unsupported, then we need to preload.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=dlprefiles
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # CHECK ME: I think I busted this. -Ossama
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$prev" = dlprefiles; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Preload the old-style object.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append dlprefiles " $pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # A PIC object.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append libobjs " $pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg="$pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Non-PIC object.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$non_pic_object" != none; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Prepend the subdirectory the object is found in.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews non_pic_object="$xdir$non_pic_object"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # A standard non-PIC object
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append non_pic_objects " $non_pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$pic_object" || test "$pic_object" = none ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg="$non_pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If the PIC object exists, use it instead.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # $xdir was prepended to $pic_object above.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews non_pic_object="$pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append non_pic_objects " $non_pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Only an error if not doing a dry-run.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $opt_dry_run; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Extract subdirectory from the argument.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname "$arg" "/" ""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews xdir="$func_dirname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_lo2o "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews pic_object=$xdir$objdir/$func_lo2o_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews non_pic_object=$xdir$func_lo2o_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append libobjs " $pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append non_pic_objects " $non_pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "\`$arg' is not a valid libtool object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "link input file \`$arg' does not exist"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg=$save_arg
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews precious_regex)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews precious_files_regex="$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews release)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews release="-$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews rpath | xrpath)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We need an absolute path.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $arg in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [\\/]* | [A-Za-z]:[\\/]*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "only absolute run-paths are allowed"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$prev" = rpath; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$rpath " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $arg "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append rpath " $arg" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$xrpath " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $arg "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append xrpath " $arg" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shrext)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shrext_cmds="$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews weak)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append weak_libs " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews xcclinker)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append linker_flags " $qarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compiler_flags " $qarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compile_command " $qarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append finalize_command " $qarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews xcompiler)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compiler_flags " $qarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compile_command " $qarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append finalize_command " $qarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews xlinker)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append linker_flags " $qarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compiler_flags " $wl$qarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compile_command " $wl$qarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append finalize_command " $wl$qarg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "$prev=\"\$arg\""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi # test -n "$prev"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prevarg="$arg"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $arg in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -all-static)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$link_static_flag"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # See comment for -static flag below, for more details.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compile_command " $link_static_flag"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append finalize_command " $link_static_flag"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -allow-undefined)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # FIXME: remove this flag sometime in the future.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "\`-allow-undefined' must not be used because it is the default"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -avoid-version)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews avoid_version=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -bindir)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=bindir
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -dlopen)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=dlfiles
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -dlpreopen)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=dlprefiles
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -export-dynamic)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export_dynamic=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -export-symbols | -export-symbols-regex)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "more than one -exported-symbols argument is not allowed"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$arg" = "X-export-symbols"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=expsyms
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=expsyms_regex
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -framework)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=framework
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -inst-prefix-dir)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=inst_prefix
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # so, if we see these flags be careful not to treat them like -L
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -L[A-Z][A-Z]*:*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $with_gcc/$host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews no/*-*-irix* | /*-*-irix*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compile_command " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append finalize_command " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -L*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname "-L" '' "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$func_stripname_result"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$#" -gt 0; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "require no space between \`-L' and \`$1'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "need path for \`-L' option"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_resolve_sysroot "$func_stripname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir=$func_resolve_sysroot_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We need an absolute path.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $dir in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [\\/]* | [A-Za-z]:[\\/]*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews absdir=`cd "$dir" && pwd`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$absdir" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "cannot determine absolute directory name of \`$dir'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir="$absdir"
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$deplibs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" -L$dir "* | *" $arg "*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Will only happen for absolute or sysroot arguments
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Preserve sysroot, but never include relative directories
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $dir in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append deplibs " -L$dir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append lib_search_path " $dir"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case :$dllsearchpath: in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *":$dir:"*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ::) dllsearchpath=$dir;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append dllsearchpath ":$dir";;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case :$dllsearchpath: in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *":$testbindir:"*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ::) dllsearchpath=$testbindir;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append dllsearchpath ":$testbindir";;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplibs $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -l*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # These systems don't actually have a C or math library (as such)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-os2*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # These systems don't actually have a C library (as such)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "X$arg" = "X-lc" && continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do not include libc due to us having libc/libc_r.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "X$arg" = "X-lc" && continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-rhapsody* | *-*-darwin1.[012])
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Rhapsody C and math libraries are in the System framework
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append deplibs " System.ltframework"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-sco3.2v5* | *-*-sco5v6*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Causes problems with __ctype
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "X$arg" = "X-lc" && continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Compiler inserts libc in the correct place for threads to work
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "X$arg" = "X-lc" && continue
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test "X$arg" = "X-lc_r"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do not include libc_r directly, use -pthread flag.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append deplibs " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -module)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews module=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Tru64 UNIX uses -model [arg] to determine the layout of C++
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # classes, name mangling, and exception handling.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Darwin uses the -arch flag to determine output architecture.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -model|-arch|-isysroot|--sysroot)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compiler_flags " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compile_command " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append finalize_command " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=xcompiler
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compiler_flags " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compile_command " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append finalize_command " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$new_inherited_linker_flags " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $arg "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews * ) func_append new_inherited_linker_flags " $arg" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -multi_module)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews single_module="${wl}-multi_module"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -no-fast-install)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fast_install=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -no-install)
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The PATH hackery in wrapper scripts is required on Windows
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # and Darwin in order for the loader to find any dlls it needs.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-no-install' is ignored for $host"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "assuming \`-no-fast-install' instead"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fast_install=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) no_install=yes ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -no-undefined)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews allow_undefined=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -objectlist)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=objectlist
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -o) prev=output ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -precious-files-regex)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=precious_regex
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -release)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=release
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -rpath)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=rpath
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -R)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=xrpath
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -R*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '-R' '' "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We need an absolute path.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $dir in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [\\/]* | [A-Za-z]:[\\/]*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews =*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '=' '' "$dir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir=$lt_sysroot$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "only absolute run-paths are allowed"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$xrpath " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $dir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append xrpath " $dir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -shared)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The effects of -shared are defined in a previous loop.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -shrext)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=shrext
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -static | -static-libtool-libs)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The effects of -static are defined in a previous loop.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We used to do the same as -all-static on platforms that
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # didn't have a PIC flag, but the assumption that the effects
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # would be equivalent was wrong. It would break on at least
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Digital Unix and AIX.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -thread-safe)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews thread_safe=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -version-info)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=vinfo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -version-number)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=vinfo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews vinfo_number=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -weak)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=weak
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -Wc,*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '-Wc,' '' "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews args=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_ifs="$IFS"; IFS=','
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for flag in $args; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS="$save_ifs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$flag"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append arg " $func_quote_for_eval_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compiler_flags " $func_quote_for_eval_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS="$save_ifs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname ' ' '' "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -Wl,*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '-Wl,' '' "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews args=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_ifs="$IFS"; IFS=','
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for flag in $args; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS="$save_ifs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$flag"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append arg " $wl$func_quote_for_eval_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compiler_flags " $wl$func_quote_for_eval_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append linker_flags " $func_quote_for_eval_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS="$save_ifs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname ' ' '' "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -Xcompiler)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=xcompiler
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -Xlinker)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=xlinker
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -XCClinker)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=xcclinker
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # -msg_* for osf cc
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -msg_*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg="$func_quote_for_eval_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Flags to be passed through unchanged, with rationale:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # -r[0-9][0-9]* specify processor for the SGI compiler
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # +DA*, +DD* enable 64-bit mode for the HP compiler
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # -q* compiler args for the IBM compiler
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # -F/path path to uninstalled frameworks, gcc on darwin
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # @file GCC response files
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # -tp=* Portland pgcc target processor selection
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # --sysroot=* for sysroot support
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg="$func_quote_for_eval_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compile_command " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append finalize_command " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compiler_flags " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Some other compiler flag.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -* | +*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg="$func_quote_for_eval_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.$objext)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # A standard object.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append objs " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.lo)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # A libtool-controlled object.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Check to see that this really is a libtool object.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if func_lalib_unsafe_p "$arg"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews pic_object=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews non_pic_object=
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Read the .lo file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_source "$arg"
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$pic_object" ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$non_pic_object" ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$pic_object" = none &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$non_pic_object" = none; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "cannot find name of object for \`$arg'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Extract subdirectory from the argument.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname "$arg" "/" ""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews xdir="$func_dirname_result"
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pic_object" != none; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Prepend the subdirectory the object is found in.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews pic_object="$xdir$pic_object"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$prev" = dlfiles; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append dlfiles " $pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If libtool objects are unsupported, then we need to preload.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=dlprefiles
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # CHECK ME: I think I busted this. -Ossama
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$prev" = dlprefiles; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Preload the old-style object.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append dlprefiles " $pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # A PIC object.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append libobjs " $pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg="$pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Non-PIC object.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$non_pic_object" != none; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Prepend the subdirectory the object is found in.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews non_pic_object="$xdir$non_pic_object"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # A standard non-PIC object
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append non_pic_objects " $non_pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$pic_object" || test "$pic_object" = none ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg="$non_pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If the PIC object exists, use it instead.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # $xdir was prepended to $pic_object above.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews non_pic_object="$pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append non_pic_objects " $non_pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Only an error if not doing a dry-run.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $opt_dry_run; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Extract subdirectory from the argument.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname "$arg" "/" ""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews xdir="$func_dirname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_lo2o "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews pic_object=$xdir$objdir/$func_lo2o_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews non_pic_object=$xdir$func_lo2o_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append libobjs " $pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append non_pic_objects " $non_pic_object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "\`$arg' is not a valid libtool object"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.$libext)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # An archive.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append deplibs " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append old_deplibs " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.la)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # A libtool-controlled library.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_resolve_sysroot "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$prev" = dlfiles; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # This library was specified with -dlopen.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append dlfiles " $func_resolve_sysroot_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test "$prev" = dlprefiles; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The library was specified with -dlpreopen.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append dlprefiles " $func_resolve_sysroot_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prev=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append deplibs " $func_resolve_sysroot_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Some other compiler argument.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Unknown arguments in both finalize_command and compile_command need
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # to be aesthetically quoted because they are evaled later.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews arg="$func_quote_for_eval_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac # arg
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Now actually substitute the argument into the commands.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$arg"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compile_command " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append finalize_command " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done # argument parsing loop
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$prev" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "the \`$prevarg' option requires an argument"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval arg=\"$export_dynamic_flag_spec\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compile_command " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append finalize_command " $arg"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldlibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # calculate the name of the file, without its directory
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews outputname="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libobjs_save="$libobjs"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$shlibpath_var"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # get the directories listed in $shlibpath_var
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shlib_search_path=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname "$output" "/" ""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output_objdir="$func_dirname_result$objdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$output_objdir/"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tool_output_objdir=$func_to_tool_file_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Create the object directory.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_mkdir_p "$output_objdir"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Determine the type of output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $output in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews "")
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "you must specify an output file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.$libext) linkmode=oldlib ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.lo | *.$objext) linkmode=obj ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.la) linkmode=lib ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) linkmode=prog ;; # Anything else should be a program.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews specialdeplibs=
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Find all interdependent deplibs by searching for libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # that are linked more than once (e.g. -la -lb -la)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for deplib in $deplibs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $opt_preserve_dup_deps ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$libs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $deplib "*) func_append specialdeplibs " $deplib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append libs " $deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = lib; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libs="$predeps $libs $compiler_lib_search_path $postdeps"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Compute libraries that are listed more than once in $predeps
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # $postdeps and mark them as special (i.e., whose duplicates are
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # not to be eliminated).
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews pre_post_deps=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $opt_duplicate_compiler_generated_deps; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for pre_post_dep in $predeps $postdeps; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$pre_post_deps " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append pre_post_deps " $pre_post_dep"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews pre_post_deps=
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdependency_libs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newlib_search_path=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews need_relink=no # whether we're linking any uninstalled libtool libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews notinst_deplibs= # not-installed libtool libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews notinst_path= # paths that contain not-installed libtool libraries
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $linkmode in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews passes="conv dlpreopen link"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for file in $dlfiles $dlprefiles; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $file in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.la) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prog)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_deplibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews alldeplibs=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdlfiles=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdlprefiles=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews passes="conv scan dlopen dlpreopen link"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) passes="conv"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for pass in $passes; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The preopen pass in lib mode reverses $deplibs; put it back here
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # so that -L comes before libs that need it for instance...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode,$pass" = "lib,link"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ## FIXME: Find the place where the list is rebuilt in the wrong
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ## order, and fix it there properly
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_deplibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for deplib in $deplibs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_deplibs="$deplib $tmp_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$tmp_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode,$pass" = "lib,link" ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$linkmode,$pass" = "prog,scan"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libs="$deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = prog; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $pass in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlopen) libs="$dlfiles" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlpreopen) libs="$dlprefiles" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode,$pass" = "lib,dlpreopen"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Collect and forward deplibs of preopened libtool libs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for lib in $dlprefiles; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Ignore non-libtool-libs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dependency_libs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_resolve_sysroot "$lib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $lib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.la) func_source "$func_resolve_sysroot_result" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Collect preopened libtool deplibs, except any this library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # has declared as weak libs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for deplib in $dependency_libs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplib_base=$func_basename_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $weak_libs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $deplib_base "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append deplibs " $deplib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libs="$dlprefiles"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" = dlopen; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Collect dlpreopened libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_deplibs="$deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for deplib in $libs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews found=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $deplib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode,$pass" = "prog,link"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs="$deplib $compile_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_deplibs="$deplib $finalize_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compiler_flags " $deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $linkmode in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$pass" = conv && continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdependency_libs="$deplib $newdependency_libs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prog)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" = conv; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" = scan; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs="$deplib $compile_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_deplibs="$deplib $finalize_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac # linkmode
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -l*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" != lib && test "$linkmode" != prog; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-l' is ignored for archives/objects"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '-l' '' "$deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = lib; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for searchdir in $searchdirs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for search_ext in .la $std_shrext .so .a; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Search the libtool library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib="$searchdir/lib${name}${search_ext}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -f "$lib"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$search_ext" = ".la"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews found=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews found=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break 2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$found" != yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # deplib doesn't seem to be a libtool library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode,$pass" = "prog,link"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs="$deplib $compile_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_deplibs="$deplib $finalize_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else # deplib is a libtool library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We need to do some special things here, and not later.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $predeps $postdeps " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $deplib "*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if func_lalib_p "$lib"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews library_names=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews old_library=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_source "$lib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for l in $old_library $library_names; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ll="$l"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$ll" = "X$old_library" ; then # only static version available
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews found=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname "$lib" "" "."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ladir="$func_dirname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib=$ladir/$old_library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode,$pass" = "prog,link"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs="$deplib $compile_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_deplibs="$deplib $finalize_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;; # -l
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.ltframework)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode,$pass" = "prog,link"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs="$deplib $compile_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_deplibs="$deplib $finalize_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = lib ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$new_inherited_linker_flags " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $deplib "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews * ) func_append new_inherited_linker_flags " $deplib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -L*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $linkmode in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$pass" = conv && continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdependency_libs="$deplib $newdependency_libs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '-L' '' "$deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_resolve_sysroot "$func_stripname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newlib_search_path " $func_resolve_sysroot_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prog)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" = conv; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" = scan; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs="$deplib $compile_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_deplibs="$deplib $finalize_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '-L' '' "$deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_resolve_sysroot "$func_stripname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newlib_search_path " $func_resolve_sysroot_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-L' is ignored for archives/objects"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac # linkmode
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;; # -L
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -R*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" = link; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '-R' '' "$deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_resolve_sysroot "$func_stripname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir=$func_resolve_sysroot_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Make sure the xrpath contains only unique directories.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$xrpath " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $dir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append xrpath " $dir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.la)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_resolve_sysroot "$deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib=$func_resolve_sysroot_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.$libext)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" = conv; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $linkmode in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Linking convenience modules into shared libraries is allowed,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # but linking other static libraries is non-portable.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $dlpreconveniencelibs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $deplib "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews valid_a_lib=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $deplibs_check_method in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews match_pattern*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews set dummy $deplibs_check_method; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews | $EGREP "$match_pattern_regex" > /dev/null; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews valid_a_lib=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews pass_all)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews valid_a_lib=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$valid_a_lib" != yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** Warning: Trying to link with static lib archive $deplib."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** I have the capability to make that library automatically link in when"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** you link to this library. But I can only do this if you have a"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** shared version of the library, which you do not appear to have"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** because the file extensions .$libext of this argument makes me believe"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** that it is just a static archive that I should not use here."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** Warning: Linking the shared library $output against the"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** static library $deplib is not portable!"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prog)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" != link; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs="$deplib $compile_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_deplibs="$deplib $finalize_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac # linkmode
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;; # *.$libext
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.lo | *.$objext)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" = conv; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test "$linkmode" = prog; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If there is no dlopen support or we're linking statically,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # we need to preload.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdlprefiles " $deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs="$deplib $compile_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_deplibs="$deplib $finalize_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdlfiles " $deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews %DEPLIBS%)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews alldeplibs=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac # case $deplib
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$found" = yes || test -f "$lib"; then :
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Check to see that this really is a libtool archive.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_lalib_unsafe_p "$lib" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews || func_fatal_error "\`$lib' is not a valid libtool archive"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname "$lib" "" "."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ladir="$func_dirname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlname=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlopen=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlpreopen=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libdir=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews library_names=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews old_library=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews inherited_linker_flags=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If the library was installed with an old release of libtool,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # it will not redefine variables installed, or shouldnotlink
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews installed=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shouldnotlink=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews avoidtemprpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Read the .la file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_source "$lib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Convert "-framework foo" to "foo.ltframework"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$inherited_linker_flags"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $new_inherited_linker_flags " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $tmp_inherited_linker_flag "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode,$pass" = "lib,link" ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$linkmode,$pass" = "prog,scan" ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews { test "$linkmode" != prog && test "$linkmode" != lib; }; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$dlopen" && func_append dlfiles " $dlopen"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" = conv; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Only check for convenience libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$lib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$libdir"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$old_library"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "cannot find name of link library for \`$lib'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # It is a libtool convenience library, so add in its objects.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append convenience " $ladir/$objdir/$old_library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append old_convenience " $ladir/$objdir/$old_library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test "$linkmode" != prog && test "$linkmode" != lib; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "\`$lib' is not a convenience library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_libs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for deplib in $dependency_libs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $opt_preserve_dup_deps ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$tmp_libs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $deplib "*) func_append specialdeplibs " $deplib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append tmp_libs " $deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi # $pass = conv
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Get the name of the library we link against.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews linklib=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$old_library" &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews { test "$prefer_static_libs" = yes ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$prefer_static_libs,$installed" = "built,no"; }; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews linklib=$old_library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for l in $old_library $library_names; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews linklib="$l"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$linklib"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "cannot find name of link library for \`$lib'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # This library was specified with -dlopen.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" = dlopen; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$libdir"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$dlname" ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$dlopen_support" != yes ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$build_libtool_libs" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If there is no dlname, no dlopen support or we're linking
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # statically, we need to preload. We also need to preload any
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # dependent libraries so libltdl's deplib preloader doesn't
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # bomb out in the load deplibs phase.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append dlprefiles " $lib $dependency_libs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdlfiles " $lib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi # $pass = dlopen
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We need an absolute path.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $ladir in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews abs_ladir=`cd "$ladir" && pwd`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$abs_ladir"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "cannot determine absolute directory name of \`$ladir'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "passing it literally to the linker, although it might fail"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews abs_ladir="$ladir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$lib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews laname="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Find the relevant object directory and library name.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$installed" = Xyes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "library \`$lib' was moved."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir="$ladir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews absdir="$abs_ladir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libdir="$abs_ladir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir="$lt_sysroot$libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews absdir="$lt_sysroot$libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir="$ladir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews absdir="$abs_ladir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Remove this search path later
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append notinst_path " $abs_ladir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir="$ladir/$objdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews absdir="$abs_ladir/$objdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Remove this search path later
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append notinst_path " $abs_ladir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi # $installed = yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname 'lib' '.la' "$laname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # This library was specified with -dlpreopen.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" = dlpreopen; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$libdir" && test "$linkmode" = prog; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$host" in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # special handling for platforms with PE-DLLs.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *cygwin* | *mingw* | *cegcc* )
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Linker will automatically link against shared library if both
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # static and shared are present. Therefore, ensure we extract
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # symbols from the import library if a shared library is present
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # (otherwise, the dlopen module name will be incorrect). We do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # this by putting the import library name into $newdlprefiles.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We recover the dlopen module name by 'saving' the la file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # name in a special purpose variable, and (later) extracting the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # dlname from the la file.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$dlname"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_tr_sh "$dir/$linklib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdlprefiles " $dir/$linklib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdlprefiles " $dir/$old_library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Keep a list of preopened convenience libraries to check
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # that they are being used correctly in the link pass.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$libdir" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append dlpreconveniencelibs " $dir/$old_library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews * )
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Prefer using a static library (so that no silly _DYNAMIC symbols
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # are required to link).
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$old_library"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdlprefiles " $dir/$old_library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Keep a list of preopened convenience libraries to check
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # that they are being used correctly in the link pass.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$libdir" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append dlpreconveniencelibs " $dir/$old_library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Otherwise, use the dlname, so that lt_dlopen finds it.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test -n "$dlname"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdlprefiles " $dir/$dlname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdlprefiles " $dir/$linklib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi # $pass = dlpreopen
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$libdir"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Link the convenience library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = lib; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$dir/$old_library $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test "$linkmode,$pass" = "prog,link"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs="$dir/$old_library $compile_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_deplibs="$dir/$old_library $finalize_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$lib $deplibs" # used for prog,scan pass
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = prog && test "$pass" != link; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newlib_search_path " $ladir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$lib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews linkalldeplibs=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$link_all_deplibs" != no || test -z "$library_names" ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$build_libtool_libs" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews linkalldeplibs=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_libs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for deplib in $dependency_libs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $deplib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -L*) func_stripname '-L' '' "$deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_resolve_sysroot "$func_stripname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newlib_search_path " $func_resolve_sysroot_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Need to link against all dependency_libs?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkalldeplibs" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Need to hardcode shared library paths
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # or/and link against static libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdependency_libs="$deplib $newdependency_libs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $opt_preserve_dup_deps ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$tmp_libs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $deplib "*) func_append specialdeplibs " $deplib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append tmp_libs " $deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done # for deplib
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi # $linkmode = prog...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode,$pass" = "prog,link"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$library_names" &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews { { test "$prefer_static_libs" = no ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$prefer_static_libs,$installed" = "built,yes"; } ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$old_library"; }; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We need to hardcode the library path
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Make sure the rpath contains only unique directories.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$temp_rpath:" in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *"$absdir:"*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append temp_rpath "$absdir:" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Hardcode the library path.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Skip directories that are in the system default run-time
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # search path.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $sys_lib_dlsearch_path " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $absdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$compile_rpath " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $absdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append compile_rpath " $absdir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $sys_lib_dlsearch_path " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $libdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$finalize_rpath " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $libdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append finalize_rpath " $libdir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi # $linkmode,$pass = prog,link...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$alldeplibs" = yes &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews { test "$deplibs_check_method" = pass_all ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews { test "$build_libtool_libs" = yes &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$library_names"; }; }; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We only need to search for static libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews link_static=no # Whether the deplib will be linked statically
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews use_static_libs=$prefer_static_libs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$use_static_libs" = built && test "$installed" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews use_static_libs=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$library_names" &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews { test "$use_static_libs" = no || test -z "$old_library"; }; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *cygwin* | *mingw* | *cegcc*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # No point in relinking DLLs because paths are not encoded
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append notinst_deplibs " $lib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews need_relink=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$installed" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append notinst_deplibs " $lib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews need_relink=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # This is a shared library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Warn about portability, can't link against -module's on some
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # systems (darwin). Don't bleat about dlopened modules though!
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlopenmodule=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for dlpremoduletest in $dlprefiles; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$dlpremoduletest" = "X$lib"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlopenmodule="$dlpremoduletest"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = prog; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** Warning: Linking the executable $output against the loadable module"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** Warning: Linking the shared library $output against the loadable module"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** $linklib is not portable!"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = lib &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$hardcode_into_libs" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Hardcode the library path.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Skip directories that are in the system default run-time
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # search path.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $sys_lib_dlsearch_path " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $absdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$compile_rpath " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $absdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append compile_rpath " $absdir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $sys_lib_dlsearch_path " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $libdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$finalize_rpath " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $libdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append finalize_rpath " $libdir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$old_archive_from_expsyms_cmds"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # figure out the soname
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews set dummy $library_names
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews realname="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libname=`eval "\\$ECHO \"$libname_spec\""`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # use dlname if we got it. it's perfectly good, no?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$dlname"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews soname="$dlname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test -n "$soname_spec"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # bleh windows
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *cygwin* | mingw* | *cegcc*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $current - $age
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix="-$major"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval soname=\"$soname_spec\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews soname="$realname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Make a new name for the extract_expsyms_cmds to use
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews soroot="$soname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$soroot"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews soname="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname 'lib' '.dll' "$soname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newlib=libimp-$func_stripname_result.a
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If the library has no export list, then create one now
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -f "$output_objdir/$soname-def"; then :
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "extracting exported symbol list from \`$soname'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Create $newlib
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -f "$output_objdir/$newlib"; then :; else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "generating import library for \`$soname'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # make sure the library variables are pointing to the new library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir=$output_objdir
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews linklib=$newlib
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi # test -n "$old_archive_from_expsyms_cmds"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = prog || test "$opt_mode" != relink; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add_shlibpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add_dir=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib_linked=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $hardcode_action in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews immediate | unsupported)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$hardcode_direct" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add="$dir/$linklib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-sysv4*uw2*) add_dir="-L$dir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-unixware7*) add_dir="-L$dir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-darwin* )
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # if the lib is a (non-dlopened) module then we can not
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # link against it, someone is ignoring the earlier warnings
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if /usr/bin/file -L $add 2> /dev/null |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $GREP ": [^:]* bundle" >/dev/null ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$dlopenmodule" != "X$lib"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** Warning: lib $linklib is a module, not a shared library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$old_library" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** And there doesn't seem to be a static archive available"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** The link will probably fail, sorry"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add="$dir/$old_library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test -n "$old_library"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add="$dir/$old_library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test "$hardcode_minus_L" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-sunos*) add_shlibpath="$dir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add_dir="-L$dir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add="-l$name"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test "$hardcode_shlibpath_var" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add_shlibpath="$dir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add="-l$name"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib_linked=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$hardcode_direct" = yes &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$hardcode_direct_absolute" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add="$dir/$linklib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test "$hardcode_minus_L" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add_dir="-L$absdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Try looking first in the location we're being installed to.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$inst_prefix_dir"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $libdir in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [\\/]*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append add_dir " -L$inst_prefix_dir$libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add="-l$name"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test "$hardcode_shlibpath_var" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add_shlibpath="$dir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add="-l$name"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib_linked=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) lib_linked=no ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$lib_linked" != yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_configuration "unsupported hardcode properties"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$add_shlibpath"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case :$compile_shlibpath: in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *":$add_shlibpath:"*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append compile_shlibpath "$add_shlibpath:" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = prog; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$add" && compile_deplibs="$add $compile_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$add_dir" && deplibs="$add_dir $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$add" && deplibs="$add $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$hardcode_direct" != yes &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$hardcode_minus_L" != yes &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$hardcode_shlibpath_var" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case :$finalize_shlibpath: in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *":$libdir:"*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append finalize_shlibpath "$libdir:" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = prog || test "$opt_mode" = relink; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add_shlibpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add_dir=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Finalize command for both is simple: just hardcode it.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$hardcode_direct" = yes &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$hardcode_direct_absolute" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add="$libdir/$linklib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test "$hardcode_minus_L" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add_dir="-L$libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add="-l$name"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test "$hardcode_shlibpath_var" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case :$finalize_shlibpath: in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *":$libdir:"*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append finalize_shlibpath "$libdir:" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add="-l$name"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test "$hardcode_automatic" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$inst_prefix_dir" &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -f "$inst_prefix_dir$libdir/$linklib" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add="$inst_prefix_dir$libdir/$linklib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add="$libdir/$linklib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We cannot seem to hardcode it, guess we'll fake it.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add_dir="-L$libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Try looking first in the location we're being installed to.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$inst_prefix_dir"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $libdir in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [\\/]*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append add_dir " -L$inst_prefix_dir$libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews add="-l$name"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = prog; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$add_dir" && deplibs="$add_dir $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$add" && deplibs="$add $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test "$linkmode" = prog; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Here we assume that one of hardcode_direct or hardcode_minus_L
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # is not unsupported. This is valid on all known static and
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # shared platforms.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$hardcode_direct" != unsupported; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$old_library" && linklib="$old_library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs="$dir/$linklib $compile_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_deplibs="$dir/$linklib $finalize_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs="-l$name -L$dir $compile_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_deplibs="-l$name -L$dir $finalize_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test "$build_libtool_libs" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Not a shared library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$deplibs_check_method" != pass_all; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We're trying link a shared library against a static one
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # but the system doesn't support it.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Just print a warning and add the library to dependency_libs so
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # that the program can be linked against the static library.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** Warning: This system can not link to static lib archive $lib."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** I have the capability to make that library automatically link in when"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** you link to this library. But I can only do this if you have a"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** shared version of the library, which you do not appear to have."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$module" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** But as you try to build a module library, libtool will still create "
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** a static module, that should work as long as the dlopening application"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$global_symbol_pipe"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** However, this would only work if libtool was able to extract symbol"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** not find such a program. So, this module is probably useless."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** \`nm' from GNU binutils and a full rebuild may help."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_old_libs" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_libtool_libs=module
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_old_libs=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_libtool_libs=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$dir/$old_library $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews link_static=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi # link shared/static library?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = lib; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$dependency_libs" &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews { test "$hardcode_into_libs" != yes ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$build_old_libs" = yes ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$link_static" = yes; }; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Extract -R from dependency_libs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews temp_deplibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for libdir in $dependency_libs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $libdir in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -R*) func_stripname '-R' '' "$libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews temp_xrpath=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $xrpath " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $temp_xrpath "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append xrpath " $temp_xrpath";;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append temp_deplibs " $libdir";;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dependency_libs="$temp_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newlib_search_path " $absdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Link against this library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # ... and its dependency_libs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_libs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for deplib in $dependency_libs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdependency_libs="$deplib $newdependency_libs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $deplib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -L*) func_stripname '-L' '' "$deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_resolve_sysroot "$func_stripname_result";;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_resolve_sysroot "$deplib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $opt_preserve_dup_deps ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$tmp_libs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $func_resolve_sysroot_result "*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append specialdeplibs " $func_resolve_sysroot_result" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append tmp_libs " $func_resolve_sysroot_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$link_all_deplibs" != no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Add the search paths of all dependency libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for deplib in $dependency_libs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews path=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $deplib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -L*) path="$deplib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.la)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_resolve_sysroot "$deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplib=$func_resolve_sysroot_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname "$deplib" "" "."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir=$func_dirname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We need an absolute path.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $dir in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews absdir=`cd "$dir" && pwd`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$absdir"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "cannot determine absolute directory name of \`$dir'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews absdir="$dir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $GREP "^installed=no" $deplib > /dev/null; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-darwin*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews depdepl=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$deplibrary_names" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for tmp in $deplibrary_names ; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews depdepl=$tmp
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -f "$absdir/$objdir/$depdepl" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews depdepl="$absdir/$objdir/$depdepl"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$darwin_install_name"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews path=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews path="-L$absdir/$objdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$libdir" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "\`$deplib' is not a valid libtool archive"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$absdir" != "$libdir" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`$deplib' seems to be moved"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews path="-L$absdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $deplibs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $path "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) deplibs="$path $deplibs" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi # link_all_deplibs != no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi # linkmode = lib
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done # for deplib in $libs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" = link; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = "prog"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dependency_libs="$newdependency_libs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" = dlpreopen; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Link the dlpreopened libraries before other libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for deplib in $save_deplibs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$deplib $deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" != dlopen; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$pass" != conv; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Make sure lib_search_path contains only unique directories.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib_search_path=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for dir in $newlib_search_path; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$lib_search_path " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $dir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append lib_search_path " $dir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newlib_search_path=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode,$pass" != "prog,link"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews vars="deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews vars="compile_deplibs finalize_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for var in $vars dependency_libs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Add libraries to $var in reverse order
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval tmp_libs=\"\$$var\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews new_libs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for deplib in $tmp_libs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # FIXME: Pedantically, this is the right thing to do, so
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # that some nasty dependency loop isn't accidentally
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # broken:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews #new_libs="$deplib $new_libs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Pragmatically, this seems to cause very few problems in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # practice:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $deplib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -L*) new_libs="$deplib $new_libs" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -R*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # And here is the reason: when a library appears more
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # than once as an explicit dependence of a library, or
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # is implicitly linked in more than once by the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # compiler, it is considered special, and multiple
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # occurrences thereof are not removed. Compare this
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # with having the same library being listed as a
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # dependency of multiple other libraries: in this case,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # we know (pedantically, we assume) the library does not
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # need to be listed more than once, so we keep only the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # last copy. This is not always right, but it is rare
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # enough that we require users that really mean to play
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # such unportable linking tricks to link the library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # using -Wl,-lname, so that libtool does not consider it
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # for duplicate removal.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $specialdeplibs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $deplib "*) new_libs="$deplib $new_libs" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $new_libs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $deplib "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) new_libs="$deplib $new_libs" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_libs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for deplib in $new_libs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $deplib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -L*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $tmp_libs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $deplib "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append tmp_libs " $deplib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append tmp_libs " $deplib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval $var=\"$tmp_libs\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done # for var
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Last step: remove runtime libs from dependency_libs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # (they stay in deplibs)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_libs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for i in $dependency_libs ; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $predeps $postdeps $compiler_lib_search_path " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $i "*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews i=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$i" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append tmp_libs " $i"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dependency_libs=$tmp_libs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done # for pass
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = prog; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlfiles="$newdlfiles"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$linkmode" = prog || test "$linkmode" = lib; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlprefiles="$newdlprefiles"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $linkmode in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldlib)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-dlopen' is ignored for archives"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $deplibs" in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *\ -l* | *\ -L*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-l' and \`-L' are ignored for archives" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$rpath" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-rpath' is ignored for archives"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$xrpath" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-R' is ignored for archives"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$vinfo" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-version-info/-version-number' is ignored for archives"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$release" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-release' is ignored for archives"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$export_symbols$export_symbols_regex" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-export-symbols' is ignored for archives"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Now set the variables for building old libraries.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_libtool_libs=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldlibs="$output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append objs "$old_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Make sure we only generate libraries of the form `libNAME.la'.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $outputname in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname 'lib' '.la' "$outputname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval shared_ext=\"$shrext_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval libname=\"$libname_spec\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$module" = no && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "libtool library \`$output' must begin with \`lib'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$need_lib_prefix" != no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Add the "lib" prefix for modules if required
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '' '.la' "$outputname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval shared_ext=\"$shrext_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval libname=\"$libname_spec\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '' '.la' "$outputname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libname=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$objs"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$deplibs_check_method" != pass_all; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** objects $objs is not portable!"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append libobjs " $objs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$dlself" != no && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-dlopen self' is ignored for libtool libraries"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews set dummy $rpath
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$#" -gt 1 && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "ignoring multiple \`-rpath's for a libtool library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews install_libdir="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldlibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$rpath"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_libtool_libs" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Building a libtool convenience library.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Some compilers have problems with a `.al' extension so
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # convenience libraries should have the same extension an
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # archive normally would.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldlibs="$output_objdir/$libname.$libext $oldlibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_libtool_libs=convenience
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_old_libs=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$vinfo" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$release" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-release' is ignored for convenience libraries"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Parse the version information argument.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_ifs="$IFS"; IFS=':'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews set dummy $vinfo 0 0 0
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS="$save_ifs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$7" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "too many parameters to \`-version-info'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # convert absolute version numbers to libtool ages
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # this retains compatibility with .la files and attempts
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # to make the code below a bit more comprehensible
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $vinfo_number in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews yes)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews number_major="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews number_minor="$2"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews number_revision="$3"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews #
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # There are really only two kinds -- those that
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # use the current revision as the major version
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # and those that subtract age and use age as
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # a minor version. But, then there is irix
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # which has an extra 1 added just for fun
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews #
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $version_type in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # correct linux to gnu/linux during the next big refactor
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin|linux|osf|windows|none)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $number_major + $number_minor
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews current=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews age="$number_minor"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews revision="$number_revision"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews freebsd-aout|freebsd-elf|qnx|sunos)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews current="$number_major"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews revision="$number_minor"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews age="0"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews irix|nonstopux)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $number_major + $number_minor
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews current=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews age="$number_minor"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews revision="$number_minor"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_irix_increment=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews no)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews current="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews revision="$2"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews age="$3"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Check that each of the things are valid numbers.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $current in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews 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]) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error "CURRENT \`$current' must be a nonnegative integer"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "\`$vinfo' is not valid version information"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $revision in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews 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]) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error "REVISION \`$revision' must be a nonnegative integer"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "\`$vinfo' is not valid version information"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $age in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews 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]) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error "AGE \`$age' must be a nonnegative integer"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "\`$vinfo' is not valid version information"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$age" -gt "$current"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_error "AGE \`$age' is greater than the current interface number \`$current'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "\`$vinfo' is not valid version information"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Calculate the version variables.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews verstring=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $version_type in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews none) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Like Linux, but with the current version available in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # verstring for coding it into the library header
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $current - $age
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=.$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix="$major.$age.$revision"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Darwin ld doesn't like 0 for these options...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $current + 1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews minor_current=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews freebsd-aout)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=".$current"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix=".$current.$revision";
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews freebsd-elf)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=".$current"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix=".$current"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews irix | nonstopux)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$lt_irix_increment" = "Xno"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $current - $age
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $current - $age + 1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $version_type in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews nonstopux) verstring_prefix=nonstopux ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) verstring_prefix=sgi ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews verstring="$verstring_prefix$major.$revision"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Add in all the interfaces that we are compatible with.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews loop=$revision
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while test "$loop" -ne 0; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $revision - $loop
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews iface=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $loop - 1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews loop=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews verstring="$verstring_prefix$major.$iface:$verstring"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Before this point, $major must not contain `.'.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=.$major
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix="$major.$revision"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews linux) # correct to gnu/linux during the next big refactor
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $current - $age
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=.$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix="$major.$age.$revision"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews osf)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $current - $age
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=.$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix=".$current.$age.$revision"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews verstring="$current.$age.$revision"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Add in all the interfaces that we are compatible with.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews loop=$age
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while test "$loop" -ne 0; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $current - $loop
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews iface=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $loop - 1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews loop=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews verstring="$verstring:${iface}.0"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Make executables depend on our current version.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append verstring ":${current}.0"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews qnx)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=".$current"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix=".$current"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews sunos)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=".$current"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix=".$current.$revision"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews windows)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Use '-' rather than '.', since we only want one
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # extension on DOS 8.3 filesystems.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $current - $age
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix="-$major"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_configuration "unknown library version type \`$version_type'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Clear the version info if we defaulted, and they specified a release.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$vinfo" && test -n "$release"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $version_type in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews darwin)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # we can't check for "0.0" in archive_cmds due to quoting
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # problems, so we reset it completely
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews verstring=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews verstring="0.0"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$need_version" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix=".0.0"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Remove version info from name if versioning should be avoided
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$avoid_version" = yes && test "$need_version" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews verstring=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Check to see if the archive will have undefined symbols.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$allow_undefined" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$allow_undefined_flag" = unsupported; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "undefined symbols not allowed in $host shared libraries"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_libtool_libs=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_old_libs=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Don't allow undefined symbols.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews allow_undefined_flag="$no_undefined_flag"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_generate_dlsyms "$libname" "$libname" "yes"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append libobjs " $symfileobj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "X$libobjs" = "X " && libobjs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$opt_mode" != relink; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Remove our outputs, but don't remove object files since they
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # may have been created when compiling PIC objects.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews removelist=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tempremovelist=`$ECHO "$output_objdir/*"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for p in $tempremovelist; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $p in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.$objext | *.gcno)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$precious_files_regex" != "X"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append removelist " $p"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$removelist" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "${RM}r \$removelist"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Now set the variables for building old libraries.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append oldlibs " $output_objdir/$libname.$libext"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Transform .lo files to .o files.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Eliminate all temporary directories.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews #for path in $notinst_path; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews #done
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$xrpath"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If the user specified any rpath flags, then add them.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews temp_xrpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for libdir in $xrpath; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_replace_sysroot "$libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append temp_xrpath " -R$func_replace_sysroot_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$finalize_rpath " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $libdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append finalize_rpath " $libdir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dependency_libs="$temp_xrpath $dependency_libs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Make sure dlfiles contains only unique files that won't be dlpreopened
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews old_dlfiles="$dlfiles"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlfiles=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for lib in $old_dlfiles; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $dlprefiles $dlfiles " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $lib "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append dlfiles " $lib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Make sure dlprefiles contains only unique files
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews old_dlprefiles="$dlprefiles"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlprefiles=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for lib in $old_dlprefiles; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$dlprefiles " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $lib "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append dlprefiles " $lib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_libtool_libs" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$rpath"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # these systems don't actually have a c library (as such)!
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-rhapsody* | *-*-darwin1.[012])
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Rhapsody C library is in the System framework
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append deplibs " System.ltframework"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-netbsd*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Don't link with libc until the a.out ld.so is fixed.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do not include libc due to us having libc/libc_r.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-sco3.2v5* | *-*-sco5v6*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Causes problems with __ctype
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Compiler inserts libc in the correct place for threads to work
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Add libc to deplibs on all other systems if necessary.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_libtool_need_lc" = "yes"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append deplibs " -lc"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Transform deplibs into only deplibs that can be linked in shared.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name_save=$name
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libname_save=$libname
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews release_save=$release
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix_save=$versuffix
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major_save=$major
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # I'm not sure if I'm treating the release correctly. I think
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # release should show up in the -l (ie -lgmp5) so we don't want to
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # add it in twice. Is that correct?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews release=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdeplibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews droppeddeps=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $deplibs_check_method in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews pass_all)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Don't check for shared/static. Everything works.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # This might be a little naive. We might want to check
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # whether the library exists or not. But this is on
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # osf3 & osf4 and I'm not really sure... Just
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # implementing what was already the behavior.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdeplibs=$deplibs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test_compile)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # This code stresses the "libraries are programs" paradigm to its
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # limits. Maybe even breaks it. We compile a program, linking it
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # against the deplibs as a proxy for the library. Then we can check
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # whether they linked in statically or dynamically with ldd.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $RM conftest.c
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cat > conftest.c <<EOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews int main() { return 0; }
63dd46733010bb9622810faa17d88c3e3c28b730Mark AndrewsEOF
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $RM conftest
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ldd_output=`ldd conftest`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for i in $deplibs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $i in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -l*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname -l '' "$i"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $predeps $postdeps " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $i "*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdeplibs " $i"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews i=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$i" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libname=`eval "\\$ECHO \"$libname_spec\""`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews set dummy $deplib_matches; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplib_match=$1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdeplibs " $i"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews droppeddeps=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** Warning: dynamic linker does not accept needed library $i."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** I have the capability to make that library automatically link in when"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** you link to this library. But I can only do this if you have a"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** shared version of the library, which I believe you do not have"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** because a test_compile did reveal that the linker did not use it for"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** its dynamic dependency list that programs get resolved with at runtime."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdeplibs " $i"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Error occurred in the first compile. Let's try to salvage
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # the situation: Compile a separate program for each library.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for i in $deplibs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $i in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -l*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname -l '' "$i"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $RM conftest
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ldd_output=`ldd conftest`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $predeps $postdeps " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $i "*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdeplibs " $i"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews i=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$i" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libname=`eval "\\$ECHO \"$libname_spec\""`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews set dummy $deplib_matches; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplib_match=$1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdeplibs " $i"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews droppeddeps=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** Warning: dynamic linker does not accept needed library $i."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** I have the capability to make that library automatically link in when"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** you link to this library. But I can only do this if you have a"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** shared version of the library, which you do not appear to have"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** because a test_compile did reveal that the linker did not use this one"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** as a dynamic dependency that programs can get resolved with at runtime."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews droppeddeps=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** make it link in! You will probably need to install it or some"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** library that it depends on before this library will be fully"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** functional. Installing it before continuing would be even better."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdeplibs " $i"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file_magic*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews set dummy $deplibs_check_method; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for a_deplib in $deplibs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $a_deplib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -l*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname -l '' "$a_deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $predeps $postdeps " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $a_deplib "*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdeplibs " $a_deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews a_deplib=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$a_deplib" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libname=`eval "\\$ECHO \"$libname_spec\""`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$file_magic_glob"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libnameglob=$libname
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$want_nocaseglob" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shopt -s nocaseglob
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $nocaseglob
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for potent_lib in $potential_libs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Follow soft links.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if ls -lLd "$potent_lib" 2>/dev/null |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $GREP " -> " >/dev/null; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews continue
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The statement above tries to avoid entering an
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # endless loop below, in case of cyclic links.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We might still enter an endless loop, since a link
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # loop can be closed while we follow links,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # but so what?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews potlib="$potent_lib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while test -h "$potlib" 2>/dev/null; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $potliblink in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $SED -e 10q |
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $EGREP "$file_magic_regex" > /dev/null; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdeplibs " $a_deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews a_deplib=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break 2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$a_deplib" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews droppeddeps=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** I have the capability to make that library automatically link in when"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** you link to this library. But I can only do this if you have a"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** shared version of the library, which you do not appear to have"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** because I did check the linker path looking for a file starting"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$potlib" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** with $libname and none of the candidates passed a file format test"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** using a file magic. Last file checked: $potlib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Add a -L argument.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdeplibs " $a_deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done # Gone through all deplibs.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews match_pattern*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews set dummy $deplibs_check_method; shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for a_deplib in $deplibs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $a_deplib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -l*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname -l '' "$a_deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $predeps $postdeps " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $a_deplib "*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdeplibs " $a_deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews a_deplib=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$a_deplib" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libname=`eval "\\$ECHO \"$libname_spec\""`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for potent_lib in $potential_libs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews potlib="$potent_lib" # see symlink-check above in file_magic test
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $EGREP "$match_pattern_regex" > /dev/null; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdeplibs " $a_deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews a_deplib=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break 2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$a_deplib" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews droppeddeps=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** I have the capability to make that library automatically link in when"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** you link to this library. But I can only do this if you have a"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** shared version of the library, which you do not appear to have"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** because I did check the linker path looking for a file starting"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$potlib" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** with $libname and none of the candidates passed a file format test"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** using a regex pattern. Last file checked: $potlib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Add a -L argument.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdeplibs " $a_deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done # Gone through all deplibs.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews none | unknown | *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdeplibs=""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for i in $predeps $postdeps ; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # can't use Xsed below, because $i might contain '/'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $tmp_deplibs in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *[!\ \ ]*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$deplibs_check_method" = "Xnone"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** Warning: inter-library dependencies are not supported in this platform."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** Warning: inter-library dependencies are not known to be supported."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** All declared inter-library dependencies are being dropped."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews droppeddeps=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews versuffix=$versuffix_save
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews major=$major_save
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews release=$release_save
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libname=$libname_save
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name=$name_save
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-rhapsody* | *-*-darwin1.[012])
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # On Rhapsody replace the C library with the System framework
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$droppeddeps" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$module" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** Warning: libtool could not satisfy all declared inter-library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** a static module, that should work as long as the dlopening"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** application is linked with the -dlopen flag."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$global_symbol_pipe"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** However, this would only work if libtool was able to extract symbol"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** not find such a program. So, this module is probably useless."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** \`nm' from GNU binutils and a full rebuild may help."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_old_libs" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldlibs="$output_objdir/$libname.$libext"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_libtool_libs=module
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_old_libs=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_libtool_libs=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** The inter-library dependencies that have been dropped here will be"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** automatically added whenever a program is linked with this library"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** or is declared to -dlopen it."
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$allow_undefined" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** Since this library must not contain undefined symbols,"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** because either the platform does not support them or"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** it was explicitly requested with -no-undefined,"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "*** libtool will only create a static version of it."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_old_libs" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldlibs="$output_objdir/$libname.$libext"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_libtool_libs=module
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_old_libs=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_libtool_libs=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Done checking deplibs!
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs=$newdeplibs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Time to change all our "foo.ltframework" stuff back to "-framework foo"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-darwin*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # move library search paths that coincide with paths to not yet
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # installed libraries to the beginning of the library search list
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews new_libs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for path in $notinst_path; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $new_libs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" -L$path/$objdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $deplibs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" -L$path/$objdir "*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append new_libs " -L$path/$objdir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for deplib in $deplibs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $deplib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -L*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $new_libs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $deplib "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append new_libs " $deplib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append new_libs " $deplib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$new_libs"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # All the library-specific variables (install_libdir is set above).
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews library_names=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews old_library=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlname=
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Test again, we may have decided not to build it any more
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_libtool_libs" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Remove ${wl} instances when linking with ld.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # FIXME: should test the right _cmds variable.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $archive_cmds in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *\$LD\ *) wl= ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$hardcode_into_libs" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Hardcode the library paths
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews hardcode_libdirs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dep_rpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews rpath="$finalize_rpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for libdir in $rpath; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$hardcode_libdir_flag_spec"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$hardcode_libdir_separator"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_replace_sysroot "$libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libdir=$func_replace_sysroot_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$hardcode_libdirs"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews hardcode_libdirs="$libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Just accumulate the unique libdirs.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval flag=\"$hardcode_libdir_flag_spec\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append dep_rpath " $flag"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test -n "$runpath_var"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$perm_rpath " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $libdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append perm_rpath " $libdir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Substitute the hardcoded libdirs into the rpath.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$hardcode_libdir_separator" &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$hardcode_libdirs"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libdir="$hardcode_libdirs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$runpath_var" && test -n "$perm_rpath"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We should set the runpath_var.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews rpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for dir in $perm_rpath; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append rpath "$dir:"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shlibpath="$finalize_shlibpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$shlibpath"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Get the real and link names of the library.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval shared_ext=\"$shrext_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval library_names=\"$library_names_spec\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews set dummy $library_names
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews realname="$1"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$soname_spec"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval soname=\"$soname_spec\"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews soname="$realname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$dlname"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlname=$soname
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lib="$output_objdir/$realname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews linknames=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for link
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append linknames " $link"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Use standard objects if they are pic
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "X$libobjs" = "X " && libobjs=
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews delfiles=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$export_symbols" && test -n "$include_expsyms"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export_symbols="$output_objdir/$libname.uexp"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append delfiles " $export_symbols"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews orig_export_symbols=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host_os in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cygwin* | mingw* | cegcc*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # exporting using user supplied symfile
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # and it's NOT already a .def file. Must figure out
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # which of the given symbols are data symbols and tag
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # them as such. So, trigger use of export_symbols_cmds.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # export_symbols gets reassigned inside the "prepare
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # the list of exported symbols" if statement, so the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # include_expsyms logic still works.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews orig_export_symbols="$export_symbols"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export_symbols=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews always_export_symbols=yes
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews fi
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Prepare the list of exported symbols
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$export_symbols"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "generating symbol list for \`$libname.la'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export_symbols="$output_objdir/$libname.exp"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $RM $export_symbols
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cmds=$export_symbols_cmds
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_ifs="$IFS"; IFS='~'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for cmd1 in $cmds; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS="$save_ifs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Take the normal branch if the nm_file_list_spec branch
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # doesn't work or if tool conversion is not needed.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $nm_file_list_spec~$to_tool_file_cmd in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews try_normal_branch=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval cmd=\"$cmd1\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_len " $cmd"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews len=$func_len_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews try_normal_branch=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$try_normal_branch" = yes \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews && { test "$len" -lt "$max_cmd_len" \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews || test "$max_cmd_len" -le -1; }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$cmd" 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews skipped_export=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test -n "$nm_file_list_spec"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output_la=$func_basename_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_libobjs=$libobjs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_output=$output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output=${output_objdir}/${output_la}.nm
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libobjs=$nm_file_list_spec$func_to_tool_file_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append delfiles " $output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "creating $NM input file list: $output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for obj in $save_libobjs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$obj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "$func_to_tool_file_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done > "$output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval cmd=\"$cmd1\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$cmd" 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output=$save_output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libobjs=$save_libobjs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews skipped_export=false
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The command line is too long to execute in one step.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "using reloadable object file for export list..."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews skipped_export=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Break out early, otherwise skipped_export may be
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # set to false by a later but shorter cmd.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS="$save_ifs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$export_symbols" && test -n "$include_expsyms"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_export_symbols="$export_symbols"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews fi
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The given exports_symbols file has to be filtered, so filter it.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # FIXME: $output_objdir/$libname.filter potentially contains lots of
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # 's' commands which not all seds can handle. GNU sed should be fine
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # though. Also, the filter scales superlinearly with the number of
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # global variables. join(1) would be nice here, but unfortunately
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # isn't a blessed tool.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append delfiles " $export_symbols $output_objdir/$libname.filter"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export_symbols=$output_objdir/$libname.def
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_deplibs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for test_deplib in $deplibs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $convenience " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $test_deplib "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append tmp_deplibs " $test_deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews deplibs="$tmp_deplibs"
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$convenience"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$whole_archive_flag_spec" &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$compiler_needs_object" = yes &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$libobjs"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # extract the archives, so we have objects to list.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # TODO: could optimize this to just extract one archive.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews whole_archive_flag_spec=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$whole_archive_flag_spec"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_libobjs=$libobjs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "X$libobjs" = "X " && libobjs=
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews gentop="$output_objdir/${outputname}x"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append generated " $gentop"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_extract_archives $gentop $convenience
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append libobjs " $func_extract_archives_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "X$libobjs" = "X " && libobjs=
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval flag=\"$thread_safe_flag_spec\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append linker_flags " $flag"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Make a backup of the uninstalled library when relinking
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$opt_mode" = relink; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do each of the archive commands.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$module" = yes && test -n "$module_cmds" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval test_cmds=\"$module_expsym_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cmds=$module_expsym_cmds
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval test_cmds=\"$module_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cmds=$module_cmds
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval test_cmds=\"$archive_expsym_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cmds=$archive_expsym_cmds
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval test_cmds=\"$archive_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cmds=$archive_cmds
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$skipped_export" != "X:" &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_len " $test_cmds" &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews len=$func_len_result &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews :
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The command line is too long to link in one step, link piecewise
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # or, if using GNU ld and skipped_export is not :, use a linker
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # script.
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Save the value of $output and $libobjs because we want to
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # use them later. If we have whole_archive_flag_spec, we
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # want to use save_libobjs as it was before
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # whole_archive_flag_spec was expanded, because we can't
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # assume the linker understands whole_archive_flag_spec.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # This may have to be revisited, in case too many
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # convenience libraries get linked in and end up exceeding
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # the spec.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_libobjs=$libobjs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_output=$output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output_la=$func_basename_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Clear the reloadable object creation command queue and
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # initialize k to one.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test_cmds=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews concat_cmds=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews objlist=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews last_robj=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews k=1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output=${output_objdir}/${output_la}.lnkscript
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "creating GNU ld script: $output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo 'INPUT (' > $output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for obj in $save_libobjs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$obj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "$func_to_tool_file_result" >> $output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo ')' >> $output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append delfiles " $output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output=$func_to_tool_file_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output=${output_objdir}/${output_la}.lnk
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "creating linker input file list: $output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews : > $output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews set x $save_libobjs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews firstobj=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$compiler_needs_object" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews firstobj="$1 "
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews shift
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for obj
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$obj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "$func_to_tool_file_result" >> $output
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append delfiles " $output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$save_libobjs"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "creating reloadable object files..."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output=$output_objdir/$output_la-${k}.$objext
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval test_cmds=\"$reload_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_len " $test_cmds"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews len0=$func_len_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews len=$len0
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Loop over the list of objects to be linked.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for obj in $save_libobjs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_len " $obj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $len + $func_len_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews len=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$objlist" = X ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$len" -lt "$max_cmd_len"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append objlist " $obj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The command $test_cmds is almost too long, add a
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # command to the queue.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$k" -eq 1 ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The first file doesn't have a previous command to add.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews reload_objs=$objlist
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval concat_cmds=\"$reload_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # All subsequent reloadable object files will link in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # the last one created.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews reload_objs="$objlist $last_robj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews last_robj=$output_objdir/$output_la-${k}.$objext
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $k + 1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews k=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output=$output_objdir/$output_la-${k}.$objext
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews objlist=" $obj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_len " $last_robj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $len0 + $func_len_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews len=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Handle the remaining objects by creating one last
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # reloadable object file. All subsequent reloadable object
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # files will link in the last one created.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$concat_cmds" || concat_cmds=$concat_cmds~
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews reload_objs="$objlist $last_robj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$last_robj"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append delfiles " $output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if ${skipped_export-false}; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "generating symbol list for \`$libname.la'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export_symbols="$output_objdir/$libname.exp"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $RM $export_symbols
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libobjs=$output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Append the command to create the export file.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$concat_cmds" || concat_cmds=$concat_cmds~
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$last_robj"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$save_libobjs" &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "creating a temporary reloadable object file: $output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Loop through the commands generated above and execute them.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_ifs="$IFS"; IFS='~'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for cmd in $concat_cmds; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS="$save_ifs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_silent || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_expand "$cmd"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "func_echo $func_quote_for_expand_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || eval "$cmd" || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_exit=$?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Restore the uninstalled library and exit
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$opt_mode" = relink; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ( cd "$output_objdir" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $RM "${realname}T" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $MV "${realname}U" "$realname" )
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $lt_exit
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS="$save_ifs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$export_symbols_regex" && ${skipped_export-false}; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if ${skipped_export-false}; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$export_symbols" && test -n "$include_expsyms"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tmp_export_symbols="$export_symbols"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$orig_export_symbols"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The given exports_symbols file has to be filtered, so filter it.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # FIXME: $output_objdir/$libname.filter potentially contains lots of
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # 's' commands which not all seds can handle. GNU sed should be fine
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # though. Also, the filter scales superlinearly with the number of
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # global variables. join(1) would be nice here, but unfortunately
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # isn't a blessed tool.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append delfiles " $export_symbols $output_objdir/$libname.filter"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews export_symbols=$output_objdir/$libname.def
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libobjs=$output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Restore the value of output.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output=$save_output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "X$libobjs" = "X " && libobjs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Expand the library linking commands again to reset the
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # value of $libobjs for piecewise linking.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do each of the archive commands.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$module" = yes && test -n "$module_cmds" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cmds=$module_expsym_cmds
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cmds=$module_cmds
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cmds=$archive_expsym_cmds
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cmds=$archive_cmds
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$delfiles"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Append the command to remove temporary files to $cmds.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval cmds=\"\$cmds~\$RM $delfiles\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Add any objects from preloaded convenience libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$dlprefiles"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews gentop="$output_objdir/${outputname}x"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append generated " $gentop"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_extract_archives $gentop $dlprefiles
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append libobjs " $func_extract_archives_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "X$libobjs" = "X " && libobjs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_ifs="$IFS"; IFS='~'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for cmd in $cmds; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS="$save_ifs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval cmd=\"$cmd\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_silent || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_expand "$cmd"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval "func_echo $func_quote_for_expand_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || eval "$cmd" || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews lt_exit=$?
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Restore the uninstalled library and exit
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$opt_mode" = relink; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ( cd "$output_objdir" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $RM "${realname}T" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $MV "${realname}U" "$realname" )
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $lt_exit
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews IFS="$save_ifs"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Restore the uninstalled library and exit
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$opt_mode" = relink; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$convenience"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$whole_archive_flag_spec"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval '${RM}r "$gentop"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $EXIT_SUCCESS
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Create links to the real library.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for linkname in $linknames; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$realname" != "$linkname"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley done
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If -module or -export-dynamic was specified, set the dlname.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$module" = yes || test "$export_dynamic" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # On all known operating systems, these are identical.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlname="$soname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews obj)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-dlopen' is ignored for objects"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $deplibs" in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *\ -l* | *\ -L*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-l' and \`-L' are ignored for objects" ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$rpath" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-rpath' is ignored for objects"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$xrpath" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-R' is ignored for objects"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$vinfo" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-version-info' is ignored for objects"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$release" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-release' is ignored for objects"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $output in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.lo)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$objs$old_deplibs" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "cannot build library object \`$output' from non-libtool objects"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libobj=$output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_lo2o "$libobj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews obj=$func_lo2o_result
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libobj=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews obj="$output"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Delete the old objects.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $RM $obj $libobj
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Objects from convenience libraries. This assumes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # single-version convenience libraries. Whenever we create
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # different ones for PIC/non-PIC, this we'll have to duplicate
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # the extraction.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews reload_conv_objs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews gentop=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # reload_cmds runs $LD directly, so let us get rid of
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # -Wl from whole_archive_flag_spec and hope we can get by with
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # turning comma into space..
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews wl=
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$convenience"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$whole_archive_flag_spec"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews gentop="$output_objdir/${obj}x"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append generated " $gentop"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_extract_archives $gentop $convenience
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews reload_conv_objs="$reload_objs $func_extract_archives_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If we're not building shared, we need to use non_pic_objs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Create the old-style object.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output="$obj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_execute_cmds "$reload_cmds" 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Exit if we aren't doing a library object file.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$libobj"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$gentop"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval '${RM}r "$gentop"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $EXIT_SUCCESS
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_libtool_libs" != yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$gentop"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval '${RM}r "$gentop"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Create an invalid libtool object if no PIC, so that we don't
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # accidentally link it into a program.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # $show "echo timestamp > $libobj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $EXIT_SUCCESS
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$pic_flag" || test "$pic_mode" != default; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Only do commands if we really have different PIC objects.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews reload_objs="$libobjs $reload_conv_objs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output="$libobj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_execute_cmds "$reload_cmds" 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$gentop"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval '${RM}r "$gentop"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $EXIT_SUCCESS
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews prog)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *cygwin*) func_stripname '' '.exe' "$output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output=$func_stripname_result.exe;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$vinfo" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-version-info' is ignored for programs"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$release" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`-release' is ignored for programs"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$preload" = yes \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews && test "$dlopen_support" = unknown \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews && test "$dlopen_self" = unknown \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews && test "$dlopen_self_static" = unknown && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-rhapsody* | *-*-darwin1.[012])
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # On Rhapsody replace the C library is the System framework
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-darwin*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Don't allow lazy linking, it breaks C++ global constructors
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # But is supposedly fixed on 10.4 or later (yay!).
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$tagname" = CXX ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews 10.[0123])
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compile_command " ${wl}-bind_at_load"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append finalize_command " ${wl}-bind_at_load"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Time to change all our "foo.ltframework" stuff back to "-framework foo"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # move library search paths that coincide with paths to not yet
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # installed libraries to the beginning of the library search list
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews new_libs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for path in $notinst_path; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $new_libs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" -L$path/$objdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $compile_deplibs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" -L$path/$objdir "*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append new_libs " -L$path/$objdir" ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for deplib in $compile_deplibs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $deplib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -L*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $new_libs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $deplib "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append new_libs " $deplib" ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append new_libs " $deplib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_deplibs="$new_libs"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append compile_command " $compile_deplibs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append finalize_command " $finalize_deplibs"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$rpath$xrpath"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If the user specified any rpath flags, then add them.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for libdir in $rpath $xrpath; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # This is the magic to use -rpath.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$finalize_rpath " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $libdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append finalize_rpath " $libdir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Now hardcode the library paths
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews rpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews hardcode_libdirs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for libdir in $compile_rpath $finalize_rpath; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$hardcode_libdir_flag_spec"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$hardcode_libdir_separator"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$hardcode_libdirs"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews hardcode_libdirs="$libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Just accumulate the unique libdirs.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval flag=\"$hardcode_libdir_flag_spec\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append rpath " $flag"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test -n "$runpath_var"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$perm_rpath " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $libdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append perm_rpath " $libdir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case :$dllsearchpath: in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *":$libdir:"*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ::) dllsearchpath=$libdir;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append dllsearchpath ":$libdir";;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case :$dllsearchpath: in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *":$testbindir:"*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ::) dllsearchpath=$testbindir;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append dllsearchpath ":$testbindir";;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Substitute the hardcoded libdirs into the rpath.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$hardcode_libdir_separator" &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$hardcode_libdirs"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libdir="$hardcode_libdirs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval rpath=\" $hardcode_libdir_flag_spec\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_rpath="$rpath"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews rpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews hardcode_libdirs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for libdir in $finalize_rpath; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$hardcode_libdir_flag_spec"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$hardcode_libdir_separator"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$hardcode_libdirs"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews hardcode_libdirs="$libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Just accumulate the unique libdirs.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval flag=\"$hardcode_libdir_flag_spec\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append rpath " $flag"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test -n "$runpath_var"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$finalize_perm_rpath " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $libdir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append finalize_perm_rpath " $libdir" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Substitute the hardcoded libdirs into the rpath.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$hardcode_libdir_separator" &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$hardcode_libdirs"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews libdir="$hardcode_libdirs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval rpath=\" $hardcode_libdir_flag_spec\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_rpath="$rpath"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$libobjs" && test "$build_old_libs" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Transform all the library objects into standard objects.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # template prelinking step
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$prelink_cmds"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_execute_cmds "$prelink_cmds" 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews wrappers_required=yes
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *cegcc* | *mingw32ce*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews wrappers_required=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *cygwin* | *mingw* )
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_libtool_libs" != yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews wrappers_required=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews wrappers_required=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$wrappers_required" = no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Replace the output file specification.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews link_command="$compile_command$compile_rpath"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We have no uninstalled library dependencies, so finalize right now.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit_status=0
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$link_command" 'exit_status=$?'
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$postlink_cmds"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_execute_cmds "$postlink_cmds" 'exit $?'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Delete the generated files.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -f "$output_objdir/${outputname}S.${objext}"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $exit_status
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$compile_shlibpath$finalize_shlibpath"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$finalize_shlibpath"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_var=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_var=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$runpath_var"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$perm_rpath"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We should set the runpath_var.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews rpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for dir in $perm_rpath; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append rpath "$dir:"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$finalize_perm_rpath"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We should set the runpath_var.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews rpath=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for dir in $finalize_perm_rpath; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append rpath "$dir:"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$no_install" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # We don't need to create a wrapper script.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews link_command="$compile_var$compile_command$compile_rpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Replace the output file specification.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Delete the old output file.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $RM $output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Link the executable and exit
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$link_command" 'exit $?'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$postlink_cmds"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_execute_cmds "$postlink_cmds" 'exit $?'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews exit $EXIT_SUCCESS
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$hardcode_action" = relink; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Fast installation is not supported
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews link_command="$compile_var$compile_command$compile_rpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command="$finalize_var$finalize_command$finalize_rpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "this platform does not like uninstalled shared libraries"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_warning "\`$output' will be relinked during installation"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$fast_install" != no; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews link_command="$finalize_var$compile_command$finalize_rpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$fast_install" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # fast_install is set to needless
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews link_command="$compile_var$compile_command$compile_rpath"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command="$finalize_var$finalize_command$finalize_rpath"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Replace the output file specification.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Delete the old output files.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$link_command" 'exit $?'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$postlink_cmds"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$output_objdir/$outputname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_execute_cmds "$postlink_cmds" 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Now create the wrapper script.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "creating $output"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Quote the relink command for shipping.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$relink_command"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Preserve any variables that may affect compiler behavior
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for var in $variables_saved_for_relink; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if eval test -z \"\${$var+set}\"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif eval var_value=\$$var; test -z "$var_value"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command="$var=; export $var; $relink_command"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$var_value"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command="(cd `pwd`; $relink_command)"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Only actually do things if not in dry run mode.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # win32 will think the script is a binary if it has
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # a .exe suffix, so we strip it off here.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $output in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.exe) func_stripname '' '.exe' "$output"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output=$func_stripname_result ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # test for cygwin because mv fails w/o .exe extensions
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *cygwin*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exeext=.exe
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '' '.exe' "$outputname"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews outputname=$func_stripname_result ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) exeext= ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *cygwin* | *mingw* )
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname_and_basename "$output" "" "."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output_name=$func_basename_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output_path=$func_dirname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cwrappersource="$output_path/$objdir/lt-$output_name.c"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cwrapper="$output_path/$output_name.exe"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $RM $cwrappersource $cwrapper
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_emit_cwrapperexe_src > $cwrappersource
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # The wrapper executable is built using the $host compiler,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # because it contains $host paths and files. If cross-
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # compiling, it, like the target executable, must be
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # executed on the $host or under an emulation environment.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $STRIP $cwrapper
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Now, create the wrapper script for func_source use:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_ltwrapper_scriptname $cwrapper
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $RM $func_ltwrapper_scriptname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # note: this script will not be executed, so do not chmod.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "x$build" = "x$host" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_emit_wrapper no > $func_ltwrapper_scriptname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews * )
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $RM $output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_emit_wrapper no > $output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews chmod +x $output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $EXIT_SUCCESS
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # See if we need to build an old-fashioned archive.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for oldlib in $oldlibs; do
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_libtool_libs" = convenience; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldobjs="$libobjs_save $symfileobj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews addlibs="$convenience"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_libtool_libs=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$build_libtool_libs" = module; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldobjs="$libobjs_save"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews build_libtool_libs=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldobjs="$old_deplibs $non_pic_objects"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$preload" = yes && test -f "$symfileobj"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append oldobjs " $symfileobj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews addlibs="$old_convenience"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$addlibs"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews gentop="$output_objdir/${outputname}x"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append generated " $gentop"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_extract_archives $gentop $addlibs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append oldobjs " $func_extract_archives_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do each command in the archive commands.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cmds=$old_archive_from_new_cmds
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Add any objects from preloaded convenience libraries
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$dlprefiles"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews gentop="$output_objdir/${outputname}x"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append generated " $gentop"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_extract_archives $gentop $dlprefiles
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append oldobjs " $func_extract_archives_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # POSIX demands no paths to be encoded in archives. We have
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # to avoid creating archives with duplicate basenames if we
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # might have to extract them afterwards, e.g., when creating a
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # static archive out of a convenience library, or when linking
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # the entirety of a libtool archive into another (currently
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # not supported by libtool).
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if (for obj in $oldobjs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$obj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done | sort | sort -uc >/dev/null 2>&1); then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews :
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews echo "copying selected object files to avoid basename conflicts..."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews gentop="$output_objdir/${outputname}x"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append generated " $gentop"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_mkdir_p "$gentop"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_oldobjs=$oldobjs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldobjs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews counter=1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for obj in $save_oldobjs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$obj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews objbase="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $oldobjs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews " ") oldobjs=$obj ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *[\ /]"$objbase "*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews while :; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Make sure we don't pick an alternate name that also
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # overlaps.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newobj=lt$counter-$objbase
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $counter + 1
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews counter=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $oldobjs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *[\ /]"$newobj "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) if test ! -f "$gentop/$newobj"; then break; fi ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append oldobjs " $gentop/$newobj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append oldobjs " $obj" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley done
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tool_oldlib=$func_to_tool_file_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval cmds=\"$old_archive_cmds\"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_len " $cmds"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews len=$func_len_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cmds=$old_archive_cmds
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif test -n "$archiver_list_spec"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "using command file archive linking..."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for obj in $oldobjs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$obj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO "$func_to_tool_file_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done > $output_objdir/$libname.libcmd
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_to_tool_file "$output_objdir/$libname.libcmd"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldobjs=" $archiver_list_spec$func_to_tool_file_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews cmds=$old_archive_cmds
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # the command line is too long to link in one step, link in parts
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "using piecewise archive linking..."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_RANLIB=$RANLIB
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews RANLIB=:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews objlist=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews concat_cmds=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews save_oldobjs=$oldobjs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldobjs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Is there a better way of finding the last object in the list?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for obj in $save_oldobjs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews last_oldobj=$obj
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval test_cmds=\"$old_archive_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_len " $test_cmds"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews len0=$func_len_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews len=$len0
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for obj in $save_oldobjs
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_len " $obj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_arith $len + $func_len_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews len=$func_arith_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append objlist " $obj"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$len" -lt "$max_cmd_len"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews :
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # the above command should be used before it gets too long
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldobjs=$objlist
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$obj" = "$last_oldobj" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews RANLIB=$save_RANLIB
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$concat_cmds" || concat_cmds=$concat_cmds~
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews objlist=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews len=$len0
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews RANLIB=$save_RANLIB
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews oldobjs=$objlist
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$oldobjs" = "X" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval cmds=\"\$concat_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_execute_cmds "$cmds" 'exit $?'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley done
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$generated" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "${RM}r$generated"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Now create the libtool archive.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $output in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.la)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews old_library=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$build_old_libs" = yes && old_library="$libname.$libext"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_verbose "creating $output"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Preserve any variables that may affect compiler behavior
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for var in $variables_saved_for_relink; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if eval test -z \"\${$var+set}\"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews elif eval var_value=\$$var; test -z "$var_value"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command="$var=; export $var; $relink_command"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_quote_for_eval "$var_value"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Quote the link command for shipping.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$hardcode_automatic" = yes ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Only create the output if not a dry run.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_dry_run || {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for installed in no yes; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$installed" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -z "$install_libdir"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews break
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews output="$output_objdir/$outputname"i
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Replace all uninstalled libtool libraries with the installed ones
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdependency_libs=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for deplib in $dependency_libs; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $deplib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.la)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_resolve_sysroot "$deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$libdir" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "\`$deplib' is not a valid libtool archive"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -L*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname -L '' "$deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_replace_sysroot "$func_stripname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdependency_libs " -L$func_replace_sysroot_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -R*)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname -R '' "$deplib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_replace_sysroot "$func_stripname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdependency_libs " -R$func_replace_sysroot_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append newdependency_libs " $deplib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dependency_libs="$newdependency_libs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdlfiles=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for lib in $dlfiles; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $lib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.la)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$lib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$libdir" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "\`$lib' is not a valid libtool archive"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append newdlfiles " $lib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlfiles="$newdlfiles"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdlprefiles=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for lib in $dlprefiles; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $lib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *.la)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Only pass preopened files to the pseudo-archive (for
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # eventual linking with the app. that links it) if we
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # didn't already link the preopened objects directly into
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # the library:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$lib"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$libdir" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_error "\`$lib' is not a valid libtool archive"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlprefiles="$newdlprefiles"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdlfiles=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for lib in $dlfiles; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $lib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) abs=`pwd`"/$lib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdlfiles " $abs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlfiles="$newdlfiles"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews newdlprefiles=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews for lib in $dlprefiles; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $lib in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) abs=`pwd`"/$lib" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append newdlprefiles " $abs"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dlprefiles="$newdlprefiles"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $RM $output
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # place dlname in correct position for cygwin
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # In fact, it would be nice if we could use this code for all target
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # systems that can't hard-code library paths into their executables
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # and that have no shared library path variable independent of PATH,
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # but it turns out we can't easily determine that from inspecting
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # libtool variables, so we have to hard-code the OSs to which it
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # applies here; at the moment, that means platforms that use the PE
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # object format with DLL files. See the long comment at the top of
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # tests/bindir.at for full details.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tdlname=$dlname
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case $host,$output,$installed,$module,$dlname in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # If a -bindir argument was supplied, place the dll there.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "x$bindir" != x ;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_relative_path "$install_libdir" "$bindir"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tdlname=$func_relative_path_result$dlname
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Otherwise fall back on heuristic.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews tdlname=../bin/$dlname
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO > $output "\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# $outputname - a libtool library file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews#
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Please DO NOT delete this file!
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# It is necessary for linking the library.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# The name that we can dlopen(3).
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsdlname='$tdlname'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Names of this library.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslibrary_names='$library_names'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# The name of the static archive.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsold_library='$old_library'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Linker flags that can not go in dependency_libs.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsinherited_linker_flags='$new_inherited_linker_flags'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Libraries that this one depends upon.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsdependency_libs='$dependency_libs'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Names of additional weak libraries provided by this library
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsweak_library_names='$weak_libs'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Version information for $libname.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewscurrent=$current
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsage=$age
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsrevision=$revision
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Is this an already installed library?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsinstalled=$installed
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Should we warn about portability when linking against -modules?
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsshouldnotlink=$module
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Files to dlopen/dlpreopen
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsdlopen='$dlfiles'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsdlpreopen='$dlprefiles'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# Directory that this library needs to be installed in:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewslibdir='$install_libdir'"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$installed" = no && test "$need_relink" = yes; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $ECHO >> $output "\
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsrelink_command=\"$relink_command\""
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews }
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Do a symbolic link so that the libtool archive can be found in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # LD_LIBRARY_PATH before the program is installed.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews exit $EXIT_SUCCESS
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_mode_link ${1+"$@"}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# func_mode_uninstall arg...
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsfunc_mode_uninstall ()
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews $opt_debug
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews RM="$nonopt"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley files=
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington rmforce=
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington exit_status=0
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington # This variable tells wrapper scripts just to set variables rather
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington # than running their programs.
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington libtool_install_magic="$magic"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley for arg
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley do
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington case $arg in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -f) func_append RM " $arg"; rmforce=yes ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews -*) func_append RM " $arg" ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append files " $arg" ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley done
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -z "$RM" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "you must specify an RM program"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington rmdirs=
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley for file in $files; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_dirname "$file" "" "."
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews dir="$func_dirname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "X$dir" = X.; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews odir="$objdir"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews odir="$dir/$objdir"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_basename "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews name="$func_basename_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$opt_mode" = uninstall && odir="$dir"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews # Remember odir for removal later, being careful to avoid duplicates
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$opt_mode" = clean; then
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington case " $rmdirs " in
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *" $odir "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) func_append rmdirs " $odir" ;;
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington esac
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington # Don't error if the file doesn't exist and rm -f was used.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if { test -L "$file"; } >/dev/null 2>&1 ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews { test -h "$file"; } >/dev/null 2>&1 ||
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -f "$file"; then
0bd1b2fbfed4aa489e9d5fcbc7f48acb96ba7248Mark Andrews :
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington elif test -d "$file"; then
0bd1b2fbfed4aa489e9d5fcbc7f48acb96ba7248Mark Andrews exit_status=1
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington continue
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington elif test "$rmforce" = yes; then
0bd1b2fbfed4aa489e9d5fcbc7f48acb96ba7248Mark Andrews continue
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley rmfiles="$file"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington case $name in
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley *.la)
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # Possibly a libtool archive, so verify it.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if func_lalib_p "$file"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_source $dir/$name
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley # Delete the libtool libraries and symlinks.
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley for n in $library_names; do
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append rmfiles " $odir/$n"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley done
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$old_library" && func_append rmfiles " $odir/$old_library"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case "$opt_mode" in
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews clean)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews case " $library_names " in
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews *" $dlname "*) ;;
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews ;;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews uninstall)
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington if test -n "$library_names"; then
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington # Do each command in the postuninstall commands.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington if test -n "$old_library"; then
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington # Do each command in the old_postuninstall commands.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington # FIXME: should reinstall the best remaining shared library.
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews ;;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews esac
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley *.lo)
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # Possibly a libtool object, so verify it.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if func_lalib_p "$file"; then
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # Read the .lo file
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_source $dir/$name
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # Add PIC object to the list of files to remove.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$pic_object" &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$pic_object" != none; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append rmfiles " $dir/$pic_object"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # Add non-PIC object to the list of files to remove.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test -n "$non_pic_object" &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews test "$non_pic_object" != none; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append rmfiles " $dir/$non_pic_object"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley *)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if test "$opt_mode" = clean ; then
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews noexename=$name
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews case $file in
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews *.exe)
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '' '.exe' "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews file=$func_stripname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_stripname '' '.exe' "$name"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews noexename=$func_stripname_result
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # $file with .exe has already been added to rmfiles,
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # add $file without .exe
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append rmfiles " $file"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews ;;
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews esac
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # Do a test to see if this is a libtool program.
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if func_ltwrapper_p "$file"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews if func_ltwrapper_executable_p "$file"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_ltwrapper_scriptname "$file"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_source $func_ltwrapper_scriptname_result
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append rmfiles " $func_ltwrapper_scriptname_result"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews else
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews relink_command=
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_source $dir/$noexename
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # note $name still contains .exe if it was in $file originally
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews # as does the version of $file that was added into $rmfiles
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews if test "$fast_install" = yes && test -n "$relink_command"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append rmfiles " $odir/lt-$name"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews fi
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews if test "X$noexename" != "X$name" ; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_append rmfiles " $odir/lt-${noexename}.c"
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley ;;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley esac
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "$RM $rmfiles" 'exit_status=1'
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley done
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington # Try to remove the ${objdir}s in the directories where we deleted files
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington for dir in $rmdirs; do
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington if test -d "$dir"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_show_eval "rmdir $dir >/dev/null 2>&1"
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington fi
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington done
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington
0b135de5a52acec5bb42f96b4e79484d1629fd93Brian Wellington exit $exit_status
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_mode_uninstall ${1+"$@"}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewstest -z "$opt_mode" && {
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews help="$generic_help"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "you must specify a MODE"
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews}
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewstest -z "$exec_cmd" && \
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews func_fatal_help "invalid operation mode \`$opt_mode'"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
0bd1b2fbfed4aa489e9d5fcbc7f48acb96ba7248Mark Andrewsif test -n "$exec_cmd"; then
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews eval exec "$exec_cmd"
7c8662961e2876e22e34c96d41dad0cd70e3ce4cMark Andrews exit $EXIT_FAILURE
0bd1b2fbfed4aa489e9d5fcbc7f48acb96ba7248Mark Andrewsfi
0bd1b2fbfed4aa489e9d5fcbc7f48acb96ba7248Mark Andrews
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsexit $exit_status
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews# The TAGs below are defined such that we never get into a situation
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews# in which we disable both kinds of libraries. Given conflicting
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews# choices, we go for a static library, that is the most portable,
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews# since we can't tell whether shared libraries were disabled because
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews# the user asked for that or because the platform doesn't support
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews# them. This is particularly important on AIX, because we don't
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews# support having both static and shared libraries enabled at the same
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews# time on that platform, so we default to a shared-only configuration.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews# If a disable-shared tag is given, we'll fallback to a static-only
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews# configuration. But we'll never go from static-only to shared-only.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsbuild_libtool_libs=no
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsbuild_old_libs=yes
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews# ### END LIBTOOL TAG CONFIG: disable-shared
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews# ### BEGIN LIBTOOL TAG CONFIG: disable-static
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrewsbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews# ### END LIBTOOL TAG CONFIG: disable-static
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley# Local Variables:
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley# mode:shell-script
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley# sh-indentation:2
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley# End:
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews# vi:sw=2
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews