Updating maintainer field.
[debian/lxappearance.git] / ltmain.sh
CommitLineData
eddc0c49 1
e7f9874d 2# libtool (GNU libtool) 2.4
eddc0c49
DB
3# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4
e7f9874d
DB
5# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
6# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
eddc0c49
DB
7# This is free software; see the source for copying conditions. There is NO
8# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9
10# GNU Libtool is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# As a special exception to the GNU General Public License,
16# if you distribute this file as part of a program or library that
17# is built using GNU Libtool, you may include this file under the
18# same distribution terms that you use for the rest of that program.
19#
20# GNU Libtool is distributed in the hope that it will be useful, but
21# WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23# General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with GNU Libtool; see the file COPYING. If not, a copy
27# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28# or obtained by writing to the Free Software Foundation, Inc.,
29# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30
31# Usage: $progname [OPTION]... [MODE-ARG]...
32#
33# Provide generalized library-building support services.
34#
e7f9874d
DB
35# --config show all configuration variables
36# --debug enable verbose shell tracing
37# -n, --dry-run display commands without modifying any files
38# --features display basic configuration information and exit
39# --mode=MODE use operation mode MODE
40# --preserve-dup-deps don't remove duplicate dependency libraries
41# --quiet, --silent don't print informational messages
42# --no-quiet, --no-silent
43# print informational messages (default)
44# --tag=TAG use configuration variables from tag TAG
45# -v, --verbose print more informational messages than default
46# --no-verbose don't print the extra informational messages
47# --version print version information
48# -h, --help, --help-all print short, long, or detailed help message
eddc0c49
DB
49#
50# MODE must be one of the following:
51#
e7f9874d
DB
52# clean remove files from the build directory
53# compile compile a source file into a libtool object
54# execute automatically set library path, then run a program
55# finish complete the installation of libtool libraries
56# install install libraries or executables
57# link create a library or an executable
58# uninstall remove libraries from an installed directory
eddc0c49 59#
e7f9874d
DB
60# MODE-ARGS vary depending on the MODE. When passed as first option,
61# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
eddc0c49
DB
62# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
63#
64# When reporting a bug, please describe a test case to reproduce it and
65# include the following information:
66#
e7f9874d
DB
67# host-triplet: $host
68# shell: $SHELL
69# compiler: $LTCC
70# compiler flags: $LTCFLAGS
71# linker: $LD (gnu? $with_gnu_ld)
72# $progname: (GNU libtool) 2.4 Debian-2.4-2
73# automake: $automake_version
74# autoconf: $autoconf_version
eddc0c49
DB
75#
76# Report bugs to <bug-libtool@gnu.org>.
e7f9874d
DB
77# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
78# General help using GNU software: <http://www.gnu.org/gethelp/>.
eddc0c49 79
e7f9874d 80PROGRAM=libtool
eddc0c49 81PACKAGE=libtool
e7f9874d 82VERSION="2.4 Debian-2.4-2"
eddc0c49 83TIMESTAMP=""
e7f9874d 84package_revision=1.3293
eddc0c49
DB
85
86# Be Bourne compatible
87if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
88 emulate sh
89 NULLCMD=:
90 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
91 # is contrary to our usage. Disable this feature.
92 alias -g '${1+"$@"}'='"$@"'
93 setopt NO_GLOB_SUBST
94else
95 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
96fi
97BIN_SH=xpg4; export BIN_SH # for Tru64
98DUALCASE=1; export DUALCASE # for MKS sh
99
e7f9874d
DB
100# A function that is used when there is no print builtin or printf.
101func_fallback_echo ()
102{
103 eval 'cat <<_LTECHO_EOF
104$1
105_LTECHO_EOF'
106}
107
eddc0c49 108# NLS nuisances: We save the old values to restore during execute mode.
eddc0c49
DB
109lt_user_locale=
110lt_safe_locale=
111for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
112do
113 eval "if test \"\${$lt_var+set}\" = set; then
114 save_$lt_var=\$$lt_var
115 $lt_var=C
116 export $lt_var
117 lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
118 lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
119 fi"
120done
e7f9874d
DB
121LC_ALL=C
122LANGUAGE=C
123export LANGUAGE LC_ALL
eddc0c49
DB
124
125$lt_unset CDPATH
126
127
e7f9874d
DB
128# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
129# is ksh but when the shell is invoked as "sh" and the current value of
130# the _XPG environment variable is not equal to 1 (one), the special
131# positional parameter $0, within a function call, is the name of the
132# function.
133progpath="$0"
eddc0c49
DB
134
135
136
137: ${CP="cp -f"}
e7f9874d 138test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
8df2f63a
DB
139: ${EGREP="/bin/grep -E"}
140: ${FGREP="/bin/grep -F"}
141: ${GREP="/bin/grep"}
eddc0c49
DB
142: ${LN_S="ln -s"}
143: ${MAKE="make"}
144: ${MKDIR="mkdir"}
145: ${MV="mv -f"}
146: ${RM="rm -f"}
8df2f63a 147: ${SED="/bin/sed"}
eddc0c49
DB
148: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
149: ${Xsed="$SED -e 1s/^X//"}
150
151# Global variables:
152EXIT_SUCCESS=0
153EXIT_FAILURE=1
154EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
155EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
156
157exit_status=$EXIT_SUCCESS
158
159# Make sure IFS has a sensible default
160lt_nl='
161'
162IFS=" $lt_nl"
163
164dirname="s,/[^/]*$,,"
165basename="s,^.*/,,"
166
e7f9874d
DB
167# func_dirname file append nondir_replacement
168# Compute the dirname of FILE. If nonempty, add APPEND to the result,
169# otherwise set result to NONDIR_REPLACEMENT.
170func_dirname ()
171{
172 func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
173 if test "X$func_dirname_result" = "X${1}"; then
174 func_dirname_result="${3}"
175 else
176 func_dirname_result="$func_dirname_result${2}"
177 fi
178} # func_dirname may be replaced by extended shell implementation
179
180
181# func_basename file
182func_basename ()
183{
184 func_basename_result=`$ECHO "${1}" | $SED "$basename"`
185} # func_basename may be replaced by extended shell implementation
186
187
eddc0c49
DB
188# func_dirname_and_basename file append nondir_replacement
189# perform func_basename and func_dirname in a single function
190# call:
191# dirname: Compute the dirname of FILE. If nonempty,
192# add APPEND to the result, otherwise set result
193# to NONDIR_REPLACEMENT.
194# value returned in "$func_dirname_result"
195# basename: Compute filename of FILE.
196# value retuned in "$func_basename_result"
197# Implementation must be kept synchronized with func_dirname
198# and func_basename. For efficiency, we do not delegate to
199# those functions but instead duplicate the functionality here.
200func_dirname_and_basename ()
201{
e7f9874d
DB
202 # Extract subdirectory from the argument.
203 func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
204 if test "X$func_dirname_result" = "X${1}"; then
205 func_dirname_result="${3}"
206 else
207 func_dirname_result="$func_dirname_result${2}"
208 fi
209 func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
210} # func_dirname_and_basename may be replaced by extended shell implementation
211
212
213# func_stripname prefix suffix name
214# strip PREFIX and SUFFIX off of NAME.
215# PREFIX and SUFFIX must not contain globbing or regex special
216# characters, hashes, percent signs, but SUFFIX may contain a leading
217# dot (in which case that matches only a dot).
218# func_strip_suffix prefix name
219func_stripname ()
220{
221 case ${2} in
222 .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
223 *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
224 esac
225} # func_stripname may be replaced by extended shell implementation
226
227
228# These SED scripts presuppose an absolute path with a trailing slash.
229pathcar='s,^/\([^/]*\).*$,\1,'
230pathcdr='s,^/[^/]*,,'
231removedotparts=':dotsl
232 s@/\./@/@g
233 t dotsl
234 s,/\.$,/,'
235collapseslashes='s@/\{1,\}@/@g'
236finalslash='s,/*$,/,'
237
238# func_normal_abspath PATH
239# Remove doubled-up and trailing slashes, "." path components,
240# and cancel out any ".." path components in PATH after making
241# it an absolute path.
242# value returned in "$func_normal_abspath_result"
243func_normal_abspath ()
244{
245 # Start from root dir and reassemble the path.
246 func_normal_abspath_result=
247 func_normal_abspath_tpath=$1
248 func_normal_abspath_altnamespace=
249 case $func_normal_abspath_tpath in
250 "")
251 # Empty path, that just means $cwd.
252 func_stripname '' '/' "`pwd`"
253 func_normal_abspath_result=$func_stripname_result
254 return
255 ;;
256 # The next three entries are used to spot a run of precisely
257 # two leading slashes without using negated character classes;
258 # we take advantage of case's first-match behaviour.
259 ///*)
260 # Unusual form of absolute path, do nothing.
261 ;;
262 //*)
263 # Not necessarily an ordinary path; POSIX reserves leading '//'
264 # and for example Cygwin uses it to access remote file shares
265 # over CIFS/SMB, so we conserve a leading double slash if found.
266 func_normal_abspath_altnamespace=/
267 ;;
268 /*)
269 # Absolute path, do nothing.
270 ;;
271 *)
272 # Relative path, prepend $cwd.
273 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
274 ;;
275 esac
276 # Cancel out all the simple stuff to save iterations. We also want
277 # the path to end with a slash for ease of parsing, so make sure
278 # there is one (and only one) here.
279 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
280 -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
281 while :; do
282 # Processed it all yet?
283 if test "$func_normal_abspath_tpath" = / ; then
284 # If we ascended to the root using ".." the result may be empty now.
285 if test -z "$func_normal_abspath_result" ; then
286 func_normal_abspath_result=/
287 fi
288 break
289 fi
290 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
291 -e "$pathcar"`
292 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
293 -e "$pathcdr"`
294 # Figure out what to do with it
295 case $func_normal_abspath_tcomponent in
296 "")
297 # Trailing empty path component, ignore it.
298 ;;
299 ..)
300 # Parent dir; strip last assembled component from result.
301 func_dirname "$func_normal_abspath_result"
302 func_normal_abspath_result=$func_dirname_result
303 ;;
304 *)
305 # Actual path component, append it.
306 func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
307 ;;
308 esac
309 done
310 # Restore leading double-slash if one was found on entry.
311 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
eddc0c49
DB
312}
313
e7f9874d
DB
314# func_relative_path SRCDIR DSTDIR
315# generates a relative path from SRCDIR to DSTDIR, with a trailing
316# slash if non-empty, suitable for immediately appending a filename
317# without needing to append a separator.
318# value returned in "$func_relative_path_result"
319func_relative_path ()
320{
321 func_relative_path_result=
322 func_normal_abspath "$1"
323 func_relative_path_tlibdir=$func_normal_abspath_result
324 func_normal_abspath "$2"
325 func_relative_path_tbindir=$func_normal_abspath_result
326
327 # Ascend the tree starting from libdir
328 while :; do
329 # check if we have found a prefix of bindir
330 case $func_relative_path_tbindir in
331 $func_relative_path_tlibdir)
332 # found an exact match
333 func_relative_path_tcancelled=
334 break
335 ;;
336 $func_relative_path_tlibdir*)
337 # found a matching prefix
338 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
339 func_relative_path_tcancelled=$func_stripname_result
340 if test -z "$func_relative_path_result"; then
341 func_relative_path_result=.
342 fi
343 break
344 ;;
345 *)
346 func_dirname $func_relative_path_tlibdir
347 func_relative_path_tlibdir=${func_dirname_result}
348 if test "x$func_relative_path_tlibdir" = x ; then
349 # Have to descend all the way to the root!
350 func_relative_path_result=../$func_relative_path_result
351 func_relative_path_tcancelled=$func_relative_path_tbindir
352 break
353 fi
354 func_relative_path_result=../$func_relative_path_result
355 ;;
356 esac
357 done
eddc0c49 358
e7f9874d
DB
359 # Now calculate path; take care to avoid doubling-up slashes.
360 func_stripname '' '/' "$func_relative_path_result"
361 func_relative_path_result=$func_stripname_result
362 func_stripname '/' '/' "$func_relative_path_tcancelled"
363 if test "x$func_stripname_result" != x ; then
364 func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
365 fi
366
367 # Normalisation. If bindir is libdir, return empty string,
368 # else relative path ending with a slash; either way, target
369 # file name can be directly appended.
370 if test ! -z "$func_relative_path_result"; then
371 func_stripname './' '' "$func_relative_path_result/"
372 func_relative_path_result=$func_stripname_result
373 fi
374}
eddc0c49
DB
375
376# The name of this program:
eddc0c49
DB
377func_dirname_and_basename "$progpath"
378progname=$func_basename_result
eddc0c49
DB
379
380# Make sure we have an absolute path for reexecution:
381case $progpath in
382 [\\/]*|[A-Za-z]:\\*) ;;
383 *[\\/]*)
384 progdir=$func_dirname_result
385 progdir=`cd "$progdir" && pwd`
386 progpath="$progdir/$progname"
387 ;;
388 *)
389 save_IFS="$IFS"
390 IFS=:
391 for progdir in $PATH; do
392 IFS="$save_IFS"
393 test -x "$progdir/$progname" && break
394 done
395 IFS="$save_IFS"
396 test -n "$progdir" || progdir=`pwd`
397 progpath="$progdir/$progname"
398 ;;
399esac
400
401# Sed substitution that helps us do robust quoting. It backslashifies
402# metacharacters that are still active within double-quoted strings.
403Xsed="${SED}"' -e 1s/^X//'
404sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
405
406# Same as above, but do not quote variable references.
407double_quote_subst='s/\(["`\\]\)/\\\1/g'
408
e7f9874d
DB
409# Sed substitution that turns a string into a regex matching for the
410# string literally.
411sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
412
413# Sed substitution that converts a w32 file name or path
414# which contains forward slashes, into one that contains
415# (escaped) backslashes. A very naive implementation.
416lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
417
eddc0c49
DB
418# Re-`\' parameter expansions in output of double_quote_subst that were
419# `\'-ed in input to the same. If an odd number of `\' preceded a '$'
420# in input to double_quote_subst, that '$' was protected from expansion.
421# Since each input `\' is now two `\'s, look for any number of runs of
422# four `\'s followed by two `\'s and then a '$'. `\' that '$'.
423bs='\\'
424bs2='\\\\'
425bs4='\\\\\\\\'
426dollar='\$'
427sed_double_backslash="\
428 s/$bs4/&\\
429/g
430 s/^$bs2$dollar/$bs&/
431 s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
432 s/\n//g"
433
434# Standard options:
435opt_dry_run=false
436opt_help=false
437opt_quiet=false
438opt_verbose=false
439opt_warning=:
440
441# func_echo arg...
442# Echo program name prefixed message, along with the current mode
443# name if it has been set yet.
444func_echo ()
445{
e7f9874d 446 $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
eddc0c49
DB
447}
448
449# func_verbose arg...
450# Echo program name prefixed message in verbose mode only.
451func_verbose ()
452{
453 $opt_verbose && func_echo ${1+"$@"}
454
455 # A bug in bash halts the script if the last line of a function
456 # fails when set -e is in force, so we need another command to
457 # work around that:
458 :
459}
460
e7f9874d
DB
461# func_echo_all arg...
462# Invoke $ECHO with all args, space-separated.
463func_echo_all ()
464{
465 $ECHO "$*"
466}
467
eddc0c49
DB
468# func_error arg...
469# Echo program name prefixed message to standard error.
470func_error ()
471{
e7f9874d 472 $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
eddc0c49
DB
473}
474
475# func_warning arg...
476# Echo program name prefixed warning message to standard error.
477func_warning ()
478{
e7f9874d 479 $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
eddc0c49
DB
480
481 # bash bug again:
482 :
483}
484
485# func_fatal_error arg...
486# Echo program name prefixed message to standard error, and exit.
487func_fatal_error ()
488{
489 func_error ${1+"$@"}
490 exit $EXIT_FAILURE
491}
492
493# func_fatal_help arg...
494# Echo program name prefixed message to standard error, followed by
495# a help hint, and exit.
496func_fatal_help ()
497{
498 func_error ${1+"$@"}
499 func_fatal_error "$help"
500}
501help="Try \`$progname --help' for more information." ## default
502
503
504# func_grep expression filename
505# Check whether EXPRESSION matches any line of FILENAME, without output.
506func_grep ()
507{
508 $GREP "$1" "$2" >/dev/null 2>&1
509}
510
511
512# func_mkdir_p directory-path
513# Make sure the entire path to DIRECTORY-PATH is available.
514func_mkdir_p ()
515{
516 my_directory_path="$1"
517 my_dir_list=
518
519 if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
520
521 # Protect directory names starting with `-'
522 case $my_directory_path in
523 -*) my_directory_path="./$my_directory_path" ;;
524 esac
525
526 # While some portion of DIR does not yet exist...
527 while test ! -d "$my_directory_path"; do
528 # ...make a list in topmost first order. Use a colon delimited
529 # list incase some portion of path contains whitespace.
530 my_dir_list="$my_directory_path:$my_dir_list"
531
532 # If the last portion added has no slash in it, the list is done
533 case $my_directory_path in */*) ;; *) break ;; esac
534
535 # ...otherwise throw away the child directory and loop
e7f9874d 536 my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
eddc0c49 537 done
e7f9874d 538 my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
eddc0c49
DB
539
540 save_mkdir_p_IFS="$IFS"; IFS=':'
541 for my_dir in $my_dir_list; do
542 IFS="$save_mkdir_p_IFS"
543 # mkdir can fail with a `File exist' error if two processes
544 # try to create one of the directories concurrently. Don't
545 # stop in that case!
546 $MKDIR "$my_dir" 2>/dev/null || :
547 done
548 IFS="$save_mkdir_p_IFS"
549
550 # Bail out if we (or some other process) failed to create a directory.
551 test -d "$my_directory_path" || \
552 func_fatal_error "Failed to create \`$1'"
553 fi
554}
555
556
557# func_mktempdir [string]
558# Make a temporary directory that won't clash with other running
559# libtool processes, and avoids race conditions if possible. If
560# given, STRING is the basename for that directory.
561func_mktempdir ()
562{
563 my_template="${TMPDIR-/tmp}/${1-$progname}"
564
565 if test "$opt_dry_run" = ":"; then
566 # Return a directory name, but don't create it in dry-run mode
567 my_tmpdir="${my_template}-$$"
568 else
569
570 # If mktemp works, use that first and foremost
571 my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
572
573 if test ! -d "$my_tmpdir"; then
574 # Failing that, at least try and use $RANDOM to avoid a race
575 my_tmpdir="${my_template}-${RANDOM-0}$$"
576
577 save_mktempdir_umask=`umask`
578 umask 0077
579 $MKDIR "$my_tmpdir"
580 umask $save_mktempdir_umask
581 fi
582
583 # If we're not in dry-run mode, bomb out on failure
584 test -d "$my_tmpdir" || \
585 func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
586 fi
587
e7f9874d 588 $ECHO "$my_tmpdir"
eddc0c49
DB
589}
590
591
592# func_quote_for_eval arg
593# Aesthetically quote ARG to be evaled later.
594# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
595# is double-quoted, suitable for a subsequent eval, whereas
596# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
597# which are still active within double quotes backslashified.
598func_quote_for_eval ()
599{
600 case $1 in
601 *[\\\`\"\$]*)
e7f9874d 602 func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
eddc0c49
DB
603 *)
604 func_quote_for_eval_unquoted_result="$1" ;;
605 esac
606
607 case $func_quote_for_eval_unquoted_result in
608 # Double-quote args containing shell metacharacters to delay
609 # word splitting, command substitution and and variable
610 # expansion for a subsequent eval.
611 # Many Bourne shells cannot handle close brackets correctly
612 # in scan sets, so we specify it separately.
613 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
614 func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
615 ;;
616 *)
617 func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
618 esac
619}
620
621
622# func_quote_for_expand arg
623# Aesthetically quote ARG to be evaled later; same as above,
624# but do not quote variable references.
625func_quote_for_expand ()
626{
627 case $1 in
628 *[\\\`\"]*)
e7f9874d 629 my_arg=`$ECHO "$1" | $SED \
eddc0c49
DB
630 -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
631 *)
632 my_arg="$1" ;;
633 esac
634
635 case $my_arg in
636 # Double-quote args containing shell metacharacters to delay
637 # word splitting and command substitution for a subsequent eval.
638 # Many Bourne shells cannot handle close brackets correctly
639 # in scan sets, so we specify it separately.
640 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
641 my_arg="\"$my_arg\""
642 ;;
643 esac
644
645 func_quote_for_expand_result="$my_arg"
646}
647
648
649# func_show_eval cmd [fail_exp]
650# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
651# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
652# is given, then evaluate it.
653func_show_eval ()
654{
655 my_cmd="$1"
656 my_fail_exp="${2-:}"
657
658 ${opt_silent-false} || {
659 func_quote_for_expand "$my_cmd"
660 eval "func_echo $func_quote_for_expand_result"
661 }
662
663 if ${opt_dry_run-false}; then :; else
664 eval "$my_cmd"
665 my_status=$?
666 if test "$my_status" -eq 0; then :; else
667 eval "(exit $my_status); $my_fail_exp"
668 fi
669 fi
670}
671
672
673# func_show_eval_locale cmd [fail_exp]
674# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
675# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
676# is given, then evaluate it. Use the saved locale for evaluation.
677func_show_eval_locale ()
678{
679 my_cmd="$1"
680 my_fail_exp="${2-:}"
681
682 ${opt_silent-false} || {
683 func_quote_for_expand "$my_cmd"
684 eval "func_echo $func_quote_for_expand_result"
685 }
686
687 if ${opt_dry_run-false}; then :; else
688 eval "$lt_user_locale
689 $my_cmd"
690 my_status=$?
691 eval "$lt_safe_locale"
692 if test "$my_status" -eq 0; then :; else
693 eval "(exit $my_status); $my_fail_exp"
694 fi
695 fi
696}
697
e7f9874d
DB
698# func_tr_sh
699# Turn $1 into a string suitable for a shell variable name.
700# Result is stored in $func_tr_sh_result. All characters
701# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
702# if $1 begins with a digit, a '_' is prepended as well.
703func_tr_sh ()
704{
705 case $1 in
706 [0-9]* | *[!a-zA-Z0-9_]*)
707 func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
708 ;;
709 * )
710 func_tr_sh_result=$1
711 ;;
712 esac
713}
eddc0c49
DB
714
715
716# func_version
717# Echo version message to standard output and exit.
718func_version ()
719{
e7f9874d
DB
720 $opt_debug
721
722 $SED -n '/(C)/!b go
723 :more
724 /\./!{
725 N
726 s/\n# / /
727 b more
728 }
729 :go
730 /^# '$PROGRAM' (GNU /,/# warranty; / {
eddc0c49
DB
731 s/^# //
732 s/^# *$//
733 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
734 p
735 }' < "$progpath"
736 exit $?
737}
738
739# func_usage
740# Echo short help message to standard output and exit.
741func_usage ()
742{
e7f9874d
DB
743 $opt_debug
744
745 $SED -n '/^# Usage:/,/^# *.*--help/ {
eddc0c49
DB
746 s/^# //
747 s/^# *$//
748 s/\$progname/'$progname'/
749 p
750 }' < "$progpath"
e7f9874d 751 echo
eddc0c49
DB
752 $ECHO "run \`$progname --help | more' for full usage"
753 exit $?
754}
755
e7f9874d
DB
756# func_help [NOEXIT]
757# Echo long help message to standard output and exit,
758# unless 'noexit' is passed as argument.
eddc0c49
DB
759func_help ()
760{
e7f9874d
DB
761 $opt_debug
762
eddc0c49 763 $SED -n '/^# Usage:/,/# Report bugs to/ {
e7f9874d 764 :print
eddc0c49
DB
765 s/^# //
766 s/^# *$//
767 s*\$progname*'$progname'*
768 s*\$host*'"$host"'*
769 s*\$SHELL*'"$SHELL"'*
770 s*\$LTCC*'"$LTCC"'*
771 s*\$LTCFLAGS*'"$LTCFLAGS"'*
772 s*\$LD*'"$LD"'*
773 s/\$with_gnu_ld/'"$with_gnu_ld"'/
774 s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
775 s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
776 p
e7f9874d
DB
777 d
778 }
779 /^# .* home page:/b print
780 /^# General help using/b print
781 ' < "$progpath"
782 ret=$?
783 if test -z "$1"; then
784 exit $ret
785 fi
eddc0c49
DB
786}
787
788# func_missing_arg argname
789# Echo program name prefixed message to standard error and set global
790# exit_cmd.
791func_missing_arg ()
792{
e7f9874d
DB
793 $opt_debug
794
795 func_error "missing argument for $1."
eddc0c49
DB
796 exit_cmd=exit
797}
798
eddc0c49 799
e7f9874d
DB
800# func_split_short_opt shortopt
801# Set func_split_short_opt_name and func_split_short_opt_arg shell
802# variables after splitting SHORTOPT after the 2nd character.
803func_split_short_opt ()
804{
805 my_sed_short_opt='1s/^\(..\).*$/\1/;q'
806 my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
eddc0c49 807
e7f9874d
DB
808 func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
809 func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
810} # func_split_short_opt may be replaced by extended shell implementation
811
812
813# func_split_long_opt longopt
814# Set func_split_long_opt_name and func_split_long_opt_arg shell
815# variables after splitting LONGOPT at the `=' sign.
816func_split_long_opt ()
817{
818 my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
819 my_sed_long_arg='1s/^--[^=]*=//'
820
821 func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
822 func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
823} # func_split_long_opt may be replaced by extended shell implementation
824
825exit_cmd=:
eddc0c49
DB
826
827
828
eddc0c49 829
eddc0c49
DB
830
831magic="%%%MAGIC variable%%%"
832magic_exe="%%%MAGIC EXE variable%%%"
833
834# Global variables.
eddc0c49 835nonopt=
eddc0c49
DB
836preserve_args=
837lo2o="s/\\.lo\$/.${objext}/"
838o2lo="s/\\.${objext}\$/.lo/"
839extracted_archives=
840extracted_serial=0
841
eddc0c49
DB
842# If this variable is set in any of the actions, the command in it
843# will be execed at the end. This prevents here-documents from being
844# left over by shells.
845exec_cmd=
846
e7f9874d
DB
847# func_append var value
848# Append VALUE to the end of shell variable VAR.
849func_append ()
850{
851 eval "${1}=\$${1}\${2}"
852} # func_append may be replaced by extended shell implementation
853
854# func_append_quoted var value
855# Quote VALUE and append to the end of shell variable VAR, separated
856# by a space.
857func_append_quoted ()
858{
859 func_quote_for_eval "${2}"
860 eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
861} # func_append_quoted may be replaced by extended shell implementation
862
863
864# func_arith arithmetic-term...
865func_arith ()
866{
867 func_arith_result=`expr "${@}"`
868} # func_arith may be replaced by extended shell implementation
869
870
871# func_len string
872# STRING may not start with a hyphen.
873func_len ()
874{
875 func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
876} # func_len may be replaced by extended shell implementation
877
878
879# func_lo2o object
880func_lo2o ()
881{
882 func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
883} # func_lo2o may be replaced by extended shell implementation
884
885
886# func_xform libobj-or-source
887func_xform ()
888{
889 func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
890} # func_xform may be replaced by extended shell implementation
891
892
eddc0c49
DB
893# func_fatal_configuration arg...
894# Echo program name prefixed message to standard error, followed by
895# a configuration failure hint, and exit.
896func_fatal_configuration ()
897{
898 func_error ${1+"$@"}
899 func_error "See the $PACKAGE documentation for more information."
900 func_fatal_error "Fatal configuration error."
901}
902
903
904# func_config
905# Display the configuration for all the tags in this script.
906func_config ()
907{
908 re_begincf='^# ### BEGIN LIBTOOL'
909 re_endcf='^# ### END LIBTOOL'
910
911 # Default configuration.
912 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
913
914 # Now print the configurations for the tags.
915 for tagname in $taglist; do
916 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
917 done
918
919 exit $?
920}
921
922# func_features
923# Display the features supported by this script.
924func_features ()
925{
e7f9874d 926 echo "host: $host"
eddc0c49 927 if test "$build_libtool_libs" = yes; then
e7f9874d 928 echo "enable shared libraries"
eddc0c49 929 else
e7f9874d 930 echo "disable shared libraries"
eddc0c49
DB
931 fi
932 if test "$build_old_libs" = yes; then
e7f9874d 933 echo "enable static libraries"
eddc0c49 934 else
e7f9874d 935 echo "disable static libraries"
eddc0c49
DB
936 fi
937
938 exit $?
939}
940
941# func_enable_tag tagname
942# Verify that TAGNAME is valid, and either flag an error and exit, or
943# enable the TAGNAME tag. We also add TAGNAME to the global $taglist
944# variable here.
945func_enable_tag ()
946{
947 # Global variable:
948 tagname="$1"
949
950 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
951 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
952 sed_extractcf="/$re_begincf/,/$re_endcf/p"
953
954 # Validate tagname.
955 case $tagname in
956 *[!-_A-Za-z0-9,/]*)
957 func_fatal_error "invalid tag name: $tagname"
958 ;;
959 esac
960
961 # Don't test for the "default" C tag, as we know it's
962 # there but not specially marked.
963 case $tagname in
964 CC) ;;
965 *)
966 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
967 taglist="$taglist $tagname"
968
969 # Evaluate the configuration. Be careful to quote the path
970 # and the sed script, to avoid splitting on whitespace, but
971 # also don't use non-portable quotes within backquotes within
972 # quotes we have to do it in 2 steps:
973 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
974 eval "$extractedcf"
975 else
976 func_error "ignoring unknown tag $tagname"
977 fi
978 ;;
979 esac
980}
981
e7f9874d
DB
982# func_check_version_match
983# Ensure that we are using m4 macros, and libtool script from the same
984# release of libtool.
985func_check_version_match ()
eddc0c49 986{
e7f9874d
DB
987 if test "$package_revision" != "$macro_revision"; then
988 if test "$VERSION" != "$macro_version"; then
989 if test -z "$macro_version"; then
990 cat >&2 <<_LT_EOF
991$progname: Version mismatch error. This is $PACKAGE $VERSION, but the
992$progname: definition of this LT_INIT comes from an older release.
993$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
994$progname: and run autoconf again.
995_LT_EOF
996 else
997 cat >&2 <<_LT_EOF
998$progname: Version mismatch error. This is $PACKAGE $VERSION, but the
999$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
1000$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
1001$progname: and run autoconf again.
1002_LT_EOF
1003 fi
1004 else
1005 cat >&2 <<_LT_EOF
1006$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
1007$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1008$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1009$progname: of $PACKAGE $VERSION and run autoconf again.
1010_LT_EOF
1011 fi
eddc0c49 1012
e7f9874d
DB
1013 exit $EXIT_MISMATCH
1014 fi
1015}
1016
1017
1018# Shorthand for --mode=foo, only valid as the first argument
1019case $1 in
1020clean|clea|cle|cl)
1021 shift; set dummy --mode clean ${1+"$@"}; shift
1022 ;;
1023compile|compil|compi|comp|com|co|c)
1024 shift; set dummy --mode compile ${1+"$@"}; shift
1025 ;;
1026execute|execut|execu|exec|exe|ex|e)
1027 shift; set dummy --mode execute ${1+"$@"}; shift
1028 ;;
1029finish|finis|fini|fin|fi|f)
1030 shift; set dummy --mode finish ${1+"$@"}; shift
1031 ;;
1032install|instal|insta|inst|ins|in|i)
1033 shift; set dummy --mode install ${1+"$@"}; shift
1034 ;;
1035link|lin|li|l)
1036 shift; set dummy --mode link ${1+"$@"}; shift
1037 ;;
1038uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1039 shift; set dummy --mode uninstall ${1+"$@"}; shift
1040 ;;
1041esac
1042
1043
1044
1045# Option defaults:
1046opt_debug=:
1047opt_dry_run=false
1048opt_config=false
1049opt_preserve_dup_deps=false
1050opt_features=false
1051opt_finish=false
1052opt_help=false
1053opt_help_all=false
1054opt_silent=:
1055opt_verbose=:
1056opt_silent=false
1057opt_verbose=false
eddc0c49 1058
e7f9874d
DB
1059
1060# Parse options once, thoroughly. This comes as soon as possible in the
1061# script to make things like `--version' happen as quickly as we can.
1062{
1063 # this just eases exit handling
1064 while test $# -gt 0; do
eddc0c49
DB
1065 opt="$1"
1066 shift
eddc0c49 1067 case $opt in
e7f9874d 1068 --debug|-x) opt_debug='set -x'
eddc0c49 1069 func_echo "enabling shell trace mode"
eddc0c49
DB
1070 $opt_debug
1071 ;;
e7f9874d
DB
1072 --dry-run|--dryrun|-n)
1073 opt_dry_run=:
eddc0c49 1074 ;;
e7f9874d
DB
1075 --config)
1076 opt_config=:
1077func_config
1078 ;;
1079 --dlopen|-dlopen)
1080 optarg="$1"
1081 opt_dlopen="${opt_dlopen+$opt_dlopen
1082}$optarg"
eddc0c49
DB
1083 shift
1084 ;;
eddc0c49 1085 --preserve-dup-deps)
e7f9874d 1086 opt_preserve_dup_deps=:
eddc0c49 1087 ;;
e7f9874d
DB
1088 --features)
1089 opt_features=:
1090func_features
1091 ;;
1092 --finish)
1093 opt_finish=:
1094set dummy --mode finish ${1+"$@"}; shift
1095 ;;
1096 --help)
1097 opt_help=:
1098 ;;
1099 --help-all)
1100 opt_help_all=:
1101opt_help=': help-all'
1102 ;;
1103 --mode)
1104 test $# = 0 && func_missing_arg $opt && break
1105 optarg="$1"
1106 opt_mode="$optarg"
1107case $optarg in
1108 # Valid mode arguments:
1109 clean|compile|execute|finish|install|link|relink|uninstall) ;;
1110
1111 # Catch anything else as an error
1112 *) func_error "invalid argument for $opt"
1113 exit_cmd=exit
1114 break
1115 ;;
1116esac
1117 shift
1118 ;;
1119 --no-silent|--no-quiet)
eddc0c49 1120 opt_silent=false
e7f9874d 1121func_append preserve_args " $opt"
eddc0c49 1122 ;;
e7f9874d
DB
1123 --no-verbose)
1124 opt_verbose=false
1125func_append preserve_args " $opt"
1126 ;;
1127 --silent|--quiet)
1128 opt_silent=:
1129func_append preserve_args " $opt"
1130 opt_verbose=false
1131 ;;
1132 --verbose|-v)
1133 opt_verbose=:
1134func_append preserve_args " $opt"
1135opt_silent=false
1136 ;;
1137 --tag)
1138 test $# = 0 && func_missing_arg $opt && break
1139 optarg="$1"
1140 opt_tag="$optarg"
1141func_append preserve_args " $opt $optarg"
1142func_enable_tag "$optarg"
eddc0c49
DB
1143 shift
1144 ;;
1145
e7f9874d
DB
1146 -\?|-h) func_usage ;;
1147 --help) func_help ;;
1148 --version) func_version ;;
1149
eddc0c49 1150 # Separate optargs to long options:
e7f9874d
DB
1151 --*=*)
1152 func_split_long_opt "$opt"
1153 set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
eddc0c49
DB
1154 shift
1155 ;;
1156
e7f9874d
DB
1157 # Separate non-argument short options:
1158 -\?*|-h*|-n*|-v*)
1159 func_split_short_opt "$opt"
1160 set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1161 shift
eddc0c49 1162 ;;
e7f9874d
DB
1163
1164 --) break ;;
1165 -*) func_fatal_help "unrecognized option \`$opt'" ;;
1166 *) set dummy "$opt" ${1+"$@"}; shift; break ;;
eddc0c49
DB
1167 esac
1168 done
1169
e7f9874d
DB
1170 # Validate options:
1171
1172 # save first non-option argument
1173 if test "$#" -gt 0; then
1174 nonopt="$opt"
1175 shift
1176 fi
1177
1178 # preserve --debug
1179 test "$opt_debug" = : || func_append preserve_args " --debug"
eddc0c49
DB
1180
1181 case $host in
1182 *cygwin* | *mingw* | *pw32* | *cegcc*)
1183 # don't eliminate duplications in $postdeps and $predeps
1184 opt_duplicate_compiler_generated_deps=:
1185 ;;
1186 *)
e7f9874d 1187 opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
eddc0c49
DB
1188 ;;
1189 esac
1190
e7f9874d
DB
1191 $opt_help || {
1192 # Sanity checks first:
1193 func_check_version_match
eddc0c49 1194
e7f9874d
DB
1195 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1196 func_fatal_configuration "not configured to build any kind of library"
eddc0c49
DB
1197 fi
1198
e7f9874d
DB
1199 # Darwin sucks
1200 eval std_shrext=\"$shrext_cmds\"
eddc0c49 1201
e7f9874d
DB
1202 # Only execute mode is allowed to have -dlopen flags.
1203 if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1204 func_error "unrecognized option \`-dlopen'"
1205 $ECHO "$help" 1>&2
1206 exit $EXIT_FAILURE
1207 fi
eddc0c49 1208
e7f9874d
DB
1209 # Change the help message to a mode-specific one.
1210 generic_help="$help"
1211 help="Try \`$progname --help --mode=$opt_mode' for more information."
1212 }
eddc0c49
DB
1213
1214
e7f9874d
DB
1215 # Bail if the options were screwed
1216 $exit_cmd $EXIT_FAILURE
1217}
eddc0c49
DB
1218
1219
eddc0c49 1220
eddc0c49 1221
e7f9874d
DB
1222## ----------- ##
1223## Main. ##
1224## ----------- ##
eddc0c49
DB
1225
1226# func_lalib_p file
1227# True iff FILE is a libtool `.la' library or `.lo' object file.
1228# This function is only a basic sanity check; it will hardly flush out
1229# determined imposters.
1230func_lalib_p ()
1231{
1232 test -f "$1" &&
1233 $SED -e 4q "$1" 2>/dev/null \
1234 | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1235}
1236
1237# func_lalib_unsafe_p file
1238# True iff FILE is a libtool `.la' library or `.lo' object file.
1239# This function implements the same check as func_lalib_p without
1240# resorting to external programs. To this end, it redirects stdin and
1241# closes it afterwards, without saving the original file descriptor.
1242# As a safety measure, use it only where a negative result would be
1243# fatal anyway. Works if `file' does not exist.
1244func_lalib_unsafe_p ()
1245{
1246 lalib_p=no
1247 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1248 for lalib_p_l in 1 2 3 4
1249 do
1250 read lalib_p_line
1251 case "$lalib_p_line" in
1252 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1253 esac
1254 done
1255 exec 0<&5 5<&-
1256 fi
1257 test "$lalib_p" = yes
1258}
1259
1260# func_ltwrapper_script_p file
1261# True iff FILE is a libtool wrapper script
1262# This function is only a basic sanity check; it will hardly flush out
1263# determined imposters.
1264func_ltwrapper_script_p ()
1265{
1266 func_lalib_p "$1"
1267}
1268
1269# func_ltwrapper_executable_p file
1270# True iff FILE is a libtool wrapper executable
1271# This function is only a basic sanity check; it will hardly flush out
1272# determined imposters.
1273func_ltwrapper_executable_p ()
1274{
1275 func_ltwrapper_exec_suffix=
1276 case $1 in
1277 *.exe) ;;
1278 *) func_ltwrapper_exec_suffix=.exe ;;
1279 esac
1280 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1281}
1282
1283# func_ltwrapper_scriptname file
1284# Assumes file is an ltwrapper_executable
1285# uses $file to determine the appropriate filename for a
1286# temporary ltwrapper_script.
1287func_ltwrapper_scriptname ()
1288{
e7f9874d
DB
1289 func_dirname_and_basename "$1" "" "."
1290 func_stripname '' '.exe' "$func_basename_result"
1291 func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
eddc0c49
DB
1292}
1293
1294# func_ltwrapper_p file
1295# True iff FILE is a libtool wrapper script or wrapper executable
1296# This function is only a basic sanity check; it will hardly flush out
1297# determined imposters.
1298func_ltwrapper_p ()
1299{
1300 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1301}
1302
1303
1304# func_execute_cmds commands fail_cmd
1305# Execute tilde-delimited COMMANDS.
1306# If FAIL_CMD is given, eval that upon failure.
1307# FAIL_CMD may read-access the current command in variable CMD!
1308func_execute_cmds ()
1309{
1310 $opt_debug
1311 save_ifs=$IFS; IFS='~'
1312 for cmd in $1; do
1313 IFS=$save_ifs
1314 eval cmd=\"$cmd\"
1315 func_show_eval "$cmd" "${2-:}"
1316 done
1317 IFS=$save_ifs
1318}
1319
1320
1321# func_source file
1322# Source FILE, adding directory component if necessary.
1323# Note that it is not necessary on cygwin/mingw to append a dot to
1324# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1325# behavior happens only for exec(3), not for open(2)! Also, sourcing
1326# `FILE.' does not work on cygwin managed mounts.
1327func_source ()
1328{
1329 $opt_debug
1330 case $1 in
1331 */* | *\\*) . "$1" ;;
1332 *) . "./$1" ;;
1333 esac
1334}
1335
1336
e7f9874d
DB
1337# func_resolve_sysroot PATH
1338# Replace a leading = in PATH with a sysroot. Store the result into
1339# func_resolve_sysroot_result
1340func_resolve_sysroot ()
1341{
1342 func_resolve_sysroot_result=$1
1343 case $func_resolve_sysroot_result in
1344 =*)
1345 func_stripname '=' '' "$func_resolve_sysroot_result"
1346 func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1347 ;;
1348 esac
1349}
1350
1351# func_replace_sysroot PATH
1352# If PATH begins with the sysroot, replace it with = and
1353# store the result into func_replace_sysroot_result.
1354func_replace_sysroot ()
1355{
1356 case "$lt_sysroot:$1" in
1357 ?*:"$lt_sysroot"*)
1358 func_stripname "$lt_sysroot" '' "$1"
1359 func_replace_sysroot_result="=$func_stripname_result"
1360 ;;
1361 *)
1362 # Including no sysroot.
1363 func_replace_sysroot_result=$1
1364 ;;
1365 esac
1366}
1367
eddc0c49
DB
1368# func_infer_tag arg
1369# Infer tagged configuration to use if any are available and
1370# if one wasn't chosen via the "--tag" command line option.
1371# Only attempt this if the compiler in the base compile
1372# command doesn't match the default compiler.
1373# arg is usually of the form 'gcc ...'
1374func_infer_tag ()
1375{
1376 $opt_debug
1377 if test -n "$available_tags" && test -z "$tagname"; then
1378 CC_quoted=
1379 for arg in $CC; do
e7f9874d 1380 func_append_quoted CC_quoted "$arg"
eddc0c49 1381 done
e7f9874d
DB
1382 CC_expanded=`func_echo_all $CC`
1383 CC_quoted_expanded=`func_echo_all $CC_quoted`
eddc0c49
DB
1384 case $@ in
1385 # Blanks in the command may have been stripped by the calling shell,
1386 # but not from the CC environment variable when configure was run.
e7f9874d
DB
1387 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1388 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
eddc0c49
DB
1389 # Blanks at the start of $base_compile will cause this to fail
1390 # if we don't check for them as well.
1391 *)
1392 for z in $available_tags; do
1393 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1394 # Evaluate the configuration.
1395 eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1396 CC_quoted=
1397 for arg in $CC; do
1398 # Double-quote args containing other shell metacharacters.
e7f9874d 1399 func_append_quoted CC_quoted "$arg"
eddc0c49 1400 done
e7f9874d
DB
1401 CC_expanded=`func_echo_all $CC`
1402 CC_quoted_expanded=`func_echo_all $CC_quoted`
eddc0c49 1403 case "$@ " in
e7f9874d
DB
1404 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1405 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
eddc0c49
DB
1406 # The compiler in the base compile command matches
1407 # the one in the tagged configuration.
1408 # Assume this is the tagged configuration we want.
1409 tagname=$z
1410 break
1411 ;;
1412 esac
1413 fi
1414 done
1415 # If $tagname still isn't set, then no tagged configuration
1416 # was found and let the user know that the "--tag" command
1417 # line option must be used.
1418 if test -z "$tagname"; then
1419 func_echo "unable to infer tagged configuration"
1420 func_fatal_error "specify a tag with \`--tag'"
1421# else
1422# func_verbose "using $tagname tagged configuration"
1423 fi
1424 ;;
1425 esac
1426 fi
1427}
1428
1429
1430
1431# func_write_libtool_object output_name pic_name nonpic_name
1432# Create a libtool object file (analogous to a ".la" file),
1433# but don't create it if we're doing a dry run.
1434func_write_libtool_object ()
1435{
1436 write_libobj=${1}
1437 if test "$build_libtool_libs" = yes; then
1438 write_lobj=\'${2}\'
1439 else
1440 write_lobj=none
1441 fi
1442
1443 if test "$build_old_libs" = yes; then
1444 write_oldobj=\'${3}\'
1445 else
1446 write_oldobj=none
1447 fi
1448
1449 $opt_dry_run || {
1450 cat >${write_libobj}T <<EOF
1451# $write_libobj - a libtool object file
1452# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1453#
1454# Please DO NOT delete this file!
1455# It is necessary for linking the library.
1456
1457# Name of the PIC object.
1458pic_object=$write_lobj
1459
1460# Name of the non-PIC object
1461non_pic_object=$write_oldobj
1462
1463EOF
1464 $MV "${write_libobj}T" "${write_libobj}"
1465 }
1466}
1467
e7f9874d
DB
1468
1469##################################################
1470# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1471##################################################
1472
1473# func_convert_core_file_wine_to_w32 ARG
1474# Helper function used by file name conversion functions when $build is *nix,
1475# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1476# correctly configured wine environment available, with the winepath program
1477# in $build's $PATH.
1478#
1479# ARG is the $build file name to be converted to w32 format.
1480# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1481# be empty on error (or when ARG is empty)
1482func_convert_core_file_wine_to_w32 ()
1483{
1484 $opt_debug
1485 func_convert_core_file_wine_to_w32_result="$1"
1486 if test -n "$1"; then
1487 # Unfortunately, winepath does not exit with a non-zero error code, so we
1488 # are forced to check the contents of stdout. On the other hand, if the
1489 # command is not found, the shell will set an exit code of 127 and print
1490 # *an error message* to stdout. So we must check for both error code of
1491 # zero AND non-empty stdout, which explains the odd construction:
1492 func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1493 if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1494 func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1495 $SED -e "$lt_sed_naive_backslashify"`
1496 else
1497 func_convert_core_file_wine_to_w32_result=
1498 fi
1499 fi
1500}
1501# end: func_convert_core_file_wine_to_w32
1502
1503
1504# func_convert_core_path_wine_to_w32 ARG
1505# Helper function used by path conversion functions when $build is *nix, and
1506# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1507# configured wine environment available, with the winepath program in $build's
1508# $PATH. Assumes ARG has no leading or trailing path separator characters.
1509#
1510# ARG is path to be converted from $build format to win32.
1511# Result is available in $func_convert_core_path_wine_to_w32_result.
1512# Unconvertible file (directory) names in ARG are skipped; if no directory names
1513# are convertible, then the result may be empty.
1514func_convert_core_path_wine_to_w32 ()
1515{
1516 $opt_debug
1517 # unfortunately, winepath doesn't convert paths, only file names
1518 func_convert_core_path_wine_to_w32_result=""
1519 if test -n "$1"; then
1520 oldIFS=$IFS
1521 IFS=:
1522 for func_convert_core_path_wine_to_w32_f in $1; do
1523 IFS=$oldIFS
1524 func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1525 if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1526 if test -z "$func_convert_core_path_wine_to_w32_result"; then
1527 func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1528 else
1529 func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1530 fi
1531 fi
1532 done
1533 IFS=$oldIFS
1534 fi
1535}
1536# end: func_convert_core_path_wine_to_w32
1537
1538
1539# func_cygpath ARGS...
1540# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1541# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1542# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1543# (2), returns the Cygwin file name or path in func_cygpath_result (input
1544# file name or path is assumed to be in w32 format, as previously converted
1545# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1546# or path in func_cygpath_result (input file name or path is assumed to be in
1547# Cygwin format). Returns an empty string on error.
1548#
1549# ARGS are passed to cygpath, with the last one being the file name or path to
1550# be converted.
1551#
1552# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1553# environment variable; do not put it in $PATH.
1554func_cygpath ()
1555{
1556 $opt_debug
1557 if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1558 func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1559 if test "$?" -ne 0; then
1560 # on failure, ensure result is empty
1561 func_cygpath_result=
1562 fi
1563 else
1564 func_cygpath_result=
1565 func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1566 fi
1567}
1568#end: func_cygpath
1569
1570
1571# func_convert_core_msys_to_w32 ARG
1572# Convert file name or path ARG from MSYS format to w32 format. Return
1573# result in func_convert_core_msys_to_w32_result.
1574func_convert_core_msys_to_w32 ()
1575{
1576 $opt_debug
1577 # awkward: cmd appends spaces to result
1578 func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1579 $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1580}
1581#end: func_convert_core_msys_to_w32
1582
1583
1584# func_convert_file_check ARG1 ARG2
1585# Verify that ARG1 (a file name in $build format) was converted to $host
1586# format in ARG2. Otherwise, emit an error message, but continue (resetting
1587# func_to_host_file_result to ARG1).
1588func_convert_file_check ()
1589{
1590 $opt_debug
1591 if test -z "$2" && test -n "$1" ; then
1592 func_error "Could not determine host file name corresponding to"
1593 func_error " \`$1'"
1594 func_error "Continuing, but uninstalled executables may not work."
1595 # Fallback:
1596 func_to_host_file_result="$1"
1597 fi
1598}
1599# end func_convert_file_check
1600
1601
1602# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1603# Verify that FROM_PATH (a path in $build format) was converted to $host
1604# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1605# func_to_host_file_result to a simplistic fallback value (see below).
1606func_convert_path_check ()
1607{
1608 $opt_debug
1609 if test -z "$4" && test -n "$3"; then
1610 func_error "Could not determine the host path corresponding to"
1611 func_error " \`$3'"
1612 func_error "Continuing, but uninstalled executables may not work."
1613 # Fallback. This is a deliberately simplistic "conversion" and
1614 # should not be "improved". See libtool.info.
1615 if test "x$1" != "x$2"; then
1616 lt_replace_pathsep_chars="s|$1|$2|g"
1617 func_to_host_path_result=`echo "$3" |
1618 $SED -e "$lt_replace_pathsep_chars"`
1619 else
1620 func_to_host_path_result="$3"
1621 fi
1622 fi
1623}
1624# end func_convert_path_check
1625
1626
1627# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1628# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1629# and appending REPL if ORIG matches BACKPAT.
1630func_convert_path_front_back_pathsep ()
1631{
1632 $opt_debug
1633 case $4 in
1634 $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1635 ;;
1636 esac
1637 case $4 in
1638 $2 ) func_append func_to_host_path_result "$3"
1639 ;;
1640 esac
1641}
1642# end func_convert_path_front_back_pathsep
1643
1644
1645##################################################
1646# $build to $host FILE NAME CONVERSION FUNCTIONS #
1647##################################################
1648# invoked via `$to_host_file_cmd ARG'
1649#
1650# In each case, ARG is the path to be converted from $build to $host format.
1651# Result will be available in $func_to_host_file_result.
1652
1653
1654# func_to_host_file ARG
1655# Converts the file name ARG from $build format to $host format. Return result
1656# in func_to_host_file_result.
1657func_to_host_file ()
1658{
1659 $opt_debug
1660 $to_host_file_cmd "$1"
1661}
1662# end func_to_host_file
1663
1664
1665# func_to_tool_file ARG LAZY
1666# converts the file name ARG from $build format to toolchain format. Return
1667# result in func_to_tool_file_result. If the conversion in use is listed
1668# in (the comma separated) LAZY, no conversion takes place.
1669func_to_tool_file ()
1670{
1671 $opt_debug
1672 case ,$2, in
1673 *,"$to_tool_file_cmd",*)
1674 func_to_tool_file_result=$1
1675 ;;
1676 *)
1677 $to_tool_file_cmd "$1"
1678 func_to_tool_file_result=$func_to_host_file_result
1679 ;;
1680 esac
1681}
1682# end func_to_tool_file
1683
1684
1685# func_convert_file_noop ARG
1686# Copy ARG to func_to_host_file_result.
1687func_convert_file_noop ()
1688{
1689 func_to_host_file_result="$1"
1690}
1691# end func_convert_file_noop
1692
1693
1694# func_convert_file_msys_to_w32 ARG
1695# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1696# conversion to w32 is not available inside the cwrapper. Returns result in
1697# func_to_host_file_result.
1698func_convert_file_msys_to_w32 ()
1699{
1700 $opt_debug
1701 func_to_host_file_result="$1"
1702 if test -n "$1"; then
1703 func_convert_core_msys_to_w32 "$1"
1704 func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1705 fi
1706 func_convert_file_check "$1" "$func_to_host_file_result"
1707}
1708# end func_convert_file_msys_to_w32
1709
1710
1711# func_convert_file_cygwin_to_w32 ARG
1712# Convert file name ARG from Cygwin to w32 format. Returns result in
1713# func_to_host_file_result.
1714func_convert_file_cygwin_to_w32 ()
1715{
1716 $opt_debug
1717 func_to_host_file_result="$1"
1718 if test -n "$1"; then
1719 # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1720 # LT_CYGPATH in this case.
1721 func_to_host_file_result=`cygpath -m "$1"`
1722 fi
1723 func_convert_file_check "$1" "$func_to_host_file_result"
1724}
1725# end func_convert_file_cygwin_to_w32
1726
1727
1728# func_convert_file_nix_to_w32 ARG
1729# Convert file name ARG from *nix to w32 format. Requires a wine environment
1730# and a working winepath. Returns result in func_to_host_file_result.
1731func_convert_file_nix_to_w32 ()
1732{
1733 $opt_debug
1734 func_to_host_file_result="$1"
1735 if test -n "$1"; then
1736 func_convert_core_file_wine_to_w32 "$1"
1737 func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1738 fi
1739 func_convert_file_check "$1" "$func_to_host_file_result"
1740}
1741# end func_convert_file_nix_to_w32
1742
1743
1744# func_convert_file_msys_to_cygwin ARG
1745# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
1746# Returns result in func_to_host_file_result.
1747func_convert_file_msys_to_cygwin ()
1748{
1749 $opt_debug
1750 func_to_host_file_result="$1"
1751 if test -n "$1"; then
1752 func_convert_core_msys_to_w32 "$1"
1753 func_cygpath -u "$func_convert_core_msys_to_w32_result"
1754 func_to_host_file_result="$func_cygpath_result"
1755 fi
1756 func_convert_file_check "$1" "$func_to_host_file_result"
1757}
1758# end func_convert_file_msys_to_cygwin
1759
1760
1761# func_convert_file_nix_to_cygwin ARG
1762# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
1763# in a wine environment, working winepath, and LT_CYGPATH set. Returns result
1764# in func_to_host_file_result.
1765func_convert_file_nix_to_cygwin ()
1766{
1767 $opt_debug
1768 func_to_host_file_result="$1"
1769 if test -n "$1"; then
1770 # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1771 func_convert_core_file_wine_to_w32 "$1"
1772 func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1773 func_to_host_file_result="$func_cygpath_result"
1774 fi
1775 func_convert_file_check "$1" "$func_to_host_file_result"
1776}
1777# end func_convert_file_nix_to_cygwin
1778
1779
1780#############################################
1781# $build to $host PATH CONVERSION FUNCTIONS #
1782#############################################
1783# invoked via `$to_host_path_cmd ARG'
1784#
1785# In each case, ARG is the path to be converted from $build to $host format.
1786# The result will be available in $func_to_host_path_result.
1787#
1788# Path separators are also converted from $build format to $host format. If
1789# ARG begins or ends with a path separator character, it is preserved (but
1790# converted to $host format) on output.
1791#
1792# All path conversion functions are named using the following convention:
1793# file name conversion function : func_convert_file_X_to_Y ()
1794# path conversion function : func_convert_path_X_to_Y ()
1795# where, for any given $build/$host combination the 'X_to_Y' value is the
1796# same. If conversion functions are added for new $build/$host combinations,
1797# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1798# will break.
1799
1800
1801# func_init_to_host_path_cmd
1802# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1803# appropriate value, based on the value of $to_host_file_cmd.
1804to_host_path_cmd=
1805func_init_to_host_path_cmd ()
1806{
1807 $opt_debug
1808 if test -z "$to_host_path_cmd"; then
1809 func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1810 to_host_path_cmd="func_convert_path_${func_stripname_result}"
1811 fi
1812}
1813
1814
1815# func_to_host_path ARG
1816# Converts the path ARG from $build format to $host format. Return result
1817# in func_to_host_path_result.
1818func_to_host_path ()
1819{
1820 $opt_debug
1821 func_init_to_host_path_cmd
1822 $to_host_path_cmd "$1"
1823}
1824# end func_to_host_path
1825
1826
1827# func_convert_path_noop ARG
1828# Copy ARG to func_to_host_path_result.
1829func_convert_path_noop ()
1830{
1831 func_to_host_path_result="$1"
1832}
1833# end func_convert_path_noop
1834
1835
1836# func_convert_path_msys_to_w32 ARG
1837# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1838# conversion to w32 is not available inside the cwrapper. Returns result in
1839# func_to_host_path_result.
1840func_convert_path_msys_to_w32 ()
1841{
1842 $opt_debug
1843 func_to_host_path_result="$1"
1844 if test -n "$1"; then
1845 # Remove leading and trailing path separator characters from ARG. MSYS
1846 # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1847 # and winepath ignores them completely.
1848 func_stripname : : "$1"
1849 func_to_host_path_tmp1=$func_stripname_result
1850 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1851 func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1852 func_convert_path_check : ";" \
1853 "$func_to_host_path_tmp1" "$func_to_host_path_result"
1854 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1855 fi
1856}
1857# end func_convert_path_msys_to_w32
1858
1859
1860# func_convert_path_cygwin_to_w32 ARG
1861# Convert path ARG from Cygwin to w32 format. Returns result in
1862# func_to_host_file_result.
1863func_convert_path_cygwin_to_w32 ()
1864{
1865 $opt_debug
1866 func_to_host_path_result="$1"
1867 if test -n "$1"; then
1868 # See func_convert_path_msys_to_w32:
1869 func_stripname : : "$1"
1870 func_to_host_path_tmp1=$func_stripname_result
1871 func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1872 func_convert_path_check : ";" \
1873 "$func_to_host_path_tmp1" "$func_to_host_path_result"
1874 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1875 fi
1876}
1877# end func_convert_path_cygwin_to_w32
1878
1879
1880# func_convert_path_nix_to_w32 ARG
1881# Convert path ARG from *nix to w32 format. Requires a wine environment and
1882# a working winepath. Returns result in func_to_host_file_result.
1883func_convert_path_nix_to_w32 ()
1884{
1885 $opt_debug
1886 func_to_host_path_result="$1"
1887 if test -n "$1"; then
1888 # See func_convert_path_msys_to_w32:
1889 func_stripname : : "$1"
1890 func_to_host_path_tmp1=$func_stripname_result
1891 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1892 func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1893 func_convert_path_check : ";" \
1894 "$func_to_host_path_tmp1" "$func_to_host_path_result"
1895 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1896 fi
1897}
1898# end func_convert_path_nix_to_w32
1899
1900
1901# func_convert_path_msys_to_cygwin ARG
1902# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
1903# Returns result in func_to_host_file_result.
1904func_convert_path_msys_to_cygwin ()
1905{
1906 $opt_debug
1907 func_to_host_path_result="$1"
1908 if test -n "$1"; then
1909 # See func_convert_path_msys_to_w32:
1910 func_stripname : : "$1"
1911 func_to_host_path_tmp1=$func_stripname_result
1912 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1913 func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1914 func_to_host_path_result="$func_cygpath_result"
1915 func_convert_path_check : : \
1916 "$func_to_host_path_tmp1" "$func_to_host_path_result"
1917 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1918 fi
1919}
1920# end func_convert_path_msys_to_cygwin
1921
1922
1923# func_convert_path_nix_to_cygwin ARG
1924# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
1925# a wine environment, working winepath, and LT_CYGPATH set. Returns result in
1926# func_to_host_file_result.
1927func_convert_path_nix_to_cygwin ()
1928{
1929 $opt_debug
1930 func_to_host_path_result="$1"
1931 if test -n "$1"; then
1932 # Remove leading and trailing path separator characters from
1933 # ARG. msys behavior is inconsistent here, cygpath turns them
1934 # into '.;' and ';.', and winepath ignores them completely.
1935 func_stripname : : "$1"
1936 func_to_host_path_tmp1=$func_stripname_result
1937 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1938 func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1939 func_to_host_path_result="$func_cygpath_result"
1940 func_convert_path_check : : \
1941 "$func_to_host_path_tmp1" "$func_to_host_path_result"
1942 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1943 fi
1944}
1945# end func_convert_path_nix_to_cygwin
1946
1947
eddc0c49
DB
1948# func_mode_compile arg...
1949func_mode_compile ()
1950{
1951 $opt_debug
1952 # Get the compilation command and the source file.
1953 base_compile=
1954 srcfile="$nonopt" # always keep a non-empty value in "srcfile"
1955 suppress_opt=yes
1956 suppress_output=
1957 arg_mode=normal
1958 libobj=
1959 later=
1960 pie_flag=
1961
1962 for arg
1963 do
1964 case $arg_mode in
1965 arg )
1966 # do not "continue". Instead, add this to base_compile
1967 lastarg="$arg"
1968 arg_mode=normal
1969 ;;
1970
1971 target )
1972 libobj="$arg"
1973 arg_mode=normal
1974 continue
1975 ;;
1976
1977 normal )
1978 # Accept any command-line options.
1979 case $arg in
1980 -o)
1981 test -n "$libobj" && \
1982 func_fatal_error "you cannot specify \`-o' more than once"
1983 arg_mode=target
1984 continue
1985 ;;
1986
1987 -pie | -fpie | -fPIE)
e7f9874d 1988 func_append pie_flag " $arg"
eddc0c49
DB
1989 continue
1990 ;;
1991
1992 -shared | -static | -prefer-pic | -prefer-non-pic)
e7f9874d 1993 func_append later " $arg"
eddc0c49
DB
1994 continue
1995 ;;
1996
1997 -no-suppress)
1998 suppress_opt=no
1999 continue
2000 ;;
2001
2002 -Xcompiler)
2003 arg_mode=arg # the next one goes into the "base_compile" arg list
2004 continue # The current "srcfile" will either be retained or
2005 ;; # replaced later. I would guess that would be a bug.
2006
2007 -Wc,*)
2008 func_stripname '-Wc,' '' "$arg"
2009 args=$func_stripname_result
2010 lastarg=
2011 save_ifs="$IFS"; IFS=','
2012 for arg in $args; do
2013 IFS="$save_ifs"
e7f9874d 2014 func_append_quoted lastarg "$arg"
eddc0c49
DB
2015 done
2016 IFS="$save_ifs"
2017 func_stripname ' ' '' "$lastarg"
2018 lastarg=$func_stripname_result
2019
2020 # Add the arguments to base_compile.
e7f9874d 2021 func_append base_compile " $lastarg"
eddc0c49
DB
2022 continue
2023 ;;
2024
2025 *)
2026 # Accept the current argument as the source file.
2027 # The previous "srcfile" becomes the current argument.
2028 #
2029 lastarg="$srcfile"
2030 srcfile="$arg"
2031 ;;
2032 esac # case $arg
2033 ;;
2034 esac # case $arg_mode
2035
2036 # Aesthetically quote the previous argument.
e7f9874d 2037 func_append_quoted base_compile "$lastarg"
eddc0c49
DB
2038 done # for arg
2039
2040 case $arg_mode in
2041 arg)
2042 func_fatal_error "you must specify an argument for -Xcompile"
2043 ;;
2044 target)
2045 func_fatal_error "you must specify a target with \`-o'"
2046 ;;
2047 *)
2048 # Get the name of the library object.
2049 test -z "$libobj" && {
2050 func_basename "$srcfile"
2051 libobj="$func_basename_result"
2052 }
2053 ;;
2054 esac
2055
2056 # Recognize several different file suffixes.
2057 # If the user specifies -o file.o, it is replaced with file.lo
2058 case $libobj in
2059 *.[cCFSifmso] | \
2060 *.ada | *.adb | *.ads | *.asm | \
2061 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
e7f9874d 2062 *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
eddc0c49
DB
2063 func_xform "$libobj"
2064 libobj=$func_xform_result
2065 ;;
2066 esac
2067
2068 case $libobj in
2069 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2070 *)
2071 func_fatal_error "cannot determine name of library object from \`$libobj'"
2072 ;;
2073 esac
2074
2075 func_infer_tag $base_compile
2076
2077 for arg in $later; do
2078 case $arg in
2079 -shared)
2080 test "$build_libtool_libs" != yes && \
2081 func_fatal_configuration "can not build a shared library"
2082 build_old_libs=no
2083 continue
2084 ;;
2085
2086 -static)
2087 build_libtool_libs=no
2088 build_old_libs=yes
2089 continue
2090 ;;
2091
2092 -prefer-pic)
2093 pic_mode=yes
2094 continue
2095 ;;
2096
2097 -prefer-non-pic)
2098 pic_mode=no
2099 continue
2100 ;;
2101 esac
2102 done
2103
2104 func_quote_for_eval "$libobj"
2105 test "X$libobj" != "X$func_quote_for_eval_result" \
2106 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
2107 && func_warning "libobj name \`$libobj' may not contain shell special characters."
2108 func_dirname_and_basename "$obj" "/" ""
2109 objname="$func_basename_result"
2110 xdir="$func_dirname_result"
2111 lobj=${xdir}$objdir/$objname
2112
2113 test -z "$base_compile" && \
2114 func_fatal_help "you must specify a compilation command"
2115
2116 # Delete any leftover library objects.
2117 if test "$build_old_libs" = yes; then
2118 removelist="$obj $lobj $libobj ${libobj}T"
2119 else
2120 removelist="$lobj $libobj ${libobj}T"
2121 fi
2122
2123 # On Cygwin there's no "real" PIC flag so we must build both object types
2124 case $host_os in
2125 cygwin* | mingw* | pw32* | os2* | cegcc*)
2126 pic_mode=default
2127 ;;
2128 esac
2129 if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2130 # non-PIC code in shared libraries is not supported
2131 pic_mode=default
2132 fi
2133
2134 # Calculate the filename of the output object if compiler does
2135 # not support -o with -c
2136 if test "$compiler_c_o" = no; then
e7f9874d 2137 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
eddc0c49
DB
2138 lockfile="$output_obj.lock"
2139 else
2140 output_obj=
2141 need_locks=no
2142 lockfile=
2143 fi
2144
2145 # Lock this critical section if it is needed
2146 # We use this script file to make the link, it avoids creating a new file
2147 if test "$need_locks" = yes; then
2148 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2149 func_echo "Waiting for $lockfile to be removed"
2150 sleep 2
2151 done
2152 elif test "$need_locks" = warn; then
2153 if test -f "$lockfile"; then
2154 $ECHO "\
2155*** ERROR, $lockfile exists and contains:
2156`cat $lockfile 2>/dev/null`
2157
2158This indicates that another process is trying to use the same
2159temporary object file, and libtool could not work around it because
2160your compiler does not support \`-c' and \`-o' together. If you
2161repeat this compilation, it may succeed, by chance, but you had better
2162avoid parallel builds (make -j) in this platform, or get a better
2163compiler."
2164
2165 $opt_dry_run || $RM $removelist
2166 exit $EXIT_FAILURE
2167 fi
e7f9874d 2168 func_append removelist " $output_obj"
eddc0c49
DB
2169 $ECHO "$srcfile" > "$lockfile"
2170 fi
2171
2172 $opt_dry_run || $RM $removelist
e7f9874d 2173 func_append removelist " $lockfile"
eddc0c49
DB
2174 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2175
e7f9874d
DB
2176 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2177 srcfile=$func_to_tool_file_result
eddc0c49
DB
2178 func_quote_for_eval "$srcfile"
2179 qsrcfile=$func_quote_for_eval_result
2180
2181 # Only build a PIC object if we are building libtool libraries.
2182 if test "$build_libtool_libs" = yes; then
2183 # Without this assignment, base_compile gets emptied.
2184 fbsd_hideous_sh_bug=$base_compile
2185
2186 if test "$pic_mode" != no; then
2187 command="$base_compile $qsrcfile $pic_flag"
2188 else
2189 # Don't build PIC code
2190 command="$base_compile $qsrcfile"
2191 fi
2192
2193 func_mkdir_p "$xdir$objdir"
2194
2195 if test -z "$output_obj"; then
2196 # Place PIC objects in $objdir
e7f9874d 2197 func_append command " -o $lobj"
eddc0c49
DB
2198 fi
2199
2200 func_show_eval_locale "$command" \
2201 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2202
2203 if test "$need_locks" = warn &&
2204 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2205 $ECHO "\
2206*** ERROR, $lockfile contains:
2207`cat $lockfile 2>/dev/null`
2208
2209but it should contain:
2210$srcfile
2211
2212This indicates that another process is trying to use the same
2213temporary object file, and libtool could not work around it because
2214your compiler does not support \`-c' and \`-o' together. If you
2215repeat this compilation, it may succeed, by chance, but you had better
2216avoid parallel builds (make -j) in this platform, or get a better
2217compiler."
2218
2219 $opt_dry_run || $RM $removelist
2220 exit $EXIT_FAILURE
2221 fi
2222
2223 # Just move the object if needed, then go on to compile the next one
2224 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2225 func_show_eval '$MV "$output_obj" "$lobj"' \
2226 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2227 fi
2228
2229 # Allow error messages only from the first compilation.
2230 if test "$suppress_opt" = yes; then
2231 suppress_output=' >/dev/null 2>&1'
2232 fi
2233 fi
2234
2235 # Only build a position-dependent object if we build old libraries.
2236 if test "$build_old_libs" = yes; then
2237 if test "$pic_mode" != yes; then
2238 # Don't build PIC code
2239 command="$base_compile $qsrcfile$pie_flag"
2240 else
2241 command="$base_compile $qsrcfile $pic_flag"
2242 fi
2243 if test "$compiler_c_o" = yes; then
e7f9874d 2244 func_append command " -o $obj"
eddc0c49
DB
2245 fi
2246
2247 # Suppress compiler output if we already did a PIC compilation.
e7f9874d 2248 func_append command "$suppress_output"
eddc0c49
DB
2249 func_show_eval_locale "$command" \
2250 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2251
2252 if test "$need_locks" = warn &&
2253 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2254 $ECHO "\
2255*** ERROR, $lockfile contains:
2256`cat $lockfile 2>/dev/null`
2257
2258but it should contain:
2259$srcfile
2260
2261This indicates that another process is trying to use the same
2262temporary object file, and libtool could not work around it because
2263your compiler does not support \`-c' and \`-o' together. If you
2264repeat this compilation, it may succeed, by chance, but you had better
2265avoid parallel builds (make -j) in this platform, or get a better
2266compiler."
2267
2268 $opt_dry_run || $RM $removelist
2269 exit $EXIT_FAILURE
2270 fi
2271
2272 # Just move the object if needed
2273 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2274 func_show_eval '$MV "$output_obj" "$obj"' \
2275 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2276 fi
2277 fi
2278
2279 $opt_dry_run || {
2280 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2281
2282 # Unlock the critical section if it was locked
2283 if test "$need_locks" != no; then
2284 removelist=$lockfile
2285 $RM "$lockfile"
2286 fi
2287 }
2288
2289 exit $EXIT_SUCCESS
2290}
2291
2292$opt_help || {
e7f9874d 2293 test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
eddc0c49
DB
2294}
2295
2296func_mode_help ()
2297{
2298 # We need to display help for each of the modes.
e7f9874d 2299 case $opt_mode in
eddc0c49
DB
2300 "")
2301 # Generic help is extracted from the usage comments
2302 # at the start of this file.
2303 func_help
2304 ;;
2305
2306 clean)
2307 $ECHO \
2308"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2309
2310Remove files from the build directory.
2311
2312RM is the name of the program to use to delete files associated with each FILE
2313(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
2314to RM.
2315
2316If FILE is a libtool library, object or program, all the files associated
2317with it are deleted. Otherwise, only FILE itself is deleted using RM."
2318 ;;
2319
2320 compile)
2321 $ECHO \
2322"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2323
2324Compile a source file into a libtool library object.
2325
2326This mode accepts the following additional options:
2327
2328 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
2329 -no-suppress do not suppress compiler output for multiple passes
e7f9874d
DB
2330 -prefer-pic try to build PIC objects only
2331 -prefer-non-pic try to build non-PIC objects only
eddc0c49
DB
2332 -shared do not build a \`.o' file suitable for static linking
2333 -static only build a \`.o' file suitable for static linking
e7f9874d 2334 -Wc,FLAG pass FLAG directly to the compiler
eddc0c49
DB
2335
2336COMPILE-COMMAND is a command to be used in creating a \`standard' object file
2337from the given SOURCEFILE.
2338
2339The output file name is determined by removing the directory component from
2340SOURCEFILE, then substituting the C source code suffix \`.c' with the
2341library object suffix, \`.lo'."
2342 ;;
2343
2344 execute)
2345 $ECHO \
2346"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2347
2348Automatically set library path, then run a program.
2349
2350This mode accepts the following additional options:
2351
2352 -dlopen FILE add the directory containing FILE to the library path
2353
2354This mode sets the library path environment variable according to \`-dlopen'
2355flags.
2356
2357If any of the ARGS are libtool executable wrappers, then they are translated
2358into their corresponding uninstalled binary, and any of their required library
2359directories are added to the library path.
2360
2361Then, COMMAND is executed, with ARGS as arguments."
2362 ;;
2363
2364 finish)
2365 $ECHO \
2366"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2367
2368Complete the installation of libtool libraries.
2369
2370Each LIBDIR is a directory that contains libtool libraries.
2371
2372The commands that this mode executes may require superuser privileges. Use
2373the \`--dry-run' option if you just want to see what would be executed."
2374 ;;
2375
2376 install)
2377 $ECHO \
2378"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2379
2380Install executables or libraries.
2381
2382INSTALL-COMMAND is the installation command. The first component should be
2383either the \`install' or \`cp' program.
2384
2385The following components of INSTALL-COMMAND are treated specially:
2386
e7f9874d 2387 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
eddc0c49
DB
2388
2389The rest of the components are interpreted as arguments to that command (only
2390BSD-compatible install options are recognized)."
2391 ;;
2392
2393 link)
2394 $ECHO \
2395"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2396
2397Link object files or libraries together to form another library, or to
2398create an executable program.
2399
2400LINK-COMMAND is a command using the C compiler that you would use to create
2401a program from several object files.
2402
2403The following components of LINK-COMMAND are treated specially:
2404
2405 -all-static do not do any dynamic linking at all
2406 -avoid-version do not add a version suffix if possible
e7f9874d
DB
2407 -bindir BINDIR specify path to binaries directory (for systems where
2408 libraries must be found in the PATH setting at runtime)
eddc0c49
DB
2409 -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
2410 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
2411 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2412 -export-symbols SYMFILE
2413 try to export only the symbols listed in SYMFILE
2414 -export-symbols-regex REGEX
2415 try to export only the symbols matching REGEX
2416 -LLIBDIR search LIBDIR for required installed libraries
2417 -lNAME OUTPUT-FILE requires the installed library libNAME
2418 -module build a library that can dlopened
2419 -no-fast-install disable the fast-install mode
2420 -no-install link a not-installable executable
2421 -no-undefined declare that a library does not refer to external symbols
2422 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
2423 -objectlist FILE Use a list of object files found in FILE to specify objects
2424 -precious-files-regex REGEX
2425 don't remove output files matching REGEX
2426 -release RELEASE specify package release information
2427 -rpath LIBDIR the created library will eventually be installed in LIBDIR
2428 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
2429 -shared only do dynamic linking of libtool libraries
2430 -shrext SUFFIX override the standard shared library file extension
2431 -static do not do any dynamic linking of uninstalled libtool libraries
2432 -static-libtool-libs
2433 do not do any dynamic linking of libtool libraries
2434 -version-info CURRENT[:REVISION[:AGE]]
2435 specify library version info [each variable defaults to 0]
2436 -weak LIBNAME declare that the target provides the LIBNAME interface
e7f9874d
DB
2437 -Wc,FLAG
2438 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
2439 -Wl,FLAG
2440 -Xlinker FLAG pass linker-specific FLAG directly to the linker
2441 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
eddc0c49
DB
2442
2443All other options (arguments beginning with \`-') are ignored.
2444
2445Every other argument is treated as a filename. Files ending in \`.la' are
2446treated as uninstalled libtool libraries, other files are standard or library
2447object files.
2448
2449If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2450only library objects (\`.lo' files) may be specified, and \`-rpath' is
2451required, except when creating a convenience library.
2452
2453If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2454using \`ar' and \`ranlib', or on Windows using \`lib'.
2455
2456If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2457is created, otherwise an executable program is created."
2458 ;;
2459
2460 uninstall)
2461 $ECHO \
2462"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2463
2464Remove libraries from an installation directory.
2465
2466RM is the name of the program to use to delete files associated with each FILE
2467(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
2468to RM.
2469
2470If FILE is a libtool library, all the files associated with it are deleted.
2471Otherwise, only FILE itself is deleted using RM."
2472 ;;
2473
2474 *)
e7f9874d 2475 func_fatal_help "invalid operation mode \`$opt_mode'"
eddc0c49
DB
2476 ;;
2477 esac
2478
e7f9874d 2479 echo
eddc0c49 2480 $ECHO "Try \`$progname --help' for more information about other modes."
eddc0c49
DB
2481}
2482
e7f9874d
DB
2483# Now that we've collected a possible --mode arg, show help if necessary
2484if $opt_help; then
2485 if test "$opt_help" = :; then
2486 func_mode_help
2487 else
2488 {
2489 func_help noexit
2490 for opt_mode in compile link execute install finish uninstall clean; do
2491 func_mode_help
2492 done
2493 } | sed -n '1p; 2,$s/^Usage:/ or: /p'
2494 {
2495 func_help noexit
2496 for opt_mode in compile link execute install finish uninstall clean; do
2497 echo
2498 func_mode_help
2499 done
2500 } |
2501 sed '1d
2502 /^When reporting/,/^Report/{
2503 H
2504 d
2505 }
2506 $x
2507 /information about other modes/d
2508 /more detailed .*MODE/d
2509 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2510 fi
2511 exit $?
2512fi
eddc0c49
DB
2513
2514
2515# func_mode_execute arg...
2516func_mode_execute ()
2517{
2518 $opt_debug
2519 # The first argument is the command name.
2520 cmd="$nonopt"
2521 test -z "$cmd" && \
2522 func_fatal_help "you must specify a COMMAND"
2523
2524 # Handle -dlopen flags immediately.
e7f9874d 2525 for file in $opt_dlopen; do
eddc0c49
DB
2526 test -f "$file" \
2527 || func_fatal_help "\`$file' is not a file"
2528
2529 dir=
2530 case $file in
2531 *.la)
e7f9874d
DB
2532 func_resolve_sysroot "$file"
2533 file=$func_resolve_sysroot_result
2534
eddc0c49
DB
2535 # Check to see that this really is a libtool archive.
2536 func_lalib_unsafe_p "$file" \
2537 || func_fatal_help "\`$lib' is not a valid libtool archive"
2538
2539 # Read the libtool library.
2540 dlname=
2541 library_names=
2542 func_source "$file"
2543
2544 # Skip this library if it cannot be dlopened.
2545 if test -z "$dlname"; then
2546 # Warn if it was a shared library.
2547 test -n "$library_names" && \
2548 func_warning "\`$file' was not linked with \`-export-dynamic'"
2549 continue
2550 fi
2551
2552 func_dirname "$file" "" "."
2553 dir="$func_dirname_result"
2554
2555 if test -f "$dir/$objdir/$dlname"; then
e7f9874d 2556 func_append dir "/$objdir"
eddc0c49
DB
2557 else
2558 if test ! -f "$dir/$dlname"; then
2559 func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2560 fi
2561 fi
2562 ;;
2563
2564 *.lo)
2565 # Just add the directory containing the .lo file.
2566 func_dirname "$file" "" "."
2567 dir="$func_dirname_result"
2568 ;;
2569
2570 *)
2571 func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2572 continue
2573 ;;
2574 esac
2575
2576 # Get the absolute pathname.
2577 absdir=`cd "$dir" && pwd`
2578 test -n "$absdir" && dir="$absdir"
2579
2580 # Now add the directory to shlibpath_var.
2581 if eval "test -z \"\$$shlibpath_var\""; then
2582 eval "$shlibpath_var=\"\$dir\""
2583 else
2584 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2585 fi
2586 done
2587
2588 # This variable tells wrapper scripts just to set shlibpath_var
2589 # rather than running their programs.
2590 libtool_execute_magic="$magic"
2591
2592 # Check if any of the arguments is a wrapper script.
2593 args=
2594 for file
2595 do
2596 case $file in
e7f9874d 2597 -* | *.la | *.lo ) ;;
eddc0c49
DB
2598 *)
2599 # Do a test to see if this is really a libtool program.
2600 if func_ltwrapper_script_p "$file"; then
2601 func_source "$file"
2602 # Transform arg to wrapped name.
2603 file="$progdir/$program"
2604 elif func_ltwrapper_executable_p "$file"; then
2605 func_ltwrapper_scriptname "$file"
2606 func_source "$func_ltwrapper_scriptname_result"
2607 # Transform arg to wrapped name.
2608 file="$progdir/$program"
2609 fi
2610 ;;
2611 esac
2612 # Quote arguments (to preserve shell metacharacters).
e7f9874d 2613 func_append_quoted args "$file"
eddc0c49
DB
2614 done
2615
2616 if test "X$opt_dry_run" = Xfalse; then
2617 if test -n "$shlibpath_var"; then
2618 # Export the shlibpath_var.
2619 eval "export $shlibpath_var"
2620 fi
2621
2622 # Restore saved environment variables
2623 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2624 do
2625 eval "if test \"\${save_$lt_var+set}\" = set; then
2626 $lt_var=\$save_$lt_var; export $lt_var
2627 else
2628 $lt_unset $lt_var
2629 fi"
2630 done
2631
2632 # Now prepare to actually exec the command.
2633 exec_cmd="\$cmd$args"
2634 else
2635 # Display what would be done.
2636 if test -n "$shlibpath_var"; then
2637 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
e7f9874d 2638 echo "export $shlibpath_var"
eddc0c49
DB
2639 fi
2640 $ECHO "$cmd$args"
2641 exit $EXIT_SUCCESS
2642 fi
2643}
2644
e7f9874d
DB
2645test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2646
2647
2648# func_mode_finish arg...
2649func_mode_finish ()
2650{
2651 $opt_debug
2652 libs=
2653 libdirs=
2654 admincmds=
2655
2656 for opt in "$nonopt" ${1+"$@"}
2657 do
2658 if test -d "$opt"; then
2659 func_append libdirs " $opt"
2660
2661 elif test -f "$opt"; then
2662 if func_lalib_unsafe_p "$opt"; then
2663 func_append libs " $opt"
2664 else
2665 func_warning "\`$opt' is not a valid libtool archive"
2666 fi
2667
2668 else
2669 func_fatal_error "invalid argument \`$opt'"
2670 fi
2671 done
eddc0c49 2672
e7f9874d
DB
2673 if test -n "$libs"; then
2674 if test -n "$lt_sysroot"; then
2675 sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2676 sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2677 else
2678 sysroot_cmd=
2679 fi
eddc0c49 2680
e7f9874d
DB
2681 # Remove sysroot references
2682 if $opt_dry_run; then
2683 for lib in $libs; do
2684 echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2685 done
2686 else
2687 tmpdir=`func_mktempdir`
2688 for lib in $libs; do
2689 sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2690 > $tmpdir/tmp-la
2691 mv -f $tmpdir/tmp-la $lib
2692 done
2693 ${RM}r "$tmpdir"
2694 fi
2695 fi
eddc0c49
DB
2696
2697 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
eddc0c49
DB
2698 for libdir in $libdirs; do
2699 if test -n "$finish_cmds"; then
2700 # Do each command in the finish commands.
2701 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2702'"$cmd"'"'
2703 fi
2704 if test -n "$finish_eval"; then
2705 # Do the single finish_eval.
2706 eval cmds=\"$finish_eval\"
e7f9874d 2707 $opt_dry_run || eval "$cmds" || func_append admincmds "
eddc0c49
DB
2708 $cmds"
2709 fi
2710 done
2711 fi
2712
2713 # Exit here if they wanted silent mode.
2714 $opt_silent && exit $EXIT_SUCCESS
2715
e7f9874d
DB
2716 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2717 echo "----------------------------------------------------------------------"
2718 echo "Libraries have been installed in:"
2719 for libdir in $libdirs; do
2720 $ECHO " $libdir"
2721 done
2722 echo
2723 echo "If you ever happen to want to link against installed libraries"
2724 echo "in a given directory, LIBDIR, you must either use libtool, and"
2725 echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2726 echo "flag during linking and do at least one of the following:"
2727 if test -n "$shlibpath_var"; then
2728 echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
2729 echo " during execution"
2730 fi
2731 if test -n "$runpath_var"; then
2732 echo " - add LIBDIR to the \`$runpath_var' environment variable"
2733 echo " during linking"
2734 fi
2735 if test -n "$hardcode_libdir_flag_spec"; then
2736 libdir=LIBDIR
2737 eval flag=\"$hardcode_libdir_flag_spec\"
eddc0c49 2738
e7f9874d
DB
2739 $ECHO " - use the \`$flag' linker flag"
2740 fi
2741 if test -n "$admincmds"; then
2742 $ECHO " - have your system administrator run these commands:$admincmds"
2743 fi
2744 if test -f /etc/ld.so.conf; then
2745 echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2746 fi
2747 echo
eddc0c49 2748
e7f9874d
DB
2749 echo "See any operating system documentation about shared libraries for"
2750 case $host in
2751 solaris2.[6789]|solaris2.1[0-9])
2752 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2753 echo "pages."
2754 ;;
2755 *)
2756 echo "more information, such as the ld(1) and ld.so(8) manual pages."
2757 ;;
2758 esac
2759 echo "----------------------------------------------------------------------"
2760 fi
eddc0c49
DB
2761 exit $EXIT_SUCCESS
2762}
2763
e7f9874d 2764test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
eddc0c49
DB
2765
2766
2767# func_mode_install arg...
2768func_mode_install ()
2769{
2770 $opt_debug
2771 # There may be an optional sh(1) argument at the beginning of
2772 # install_prog (especially on Windows NT).
2773 if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2774 # Allow the use of GNU shtool's install command.
e7f9874d 2775 case $nonopt in *shtool*) :;; *) false;; esac; then
eddc0c49
DB
2776 # Aesthetically quote it.
2777 func_quote_for_eval "$nonopt"
2778 install_prog="$func_quote_for_eval_result "
2779 arg=$1
2780 shift
2781 else
2782 install_prog=
2783 arg=$nonopt
2784 fi
2785
2786 # The real first argument should be the name of the installation program.
2787 # Aesthetically quote it.
2788 func_quote_for_eval "$arg"
e7f9874d
DB
2789 func_append install_prog "$func_quote_for_eval_result"
2790 install_shared_prog=$install_prog
2791 case " $install_prog " in
2792 *[\\\ /]cp\ *) install_cp=: ;;
2793 *) install_cp=false ;;
2794 esac
eddc0c49
DB
2795
2796 # We need to accept at least all the BSD install flags.
2797 dest=
2798 files=
2799 opts=
2800 prev=
2801 install_type=
2802 isdir=no
2803 stripme=
e7f9874d 2804 no_mode=:
eddc0c49
DB
2805 for arg
2806 do
e7f9874d 2807 arg2=
eddc0c49 2808 if test -n "$dest"; then
e7f9874d 2809 func_append files " $dest"
eddc0c49
DB
2810 dest=$arg
2811 continue
2812 fi
2813
2814 case $arg in
2815 -d) isdir=yes ;;
2816 -f)
e7f9874d
DB
2817 if $install_cp; then :; else
2818 prev=$arg
2819 fi
eddc0c49
DB
2820 ;;
2821 -g | -m | -o)
2822 prev=$arg
2823 ;;
2824 -s)
2825 stripme=" -s"
2826 continue
2827 ;;
2828 -*)
2829 ;;
2830 *)
2831 # If the previous option needed an argument, then skip it.
2832 if test -n "$prev"; then
e7f9874d
DB
2833 if test "x$prev" = x-m && test -n "$install_override_mode"; then
2834 arg2=$install_override_mode
2835 no_mode=false
2836 fi
eddc0c49
DB
2837 prev=
2838 else
2839 dest=$arg
2840 continue
2841 fi
2842 ;;
2843 esac
2844
2845 # Aesthetically quote the argument.
2846 func_quote_for_eval "$arg"
e7f9874d
DB
2847 func_append install_prog " $func_quote_for_eval_result"
2848 if test -n "$arg2"; then
2849 func_quote_for_eval "$arg2"
2850 fi
2851 func_append install_shared_prog " $func_quote_for_eval_result"
eddc0c49
DB
2852 done
2853
2854 test -z "$install_prog" && \
2855 func_fatal_help "you must specify an install program"
2856
2857 test -n "$prev" && \
2858 func_fatal_help "the \`$prev' option requires an argument"
2859
e7f9874d
DB
2860 if test -n "$install_override_mode" && $no_mode; then
2861 if $install_cp; then :; else
2862 func_quote_for_eval "$install_override_mode"
2863 func_append install_shared_prog " -m $func_quote_for_eval_result"
2864 fi
2865 fi
2866
eddc0c49
DB
2867 if test -z "$files"; then
2868 if test -z "$dest"; then
2869 func_fatal_help "no file or destination specified"
2870 else
2871 func_fatal_help "you must specify a destination"
2872 fi
2873 fi
2874
2875 # Strip any trailing slash from the destination.
2876 func_stripname '' '/' "$dest"
2877 dest=$func_stripname_result
2878
2879 # Check to see that the destination is a directory.
2880 test -d "$dest" && isdir=yes
2881 if test "$isdir" = yes; then
2882 destdir="$dest"
2883 destname=
2884 else
2885 func_dirname_and_basename "$dest" "" "."
2886 destdir="$func_dirname_result"
2887 destname="$func_basename_result"
2888
2889 # Not a directory, so check to see that there is only one file specified.
2890 set dummy $files; shift
2891 test "$#" -gt 1 && \
2892 func_fatal_help "\`$dest' is not a directory"
2893 fi
2894 case $destdir in
2895 [\\/]* | [A-Za-z]:[\\/]*) ;;
2896 *)
2897 for file in $files; do
2898 case $file in
2899 *.lo) ;;
2900 *)
2901 func_fatal_help "\`$destdir' must be an absolute directory name"
2902 ;;
2903 esac
2904 done
2905 ;;
2906 esac
2907
2908 # This variable tells wrapper scripts just to set variables rather
2909 # than running their programs.
2910 libtool_install_magic="$magic"
2911
2912 staticlibs=
2913 future_libdirs=
2914 current_libdirs=
2915 for file in $files; do
2916
2917 # Do each installation.
2918 case $file in
2919 *.$libext)
2920 # Do the static libraries later.
e7f9874d 2921 func_append staticlibs " $file"
eddc0c49
DB
2922 ;;
2923
2924 *.la)
e7f9874d
DB
2925 func_resolve_sysroot "$file"
2926 file=$func_resolve_sysroot_result
2927
eddc0c49
DB
2928 # Check to see that this really is a libtool archive.
2929 func_lalib_unsafe_p "$file" \
2930 || func_fatal_help "\`$file' is not a valid libtool archive"
2931
2932 library_names=
2933 old_library=
2934 relink_command=
2935 func_source "$file"
2936
2937 # Add the libdir to current_libdirs if it is the destination.
2938 if test "X$destdir" = "X$libdir"; then
2939 case "$current_libdirs " in
2940 *" $libdir "*) ;;
e7f9874d 2941 *) func_append current_libdirs " $libdir" ;;
eddc0c49
DB
2942 esac
2943 else
2944 # Note the libdir as a future libdir.
2945 case "$future_libdirs " in
2946 *" $libdir "*) ;;
e7f9874d 2947 *) func_append future_libdirs " $libdir" ;;
eddc0c49
DB
2948 esac
2949 fi
2950
2951 func_dirname "$file" "/" ""
2952 dir="$func_dirname_result"
e7f9874d 2953 func_append dir "$objdir"
eddc0c49
DB
2954
2955 if test -n "$relink_command"; then
2956 # Determine the prefix the user has applied to our future dir.
e7f9874d 2957 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
eddc0c49
DB
2958
2959 # Don't allow the user to place us outside of our expected
2960 # location b/c this prevents finding dependent libraries that
2961 # are installed to the same prefix.
2962 # At present, this check doesn't affect windows .dll's that
2963 # are installed into $libdir/../bin (currently, that works fine)
2964 # but it's something to keep an eye on.
2965 test "$inst_prefix_dir" = "$destdir" && \
2966 func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2967
2968 if test -n "$inst_prefix_dir"; then
2969 # Stick the inst_prefix_dir data into the link command.
e7f9874d 2970 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
eddc0c49 2971 else
e7f9874d 2972 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
eddc0c49
DB
2973 fi
2974
2975 func_warning "relinking \`$file'"
2976 func_show_eval "$relink_command" \
2977 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2978 fi
2979
2980 # See the names of the shared library.
2981 set dummy $library_names; shift
2982 if test -n "$1"; then
2983 realname="$1"
2984 shift
2985
2986 srcname="$realname"
2987 test -n "$relink_command" && srcname="$realname"T
2988
2989 # Install the shared library and build the symlinks.
e7f9874d 2990 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
eddc0c49
DB
2991 'exit $?'
2992 tstripme="$stripme"
2993 case $host_os in
2994 cygwin* | mingw* | pw32* | cegcc*)
2995 case $realname in
2996 *.dll.a)
2997 tstripme=""
2998 ;;
2999 esac
3000 ;;
3001 esac
3002 if test -n "$tstripme" && test -n "$striplib"; then
3003 func_show_eval "$striplib $destdir/$realname" 'exit $?'
3004 fi
3005
3006 if test "$#" -gt 0; then
3007 # Delete the old symlinks, and create new ones.
3008 # Try `ln -sf' first, because the `ln' binary might depend on
3009 # the symlink we replace! Solaris /bin/ln does not understand -f,
3010 # so we also need to try rm && ln -s.
3011 for linkname
3012 do
3013 test "$linkname" != "$realname" \
3014 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3015 done
3016 fi
3017
3018 # Do each command in the postinstall commands.
3019 lib="$destdir/$realname"
3020 func_execute_cmds "$postinstall_cmds" 'exit $?'
3021 fi
3022
3023 # Install the pseudo-library for information purposes.
3024 func_basename "$file"
3025 name="$func_basename_result"
3026 instname="$dir/$name"i
3027 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3028
3029 # Maybe install the static library, too.
e7f9874d 3030 test -n "$old_library" && func_append staticlibs " $dir/$old_library"
eddc0c49
DB
3031 ;;
3032
3033 *.lo)
3034 # Install (i.e. copy) a libtool object.
3035
3036 # Figure out destination file name, if it wasn't already specified.
3037 if test -n "$destname"; then
3038 destfile="$destdir/$destname"
3039 else
3040 func_basename "$file"
3041 destfile="$func_basename_result"
3042 destfile="$destdir/$destfile"
3043 fi
3044
3045 # Deduce the name of the destination old-style object file.
3046 case $destfile in
3047 *.lo)
3048 func_lo2o "$destfile"
3049 staticdest=$func_lo2o_result
3050 ;;
3051 *.$objext)
3052 staticdest="$destfile"
3053 destfile=
3054 ;;
3055 *)
3056 func_fatal_help "cannot copy a libtool object to \`$destfile'"
3057 ;;
3058 esac
3059
3060 # Install the libtool object if requested.
3061 test -n "$destfile" && \
3062 func_show_eval "$install_prog $file $destfile" 'exit $?'
3063
3064 # Install the old object if enabled.
3065 if test "$build_old_libs" = yes; then
3066 # Deduce the name of the old-style object file.
3067 func_lo2o "$file"
3068 staticobj=$func_lo2o_result
3069 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3070 fi
3071 exit $EXIT_SUCCESS
3072 ;;
3073
3074 *)
3075 # Figure out destination file name, if it wasn't already specified.
3076 if test -n "$destname"; then
3077 destfile="$destdir/$destname"
3078 else
3079 func_basename "$file"
3080 destfile="$func_basename_result"
3081 destfile="$destdir/$destfile"
3082 fi
3083
3084 # If the file is missing, and there is a .exe on the end, strip it
3085 # because it is most likely a libtool script we actually want to
3086 # install
3087 stripped_ext=""
3088 case $file in
3089 *.exe)
3090 if test ! -f "$file"; then
3091 func_stripname '' '.exe' "$file"
3092 file=$func_stripname_result
3093 stripped_ext=".exe"
3094 fi
3095 ;;
3096 esac
3097
3098 # Do a test to see if this is really a libtool program.
3099 case $host in
3100 *cygwin* | *mingw*)
3101 if func_ltwrapper_executable_p "$file"; then
3102 func_ltwrapper_scriptname "$file"
3103 wrapper=$func_ltwrapper_scriptname_result
3104 else
3105 func_stripname '' '.exe' "$file"
3106 wrapper=$func_stripname_result
3107 fi
3108 ;;
3109 *)
3110 wrapper=$file
3111 ;;
3112 esac
3113 if func_ltwrapper_script_p "$wrapper"; then
3114 notinst_deplibs=
3115 relink_command=
3116
3117 func_source "$wrapper"
3118
3119 # Check the variables that should have been set.
3120 test -z "$generated_by_libtool_version" && \
3121 func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3122
3123 finalize=yes
3124 for lib in $notinst_deplibs; do
3125 # Check to see that each library is installed.
3126 libdir=
3127 if test -f "$lib"; then
3128 func_source "$lib"
3129 fi
e7f9874d 3130 libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
eddc0c49
DB
3131 if test -n "$libdir" && test ! -f "$libfile"; then
3132 func_warning "\`$lib' has not been installed in \`$libdir'"
3133 finalize=no
3134 fi
3135 done
3136
3137 relink_command=
3138 func_source "$wrapper"
3139
3140 outputname=
3141 if test "$fast_install" = no && test -n "$relink_command"; then
3142 $opt_dry_run || {
3143 if test "$finalize" = yes; then
3144 tmpdir=`func_mktempdir`
3145 func_basename "$file$stripped_ext"
3146 file="$func_basename_result"
3147 outputname="$tmpdir/$file"
3148 # Replace the output file specification.
e7f9874d 3149 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
eddc0c49
DB
3150
3151 $opt_silent || {
3152 func_quote_for_expand "$relink_command"
3153 eval "func_echo $func_quote_for_expand_result"
3154 }
3155 if eval "$relink_command"; then :
3156 else
3157 func_error "error: relink \`$file' with the above command before installing it"
3158 $opt_dry_run || ${RM}r "$tmpdir"
3159 continue
3160 fi
3161 file="$outputname"
3162 else
3163 func_warning "cannot relink \`$file'"
3164 fi
3165 }
3166 else
3167 # Install the binary that we compiled earlier.
e7f9874d 3168 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
eddc0c49
DB
3169 fi
3170 fi
3171
3172 # remove .exe since cygwin /usr/bin/install will append another
3173 # one anyway
3174 case $install_prog,$host in
3175 */usr/bin/install*,*cygwin*)
3176 case $file:$destfile in
3177 *.exe:*.exe)
3178 # this is ok
3179 ;;
3180 *.exe:*)
3181 destfile=$destfile.exe
3182 ;;
3183 *:*.exe)
3184 func_stripname '' '.exe' "$destfile"
3185 destfile=$func_stripname_result
3186 ;;
3187 esac
3188 ;;
3189 esac
3190 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3191 $opt_dry_run || if test -n "$outputname"; then
3192 ${RM}r "$tmpdir"
3193 fi
3194 ;;
3195 esac
3196 done
3197
3198 for file in $staticlibs; do
3199 func_basename "$file"
3200 name="$func_basename_result"
3201
3202 # Set up the ranlib parameters.
3203 oldlib="$destdir/$name"
3204
3205 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3206
3207 if test -n "$stripme" && test -n "$old_striplib"; then
3208 func_show_eval "$old_striplib $oldlib" 'exit $?'
3209 fi
3210
3211 # Do each command in the postinstall commands.
3212 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3213 done
3214
3215 test -n "$future_libdirs" && \
3216 func_warning "remember to run \`$progname --finish$future_libdirs'"
3217
3218 if test -n "$current_libdirs"; then
3219 # Maybe just do a dry run.
3220 $opt_dry_run && current_libdirs=" -n$current_libdirs"
3221 exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3222 else
3223 exit $EXIT_SUCCESS
3224 fi
3225}
3226
e7f9874d 3227test "$opt_mode" = install && func_mode_install ${1+"$@"}
eddc0c49
DB
3228
3229
3230# func_generate_dlsyms outputname originator pic_p
3231# Extract symbols from dlprefiles and create ${outputname}S.o with
3232# a dlpreopen symbol table.
3233func_generate_dlsyms ()
3234{
3235 $opt_debug
3236 my_outputname="$1"
3237 my_originator="$2"
3238 my_pic_p="${3-no}"
3239 my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3240 my_dlsyms=
3241
3242 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3243 if test -n "$NM" && test -n "$global_symbol_pipe"; then
3244 my_dlsyms="${my_outputname}S.c"
3245 else
3246 func_error "not configured to extract global symbols from dlpreopened files"
3247 fi
3248 fi
3249
3250 if test -n "$my_dlsyms"; then
3251 case $my_dlsyms in
3252 "") ;;
3253 *.c)
3254 # Discover the nlist of each of the dlfiles.
3255 nlist="$output_objdir/${my_outputname}.nm"
3256
3257 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3258
3259 # Parse the name list into a source file.
3260 func_verbose "creating $output_objdir/$my_dlsyms"
3261
3262 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3263/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3264/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3265
3266#ifdef __cplusplus
3267extern \"C\" {
3268#endif
3269
e7f9874d
DB
3270#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3271#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3272#endif
3273
3274/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
3275#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3276/* DATA imports from DLLs on WIN32 con't be const, because runtime
3277 relocations are performed -- see ld's documentation on pseudo-relocs. */
3278# define LT_DLSYM_CONST
3279#elif defined(__osf__)
3280/* This system does not cope well with relocations in const data. */
3281# define LT_DLSYM_CONST
3282#else
3283# define LT_DLSYM_CONST const
3284#endif
3285
eddc0c49
DB
3286/* External symbol declarations for the compiler. */\
3287"
3288
3289 if test "$dlself" = yes; then
3290 func_verbose "generating symbol list for \`$output'"
3291
3292 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3293
3294 # Add our own program objects to the symbol list.
e7f9874d 3295 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
eddc0c49 3296 for progfile in $progfiles; do
e7f9874d
DB
3297 func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3298 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3299 $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
eddc0c49
DB
3300 done
3301
3302 if test -n "$exclude_expsyms"; then
3303 $opt_dry_run || {
3304 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3305 eval '$MV "$nlist"T "$nlist"'
3306 }
3307 fi
3308
3309 if test -n "$export_symbols_regex"; then
3310 $opt_dry_run || {
3311 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3312 eval '$MV "$nlist"T "$nlist"'
3313 }
3314 fi
3315
3316 # Prepare the list of exported symbols
3317 if test -z "$export_symbols"; then
3318 export_symbols="$output_objdir/$outputname.exp"
3319 $opt_dry_run || {
3320 $RM $export_symbols
3321 eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3322 case $host in
3323 *cygwin* | *mingw* | *cegcc* )
3324 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3325 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3326 ;;
3327 esac
3328 }
3329 else
3330 $opt_dry_run || {
3331 eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3332 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3333 eval '$MV "$nlist"T "$nlist"'
3334 case $host in
e7f9874d 3335 *cygwin* | *mingw* | *cegcc* )
eddc0c49
DB
3336 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3337 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3338 ;;
3339 esac
3340 }
3341 fi
3342 fi
3343
3344 for dlprefile in $dlprefiles; do
3345 func_verbose "extracting global C symbols from \`$dlprefile'"
3346 func_basename "$dlprefile"
3347 name="$func_basename_result"
e7f9874d
DB
3348 case $host in
3349 *cygwin* | *mingw* | *cegcc* )
3350 # if an import library, we need to obtain dlname
3351 if func_win32_import_lib_p "$dlprefile"; then
3352 func_tr_sh "$dlprefile"
3353 eval "curr_lafile=\$libfile_$func_tr_sh_result"
3354 dlprefile_dlbasename=""
3355 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3356 # Use subshell, to avoid clobbering current variable values
3357 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3358 if test -n "$dlprefile_dlname" ; then
3359 func_basename "$dlprefile_dlname"
3360 dlprefile_dlbasename="$func_basename_result"
3361 else
3362 # no lafile. user explicitly requested -dlpreopen <import library>.
3363 $sharedlib_from_linklib_cmd "$dlprefile"
3364 dlprefile_dlbasename=$sharedlib_from_linklib_result
3365 fi
3366 fi
3367 $opt_dry_run || {
3368 if test -n "$dlprefile_dlbasename" ; then
3369 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3370 else
3371 func_warning "Could not compute DLL name from $name"
3372 eval '$ECHO ": $name " >> "$nlist"'
3373 fi
3374 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3375 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3376 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3377 }
3378 else # not an import lib
3379 $opt_dry_run || {
3380 eval '$ECHO ": $name " >> "$nlist"'
3381 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3382 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3383 }
3384 fi
3385 ;;
3386 *)
3387 $opt_dry_run || {
3388 eval '$ECHO ": $name " >> "$nlist"'
3389 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3390 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3391 }
3392 ;;
3393 esac
eddc0c49
DB
3394 done
3395
3396 $opt_dry_run || {
3397 # Make sure we have at least an empty file.
3398 test -f "$nlist" || : > "$nlist"
3399
3400 if test -n "$exclude_expsyms"; then
3401 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3402 $MV "$nlist"T "$nlist"
3403 fi
3404
3405 # Try sorting and uniquifying the output.
3406 if $GREP -v "^: " < "$nlist" |
3407 if sort -k 3 </dev/null >/dev/null 2>&1; then
3408 sort -k 3
3409 else
3410 sort +2
3411 fi |
3412 uniq > "$nlist"S; then
3413 :
3414 else
3415 $GREP -v "^: " < "$nlist" > "$nlist"S
3416 fi
3417
3418 if test -f "$nlist"S; then
3419 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3420 else
e7f9874d 3421 echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
eddc0c49
DB
3422 fi
3423
e7f9874d 3424 echo >> "$output_objdir/$my_dlsyms" "\
eddc0c49
DB
3425
3426/* The mapping between symbol names and symbols. */
3427typedef struct {
3428 const char *name;
3429 void *address;
3430} lt_dlsymlist;
e7f9874d 3431extern LT_DLSYM_CONST lt_dlsymlist
eddc0c49 3432lt_${my_prefix}_LTX_preloaded_symbols[];
e7f9874d 3433LT_DLSYM_CONST lt_dlsymlist
eddc0c49
DB
3434lt_${my_prefix}_LTX_preloaded_symbols[] =
3435{\
3436 { \"$my_originator\", (void *) 0 },"
3437
3438 case $need_lib_prefix in
3439 no)
3440 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3441 ;;
3442 *)
3443 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3444 ;;
3445 esac
e7f9874d 3446 echo >> "$output_objdir/$my_dlsyms" "\
eddc0c49
DB
3447 {0, (void *) 0}
3448};
3449
3450/* This works around a problem in FreeBSD linker */
3451#ifdef FREEBSD_WORKAROUND
3452static const void *lt_preloaded_setup() {
3453 return lt_${my_prefix}_LTX_preloaded_symbols;
3454}
3455#endif
3456
3457#ifdef __cplusplus
3458}
3459#endif\
3460"
3461 } # !$opt_dry_run
3462
3463 pic_flag_for_symtable=
3464 case "$compile_command " in
3465 *" -static "*) ;;
3466 *)
3467 case $host in
3468 # compiling the symbol table file with pic_flag works around
3469 # a FreeBSD bug that causes programs to crash when -lm is
3470 # linked before any other PIC object. But we must not use
3471 # pic_flag when linking with -static. The problem exists in
3472 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3473 *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3474 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3475 *-*-hpux*)
3476 pic_flag_for_symtable=" $pic_flag" ;;
3477 *)
3478 if test "X$my_pic_p" != Xno; then
3479 pic_flag_for_symtable=" $pic_flag"
3480 fi
3481 ;;
3482 esac
3483 ;;
3484 esac
3485 symtab_cflags=
3486 for arg in $LTCFLAGS; do
3487 case $arg in
3488 -pie | -fpie | -fPIE) ;;
e7f9874d 3489 *) func_append symtab_cflags " $arg" ;;
eddc0c49
DB
3490 esac
3491 done
3492
3493 # Now compile the dynamic symbol file.
3494 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3495
3496 # Clean up the generated files.
3497 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3498
3499 # Transform the symbol file into the correct name.
3500 symfileobj="$output_objdir/${my_outputname}S.$objext"
3501 case $host in
3502 *cygwin* | *mingw* | *cegcc* )
3503 if test -f "$output_objdir/$my_outputname.def"; then
e7f9874d
DB
3504 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3505 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
eddc0c49 3506 else
e7f9874d
DB
3507 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3508 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
eddc0c49
DB
3509 fi
3510 ;;
3511 *)
e7f9874d
DB
3512 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3513 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
eddc0c49
DB
3514 ;;
3515 esac
3516 ;;
3517 *)
3518 func_fatal_error "unknown suffix for \`$my_dlsyms'"
3519 ;;
3520 esac
3521 else
3522 # We keep going just in case the user didn't refer to
3523 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
3524 # really was required.
3525
3526 # Nullify the symbol file.
e7f9874d
DB
3527 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3528 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
eddc0c49
DB
3529 fi
3530}
3531
3532# func_win32_libid arg
3533# return the library type of file 'arg'
3534#
3535# Need a lot of goo to handle *both* DLLs and import libs
3536# Has to be a shell function in order to 'eat' the argument
3537# that is supplied when $file_magic_command is called.
e7f9874d 3538# Despite the name, also deal with 64 bit binaries.
eddc0c49
DB
3539func_win32_libid ()
3540{
3541 $opt_debug
3542 win32_libid_type="unknown"
3543 win32_fileres=`file -L $1 2>/dev/null`
3544 case $win32_fileres in
3545 *ar\ archive\ import\ library*) # definitely import
3546 win32_libid_type="x86 archive import"
3547 ;;
3548 *ar\ archive*) # could be an import, or static
e7f9874d 3549 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
eddc0c49 3550 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
e7f9874d
DB
3551 $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3552 func_to_tool_file "$1" func_convert_file_msys_to_w32
3553 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
eddc0c49
DB
3554 $SED -n -e '
3555 1,100{
3556 / I /{
3557 s,.*,import,
3558 p
3559 q
3560 }
3561 }'`
3562 case $win32_nmres in
3563 import*) win32_libid_type="x86 archive import";;
3564 *) win32_libid_type="x86 archive static";;
3565 esac
3566 fi
3567 ;;
3568 *DLL*)
3569 win32_libid_type="x86 DLL"
3570 ;;
3571 *executable*) # but shell scripts are "executable" too...
3572 case $win32_fileres in
3573 *MS\ Windows\ PE\ Intel*)
3574 win32_libid_type="x86 DLL"
3575 ;;
3576 esac
3577 ;;
3578 esac
3579 $ECHO "$win32_libid_type"
3580}
3581
e7f9874d
DB
3582# func_cygming_dll_for_implib ARG
3583#
3584# Platform-specific function to extract the
3585# name of the DLL associated with the specified
3586# import library ARG.
3587# Invoked by eval'ing the libtool variable
3588# $sharedlib_from_linklib_cmd
3589# Result is available in the variable
3590# $sharedlib_from_linklib_result
3591func_cygming_dll_for_implib ()
3592{
3593 $opt_debug
3594 sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3595}
3596
3597# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3598#
3599# The is the core of a fallback implementation of a
3600# platform-specific function to extract the name of the
3601# DLL associated with the specified import library LIBNAME.
3602#
3603# SECTION_NAME is either .idata$6 or .idata$7, depending
3604# on the platform and compiler that created the implib.
3605#
3606# Echos the name of the DLL associated with the
3607# specified import library.
3608func_cygming_dll_for_implib_fallback_core ()
3609{
3610 $opt_debug
3611 match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3612 $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3613 $SED '/^Contents of section '"$match_literal"':/{
3614 # Place marker at beginning of archive member dllname section
3615 s/.*/====MARK====/
3616 p
3617 d
3618 }
3619 # These lines can sometimes be longer than 43 characters, but
3620 # are always uninteresting
3621 /:[ ]*file format pe[i]\{,1\}-/d
3622 /^In archive [^:]*:/d
3623 # Ensure marker is printed
3624 /^====MARK====/p
3625 # Remove all lines with less than 43 characters
3626 /^.\{43\}/!d
3627 # From remaining lines, remove first 43 characters
3628 s/^.\{43\}//' |
3629 $SED -n '
3630 # Join marker and all lines until next marker into a single line
3631 /^====MARK====/ b para
3632 H
3633 $ b para
3634 b
3635 :para
3636 x
3637 s/\n//g
3638 # Remove the marker
3639 s/^====MARK====//
3640 # Remove trailing dots and whitespace
3641 s/[\. \t]*$//
3642 # Print
3643 /./p' |
3644 # we now have a list, one entry per line, of the stringified
3645 # contents of the appropriate section of all members of the
3646 # archive which possess that section. Heuristic: eliminate
3647 # all those which have a first or second character that is
3648 # a '.' (that is, objdump's representation of an unprintable
3649 # character.) This should work for all archives with less than
3650 # 0x302f exports -- but will fail for DLLs whose name actually
3651 # begins with a literal '.' or a single character followed by
3652 # a '.'.
3653 #
3654 # Of those that remain, print the first one.
3655 $SED -e '/^\./d;/^.\./d;q'
3656}
3657
3658# func_cygming_gnu_implib_p ARG
3659# This predicate returns with zero status (TRUE) if
3660# ARG is a GNU/binutils-style import library. Returns
3661# with nonzero status (FALSE) otherwise.
3662func_cygming_gnu_implib_p ()
3663{
3664 $opt_debug
3665 func_to_tool_file "$1" func_convert_file_msys_to_w32
3666 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)$'`
3667 test -n "$func_cygming_gnu_implib_tmp"
3668}
3669
3670# func_cygming_ms_implib_p ARG
3671# This predicate returns with zero status (TRUE) if
3672# ARG is an MS-style import library. Returns
3673# with nonzero status (FALSE) otherwise.
3674func_cygming_ms_implib_p ()
3675{
3676 $opt_debug
3677 func_to_tool_file "$1" func_convert_file_msys_to_w32
3678 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3679 test -n "$func_cygming_ms_implib_tmp"
3680}
3681
3682# func_cygming_dll_for_implib_fallback ARG
3683# Platform-specific function to extract the
3684# name of the DLL associated with the specified
3685# import library ARG.
3686#
3687# This fallback implementation is for use when $DLLTOOL
3688# does not support the --identify-strict option.
3689# Invoked by eval'ing the libtool variable
3690# $sharedlib_from_linklib_cmd
3691# Result is available in the variable
3692# $sharedlib_from_linklib_result
3693func_cygming_dll_for_implib_fallback ()
3694{
3695 $opt_debug
3696 if func_cygming_gnu_implib_p "$1" ; then
3697 # binutils import library
3698 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3699 elif func_cygming_ms_implib_p "$1" ; then
3700 # ms-generated import library
3701 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3702 else
3703 # unknown
3704 sharedlib_from_linklib_result=""
3705 fi
3706}
eddc0c49
DB
3707
3708
3709# func_extract_an_archive dir oldlib
3710func_extract_an_archive ()
3711{
3712 $opt_debug
3713 f_ex_an_ar_dir="$1"; shift
3714 f_ex_an_ar_oldlib="$1"
e7f9874d
DB
3715 if test "$lock_old_archive_extraction" = yes; then
3716 lockfile=$f_ex_an_ar_oldlib.lock
3717 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3718 func_echo "Waiting for $lockfile to be removed"
3719 sleep 2
3720 done
3721 fi
3722 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3723 'stat=$?; rm -f "$lockfile"; exit $stat'
3724 if test "$lock_old_archive_extraction" = yes; then
3725 $opt_dry_run || rm -f "$lockfile"
3726 fi
eddc0c49
DB
3727 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3728 :
3729 else
3730 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3731 fi
3732}
3733
3734
3735# func_extract_archives gentop oldlib ...
3736func_extract_archives ()
3737{
3738 $opt_debug
3739 my_gentop="$1"; shift
3740 my_oldlibs=${1+"$@"}
3741 my_oldobjs=""
3742 my_xlib=""
3743 my_xabs=""
3744 my_xdir=""
3745
3746 for my_xlib in $my_oldlibs; do
3747 # Extract the objects.
3748 case $my_xlib in
3749 [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3750 *) my_xabs=`pwd`"/$my_xlib" ;;
3751 esac
3752 func_basename "$my_xlib"
3753 my_xlib="$func_basename_result"
3754 my_xlib_u=$my_xlib
3755 while :; do
3756 case " $extracted_archives " in
3757 *" $my_xlib_u "*)
3758 func_arith $extracted_serial + 1
3759 extracted_serial=$func_arith_result
3760 my_xlib_u=lt$extracted_serial-$my_xlib ;;
3761 *) break ;;
3762 esac
3763 done
3764 extracted_archives="$extracted_archives $my_xlib_u"
3765 my_xdir="$my_gentop/$my_xlib_u"
3766
3767 func_mkdir_p "$my_xdir"
3768
3769 case $host in
3770 *-darwin*)
3771 func_verbose "Extracting $my_xabs"
3772 # Do not bother doing anything if just a dry run
3773 $opt_dry_run || {
3774 darwin_orig_dir=`pwd`
3775 cd $my_xdir || exit $?
3776 darwin_archive=$my_xabs
3777 darwin_curdir=`pwd`
3778 darwin_base_archive=`basename "$darwin_archive"`
3779 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3780 if test -n "$darwin_arches"; then