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