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