~ubuntu-branches/ubuntu/vivid/nbdkit/vivid

1 by Hilko Bengen
Import upstream version 1.1.2
1
# libtool (GNU libtool) 2.4.2
2
# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
3
4
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
5
# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
6
# This is free software; see the source for copying conditions.  There is NO
7
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8
9
# GNU Libtool is free software; you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation; either version 2 of the License, or
12
# (at your option) any later version.
13
#
14
# As a special exception to the GNU General Public License,
15
# if you distribute this file as part of a program or library that
16
# is built using GNU Libtool, you may include this file under the
17
# same distribution terms that you use for the rest of that program.
18
#
19
# GNU Libtool is distributed in the hope that it will be useful, but
20
# WITHOUT ANY WARRANTY; without even the implied warranty of
21
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22
# General Public License for more details.
23
#
24
# You should have received a copy of the GNU General Public License
25
# along with GNU Libtool; see the file COPYING.  If not, a copy
26
# can be downloaded from http://www.gnu.org/licenses/gpl.html,
27
# or obtained by writing to the Free Software Foundation, Inc.,
28
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
30
# Usage: $progname [OPTION]... [MODE-ARG]...
31
#
32
# Provide generalized library-building support services.
33
#
34
#       --config             show all configuration variables
35
#       --debug              enable verbose shell tracing
36
#   -n, --dry-run            display commands without modifying any files
37
#       --features           display basic configuration information and exit
38
#       --mode=MODE          use operation mode MODE
39
#       --preserve-dup-deps  don't remove duplicate dependency libraries
40
#       --quiet, --silent    don't print informational messages
41
#       --no-quiet, --no-silent
42
#                            print informational messages (default)
43
#       --no-warn            don't display warning messages
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
49
#
50
# MODE must be one of the following:
51
#
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
59
#
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.
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
#
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.2
73
#         automake:	$automake_version
74
#         autoconf:	$autoconf_version
75
#
76
# Report bugs to <bug-libtool@gnu.org>.
77
# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
78
# General help using GNU software: <http://www.gnu.org/gethelp/>.
79
80
PROGRAM=libtool
81
PACKAGE=libtool
82
VERSION=2.4.2
83
TIMESTAMP=""
84
package_revision=1.3337
85
86
# Be Bourne compatible
87
if 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
94
else
95
  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
96
fi
97
BIN_SH=xpg4; export BIN_SH # for Tru64
98
DUALCASE=1; export DUALCASE # for MKS sh
99
100
# A function that is used when there is no print builtin or printf.
101
func_fallback_echo ()
102
{
103
  eval 'cat <<_LTECHO_EOF
104
$1
105
_LTECHO_EOF'
106
}
107
108
# NLS nuisances: We save the old values to restore during execute mode.
109
lt_user_locale=
110
lt_safe_locale=
111
for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
112
do
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"
120
done
121
LC_ALL=C
122
LANGUAGE=C
123
export LANGUAGE LC_ALL
124
125
$lt_unset CDPATH
126
127
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.
133
progpath="$0"
134
135
136
137
: ${CP="cp -f"}
138
test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
139
: ${MAKE="make"}
140
: ${MKDIR="mkdir"}
141
: ${MV="mv -f"}
142
: ${RM="rm -f"}
143
: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
144
: ${Xsed="$SED -e 1s/^X//"}
145
146
# Global variables:
147
EXIT_SUCCESS=0
148
EXIT_FAILURE=1
149
EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
150
EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
151
152
exit_status=$EXIT_SUCCESS
153
154
# Make sure IFS has a sensible default
155
lt_nl='
156
'
157
IFS=" 	$lt_nl"
158
159
dirname="s,/[^/]*$,,"
160
basename="s,^.*/,,"
161
162
# func_dirname file append nondir_replacement
163
# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
164
# otherwise set result to NONDIR_REPLACEMENT.
165
func_dirname ()
166
{
167
    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
168
    if test "X$func_dirname_result" = "X${1}"; then
169
      func_dirname_result="${3}"
170
    else
171
      func_dirname_result="$func_dirname_result${2}"
172
    fi
173
} # func_dirname may be replaced by extended shell implementation
174
175
176
# func_basename file
177
func_basename ()
178
{
179
    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
180
} # func_basename may be replaced by extended shell implementation
181
182
183
# func_dirname_and_basename file append nondir_replacement
184
# perform func_basename and func_dirname in a single function
185
# call:
186
#   dirname:  Compute the dirname of FILE.  If nonempty,
187
#             add APPEND to the result, otherwise set result
188
#             to NONDIR_REPLACEMENT.
189
#             value returned in "$func_dirname_result"
190
#   basename: Compute filename of FILE.
191
#             value retuned in "$func_basename_result"
192
# Implementation must be kept synchronized with func_dirname
193
# and func_basename. For efficiency, we do not delegate to
194
# those functions but instead duplicate the functionality here.
195
func_dirname_and_basename ()
196
{
197
    # Extract subdirectory from the argument.
198
    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
199
    if test "X$func_dirname_result" = "X${1}"; then
200
      func_dirname_result="${3}"
201
    else
202
      func_dirname_result="$func_dirname_result${2}"
203
    fi
204
    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
205
} # func_dirname_and_basename may be replaced by extended shell implementation
206
207
208
# func_stripname prefix suffix name
209
# strip PREFIX and SUFFIX off of NAME.
210
# PREFIX and SUFFIX must not contain globbing or regex special
211
# characters, hashes, percent signs, but SUFFIX may contain a leading
212
# dot (in which case that matches only a dot).
213
# func_strip_suffix prefix name
214
func_stripname ()
215
{
216
    case ${2} in
217
      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
218
      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
219
    esac
220
} # func_stripname may be replaced by extended shell implementation
221
222
223
# These SED scripts presuppose an absolute path with a trailing slash.
224
pathcar='s,^/\([^/]*\).*$,\1,'
225
pathcdr='s,^/[^/]*,,'
226
removedotparts=':dotsl
227
		s@/\./@/@g
228
		t dotsl
229
		s,/\.$,/,'
230
collapseslashes='s@/\{1,\}@/@g'
231
finalslash='s,/*$,/,'
232
233
# func_normal_abspath PATH
234
# Remove doubled-up and trailing slashes, "." path components,
235
# and cancel out any ".." path components in PATH after making
236
# it an absolute path.
237
#             value returned in "$func_normal_abspath_result"
238
func_normal_abspath ()
239
{
240
  # Start from root dir and reassemble the path.
241
  func_normal_abspath_result=
242
  func_normal_abspath_tpath=$1
243
  func_normal_abspath_altnamespace=
244
  case $func_normal_abspath_tpath in
245
    "")
246
      # Empty path, that just means $cwd.
247
      func_stripname '' '/' "`pwd`"
248
      func_normal_abspath_result=$func_stripname_result
249
      return
250
    ;;
251
    # The next three entries are used to spot a run of precisely
252
    # two leading slashes without using negated character classes;
253
    # we take advantage of case's first-match behaviour.
254
    ///*)
255
      # Unusual form of absolute path, do nothing.
256
    ;;
257
    //*)
258
      # Not necessarily an ordinary path; POSIX reserves leading '//'
259
      # and for example Cygwin uses it to access remote file shares
260
      # over CIFS/SMB, so we conserve a leading double slash if found.
261
      func_normal_abspath_altnamespace=/
262
    ;;
263
    /*)
264
      # Absolute path, do nothing.
265
    ;;
266
    *)
267
      # Relative path, prepend $cwd.
268
      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
269
    ;;
270
  esac
271
  # Cancel out all the simple stuff to save iterations.  We also want
272
  # the path to end with a slash for ease of parsing, so make sure
273
  # there is one (and only one) here.
274
  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
275
        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
276
  while :; do
277
    # Processed it all yet?
278
    if test "$func_normal_abspath_tpath" = / ; then
279
      # If we ascended to the root using ".." the result may be empty now.
280
      if test -z "$func_normal_abspath_result" ; then
281
        func_normal_abspath_result=/
282
      fi
283
      break
284
    fi
285
    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
286
        -e "$pathcar"`
287
    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
288
        -e "$pathcdr"`
289
    # Figure out what to do with it
290
    case $func_normal_abspath_tcomponent in
291
      "")
292
        # Trailing empty path component, ignore it.
293
      ;;
294
      ..)
295
        # Parent dir; strip last assembled component from result.
296
        func_dirname "$func_normal_abspath_result"
297
        func_normal_abspath_result=$func_dirname_result
298
      ;;
299
      *)
300
        # Actual path component, append it.
301
        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
302
      ;;
303
    esac
304
  done
305
  # Restore leading double-slash if one was found on entry.
306
  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
307
}
308
309
# func_relative_path SRCDIR DSTDIR
310
# generates a relative path from SRCDIR to DSTDIR, with a trailing
311
# slash if non-empty, suitable for immediately appending a filename
312
# without needing to append a separator.
313
#             value returned in "$func_relative_path_result"
314
func_relative_path ()
315
{
316
  func_relative_path_result=
317
  func_normal_abspath "$1"
318
  func_relative_path_tlibdir=$func_normal_abspath_result
319
  func_normal_abspath "$2"
320
  func_relative_path_tbindir=$func_normal_abspath_result
321
322
  # Ascend the tree starting from libdir
323
  while :; do
324
    # check if we have found a prefix of bindir
325
    case $func_relative_path_tbindir in
326
      $func_relative_path_tlibdir)
327
        # found an exact match
328
        func_relative_path_tcancelled=
329
        break
330
        ;;
331
      $func_relative_path_tlibdir*)
332
        # found a matching prefix
333
        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
334
        func_relative_path_tcancelled=$func_stripname_result
335
        if test -z "$func_relative_path_result"; then
336
          func_relative_path_result=.
337
        fi
338
        break
339
        ;;
340
      *)
341
        func_dirname $func_relative_path_tlibdir
342
        func_relative_path_tlibdir=${func_dirname_result}
343
        if test "x$func_relative_path_tlibdir" = x ; then
344
          # Have to descend all the way to the root!
345
          func_relative_path_result=../$func_relative_path_result
346
          func_relative_path_tcancelled=$func_relative_path_tbindir
347
          break
348
        fi
349
        func_relative_path_result=../$func_relative_path_result
350
        ;;
351
    esac
352
  done
353
354
  # Now calculate path; take care to avoid doubling-up slashes.
355
  func_stripname '' '/' "$func_relative_path_result"
356
  func_relative_path_result=$func_stripname_result
357
  func_stripname '/' '/' "$func_relative_path_tcancelled"
358
  if test "x$func_stripname_result" != x ; then
359
    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
360
  fi
361
362
  # Normalisation. If bindir is libdir, return empty string,
363
  # else relative path ending with a slash; either way, target
364
  # file name can be directly appended.
365
  if test ! -z "$func_relative_path_result"; then
366
    func_stripname './' '' "$func_relative_path_result/"
367
    func_relative_path_result=$func_stripname_result
368
  fi
369
}
370
371
# The name of this program:
372
func_dirname_and_basename "$progpath"
373
progname=$func_basename_result
374
375
# Make sure we have an absolute path for reexecution:
376
case $progpath in
377
  [\\/]*|[A-Za-z]:\\*) ;;
378
  *[\\/]*)
379
     progdir=$func_dirname_result
380
     progdir=`cd "$progdir" && pwd`
381
     progpath="$progdir/$progname"
382
     ;;
383
  *)
384
     save_IFS="$IFS"
385
     IFS=${PATH_SEPARATOR-:}
386
     for progdir in $PATH; do
387
       IFS="$save_IFS"
388
       test -x "$progdir/$progname" && break
389
     done
390
     IFS="$save_IFS"
391
     test -n "$progdir" || progdir=`pwd`
392
     progpath="$progdir/$progname"
393
     ;;
394
esac
395
396
# Sed substitution that helps us do robust quoting.  It backslashifies
397
# metacharacters that are still active within double-quoted strings.
398
Xsed="${SED}"' -e 1s/^X//'
399
sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
400
401
# Same as above, but do not quote variable references.
402
double_quote_subst='s/\(["`\\]\)/\\\1/g'
403
404
# Sed substitution that turns a string into a regex matching for the
405
# string literally.
406
sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
407
408
# Sed substitution that converts a w32 file name or path
409
# which contains forward slashes, into one that contains
410
# (escaped) backslashes.  A very naive implementation.
411
lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
412
413
# Re-`\' parameter expansions in output of double_quote_subst that were
414
# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
415
# in input to double_quote_subst, that '$' was protected from expansion.
416
# Since each input `\' is now two `\'s, look for any number of runs of
417
# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
418
bs='\\'
419
bs2='\\\\'
420
bs4='\\\\\\\\'
421
dollar='\$'
422
sed_double_backslash="\
423
  s/$bs4/&\\
424
/g
425
  s/^$bs2$dollar/$bs&/
426
  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
427
  s/\n//g"
428
429
# Standard options:
430
opt_dry_run=false
431
opt_help=false
432
opt_quiet=false
433
opt_verbose=false
434
opt_warning=:
435
436
# func_echo arg...
437
# Echo program name prefixed message, along with the current mode
438
# name if it has been set yet.
439
func_echo ()
440
{
441
    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
442
}
443
444
# func_verbose arg...
445
# Echo program name prefixed message in verbose mode only.
446
func_verbose ()
447
{
448
    $opt_verbose && func_echo ${1+"$@"}
449
450
    # A bug in bash halts the script if the last line of a function
451
    # fails when set -e is in force, so we need another command to
452
    # work around that:
453
    :
454
}
455
456
# func_echo_all arg...
457
# Invoke $ECHO with all args, space-separated.
458
func_echo_all ()
459
{
460
    $ECHO "$*"
461
}
462
463
# func_error arg...
464
# Echo program name prefixed message to standard error.
465
func_error ()
466
{
467
    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
468
}
469
470
# func_warning arg...
471
# Echo program name prefixed warning message to standard error.
472
func_warning ()
473
{
474
    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
475
476
    # bash bug again:
477
    :
478
}
479
480
# func_fatal_error arg...
481
# Echo program name prefixed message to standard error, and exit.
482
func_fatal_error ()
483
{
484
    func_error ${1+"$@"}
485
    exit $EXIT_FAILURE
486
}
487
488
# func_fatal_help arg...
489
# Echo program name prefixed message to standard error, followed by
490
# a help hint, and exit.
491
func_fatal_help ()
492
{
493
    func_error ${1+"$@"}
494
    func_fatal_error "$help"
495
}
496
help="Try \`$progname --help' for more information."  ## default
497
498
499
# func_grep expression filename
500
# Check whether EXPRESSION matches any line of FILENAME, without output.
501
func_grep ()
502
{
503
    $GREP "$1" "$2" >/dev/null 2>&1
504
}
505
506
507
# func_mkdir_p directory-path
508
# Make sure the entire path to DIRECTORY-PATH is available.
509
func_mkdir_p ()
510
{
511
    my_directory_path="$1"
512
    my_dir_list=
513
514
    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
515
516
      # Protect directory names starting with `-'
517
      case $my_directory_path in
518
        -*) my_directory_path="./$my_directory_path" ;;
519
      esac
520
521
      # While some portion of DIR does not yet exist...
522
      while test ! -d "$my_directory_path"; do
523
        # ...make a list in topmost first order.  Use a colon delimited
524
	# list incase some portion of path contains whitespace.
525
        my_dir_list="$my_directory_path:$my_dir_list"
526
527
        # If the last portion added has no slash in it, the list is done
528
        case $my_directory_path in */*) ;; *) break ;; esac
529
530
        # ...otherwise throw away the child directory and loop
531
        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
532
      done
533
      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
534
535
      save_mkdir_p_IFS="$IFS"; IFS=':'
536
      for my_dir in $my_dir_list; do
537
	IFS="$save_mkdir_p_IFS"
538
        # mkdir can fail with a `File exist' error if two processes
539
        # try to create one of the directories concurrently.  Don't
540
        # stop in that case!
541
        $MKDIR "$my_dir" 2>/dev/null || :
542
      done
543
      IFS="$save_mkdir_p_IFS"
544
545
      # Bail out if we (or some other process) failed to create a directory.
546
      test -d "$my_directory_path" || \
547
        func_fatal_error "Failed to create \`$1'"
548
    fi
549
}
550
551
552
# func_mktempdir [string]
553
# Make a temporary directory that won't clash with other running
554
# libtool processes, and avoids race conditions if possible.  If
555
# given, STRING is the basename for that directory.
556
func_mktempdir ()
557
{
558
    my_template="${TMPDIR-/tmp}/${1-$progname}"
559
560
    if test "$opt_dry_run" = ":"; then
561
      # Return a directory name, but don't create it in dry-run mode
562
      my_tmpdir="${my_template}-$$"
563
    else
564
565
      # If mktemp works, use that first and foremost
566
      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
567
568
      if test ! -d "$my_tmpdir"; then
569
        # Failing that, at least try and use $RANDOM to avoid a race
570
        my_tmpdir="${my_template}-${RANDOM-0}$$"
571
572
        save_mktempdir_umask=`umask`
573
        umask 0077
574
        $MKDIR "$my_tmpdir"
575
        umask $save_mktempdir_umask
576
      fi
577
578
      # If we're not in dry-run mode, bomb out on failure
579
      test -d "$my_tmpdir" || \
580
        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
581
    fi
582
583
    $ECHO "$my_tmpdir"
584
}
585
586
587
# func_quote_for_eval arg
588
# Aesthetically quote ARG to be evaled later.
589
# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
590
# is double-quoted, suitable for a subsequent eval, whereas
591
# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
592
# which are still active within double quotes backslashified.
593
func_quote_for_eval ()
594
{
595
    case $1 in
596
      *[\\\`\"\$]*)
597
	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
598
      *)
599
        func_quote_for_eval_unquoted_result="$1" ;;
600
    esac
601
602
    case $func_quote_for_eval_unquoted_result in
603
      # Double-quote args containing shell metacharacters to delay
604
      # word splitting, command substitution and and variable
605
      # expansion for a subsequent eval.
606
      # Many Bourne shells cannot handle close brackets correctly
607
      # in scan sets, so we specify it separately.
608
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
609
        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
610
        ;;
611
      *)
612
        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
613
    esac
614
}
615
616
617
# func_quote_for_expand arg
618
# Aesthetically quote ARG to be evaled later; same as above,
619
# but do not quote variable references.
620
func_quote_for_expand ()
621
{
622
    case $1 in
623
      *[\\\`\"]*)
624
	my_arg=`$ECHO "$1" | $SED \
625
	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
626
      *)
627
        my_arg="$1" ;;
628
    esac
629
630
    case $my_arg in
631
      # Double-quote args containing shell metacharacters to delay
632
      # word splitting and command substitution for a subsequent eval.
633
      # Many Bourne shells cannot handle close brackets correctly
634
      # in scan sets, so we specify it separately.
635
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
636
        my_arg="\"$my_arg\""
637
        ;;
638
    esac
639
640
    func_quote_for_expand_result="$my_arg"
641
}
642
643
644
# func_show_eval cmd [fail_exp]
645
# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
646
# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
647
# is given, then evaluate it.
648
func_show_eval ()
649
{
650
    my_cmd="$1"
651
    my_fail_exp="${2-:}"
652
653
    ${opt_silent-false} || {
654
      func_quote_for_expand "$my_cmd"
655
      eval "func_echo $func_quote_for_expand_result"
656
    }
657
658
    if ${opt_dry_run-false}; then :; else
659
      eval "$my_cmd"
660
      my_status=$?
661
      if test "$my_status" -eq 0; then :; else
662
	eval "(exit $my_status); $my_fail_exp"
663
      fi
664
    fi
665
}
666
667
668
# func_show_eval_locale cmd [fail_exp]
669
# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
670
# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
671
# is given, then evaluate it.  Use the saved locale for evaluation.
672
func_show_eval_locale ()
673
{
674
    my_cmd="$1"
675
    my_fail_exp="${2-:}"
676
677
    ${opt_silent-false} || {
678
      func_quote_for_expand "$my_cmd"
679
      eval "func_echo $func_quote_for_expand_result"
680
    }
681
682
    if ${opt_dry_run-false}; then :; else
683
      eval "$lt_user_locale
684
	    $my_cmd"
685
      my_status=$?
686
      eval "$lt_safe_locale"
687
      if test "$my_status" -eq 0; then :; else
688
	eval "(exit $my_status); $my_fail_exp"
689
      fi
690
    fi
691
}
692
693
# func_tr_sh
694
# Turn $1 into a string suitable for a shell variable name.
695
# Result is stored in $func_tr_sh_result.  All characters
696
# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
697
# if $1 begins with a digit, a '_' is prepended as well.
698
func_tr_sh ()
699
{
700
  case $1 in
701
  [0-9]* | *[!a-zA-Z0-9_]*)
702
    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
703
    ;;
704
  * )
705
    func_tr_sh_result=$1
706
    ;;
707
  esac
708
}
709
710
711
# func_version
712
# Echo version message to standard output and exit.
713
func_version ()
714
{
715
    $opt_debug
716
717
    $SED -n '/(C)/!b go
718
	:more
719
	/\./!{
720
	  N
721
	  s/\n# / /
722
	  b more
723
	}
724
	:go
725
	/^# '$PROGRAM' (GNU /,/# warranty; / {
726
        s/^# //
727
	s/^# *$//
728
        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
729
        p
730
     }' < "$progpath"
731
     exit $?
732
}
733
734
# func_usage
735
# Echo short help message to standard output and exit.
736
func_usage ()
737
{
738
    $opt_debug
739
740
    $SED -n '/^# Usage:/,/^#  *.*--help/ {
741
        s/^# //
742
	s/^# *$//
743
	s/\$progname/'$progname'/
744
	p
745
    }' < "$progpath"
746
    echo
747
    $ECHO "run \`$progname --help | more' for full usage"
748
    exit $?
749
}
750
751
# func_help [NOEXIT]
752
# Echo long help message to standard output and exit,
753
# unless 'noexit' is passed as argument.
754
func_help ()
755
{
756
    $opt_debug
757
758
    $SED -n '/^# Usage:/,/# Report bugs to/ {
759
	:print
760
        s/^# //
761
	s/^# *$//
762
	s*\$progname*'$progname'*
763
	s*\$host*'"$host"'*
764
	s*\$SHELL*'"$SHELL"'*
765
	s*\$LTCC*'"$LTCC"'*
766
	s*\$LTCFLAGS*'"$LTCFLAGS"'*
767
	s*\$LD*'"$LD"'*
768
	s/\$with_gnu_ld/'"$with_gnu_ld"'/
769
	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
770
	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
771
	p
772
	d
773
     }
774
     /^# .* home page:/b print
775
     /^# General help using/b print
776
     ' < "$progpath"
777
    ret=$?
778
    if test -z "$1"; then
779
      exit $ret
780
    fi
781
}
782
783
# func_missing_arg argname
784
# Echo program name prefixed message to standard error and set global
785
# exit_cmd.
786
func_missing_arg ()
787
{
788
    $opt_debug
789
790
    func_error "missing argument for $1."
791
    exit_cmd=exit
792
}
793
794
795
# func_split_short_opt shortopt
796
# Set func_split_short_opt_name and func_split_short_opt_arg shell
797
# variables after splitting SHORTOPT after the 2nd character.
798
func_split_short_opt ()
799
{
800
    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
801
    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
802
803
    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
804
    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
805
} # func_split_short_opt may be replaced by extended shell implementation
806
807
808
# func_split_long_opt longopt
809
# Set func_split_long_opt_name and func_split_long_opt_arg shell
810
# variables after splitting LONGOPT at the `=' sign.
811
func_split_long_opt ()
812
{
813
    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
814
    my_sed_long_arg='1s/^--[^=]*=//'
815
816
    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
817
    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
818
} # func_split_long_opt may be replaced by extended shell implementation
819
820
exit_cmd=:
821
822
823
824
825
826
magic="%%%MAGIC variable%%%"
827
magic_exe="%%%MAGIC EXE variable%%%"
828
829
# Global variables.
830
nonopt=
831
preserve_args=
832
lo2o="s/\\.lo\$/.${objext}/"
833
o2lo="s/\\.${objext}\$/.lo/"
834
extracted_archives=
835
extracted_serial=0
836
837
# If this variable is set in any of the actions, the command in it
838
# will be execed at the end.  This prevents here-documents from being
839
# left over by shells.
840
exec_cmd=
841
842
# func_append var value
843
# Append VALUE to the end of shell variable VAR.
844
func_append ()
845
{
846
    eval "${1}=\$${1}\${2}"
847
} # func_append may be replaced by extended shell implementation
848
849
# func_append_quoted var value
850
# Quote VALUE and append to the end of shell variable VAR, separated
851
# by a space.
852
func_append_quoted ()
853
{
854
    func_quote_for_eval "${2}"
855
    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
856
} # func_append_quoted may be replaced by extended shell implementation
857
858
859
# func_arith arithmetic-term...
860
func_arith ()
861
{
862
    func_arith_result=`expr "${@}"`
863
} # func_arith may be replaced by extended shell implementation
864
865
866
# func_len string
867
# STRING may not start with a hyphen.
868
func_len ()
869
{
870
    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
871
} # func_len may be replaced by extended shell implementation
872
873
874
# func_lo2o object
875
func_lo2o ()
876
{
877
    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
878
} # func_lo2o may be replaced by extended shell implementation
879
880
881
# func_xform libobj-or-source
882
func_xform ()
883
{
884
    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
885
} # func_xform may be replaced by extended shell implementation
886
887
888
# func_fatal_configuration arg...
889
# Echo program name prefixed message to standard error, followed by
890
# a configuration failure hint, and exit.
891
func_fatal_configuration ()
892
{
893
    func_error ${1+"$@"}
894
    func_error "See the $PACKAGE documentation for more information."
895
    func_fatal_error "Fatal configuration error."
896
}
897
898
899
# func_config
900
# Display the configuration for all the tags in this script.
901
func_config ()
902
{
903
    re_begincf='^# ### BEGIN LIBTOOL'
904
    re_endcf='^# ### END LIBTOOL'
905
906
    # Default configuration.
907
    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
908
909
    # Now print the configurations for the tags.
910
    for tagname in $taglist; do
911
      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
912
    done
913
914
    exit $?
915
}
916
917
# func_features
918
# Display the features supported by this script.
919
func_features ()
920
{
921
    echo "host: $host"
922
    if test "$build_libtool_libs" = yes; then
923
      echo "enable shared libraries"
924
    else
925
      echo "disable shared libraries"
926
    fi
927
    if test "$build_old_libs" = yes; then
928
      echo "enable static libraries"
929
    else
930
      echo "disable static libraries"
931
    fi
932
933
    exit $?
934
}
935
936
# func_enable_tag tagname
937
# Verify that TAGNAME is valid, and either flag an error and exit, or
938
# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
939
# variable here.
940
func_enable_tag ()
941
{
942
  # Global variable:
943
  tagname="$1"
944
945
  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
946
  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
947
  sed_extractcf="/$re_begincf/,/$re_endcf/p"
948
949
  # Validate tagname.
950
  case $tagname in
951
    *[!-_A-Za-z0-9,/]*)
952
      func_fatal_error "invalid tag name: $tagname"
953
      ;;
954
  esac
955
956
  # Don't test for the "default" C tag, as we know it's
957
  # there but not specially marked.
958
  case $tagname in
959
    CC) ;;
960
    *)
961
      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
962
	taglist="$taglist $tagname"
963
964
	# Evaluate the configuration.  Be careful to quote the path
965
	# and the sed script, to avoid splitting on whitespace, but
966
	# also don't use non-portable quotes within backquotes within
967
	# quotes we have to do it in 2 steps:
968
	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
969
	eval "$extractedcf"
970
      else
971
	func_error "ignoring unknown tag $tagname"
972
      fi
973
      ;;
974
  esac
975
}
976
977
# func_check_version_match
978
# Ensure that we are using m4 macros, and libtool script from the same
979
# release of libtool.
980
func_check_version_match ()
981
{
982
  if test "$package_revision" != "$macro_revision"; then
983
    if test "$VERSION" != "$macro_version"; then
984
      if test -z "$macro_version"; then
985
        cat >&2 <<_LT_EOF
986
$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
987
$progname: definition of this LT_INIT comes from an older release.
988
$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
989
$progname: and run autoconf again.
990
_LT_EOF
991
      else
992
        cat >&2 <<_LT_EOF
993
$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
994
$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
995
$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
996
$progname: and run autoconf again.
997
_LT_EOF
998
      fi
999
    else
1000
      cat >&2 <<_LT_EOF
1001
$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1002
$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1003
$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1004
$progname: of $PACKAGE $VERSION and run autoconf again.
1005
_LT_EOF
1006
    fi
1007
1008
    exit $EXIT_MISMATCH
1009
  fi
1010
}
1011
1012
1013
# Shorthand for --mode=foo, only valid as the first argument
1014
case $1 in
1015
clean|clea|cle|cl)
1016
  shift; set dummy --mode clean ${1+"$@"}; shift
1017
  ;;
1018
compile|compil|compi|comp|com|co|c)
1019
  shift; set dummy --mode compile ${1+"$@"}; shift
1020
  ;;
1021
execute|execut|execu|exec|exe|ex|e)
1022
  shift; set dummy --mode execute ${1+"$@"}; shift
1023
  ;;
1024
finish|finis|fini|fin|fi|f)
1025
  shift; set dummy --mode finish ${1+"$@"}; shift
1026
  ;;
1027
install|instal|insta|inst|ins|in|i)
1028
  shift; set dummy --mode install ${1+"$@"}; shift
1029
  ;;
1030
link|lin|li|l)
1031
  shift; set dummy --mode link ${1+"$@"}; shift
1032
  ;;
1033
uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1034
  shift; set dummy --mode uninstall ${1+"$@"}; shift
1035
  ;;
1036
esac
1037
1038
1039
1040
# Option defaults:
1041
opt_debug=:
1042
opt_dry_run=false
1043
opt_config=false
1044
opt_preserve_dup_deps=false
1045
opt_features=false
1046
opt_finish=false
1047
opt_help=false
1048
opt_help_all=false
1049
opt_silent=:
1050
opt_warning=:
1051
opt_verbose=:
1052
opt_silent=false
1053
opt_verbose=false
1054
1055
1056
# Parse options once, thoroughly.  This comes as soon as possible in the
1057
# script to make things like `--version' happen as quickly as we can.
1058
{
1059
  # this just eases exit handling
1060
  while test $# -gt 0; do
1061
    opt="$1"
1062
    shift
1063
    case $opt in
1064
      --debug|-x)	opt_debug='set -x'
1065
			func_echo "enabling shell trace mode"
1066
			$opt_debug
1067
			;;
1068
      --dry-run|--dryrun|-n)
1069
			opt_dry_run=:
1070
			;;
1071
      --config)
1072
			opt_config=:
1073
func_config
1074
			;;
1075
      --dlopen|-dlopen)
1076
			optarg="$1"
1077
			opt_dlopen="${opt_dlopen+$opt_dlopen
1078
}$optarg"
1079
			shift
1080
			;;
1081
      --preserve-dup-deps)
1082
			opt_preserve_dup_deps=:
1083
			;;
1084
      --features)
1085
			opt_features=:
1086
func_features
1087
			;;
1088
      --finish)
1089
			opt_finish=:
1090
set dummy --mode finish ${1+"$@"}; shift
1091
			;;
1092
      --help)
1093
			opt_help=:
1094
			;;
1095
      --help-all)
1096
			opt_help_all=:
1097
opt_help=': help-all'
1098
			;;
1099
      --mode)
1100
			test $# = 0 && func_missing_arg $opt && break
1101
			optarg="$1"
1102
			opt_mode="$optarg"
1103
case $optarg in
1104
  # Valid mode arguments:
1105
  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1106
1107
  # Catch anything else as an error
1108
  *) func_error "invalid argument for $opt"
1109
     exit_cmd=exit
1110
     break
1111
     ;;
1112
esac
1113
			shift
1114
			;;
1115
      --no-silent|--no-quiet)
1116
			opt_silent=false
1117
func_append preserve_args " $opt"
1118
			;;
1119
      --no-warning|--no-warn)
1120
			opt_warning=false
1121
func_append preserve_args " $opt"
1122
			;;
1123
      --no-verbose)
1124
			opt_verbose=false
1125
func_append preserve_args " $opt"
1126
			;;
1127
      --silent|--quiet)
1128
			opt_silent=:
1129
func_append preserve_args " $opt"
1130
        opt_verbose=false
1131
			;;
1132
      --verbose|-v)
1133
			opt_verbose=:
1134
func_append preserve_args " $opt"
1135
opt_silent=false
1136
			;;
1137
      --tag)
1138
			test $# = 0 && func_missing_arg $opt && break
1139
			optarg="$1"
1140
			opt_tag="$optarg"
1141
func_append preserve_args " $opt $optarg"
1142
func_enable_tag "$optarg"
1143
			shift
1144
			;;
1145
1146
      -\?|-h)		func_usage				;;
1147
      --help)		func_help				;;
1148
      --version)	func_version				;;
1149
1150
      # Separate optargs to long options:
1151
      --*=*)
1152
			func_split_long_opt "$opt"
1153
			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1154
			shift
1155
			;;
1156
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
1162
			;;
1163
1164
      --)		break					;;
1165
      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1166
      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1167
    esac
1168
  done
1169
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"
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
    *)
1187
      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1188
      ;;
1189
  esac
1190
1191
  $opt_help || {
1192
    # Sanity checks first:
1193
    func_check_version_match
1194
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"
1197
    fi
1198
1199
    # Darwin sucks
1200
    eval std_shrext=\"$shrext_cmds\"
1201
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
1208
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
  }
1213
1214
1215
  # Bail if the options were screwed
1216
  $exit_cmd $EXIT_FAILURE
1217
}
1218
1219
1220
1221
1222
## ----------- ##
1223
##    Main.    ##
1224
## ----------- ##
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.
1230
func_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.
1244
func_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.
1264
func_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.
1273
func_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.
1287
func_ltwrapper_scriptname ()
1288
{
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"
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.
1298
func_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!
1308
func_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.
1327
func_source ()
1328
{
1329
    $opt_debug
1330
    case $1 in
1331
    */* | *\\*)	. "$1" ;;
1332
    *)		. "./$1" ;;
1333
    esac
1334
}
1335
1336
1337
# func_resolve_sysroot PATH
1338
# Replace a leading = in PATH with a sysroot.  Store the result into
1339
# func_resolve_sysroot_result
1340
func_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.
1354
func_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
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 ...'
1374
func_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
1380
	func_append_quoted CC_quoted "$arg"
1381
      done
1382
      CC_expanded=`func_echo_all $CC`
1383
      CC_quoted_expanded=`func_echo_all $CC_quoted`
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.
1387
      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1388
      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
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.
1399
	      func_append_quoted CC_quoted "$arg"
1400
	    done
1401
	    CC_expanded=`func_echo_all $CC`
1402
	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1403
	    case "$@ " in
1404
	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1405
	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
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.
1434
func_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.
1458
pic_object=$write_lobj
1459
1460
# Name of the non-PIC object
1461
non_pic_object=$write_oldobj
1462
1463
EOF
1464
      $MV "${write_libobj}T" "${write_libobj}"
1465
    }
1466
}
1467
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)
1482
func_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.
1514
func_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.
1554
func_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.
1574
func_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).
1588
func_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).
1606
func_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.
1630
func_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.
1657
func_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.
1669
func_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.
1687
func_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.
1698
func_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.
1714
func_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.
1731
func_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.
1747
func_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.
1765
func_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.
1804
to_host_path_cmd=
1805
func_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.
1818
func_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.
1829
func_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.
1840
func_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.
1863
func_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.
1883
func_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.
1904
func_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.
1927
func_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
1948
# func_mode_compile arg...
1949
func_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)
1988
          func_append pie_flag " $arg"
1989
	  continue
1990
	  ;;
1991
1992
	-shared | -static | -prefer-pic | -prefer-non-pic)
1993
	  func_append later " $arg"
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"
2014
	    func_append_quoted lastarg "$arg"
2015
	  done
2016
	  IFS="$save_ifs"
2017
	  func_stripname ' ' '' "$lastarg"
2018
	  lastarg=$func_stripname_result
2019
2020
	  # Add the arguments to base_compile.
2021
	  func_append base_compile " $lastarg"
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.
2037
      func_append_quoted base_compile "$lastarg"
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 | \
2062
    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
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
2137
      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
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
2158
This indicates that another process is trying to use the same
2159
temporary object file, and libtool could not work around it because
2160
your compiler does not support \`-c' and \`-o' together.  If you
2161
repeat this compilation, it may succeed, by chance, but you had better
2162
avoid parallel builds (make -j) in this platform, or get a better
2163
compiler."
2164
2165
	$opt_dry_run || $RM $removelist
2166
	exit $EXIT_FAILURE
2167
      fi
2168
      func_append removelist " $output_obj"
2169
      $ECHO "$srcfile" > "$lockfile"
2170
    fi
2171
2172
    $opt_dry_run || $RM $removelist
2173
    func_append removelist " $lockfile"
2174
    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2175
2176
    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2177
    srcfile=$func_to_tool_file_result
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
2197
	func_append command " -o $lobj"
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
2209
but it should contain:
2210
$srcfile
2211
2212
This indicates that another process is trying to use the same
2213
temporary object file, and libtool could not work around it because
2214
your compiler does not support \`-c' and \`-o' together.  If you
2215
repeat this compilation, it may succeed, by chance, but you had better
2216
avoid parallel builds (make -j) in this platform, or get a better
2217
compiler."
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
2244
	func_append command " -o $obj"
2245
      fi
2246
2247
      # Suppress compiler output if we already did a PIC compilation.
2248
      func_append command "$suppress_output"
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
2258
but it should contain:
2259
$srcfile
2260
2261
This indicates that another process is trying to use the same
2262
temporary object file, and libtool could not work around it because
2263
your compiler does not support \`-c' and \`-o' together.  If you
2264
repeat this compilation, it may succeed, by chance, but you had better
2265
avoid parallel builds (make -j) in this platform, or get a better
2266
compiler."
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 || {
2293
  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2294
}
2295
2296
func_mode_help ()
2297
{
2298
    # We need to display help for each of the modes.
2299
    case $opt_mode in
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
2310
Remove files from the build directory.
2311
2312
RM 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
2314
to RM.
2315
2316
If FILE is a libtool library, object or program, all the files associated
2317
with 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
2324
Compile a source file into a libtool library object.
2325
2326
This 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
2330
  -prefer-pic       try to build PIC objects only
2331
  -prefer-non-pic   try to build non-PIC objects only
2332
  -shared           do not build a \`.o' file suitable for static linking
2333
  -static           only build a \`.o' file suitable for static linking
2334
  -Wc,FLAG          pass FLAG directly to the compiler
2335
2336
COMPILE-COMMAND is a command to be used in creating a \`standard' object file
2337
from the given SOURCEFILE.
2338
2339
The output file name is determined by removing the directory component from
2340
SOURCEFILE, then substituting the C source code suffix \`.c' with the
2341
library object suffix, \`.lo'."
2342
        ;;
2343
2344
      execute)
2345
        $ECHO \
2346
"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2347
2348
Automatically set library path, then run a program.
2349
2350
This mode accepts the following additional options:
2351
2352
  -dlopen FILE      add the directory containing FILE to the library path
2353
2354
This mode sets the library path environment variable according to \`-dlopen'
2355
flags.
2356
2357
If any of the ARGS are libtool executable wrappers, then they are translated
2358
into their corresponding uninstalled binary, and any of their required library
2359
directories are added to the library path.
2360
2361
Then, COMMAND is executed, with ARGS as arguments."
2362
        ;;
2363
2364
      finish)
2365
        $ECHO \
2366
"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2367
2368
Complete the installation of libtool libraries.
2369
2370
Each LIBDIR is a directory that contains libtool libraries.
2371
2372
The commands that this mode executes may require superuser privileges.  Use
2373
the \`--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
2380
Install executables or libraries.
2381
2382
INSTALL-COMMAND is the installation command.  The first component should be
2383
either the \`install' or \`cp' program.
2384
2385
The following components of INSTALL-COMMAND are treated specially:
2386
2387
  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
2388
2389
The rest of the components are interpreted as arguments to that command (only
2390
BSD-compatible install options are recognized)."
2391
        ;;
2392
2393
      link)
2394
        $ECHO \
2395
"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2396
2397
Link object files or libraries together to form another library, or to
2398
create an executable program.
2399
2400
LINK-COMMAND is a command using the C compiler that you would use to create
2401
a program from several object files.
2402
2403
The 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
2407
  -bindir BINDIR    specify path to binaries directory (for systems where
2408
                    libraries must be found in the PATH setting at runtime)
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
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)
2442
2443
All other options (arguments beginning with \`-') are ignored.
2444
2445
Every other argument is treated as a filename.  Files ending in \`.la' are
2446
treated as uninstalled libtool libraries, other files are standard or library
2447
object files.
2448
2449
If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2450
only library objects (\`.lo' files) may be specified, and \`-rpath' is
2451
required, except when creating a convenience library.
2452
2453
If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2454
using \`ar' and \`ranlib', or on Windows using \`lib'.
2455
2456
If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2457
is created, otherwise an executable program is created."
2458
        ;;
2459
2460
      uninstall)
2461
        $ECHO \
2462
"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2463
2464
Remove libraries from an installation directory.
2465
2466
RM 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
2468
to RM.
2469
2470
If FILE is a libtool library, all the files associated with it are deleted.
2471
Otherwise, only FILE itself is deleted using RM."
2472
        ;;
2473
2474
      *)
2475
        func_fatal_help "invalid operation mode \`$opt_mode'"
2476
        ;;
2477
    esac
2478
2479
    echo
2480
    $ECHO "Try \`$progname --help' for more information about other modes."
2481
}
2482
2483
# Now that we've collected a possible --mode arg, show help if necessary
2484
if $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 $?
2512
fi
2513
2514
2515
# func_mode_execute arg...
2516
func_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.
2525
    for file in $opt_dlopen; do
2526
      test -f "$file" \
2527
	|| func_fatal_help "\`$file' is not a file"
2528
2529
      dir=
2530
      case $file in
2531
      *.la)
2532
	func_resolve_sysroot "$file"
2533
	file=$func_resolve_sysroot_result
2534
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
2556
	  func_append dir "/$objdir"
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
2597
      -* | *.la | *.lo ) ;;
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).
2613
      func_append_quoted args "$file"
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\""
2638
	echo "export $shlibpath_var"
2639
      fi
2640
      $ECHO "$cmd$args"
2641
      exit $EXIT_SUCCESS
2642
    fi
2643
}
2644
2645
test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2646
2647
2648
# func_mode_finish arg...
2649
func_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
2672
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
2680
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
2696
2697
    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
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\"
2707
	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2708
       $cmds"
2709
	fi
2710
      done
2711
    fi
2712
2713
    # Exit here if they wanted silent mode.
2714
    $opt_silent && exit $EXIT_SUCCESS
2715
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\"
2738
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
2748
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
2761
    exit $EXIT_SUCCESS
2762
}
2763
2764
test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2765
2766
2767
# func_mode_install arg...
2768
func_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.
2775
       case $nonopt in *shtool*) :;; *) false;; esac; then
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"
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
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=
2804
    no_mode=:
2805
    for arg
2806
    do
2807
      arg2=
2808
      if test -n "$dest"; then
2809
	func_append files " $dest"
2810
	dest=$arg
2811
	continue
2812
      fi
2813
2814
      case $arg in
2815
      -d) isdir=yes ;;
2816
      -f)
2817
	if $install_cp; then :; else
2818
	  prev=$arg
2819
	fi
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
2833
	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2834
	    arg2=$install_override_mode
2835
	    no_mode=false
2836
	  fi
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"
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"
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
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
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.
2921
	func_append staticlibs " $file"
2922
	;;
2923
2924
      *.la)
2925
	func_resolve_sysroot "$file"
2926
	file=$func_resolve_sysroot_result
2927
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 "*) ;;
2941
	  *) func_append current_libdirs " $libdir" ;;
2942
	  esac
2943
	else
2944
	  # Note the libdir as a future libdir.
2945
	  case "$future_libdirs " in
2946
	  *" $libdir "*) ;;
2947
	  *) func_append future_libdirs " $libdir" ;;
2948
	  esac
2949
	fi
2950
2951
	func_dirname "$file" "/" ""
2952
	dir="$func_dirname_result"
2953
	func_append dir "$objdir"
2954
2955
	if test -n "$relink_command"; then
2956
	  # Determine the prefix the user has applied to our future dir.
2957
	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
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.
2970
	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2971
	  else
2972
	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
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.
2990
	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
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.
3030
	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
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
3130
	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
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.
3149
	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
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.
3168
	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
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
      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3205
      tool_oldlib=$func_to_tool_file_result
3206
3207
      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3208
3209
      if test -n "$stripme" && test -n "$old_striplib"; then
3210
	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3211
      fi
3212
3213
      # Do each command in the postinstall commands.
3214
      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3215
    done
3216
3217
    test -n "$future_libdirs" && \
3218
      func_warning "remember to run \`$progname --finish$future_libdirs'"
3219
3220
    if test -n "$current_libdirs"; then
3221
      # Maybe just do a dry run.
3222
      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3223
      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3224
    else
3225
      exit $EXIT_SUCCESS
3226
    fi
3227
}
3228
3229
test "$opt_mode" = install && func_mode_install ${1+"$@"}
3230
3231
3232
# func_generate_dlsyms outputname originator pic_p
3233
# Extract symbols from dlprefiles and create ${outputname}S.o with
3234
# a dlpreopen symbol table.
3235
func_generate_dlsyms ()
3236
{
3237
    $opt_debug
3238
    my_outputname="$1"
3239
    my_originator="$2"
3240
    my_pic_p="${3-no}"
3241
    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3242
    my_dlsyms=
3243
3244
    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3245
      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3246
	my_dlsyms="${my_outputname}S.c"
3247
      else
3248
	func_error "not configured to extract global symbols from dlpreopened files"
3249
      fi
3250
    fi
3251
3252
    if test -n "$my_dlsyms"; then
3253
      case $my_dlsyms in
3254
      "") ;;
3255
      *.c)
3256
	# Discover the nlist of each of the dlfiles.
3257
	nlist="$output_objdir/${my_outputname}.nm"
3258
3259
	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3260
3261
	# Parse the name list into a source file.
3262
	func_verbose "creating $output_objdir/$my_dlsyms"
3263
3264
	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3265
/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3266
/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3267
3268
#ifdef __cplusplus
3269
extern \"C\" {
3270
#endif
3271
3272
#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3273
#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3274
#endif
3275
3276
/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3277
#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3278
/* DATA imports from DLLs on WIN32 con't be const, because runtime
3279
   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3280
# define LT_DLSYM_CONST
3281
#elif defined(__osf__)
3282
/* This system does not cope well with relocations in const data.  */
3283
# define LT_DLSYM_CONST
3284
#else
3285
# define LT_DLSYM_CONST const
3286
#endif
3287
3288
/* External symbol declarations for the compiler. */\
3289
"
3290
3291
	if test "$dlself" = yes; then
3292
	  func_verbose "generating symbol list for \`$output'"
3293
3294
	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3295
3296
	  # Add our own program objects to the symbol list.
3297
	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3298
	  for progfile in $progfiles; do
3299
	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3300
	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3301
	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3302
	  done
3303
3304
	  if test -n "$exclude_expsyms"; then
3305
	    $opt_dry_run || {
3306
	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3307
	      eval '$MV "$nlist"T "$nlist"'
3308
	    }
3309
	  fi
3310
3311
	  if test -n "$export_symbols_regex"; then
3312
	    $opt_dry_run || {
3313
	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3314
	      eval '$MV "$nlist"T "$nlist"'
3315
	    }
3316
	  fi
3317
3318
	  # Prepare the list of exported symbols
3319
	  if test -z "$export_symbols"; then
3320
	    export_symbols="$output_objdir/$outputname.exp"
3321
	    $opt_dry_run || {
3322
	      $RM $export_symbols
3323
	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3324
	      case $host in
3325
	      *cygwin* | *mingw* | *cegcc* )
3326
                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3327
                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3328
	        ;;
3329
	      esac
3330
	    }
3331
	  else
3332
	    $opt_dry_run || {
3333
	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3334
	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3335
	      eval '$MV "$nlist"T "$nlist"'
3336
	      case $host in
3337
	        *cygwin* | *mingw* | *cegcc* )
3338
	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3339
	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3340
	          ;;
3341
	      esac
3342
	    }
3343
	  fi
3344
	fi
3345
3346
	for dlprefile in $dlprefiles; do
3347
	  func_verbose "extracting global C symbols from \`$dlprefile'"
3348
	  func_basename "$dlprefile"
3349
	  name="$func_basename_result"
3350
          case $host in
3351
	    *cygwin* | *mingw* | *cegcc* )
3352
	      # if an import library, we need to obtain dlname
3353
	      if func_win32_import_lib_p "$dlprefile"; then
3354
	        func_tr_sh "$dlprefile"
3355
	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3356
	        dlprefile_dlbasename=""
3357
	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3358
	          # Use subshell, to avoid clobbering current variable values
3359
	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3360
	          if test -n "$dlprefile_dlname" ; then
3361
	            func_basename "$dlprefile_dlname"
3362
	            dlprefile_dlbasename="$func_basename_result"
3363
	          else
3364
	            # no lafile. user explicitly requested -dlpreopen <import library>.
3365
	            $sharedlib_from_linklib_cmd "$dlprefile"
3366
	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3367
	          fi
3368
	        fi
3369
	        $opt_dry_run || {
3370
	          if test -n "$dlprefile_dlbasename" ; then
3371
	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3372
	          else
3373
	            func_warning "Could not compute DLL name from $name"
3374
	            eval '$ECHO ": $name " >> "$nlist"'
3375
	          fi
3376
	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3377
	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3378
	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3379
	        }
3380
	      else # not an import lib
3381
	        $opt_dry_run || {
3382
	          eval '$ECHO ": $name " >> "$nlist"'
3383
	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3384
	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3385
	        }
3386
	      fi
3387
	    ;;
3388
	    *)
3389
	      $opt_dry_run || {
3390
	        eval '$ECHO ": $name " >> "$nlist"'
3391
	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3392
	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3393
	      }
3394
	    ;;
3395
          esac
3396
	done
3397
3398
	$opt_dry_run || {
3399
	  # Make sure we have at least an empty file.
3400
	  test -f "$nlist" || : > "$nlist"
3401
3402
	  if test -n "$exclude_expsyms"; then
3403
	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3404
	    $MV "$nlist"T "$nlist"
3405
	  fi
3406
3407
	  # Try sorting and uniquifying the output.
3408
	  if $GREP -v "^: " < "$nlist" |
3409
	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3410
		sort -k 3
3411
	      else
3412
		sort +2
3413
	      fi |
3414
	      uniq > "$nlist"S; then
3415
	    :
3416
	  else
3417
	    $GREP -v "^: " < "$nlist" > "$nlist"S
3418
	  fi
3419
3420
	  if test -f "$nlist"S; then
3421
	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3422
	  else
3423
	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3424
	  fi
3425
3426
	  echo >> "$output_objdir/$my_dlsyms" "\
3427
3428
/* The mapping between symbol names and symbols.  */
3429
typedef struct {
3430
  const char *name;
3431
  void *address;
3432
} lt_dlsymlist;
3433
extern LT_DLSYM_CONST lt_dlsymlist
3434
lt_${my_prefix}_LTX_preloaded_symbols[];
3435
LT_DLSYM_CONST lt_dlsymlist
3436
lt_${my_prefix}_LTX_preloaded_symbols[] =
3437
{\
3438
  { \"$my_originator\", (void *) 0 },"
3439
3440
	  case $need_lib_prefix in
3441
	  no)
3442
	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3443
	    ;;
3444
	  *)
3445
	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3446
	    ;;
3447
	  esac
3448
	  echo >> "$output_objdir/$my_dlsyms" "\
3449
  {0, (void *) 0}
3450
};
3451
3452
/* This works around a problem in FreeBSD linker */
3453
#ifdef FREEBSD_WORKAROUND
3454
static const void *lt_preloaded_setup() {
3455
  return lt_${my_prefix}_LTX_preloaded_symbols;
3456
}
3457
#endif
3458
3459
#ifdef __cplusplus
3460
}
3461
#endif\
3462
"
3463
	} # !$opt_dry_run
3464
3465
	pic_flag_for_symtable=
3466
	case "$compile_command " in
3467
	*" -static "*) ;;
3468
	*)
3469
	  case $host in
3470
	  # compiling the symbol table file with pic_flag works around
3471
	  # a FreeBSD bug that causes programs to crash when -lm is
3472
	  # linked before any other PIC object.  But we must not use
3473
	  # pic_flag when linking with -static.  The problem exists in
3474
	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3475
	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3476
	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3477
	  *-*-hpux*)
3478
	    pic_flag_for_symtable=" $pic_flag"  ;;
3479
	  *)
3480
	    if test "X$my_pic_p" != Xno; then
3481
	      pic_flag_for_symtable=" $pic_flag"
3482
	    fi
3483
	    ;;
3484
	  esac
3485
	  ;;
3486
	esac
3487
	symtab_cflags=
3488
	for arg in $LTCFLAGS; do
3489
	  case $arg in
3490
	  -pie | -fpie | -fPIE) ;;
3491
	  *) func_append symtab_cflags " $arg" ;;
3492
	  esac
3493
	done
3494
3495
	# Now compile the dynamic symbol file.
3496
	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3497
3498
	# Clean up the generated files.
3499
	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3500
3501
	# Transform the symbol file into the correct name.
3502
	symfileobj="$output_objdir/${my_outputname}S.$objext"
3503
	case $host in
3504
	*cygwin* | *mingw* | *cegcc* )
3505
	  if test -f "$output_objdir/$my_outputname.def"; then
3506
	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3507
	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3508
	  else
3509
	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3510
	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3511
	  fi
3512
	  ;;
3513
	*)
3514
	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3515
	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3516
	  ;;
3517
	esac
3518
	;;
3519
      *)
3520
	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3521
	;;
3522
      esac
3523
    else
3524
      # We keep going just in case the user didn't refer to
3525
      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3526
      # really was required.
3527
3528
      # Nullify the symbol file.
3529
      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3530
      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3531
    fi
3532
}
3533
3534
# func_win32_libid arg
3535
# return the library type of file 'arg'
3536
#
3537
# Need a lot of goo to handle *both* DLLs and import libs
3538
# Has to be a shell function in order to 'eat' the argument
3539
# that is supplied when $file_magic_command is called.
3540
# Despite the name, also deal with 64 bit binaries.
3541
func_win32_libid ()
3542
{
3543
  $opt_debug
3544
  win32_libid_type="unknown"
3545
  win32_fileres=`file -L $1 2>/dev/null`
3546
  case $win32_fileres in
3547
  *ar\ archive\ import\ library*) # definitely import
3548
    win32_libid_type="x86 archive import"
3549
    ;;
3550
  *ar\ archive*) # could be an import, or static
3551
    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3552
    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3553
       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3554
      func_to_tool_file "$1" func_convert_file_msys_to_w32
3555
      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3556
	$SED -n -e '
3557
	    1,100{
3558
		/ I /{
3559
		    s,.*,import,
3560
		    p
3561
		    q
3562
		}
3563
	    }'`
3564
      case $win32_nmres in
3565
      import*)  win32_libid_type="x86 archive import";;
3566
      *)        win32_libid_type="x86 archive static";;
3567
      esac
3568
    fi
3569
    ;;
3570
  *DLL*)
3571
    win32_libid_type="x86 DLL"
3572
    ;;
3573
  *executable*) # but shell scripts are "executable" too...
3574
    case $win32_fileres in
3575
    *MS\ Windows\ PE\ Intel*)
3576
      win32_libid_type="x86 DLL"
3577
      ;;
3578
    esac
3579
    ;;
3580
  esac
3581
  $ECHO "$win32_libid_type"
3582
}
3583
3584
# func_cygming_dll_for_implib ARG
3585
#
3586
# Platform-specific function to extract the
3587
# name of the DLL associated with the specified
3588
# import library ARG.
3589
# Invoked by eval'ing the libtool variable
3590
#    $sharedlib_from_linklib_cmd
3591
# Result is available in the variable
3592
#    $sharedlib_from_linklib_result
3593
func_cygming_dll_for_implib ()
3594
{
3595
  $opt_debug
3596
  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3597
}
3598
3599
# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3600
#
3601
# The is the core of a fallback implementation of a
3602
# platform-specific function to extract the name of the
3603
# DLL associated with the specified import library LIBNAME.
3604
#
3605
# SECTION_NAME is either .idata$6 or .idata$7, depending
3606
# on the platform and compiler that created the implib.
3607
#
3608
# Echos the name of the DLL associated with the
3609
# specified import library.
3610
func_cygming_dll_for_implib_fallback_core ()
3611
{
3612
  $opt_debug
3613
  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3614
  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3615
    $SED '/^Contents of section '"$match_literal"':/{
3616
      # Place marker at beginning of archive member dllname section
3617
      s/.*/====MARK====/
3618
      p
3619
      d
3620
    }
3621
    # These lines can sometimes be longer than 43 characters, but
3622
    # are always uninteresting
3623
    /:[	 ]*file format pe[i]\{,1\}-/d
3624
    /^In archive [^:]*:/d
3625
    # Ensure marker is printed
3626
    /^====MARK====/p
3627
    # Remove all lines with less than 43 characters
3628
    /^.\{43\}/!d
3629
    # From remaining lines, remove first 43 characters
3630
    s/^.\{43\}//' |
3631
    $SED -n '
3632
      # Join marker and all lines until next marker into a single line
3633
      /^====MARK====/ b para
3634
      H
3635
      $ b para
3636
      b
3637
      :para
3638
      x
3639
      s/\n//g
3640
      # Remove the marker
3641
      s/^====MARK====//
3642
      # Remove trailing dots and whitespace
3643
      s/[\. \t]*$//
3644
      # Print
3645
      /./p' |
3646
    # we now have a list, one entry per line, of the stringified
3647
    # contents of the appropriate section of all members of the
3648
    # archive which possess that section. Heuristic: eliminate
3649
    # all those which have a first or second character that is
3650
    # a '.' (that is, objdump's representation of an unprintable
3651
    # character.) This should work for all archives with less than
3652
    # 0x302f exports -- but will fail for DLLs whose name actually
3653
    # begins with a literal '.' or a single character followed by
3654
    # a '.'.
3655
    #
3656
    # Of those that remain, print the first one.
3657
    $SED -e '/^\./d;/^.\./d;q'
3658
}
3659
3660
# func_cygming_gnu_implib_p ARG
3661
# This predicate returns with zero status (TRUE) if
3662
# ARG is a GNU/binutils-style import library. Returns
3663
# with nonzero status (FALSE) otherwise.
3664
func_cygming_gnu_implib_p ()
3665
{
3666
  $opt_debug
3667
  func_to_tool_file "$1" func_convert_file_msys_to_w32
3668
  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)$'`
3669
  test -n "$func_cygming_gnu_implib_tmp"
3670
}
3671
3672
# func_cygming_ms_implib_p ARG
3673
# This predicate returns with zero status (TRUE) if
3674
# ARG is an MS-style import library. Returns
3675
# with nonzero status (FALSE) otherwise.
3676
func_cygming_ms_implib_p ()
3677
{
3678
  $opt_debug
3679
  func_to_tool_file "$1" func_convert_file_msys_to_w32
3680
  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3681
  test -n "$func_cygming_ms_implib_tmp"
3682
}
3683
3684
# func_cygming_dll_for_implib_fallback ARG
3685
# Platform-specific function to extract the
3686
# name of the DLL associated with the specified
3687
# import library ARG.
3688
#
3689
# This fallback implementation is for use when $DLLTOOL
3690
# does not support the --identify-strict option.
3691
# Invoked by eval'ing the libtool variable
3692
#    $sharedlib_from_linklib_cmd
3693
# Result is available in the variable
3694
#    $sharedlib_from_linklib_result
3695
func_cygming_dll_for_implib_fallback ()
3696
{
3697
  $opt_debug
3698
  if func_cygming_gnu_implib_p "$1" ; then
3699
    # binutils import library
3700
    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3701
  elif func_cygming_ms_implib_p "$1" ; then
3702
    # ms-generated import library
3703
    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3704
  else
3705
    # unknown
3706
    sharedlib_from_linklib_result=""
3707
  fi
3708
}
3709
3710
3711
# func_extract_an_archive dir oldlib
3712
func_extract_an_archive ()
3713
{
3714
    $opt_debug
3715
    f_ex_an_ar_dir="$1"; shift
3716
    f_ex_an_ar_oldlib="$1"
3717
    if test "$lock_old_archive_extraction" = yes; then
3718
      lockfile=$f_ex_an_ar_oldlib.lock
3719
      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3720
	func_echo "Waiting for $lockfile to be removed"
3721
	sleep 2
3722
      done
3723
    fi
3724
    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3725
		   'stat=$?; rm -f "$lockfile"; exit $stat'
3726
    if test "$lock_old_archive_extraction" = yes; then
3727
      $opt_dry_run || rm -f "$lockfile"
3728
    fi
3729
    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3730
     :
3731
    else
3732
      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3733
    fi
3734
}
3735
3736
3737
# func_extract_archives gentop oldlib ...
3738
func_extract_archives ()
3739
{
3740
    $opt_debug
3741
    my_gentop="$1"; shift
3742
    my_oldlibs=${1+"$@"}
3743
    my_oldobjs=""
3744
    my_xlib=""
3745
    my_xabs=""
3746
    my_xdir=""
3747
3748
    for my_xlib in $my_oldlibs; do
3749
      # Extract the objects.
3750
      case $my_xlib in
3751
	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3752
	*) my_xabs=`pwd`"/$my_xlib" ;;
3753
      esac
3754
      func_basename "$my_xlib"
3755
      my_xlib="$func_basename_result"
3756
      my_xlib_u=$my_xlib
3757
      while :; do
3758
        case " $extracted_archives " in
3759
	*" $my_xlib_u "*)
3760
	  func_arith $extracted_serial + 1
3761
	  extracted_serial=$func_arith_result
3762
	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3763
	*) break ;;
3764
	esac
3765
      done
3766
      extracted_archives="$extracted_archives $my_xlib_u"
3767
      my_xdir="$my_gentop/$my_xlib_u"
3768
3769
      func_mkdir_p "$my_xdir"
3770
3771
      case $host in
3772
      *-darwin*)
3773
	func_verbose "Extracting $my_xabs"
3774
	# Do not bother doing anything if just a dry run
3775
	$opt_dry_run || {
3776
	  darwin_orig_dir=`pwd`
3777
	  cd $my_xdir || exit $?
3778
	  darwin_archive=$my_xabs
3779
	  darwin_curdir=`pwd`
3780
	  darwin_base_archive=`basename "$darwin_archive"`
3781
	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3782
	  if test -n "$darwin_arches"; then
3783
	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3784
	    darwin_arch=
3785
	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3786
	    for darwin_arch in  $darwin_arches ; do
3787
	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3788
	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3789
	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3790
	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3791
	      cd "$darwin_curdir"
3792
	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3793
	    done # $darwin_arches
3794
            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3795
	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3796
	    darwin_file=
3797
	    darwin_files=
3798
	    for darwin_file in $darwin_filelist; do
3799
	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3800
	      $LIPO -create -output "$darwin_file" $darwin_files
3801
	    done # $darwin_filelist
3802
	    $RM -rf unfat-$$
3803
	    cd "$darwin_orig_dir"
3804
	  else
3805
	    cd $darwin_orig_dir
3806
	    func_extract_an_archive "$my_xdir" "$my_xabs"
3807
	  fi # $darwin_arches
3808
	} # !$opt_dry_run
3809
	;;
3810
      *)
3811
        func_extract_an_archive "$my_xdir" "$my_xabs"
3812
	;;
3813
      esac
3814
      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3815
    done
3816
3817
    func_extract_archives_result="$my_oldobjs"
3818
}
3819
3820
3821
# func_emit_wrapper [arg=no]
3822
#
3823
# Emit a libtool wrapper script on stdout.
3824
# Don't directly open a file because we may want to
3825
# incorporate the script contents within a cygwin/mingw
3826
# wrapper executable.  Must ONLY be called from within
3827
# func_mode_link because it depends on a number of variables
3828
# set therein.
3829
#
3830
# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3831
# variable will take.  If 'yes', then the emitted script
3832
# will assume that the directory in which it is stored is
3833
# the $objdir directory.  This is a cygwin/mingw-specific
3834
# behavior.
3835
func_emit_wrapper ()
3836
{
3837
	func_emit_wrapper_arg1=${1-no}
3838
3839
	$ECHO "\
3840
#! $SHELL
3841
3842
# $output - temporary wrapper script for $objdir/$outputname
3843
# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3844
#
3845
# The $output program cannot be directly executed until all the libtool
3846
# libraries that it depends on are installed.
3847
#
3848
# This wrapper script should never be moved out of the build directory.
3849
# If it is, it will not operate correctly.
3850
3851
# Sed substitution that helps us do robust quoting.  It backslashifies
3852
# metacharacters that are still active within double-quoted strings.
3853
sed_quote_subst='$sed_quote_subst'
3854
3855
# Be Bourne compatible
3856
if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3857
  emulate sh
3858
  NULLCMD=:
3859
  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3860
  # is contrary to our usage.  Disable this feature.
3861
  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3862
  setopt NO_GLOB_SUBST
3863
else
3864
  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3865
fi
3866
BIN_SH=xpg4; export BIN_SH # for Tru64
3867
DUALCASE=1; export DUALCASE # for MKS sh
3868
3869
# The HP-UX ksh and POSIX shell print the target directory to stdout
3870
# if CDPATH is set.
3871
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3872
3873
relink_command=\"$relink_command\"
3874
3875
# This environment variable determines our operation mode.
3876
if test \"\$libtool_install_magic\" = \"$magic\"; then
3877
  # install mode needs the following variables:
3878
  generated_by_libtool_version='$macro_version'
3879
  notinst_deplibs='$notinst_deplibs'
3880
else
3881
  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3882
  if test \"\$libtool_execute_magic\" != \"$magic\"; then
3883
    file=\"\$0\""
3884
3885
    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3886
    $ECHO "\
3887
3888
# A function that is used when there is no print builtin or printf.
3889
func_fallback_echo ()
3890
{
3891
  eval 'cat <<_LTECHO_EOF
3892
\$1
3893
_LTECHO_EOF'
3894
}
3895
    ECHO=\"$qECHO\"
3896
  fi
3897
3898
# Very basic option parsing. These options are (a) specific to
3899
# the libtool wrapper, (b) are identical between the wrapper
3900
# /script/ and the wrapper /executable/ which is used only on
3901
# windows platforms, and (c) all begin with the string "--lt-"
3902
# (application programs are unlikely to have options which match
3903
# this pattern).
3904
#
3905
# There are only two supported options: --lt-debug and
3906
# --lt-dump-script. There is, deliberately, no --lt-help.
3907
#
3908
# The first argument to this parsing function should be the
3909
# script's $0 value, followed by "$@".
3910
lt_option_debug=
3911
func_parse_lt_options ()
3912
{
3913
  lt_script_arg0=\$0
3914
  shift
3915
  for lt_opt
3916
  do
3917
    case \"\$lt_opt\" in
3918
    --lt-debug) lt_option_debug=1 ;;
3919
    --lt-dump-script)
3920
        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3921
        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3922
        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3923
        cat \"\$lt_dump_D/\$lt_dump_F\"
3924
        exit 0
3925
      ;;
3926
    --lt-*)
3927
        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3928
        exit 1
3929
      ;;
3930
    esac
3931
  done
3932
3933
  # Print the debug banner immediately:
3934
  if test -n \"\$lt_option_debug\"; then
3935
    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3936
  fi
3937
}
3938
3939
# Used when --lt-debug. Prints its arguments to stdout
3940
# (redirection is the responsibility of the caller)
3941
func_lt_dump_args ()
3942
{
3943
  lt_dump_args_N=1;
3944
  for lt_arg
3945
  do
3946
    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3947
    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3948
  done
3949
}
3950
3951
# Core function for launching the target application
3952
func_exec_program_core ()
3953
{
3954
"
3955
  case $host in
3956
  # Backslashes separate directories on plain windows
3957
  *-*-mingw | *-*-os2* | *-cegcc*)
3958
    $ECHO "\
3959
      if test -n \"\$lt_option_debug\"; then
3960
        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3961
        func_lt_dump_args \${1+\"\$@\"} 1>&2
3962
      fi
3963
      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3964
"
3965
    ;;
3966
3967
  *)
3968
    $ECHO "\
3969
      if test -n \"\$lt_option_debug\"; then
3970
        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
3971
        func_lt_dump_args \${1+\"\$@\"} 1>&2
3972
      fi
3973
      exec \"\$progdir/\$program\" \${1+\"\$@\"}
3974
"
3975
    ;;
3976
  esac
3977
  $ECHO "\
3978
      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3979
      exit 1
3980
}
3981
3982
# A function to encapsulate launching the target application
3983
# Strips options in the --lt-* namespace from \$@ and
3984
# launches target application with the remaining arguments.
3985
func_exec_program ()
3986
{
3987
  case \" \$* \" in
3988
  *\\ --lt-*)
3989
    for lt_wr_arg
3990
    do
3991
      case \$lt_wr_arg in
3992
      --lt-*) ;;
3993
      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3994
      esac
3995
      shift
3996
    done ;;
3997
  esac
3998
  func_exec_program_core \${1+\"\$@\"}
3999
}
4000
4001
  # Parse options
4002
  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
4003
4004
  # Find the directory that this script lives in.
4005
  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4006
  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4007
4008
  # Follow symbolic links until we get to the real thisdir.
4009
  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4010
  while test -n \"\$file\"; do
4011
    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4012
4013
    # If there was a directory component, then change thisdir.
4014
    if test \"x\$destdir\" != \"x\$file\"; then
4015
      case \"\$destdir\" in
4016
      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4017
      *) thisdir=\"\$thisdir/\$destdir\" ;;
4018
      esac
4019
    fi
4020
4021
    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4022
    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4023
  done
4024
4025
  # Usually 'no', except on cygwin/mingw when embedded into
4026
  # the cwrapper.
4027
  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4028
  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4029
    # special case for '.'
4030
    if test \"\$thisdir\" = \".\"; then
4031
      thisdir=\`pwd\`
4032
    fi
4033
    # remove .libs from thisdir
4034
    case \"\$thisdir\" in
4035
    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4036
    $objdir )   thisdir=. ;;
4037
    esac
4038
  fi
4039
4040
  # Try to get the absolute directory name.
4041
  absdir=\`cd \"\$thisdir\" && pwd\`
4042
  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4043
"
4044
4045
	if test "$fast_install" = yes; then
4046
	  $ECHO "\
4047
  program=lt-'$outputname'$exeext
4048
  progdir=\"\$thisdir/$objdir\"
4049
4050
  if test ! -f \"\$progdir/\$program\" ||
4051
     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4052
       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4053
4054
    file=\"\$\$-\$program\"
4055
4056
    if test ! -d \"\$progdir\"; then
4057
      $MKDIR \"\$progdir\"
4058
    else
4059
      $RM \"\$progdir/\$file\"
4060
    fi"
4061
4062
	  $ECHO "\
4063
4064
    # relink executable if necessary
4065
    if test -n \"\$relink_command\"; then
4066
      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4067
      else
4068
	$ECHO \"\$relink_command_output\" >&2
4069
	$RM \"\$progdir/\$file\"
4070
	exit 1
4071
      fi
4072
    fi
4073
4074
    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4075
    { $RM \"\$progdir/\$program\";
4076
      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4077
    $RM \"\$progdir/\$file\"
4078
  fi"
4079
	else
4080
	  $ECHO "\
4081
  program='$outputname'
4082
  progdir=\"\$thisdir/$objdir\"
4083
"
4084
	fi
4085
4086
	$ECHO "\
4087
4088
  if test -f \"\$progdir/\$program\"; then"
4089
4090
	# fixup the dll searchpath if we need to.
4091
	#
4092
	# Fix the DLL searchpath if we need to.  Do this before prepending
4093
	# to shlibpath, because on Windows, both are PATH and uninstalled
4094
	# libraries must come first.
4095
	if test -n "$dllsearchpath"; then
4096
	  $ECHO "\
4097
    # Add the dll search path components to the executable PATH
4098
    PATH=$dllsearchpath:\$PATH
4099
"
4100
	fi
4101
4102
	# Export our shlibpath_var if we have one.
4103
	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4104
	  $ECHO "\
4105
    # Add our own library path to $shlibpath_var
4106
    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4107
4108
    # Some systems cannot cope with colon-terminated $shlibpath_var
4109
    # The second colon is a workaround for a bug in BeOS R4 sed
4110
    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4111
4112
    export $shlibpath_var
4113
"
4114
	fi
4115
4116
	$ECHO "\
4117
    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4118
      # Run the actual program with our arguments.
4119
      func_exec_program \${1+\"\$@\"}
4120
    fi
4121
  else
4122
    # The program doesn't exist.
4123
    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4124
    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4125
    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4126
    exit 1
4127
  fi
4128
fi\
4129
"
4130
}
4131
4132
4133
# func_emit_cwrapperexe_src
4134
# emit the source code for a wrapper executable on stdout
4135
# Must ONLY be called from within func_mode_link because
4136
# it depends on a number of variable set therein.
4137
func_emit_cwrapperexe_src ()
4138
{
4139
	cat <<EOF
4140
4141
/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4142
   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4143
4144
   The $output program cannot be directly executed until all the libtool
4145
   libraries that it depends on are installed.
4146
4147
   This wrapper executable should never be moved out of the build directory.
4148
   If it is, it will not operate correctly.
4149
*/
4150
EOF
4151
	    cat <<"EOF"
4152
#ifdef _MSC_VER
4153
# define _CRT_SECURE_NO_DEPRECATE 1
4154
#endif
4155
#include <stdio.h>
4156
#include <stdlib.h>
4157
#ifdef _MSC_VER
4158
# include <direct.h>
4159
# include <process.h>
4160
# include <io.h>
4161
#else
4162
# include <unistd.h>
4163
# include <stdint.h>
4164
# ifdef __CYGWIN__
4165
#  include <io.h>
4166
# endif
4167
#endif
4168
#include <malloc.h>
4169
#include <stdarg.h>
4170
#include <assert.h>
4171
#include <string.h>
4172
#include <ctype.h>
4173
#include <errno.h>
4174
#include <fcntl.h>
4175
#include <sys/stat.h>
4176
4177
/* declarations of non-ANSI functions */
4178
#if defined(__MINGW32__)
4179
# ifdef __STRICT_ANSI__
4180
int _putenv (const char *);
4181
# endif
4182
#elif defined(__CYGWIN__)
4183
# ifdef __STRICT_ANSI__
4184
char *realpath (const char *, char *);
4185
int putenv (char *);
4186
int setenv (const char *, const char *, int);
4187
# endif
4188
/* #elif defined (other platforms) ... */
4189
#endif
4190
4191
/* portability defines, excluding path handling macros */
4192
#if defined(_MSC_VER)
4193
# define setmode _setmode
4194
# define stat    _stat
4195
# define chmod   _chmod
4196
# define getcwd  _getcwd
4197
# define putenv  _putenv
4198
# define S_IXUSR _S_IEXEC
4199
# ifndef _INTPTR_T_DEFINED
4200
#  define _INTPTR_T_DEFINED
4201
#  define intptr_t int
4202
# endif
4203
#elif defined(__MINGW32__)
4204
# define setmode _setmode
4205
# define stat    _stat
4206
# define chmod   _chmod
4207
# define getcwd  _getcwd
4208
# define putenv  _putenv
4209
#elif defined(__CYGWIN__)
4210
# define HAVE_SETENV
4211
# define FOPEN_WB "wb"
4212
/* #elif defined (other platforms) ... */
4213
#endif
4214
4215
#if defined(PATH_MAX)
4216
# define LT_PATHMAX PATH_MAX
4217
#elif defined(MAXPATHLEN)
4218
# define LT_PATHMAX MAXPATHLEN
4219
#else
4220
# define LT_PATHMAX 1024
4221
#endif
4222
4223
#ifndef S_IXOTH
4224
# define S_IXOTH 0
4225
#endif
4226
#ifndef S_IXGRP
4227
# define S_IXGRP 0
4228
#endif
4229
4230
/* path handling portability macros */
4231
#ifndef DIR_SEPARATOR
4232
# define DIR_SEPARATOR '/'
4233
# define PATH_SEPARATOR ':'
4234
#endif
4235
4236
#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4237
  defined (__OS2__)
4238
# define HAVE_DOS_BASED_FILE_SYSTEM
4239
# define FOPEN_WB "wb"
4240
# ifndef DIR_SEPARATOR_2
4241
#  define DIR_SEPARATOR_2 '\\'
4242
# endif
4243
# ifndef PATH_SEPARATOR_2
4244
#  define PATH_SEPARATOR_2 ';'
4245
# endif
4246
#endif
4247
4248
#ifndef DIR_SEPARATOR_2
4249
# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4250
#else /* DIR_SEPARATOR_2 */
4251
# define IS_DIR_SEPARATOR(ch) \
4252
	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4253
#endif /* DIR_SEPARATOR_2 */
4254
4255
#ifndef PATH_SEPARATOR_2
4256
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4257
#else /* PATH_SEPARATOR_2 */
4258
# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4259
#endif /* PATH_SEPARATOR_2 */
4260
4261
#ifndef FOPEN_WB
4262
# define FOPEN_WB "w"
4263
#endif
4264
#ifndef _O_BINARY
4265
# define _O_BINARY 0
4266
#endif
4267
4268
#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4269
#define XFREE(stale) do { \
4270
  if (stale) { free ((void *) stale); stale = 0; } \
4271
} while (0)
4272
4273
#if defined(LT_DEBUGWRAPPER)
4274
static int lt_debug = 1;
4275
#else
4276
static int lt_debug = 0;
4277
#endif
4278
4279
const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4280
4281
void *xmalloc (size_t num);
4282
char *xstrdup (const char *string);
4283
const char *base_name (const char *name);
4284
char *find_executable (const char *wrapper);
4285
char *chase_symlinks (const char *pathspec);
4286
int make_executable (const char *path);
4287
int check_executable (const char *path);
4288
char *strendzap (char *str, const char *pat);
4289
void lt_debugprintf (const char *file, int line, const char *fmt, ...);
4290
void lt_fatal (const char *file, int line, const char *message, ...);
4291
static const char *nonnull (const char *s);
4292
static const char *nonempty (const char *s);
4293
void lt_setenv (const char *name, const char *value);
4294
char *lt_extend_str (const char *orig_value, const char *add, int to_end);
4295
void lt_update_exe_path (const char *name, const char *value);
4296
void lt_update_lib_path (const char *name, const char *value);
4297
char **prepare_spawn (char **argv);
4298
void lt_dump_script (FILE *f);
4299
EOF
4300
4301
	    cat <<EOF
4302
volatile const char * MAGIC_EXE = "$magic_exe";
4303
const char * LIB_PATH_VARNAME = "$shlibpath_var";
4304
EOF
4305
4306
	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4307
              func_to_host_path "$temp_rpath"
4308
	      cat <<EOF
4309
const char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4310
EOF
4311
	    else
4312
	      cat <<"EOF"
4313
const char * LIB_PATH_VALUE   = "";
4314
EOF
4315
	    fi
4316
4317
	    if test -n "$dllsearchpath"; then
4318
              func_to_host_path "$dllsearchpath:"
4319
	      cat <<EOF
4320
const char * EXE_PATH_VARNAME = "PATH";
4321
const char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4322
EOF
4323
	    else
4324
	      cat <<"EOF"
4325
const char * EXE_PATH_VARNAME = "";
4326
const char * EXE_PATH_VALUE   = "";
4327
EOF
4328
	    fi
4329
4330
	    if test "$fast_install" = yes; then
4331
	      cat <<EOF
4332
const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4333
EOF
4334
	    else
4335
	      cat <<EOF
4336
const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4337
EOF
4338
	    fi
4339
4340
4341
	    cat <<"EOF"
4342
4343
#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4344
4345
static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4346
static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
4347
static const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4348
4349
int
4350
main (int argc, char *argv[])
4351
{
4352
  char **newargz;
4353
  int  newargc;
4354
  char *tmp_pathspec;
4355
  char *actual_cwrapper_path;
4356
  char *actual_cwrapper_name;
4357
  char *target_name;
4358
  char *lt_argv_zero;
4359
  intptr_t rval = 127;
4360
4361
  int i;
4362
4363
  program_name = (char *) xstrdup (base_name (argv[0]));
4364
  newargz = XMALLOC (char *, argc + 1);
4365
4366
  /* very simple arg parsing; don't want to rely on getopt
4367
   * also, copy all non cwrapper options to newargz, except
4368
   * argz[0], which is handled differently
4369
   */
4370
  newargc=0;
4371
  for (i = 1; i < argc; i++)
4372
    {
4373
      if (strcmp (argv[i], dumpscript_opt) == 0)
4374
	{
4375
EOF
4376
	    case "$host" in
4377
	      *mingw* | *cygwin* )
4378
		# make stdout use "unix" line endings
4379
		echo "          setmode(1,_O_BINARY);"
4380
		;;
4381
	      esac
4382
4383
	    cat <<"EOF"
4384
	  lt_dump_script (stdout);
4385
	  return 0;
4386
	}
4387
      if (strcmp (argv[i], debug_opt) == 0)
4388
	{
4389
          lt_debug = 1;
4390
          continue;
4391
	}
4392
      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4393
        {
4394
          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4395
             namespace, but it is not one of the ones we know about and
4396
             have already dealt with, above (inluding dump-script), then
4397
             report an error. Otherwise, targets might begin to believe
4398
             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4399
             namespace. The first time any user complains about this, we'll
4400
             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4401
             or a configure.ac-settable value.
4402
           */
4403
          lt_fatal (__FILE__, __LINE__,
4404
		    "unrecognized %s option: '%s'",
4405
                    ltwrapper_option_prefix, argv[i]);
4406
        }
4407
      /* otherwise ... */
4408
      newargz[++newargc] = xstrdup (argv[i]);
4409
    }
4410
  newargz[++newargc] = NULL;
4411
4412
EOF
4413
	    cat <<EOF
4414
  /* The GNU banner must be the first non-error debug message */
4415
  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4416
EOF
4417
	    cat <<"EOF"
4418
  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4419
  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4420
4421
  tmp_pathspec = find_executable (argv[0]);
4422
  if (tmp_pathspec == NULL)
4423
    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4424
  lt_debugprintf (__FILE__, __LINE__,
4425
                  "(main) found exe (before symlink chase) at: %s\n",
4426
		  tmp_pathspec);
4427
4428
  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4429
  lt_debugprintf (__FILE__, __LINE__,
4430
                  "(main) found exe (after symlink chase) at: %s\n",
4431
		  actual_cwrapper_path);
4432
  XFREE (tmp_pathspec);
4433
4434
  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4435
  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4436
4437
  /* wrapper name transforms */
4438
  strendzap (actual_cwrapper_name, ".exe");
4439
  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4440
  XFREE (actual_cwrapper_name);
4441
  actual_cwrapper_name = tmp_pathspec;
4442
  tmp_pathspec = 0;
4443
4444
  /* target_name transforms -- use actual target program name; might have lt- prefix */
4445
  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4446
  strendzap (target_name, ".exe");
4447
  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4448
  XFREE (target_name);
4449
  target_name = tmp_pathspec;
4450
  tmp_pathspec = 0;
4451
4452
  lt_debugprintf (__FILE__, __LINE__,
4453
		  "(main) libtool target name: %s\n",
4454
		  target_name);
4455
EOF
4456
4457
	    cat <<EOF
4458
  newargz[0] =
4459
    XMALLOC (char, (strlen (actual_cwrapper_path) +
4460
		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4461
  strcpy (newargz[0], actual_cwrapper_path);
4462
  strcat (newargz[0], "$objdir");
4463
  strcat (newargz[0], "/");
4464
EOF
4465
4466
	    cat <<"EOF"
4467
  /* stop here, and copy so we don't have to do this twice */
4468
  tmp_pathspec = xstrdup (newargz[0]);
4469
4470
  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4471
  strcat (newargz[0], actual_cwrapper_name);
4472
4473
  /* DO want the lt- prefix here if it exists, so use target_name */
4474
  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4475
  XFREE (tmp_pathspec);
4476
  tmp_pathspec = NULL;
4477
EOF
4478
4479
	    case $host_os in
4480
	      mingw*)
4481
	    cat <<"EOF"
4482
  {
4483
    char* p;
4484
    while ((p = strchr (newargz[0], '\\')) != NULL)
4485
      {
4486
	*p = '/';
4487
      }
4488
    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4489
      {
4490
	*p = '/';
4491
      }
4492
  }
4493
EOF
4494
	    ;;
4495
	    esac
4496
4497
	    cat <<"EOF"
4498
  XFREE (target_name);
4499
  XFREE (actual_cwrapper_path);
4500
  XFREE (actual_cwrapper_name);
4501
4502
  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4503
  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4504
  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4505
     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4506
     because on Windows, both *_VARNAMEs are PATH but uninstalled
4507
     libraries must come first. */
4508
  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4509
  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4510
4511
  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4512
		  nonnull (lt_argv_zero));
4513
  for (i = 0; i < newargc; i++)
4514
    {
4515
      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4516
		      i, nonnull (newargz[i]));
4517
    }
4518
4519
EOF
4520
4521
	    case $host_os in
4522
	      mingw*)
4523
		cat <<"EOF"
4524
  /* execv doesn't actually work on mingw as expected on unix */
4525
  newargz = prepare_spawn (newargz);
4526
  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4527
  if (rval == -1)
4528
    {
4529
      /* failed to start process */
4530
      lt_debugprintf (__FILE__, __LINE__,
4531
		      "(main) failed to launch target \"%s\": %s\n",
4532
		      lt_argv_zero, nonnull (strerror (errno)));
4533
      return 127;
4534
    }
4535
  return rval;
4536
EOF
4537
		;;
4538
	      *)
4539
		cat <<"EOF"
4540
  execv (lt_argv_zero, newargz);
4541
  return rval; /* =127, but avoids unused variable warning */
4542
EOF
4543
		;;
4544
	    esac
4545
4546
	    cat <<"EOF"
4547
}
4548
4549
void *
4550
xmalloc (size_t num)
4551
{
4552
  void *p = (void *) malloc (num);
4553
  if (!p)
4554
    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4555
4556
  return p;
4557
}
4558
4559
char *
4560
xstrdup (const char *string)
4561
{
4562
  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4563
			  string) : NULL;
4564
}
4565
4566
const char *
4567
base_name (const char *name)
4568
{
4569
  const char *base;
4570
4571
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4572
  /* Skip over the disk name in MSDOS pathnames. */
4573
  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4574
    name += 2;
4575
#endif
4576
4577
  for (base = name; *name; name++)
4578
    if (IS_DIR_SEPARATOR (*name))
4579
      base = name + 1;
4580
  return base;
4581
}
4582
4583
int
4584
check_executable (const char *path)
4585
{
4586
  struct stat st;
4587
4588
  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4589
                  nonempty (path));
4590
  if ((!path) || (!*path))
4591
    return 0;
4592
4593
  if ((stat (path, &st) >= 0)
4594
      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4595
    return 1;
4596
  else
4597
    return 0;
4598
}
4599
4600
int
4601
make_executable (const char *path)
4602
{
4603
  int rval = 0;
4604
  struct stat st;
4605
4606
  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4607
                  nonempty (path));
4608
  if ((!path) || (!*path))
4609
    return 0;
4610
4611
  if (stat (path, &st) >= 0)
4612
    {
4613
      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4614
    }
4615
  return rval;
4616
}
4617
4618
/* Searches for the full path of the wrapper.  Returns
4619
   newly allocated full path name if found, NULL otherwise
4620
   Does not chase symlinks, even on platforms that support them.
4621
*/
4622
char *
4623
find_executable (const char *wrapper)
4624
{
4625
  int has_slash = 0;
4626
  const char *p;
4627
  const char *p_next;
4628
  /* static buffer for getcwd */
4629
  char tmp[LT_PATHMAX + 1];
4630
  int tmp_len;
4631
  char *concat_name;
4632
4633
  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4634
                  nonempty (wrapper));
4635
4636
  if ((wrapper == NULL) || (*wrapper == '\0'))
4637
    return NULL;
4638
4639
  /* Absolute path? */
4640
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4641
  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4642
    {
4643
      concat_name = xstrdup (wrapper);
4644
      if (check_executable (concat_name))
4645
	return concat_name;
4646
      XFREE (concat_name);
4647
    }
4648
  else
4649
    {
4650
#endif
4651
      if (IS_DIR_SEPARATOR (wrapper[0]))
4652
	{
4653
	  concat_name = xstrdup (wrapper);
4654
	  if (check_executable (concat_name))
4655
	    return concat_name;
4656
	  XFREE (concat_name);
4657
	}
4658
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4659
    }
4660
#endif
4661
4662
  for (p = wrapper; *p; p++)
4663
    if (*p == '/')
4664
      {
4665
	has_slash = 1;
4666
	break;
4667
      }
4668
  if (!has_slash)
4669
    {
4670
      /* no slashes; search PATH */
4671
      const char *path = getenv ("PATH");
4672
      if (path != NULL)
4673
	{
4674
	  for (p = path; *p; p = p_next)
4675
	    {
4676
	      const char *q;
4677
	      size_t p_len;
4678
	      for (q = p; *q; q++)
4679
		if (IS_PATH_SEPARATOR (*q))
4680
		  break;
4681
	      p_len = q - p;
4682
	      p_next = (*q == '\0' ? q : q + 1);
4683
	      if (p_len == 0)
4684
		{
4685
		  /* empty path: current directory */
4686
		  if (getcwd (tmp, LT_PATHMAX) == NULL)
4687
		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4688
                              nonnull (strerror (errno)));
4689
		  tmp_len = strlen (tmp);
4690
		  concat_name =
4691
		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4692
		  memcpy (concat_name, tmp, tmp_len);
4693
		  concat_name[tmp_len] = '/';
4694
		  strcpy (concat_name + tmp_len + 1, wrapper);
4695
		}
4696
	      else
4697
		{
4698
		  concat_name =
4699
		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4700
		  memcpy (concat_name, p, p_len);
4701
		  concat_name[p_len] = '/';
4702
		  strcpy (concat_name + p_len + 1, wrapper);
4703
		}
4704
	      if (check_executable (concat_name))
4705
		return concat_name;
4706
	      XFREE (concat_name);
4707
	    }
4708
	}
4709
      /* not found in PATH; assume curdir */
4710
    }
4711
  /* Relative path | not found in path: prepend cwd */
4712
  if (getcwd (tmp, LT_PATHMAX) == NULL)
4713
    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4714
              nonnull (strerror (errno)));
4715
  tmp_len = strlen (tmp);
4716
  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4717
  memcpy (concat_name, tmp, tmp_len);
4718
  concat_name[tmp_len] = '/';
4719
  strcpy (concat_name + tmp_len + 1, wrapper);
4720
4721
  if (check_executable (concat_name))
4722
    return concat_name;
4723
  XFREE (concat_name);
4724
  return NULL;
4725
}
4726
4727
char *
4728
chase_symlinks (const char *pathspec)
4729
{
4730
#ifndef S_ISLNK
4731
  return xstrdup (pathspec);
4732
#else
4733
  char buf[LT_PATHMAX];
4734
  struct stat s;
4735
  char *tmp_pathspec = xstrdup (pathspec);
4736
  char *p;
4737
  int has_symlinks = 0;
4738
  while (strlen (tmp_pathspec) && !has_symlinks)
4739
    {
4740
      lt_debugprintf (__FILE__, __LINE__,
4741
		      "checking path component for symlinks: %s\n",
4742
		      tmp_pathspec);
4743
      if (lstat (tmp_pathspec, &s) == 0)
4744
	{
4745
	  if (S_ISLNK (s.st_mode) != 0)
4746
	    {
4747
	      has_symlinks = 1;
4748
	      break;
4749
	    }
4750
4751
	  /* search backwards for last DIR_SEPARATOR */
4752
	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4753
	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4754
	    p--;
4755
	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4756
	    {
4757
	      /* no more DIR_SEPARATORS left */
4758
	      break;
4759
	    }
4760
	  *p = '\0';
4761
	}
4762
      else
4763
	{
4764
	  lt_fatal (__FILE__, __LINE__,
4765
		    "error accessing file \"%s\": %s",
4766
		    tmp_pathspec, nonnull (strerror (errno)));
4767
	}
4768
    }
4769
  XFREE (tmp_pathspec);
4770
4771
  if (!has_symlinks)
4772
    {
4773
      return xstrdup (pathspec);
4774
    }
4775
4776
  tmp_pathspec = realpath (pathspec, buf);
4777
  if (tmp_pathspec == 0)
4778
    {
4779
      lt_fatal (__FILE__, __LINE__,
4780
		"could not follow symlinks for %s", pathspec);
4781
    }
4782
  return xstrdup (tmp_pathspec);
4783
#endif
4784
}
4785
4786
char *
4787
strendzap (char *str, const char *pat)
4788
{
4789
  size_t len, patlen;
4790
4791
  assert (str != NULL);
4792
  assert (pat != NULL);
4793
4794
  len = strlen (str);
4795
  patlen = strlen (pat);
4796
4797
  if (patlen <= len)
4798
    {
4799
      str += len - patlen;
4800
      if (strcmp (str, pat) == 0)
4801
	*str = '\0';
4802
    }
4803
  return str;
4804
}
4805
4806
void
4807
lt_debugprintf (const char *file, int line, const char *fmt, ...)
4808
{
4809
  va_list args;
4810
  if (lt_debug)
4811
    {
4812
      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4813
      va_start (args, fmt);
4814
      (void) vfprintf (stderr, fmt, args);
4815
      va_end (args);
4816
    }
4817
}
4818
4819
static void
4820
lt_error_core (int exit_status, const char *file,
4821
	       int line, const char *mode,
4822
	       const char *message, va_list ap)
4823
{
4824
  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4825
  vfprintf (stderr, message, ap);
4826
  fprintf (stderr, ".\n");
4827
4828
  if (exit_status >= 0)
4829
    exit (exit_status);
4830
}
4831
4832
void
4833
lt_fatal (const char *file, int line, const char *message, ...)
4834
{
4835
  va_list ap;
4836
  va_start (ap, message);
4837
  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4838
  va_end (ap);
4839
}
4840
4841
static const char *
4842
nonnull (const char *s)
4843
{
4844
  return s ? s : "(null)";
4845
}
4846
4847
static const char *
4848
nonempty (const char *s)
4849
{
4850
  return (s && !*s) ? "(empty)" : nonnull (s);
4851
}
4852
4853
void
4854
lt_setenv (const char *name, const char *value)
4855
{
4856
  lt_debugprintf (__FILE__, __LINE__,
4857
		  "(lt_setenv) setting '%s' to '%s'\n",
4858
                  nonnull (name), nonnull (value));
4859
  {
4860
#ifdef HAVE_SETENV
4861
    /* always make a copy, for consistency with !HAVE_SETENV */
4862
    char *str = xstrdup (value);
4863
    setenv (name, str, 1);
4864
#else
4865
    int len = strlen (name) + 1 + strlen (value) + 1;
4866
    char *str = XMALLOC (char, len);
4867
    sprintf (str, "%s=%s", name, value);
4868
    if (putenv (str) != EXIT_SUCCESS)
4869
      {
4870
        XFREE (str);
4871
      }
4872
#endif
4873
  }
4874
}
4875
4876
char *
4877
lt_extend_str (const char *orig_value, const char *add, int to_end)
4878
{
4879
  char *new_value;
4880
  if (orig_value && *orig_value)
4881
    {
4882
      int orig_value_len = strlen (orig_value);
4883
      int add_len = strlen (add);
4884
      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4885
      if (to_end)
4886
        {
4887
          strcpy (new_value, orig_value);
4888
          strcpy (new_value + orig_value_len, add);
4889
        }
4890
      else
4891
        {
4892
          strcpy (new_value, add);
4893
          strcpy (new_value + add_len, orig_value);
4894
        }
4895
    }
4896
  else
4897
    {
4898
      new_value = xstrdup (add);
4899
    }
4900
  return new_value;
4901
}
4902
4903
void
4904
lt_update_exe_path (const char *name, const char *value)
4905
{
4906
  lt_debugprintf (__FILE__, __LINE__,
4907
		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4908
                  nonnull (name), nonnull (value));
4909
4910
  if (name && *name && value && *value)
4911
    {
4912
      char *new_value = lt_extend_str (getenv (name), value, 0);
4913
      /* some systems can't cope with a ':'-terminated path #' */
4914
      int len = strlen (new_value);
4915
      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4916
        {
4917
          new_value[len-1] = '\0';
4918
        }
4919
      lt_setenv (name, new_value);
4920
      XFREE (new_value);
4921
    }
4922
}
4923
4924
void
4925
lt_update_lib_path (const char *name, const char *value)
4926
{
4927
  lt_debugprintf (__FILE__, __LINE__,
4928
		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4929
                  nonnull (name), nonnull (value));
4930
4931
  if (name && *name && value && *value)
4932
    {
4933
      char *new_value = lt_extend_str (getenv (name), value, 0);
4934
      lt_setenv (name, new_value);
4935
      XFREE (new_value);
4936
    }
4937
}
4938
4939
EOF
4940
	    case $host_os in
4941
	      mingw*)
4942
		cat <<"EOF"
4943
4944
/* Prepares an argument vector before calling spawn().
4945
   Note that spawn() does not by itself call the command interpreter
4946
     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4947
      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4948
         GetVersionEx(&v);
4949
         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4950
      }) ? "cmd.exe" : "command.com").
4951
   Instead it simply concatenates the arguments, separated by ' ', and calls
4952
   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4953
   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4954
   special way:
4955
   - Space and tab are interpreted as delimiters. They are not treated as
4956
     delimiters if they are surrounded by double quotes: "...".
4957
   - Unescaped double quotes are removed from the input. Their only effect is
4958
     that within double quotes, space and tab are treated like normal
4959
     characters.
4960
   - Backslashes not followed by double quotes are not special.
4961
   - But 2*n+1 backslashes followed by a double quote become
4962
     n backslashes followed by a double quote (n >= 0):
4963
       \" -> "
4964
       \\\" -> \"
4965
       \\\\\" -> \\"
4966
 */
4967
#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
4968
#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
4969
char **
4970
prepare_spawn (char **argv)
4971
{
4972
  size_t argc;
4973
  char **new_argv;
4974
  size_t i;
4975
4976
  /* Count number of arguments.  */
4977
  for (argc = 0; argv[argc] != NULL; argc++)
4978
    ;
4979
4980
  /* Allocate new argument vector.  */
4981
  new_argv = XMALLOC (char *, argc + 1);
4982
4983
  /* Put quoted arguments into the new argument vector.  */
4984
  for (i = 0; i < argc; i++)
4985
    {
4986
      const char *string = argv[i];
4987
4988
      if (string[0] == '\0')
4989
	new_argv[i] = xstrdup ("\"\"");
4990
      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4991
	{
4992
	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4993
	  size_t length;
4994
	  unsigned int backslashes;
4995
	  const char *s;
4996
	  char *quoted_string;
4997
	  char *p;
4998
4999
	  length = 0;
5000
	  backslashes = 0;
5001
	  if (quote_around)
5002
	    length++;
5003
	  for (s = string; *s != '\0'; s++)
5004
	    {
5005
	      char c = *s;
5006
	      if (c == '"')
5007
		length += backslashes + 1;
5008
	      length++;
5009
	      if (c == '\\')
5010
		backslashes++;
5011
	      else
5012
		backslashes = 0;
5013
	    }
5014
	  if (quote_around)
5015
	    length += backslashes + 1;
5016
5017
	  quoted_string = XMALLOC (char, length + 1);
5018
5019
	  p = quoted_string;
5020
	  backslashes = 0;
5021
	  if (quote_around)
5022
	    *p++ = '"';
5023
	  for (s = string; *s != '\0'; s++)
5024
	    {
5025
	      char c = *s;
5026
	      if (c == '"')
5027
		{
5028
		  unsigned int j;
5029
		  for (j = backslashes + 1; j > 0; j--)
5030
		    *p++ = '\\';
5031
		}
5032
	      *p++ = c;
5033
	      if (c == '\\')
5034
		backslashes++;
5035
	      else
5036
		backslashes = 0;
5037
	    }
5038
	  if (quote_around)
5039
	    {
5040
	      unsigned int j;
5041
	      for (j = backslashes; j > 0; j--)
5042
		*p++ = '\\';
5043
	      *p++ = '"';
5044
	    }
5045
	  *p = '\0';
5046
5047
	  new_argv[i] = quoted_string;
5048
	}
5049
      else
5050
	new_argv[i] = (char *) string;
5051
    }
5052
  new_argv[argc] = NULL;
5053
5054
  return new_argv;
5055
}
5056
EOF
5057
		;;
5058
	    esac
5059
5060
            cat <<"EOF"
5061
void lt_dump_script (FILE* f)
5062
{
5063
EOF
5064
	    func_emit_wrapper yes |
5065
	      $SED -n -e '
5066
s/^\(.\{79\}\)\(..*\)/\1\
5067
\2/
5068
h
5069
s/\([\\"]\)/\\\1/g
5070
s/$/\\n/
5071
s/\([^\n]*\).*/  fputs ("\1", f);/p
5072
g
5073
D'
5074
            cat <<"EOF"
5075
}
5076
EOF
5077
}
5078
# end: func_emit_cwrapperexe_src
5079
5080
# func_win32_import_lib_p ARG
5081
# True if ARG is an import lib, as indicated by $file_magic_cmd
5082
func_win32_import_lib_p ()
5083
{
5084
    $opt_debug
5085
    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5086
    *import*) : ;;
5087
    *) false ;;
5088
    esac
5089
}
5090
5091
# func_mode_link arg...
5092
func_mode_link ()
5093
{
5094
    $opt_debug
5095
    case $host in
5096
    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5097
      # It is impossible to link a dll without this setting, and
5098
      # we shouldn't force the makefile maintainer to figure out
5099
      # which system we are compiling for in order to pass an extra
5100
      # flag for every libtool invocation.
5101
      # allow_undefined=no
5102
5103
      # FIXME: Unfortunately, there are problems with the above when trying
5104
      # to make a dll which has undefined symbols, in which case not
5105
      # even a static library is built.  For now, we need to specify
5106
      # -no-undefined on the libtool link line when we can be certain
5107
      # that all symbols are satisfied, otherwise we get a static library.
5108
      allow_undefined=yes
5109
      ;;
5110
    *)
5111
      allow_undefined=yes
5112
      ;;
5113
    esac
5114
    libtool_args=$nonopt
5115
    base_compile="$nonopt $@"
5116
    compile_command=$nonopt
5117
    finalize_command=$nonopt
5118
5119
    compile_rpath=
5120
    finalize_rpath=
5121
    compile_shlibpath=
5122
    finalize_shlibpath=
5123
    convenience=
5124
    old_convenience=
5125
    deplibs=
5126
    old_deplibs=
5127
    compiler_flags=
5128
    linker_flags=
5129
    dllsearchpath=
5130
    lib_search_path=`pwd`
5131
    inst_prefix_dir=
5132
    new_inherited_linker_flags=
5133
5134
    avoid_version=no
5135
    bindir=
5136
    dlfiles=
5137
    dlprefiles=
5138
    dlself=no
5139
    export_dynamic=no
5140
    export_symbols=
5141
    export_symbols_regex=
5142
    generated=
5143
    libobjs=
5144
    ltlibs=
5145
    module=no
5146
    no_install=no
5147
    objs=
5148
    non_pic_objects=
5149
    precious_files_regex=
5150
    prefer_static_libs=no
5151
    preload=no
5152
    prev=
5153
    prevarg=
5154
    release=
5155
    rpath=
5156
    xrpath=
5157
    perm_rpath=
5158
    temp_rpath=
5159
    thread_safe=no
5160
    vinfo=
5161
    vinfo_number=no
5162
    weak_libs=
5163
    single_module="${wl}-single_module"
5164
    func_infer_tag $base_compile
5165
5166
    # We need to know -static, to get the right output filenames.
5167
    for arg
5168
    do
5169
      case $arg in
5170
      -shared)
5171
	test "$build_libtool_libs" != yes && \
5172
	  func_fatal_configuration "can not build a shared library"
5173
	build_old_libs=no
5174
	break
5175
	;;
5176
      -all-static | -static | -static-libtool-libs)
5177
	case $arg in
5178
	-all-static)
5179
	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5180
	    func_warning "complete static linking is impossible in this configuration"
5181
	  fi
5182
	  if test -n "$link_static_flag"; then
5183
	    dlopen_self=$dlopen_self_static
5184
	  fi
5185
	  prefer_static_libs=yes
5186
	  ;;
5187
	-static)
5188
	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5189
	    dlopen_self=$dlopen_self_static
5190
	  fi
5191
	  prefer_static_libs=built
5192
	  ;;
5193
	-static-libtool-libs)
5194
	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5195
	    dlopen_self=$dlopen_self_static
5196
	  fi
5197
	  prefer_static_libs=yes
5198
	  ;;
5199
	esac
5200
	build_libtool_libs=no
5201
	build_old_libs=yes
5202
	break
5203
	;;
5204
      esac
5205
    done
5206
5207
    # See if our shared archives depend on static archives.
5208
    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5209
5210
    # Go through the arguments, transforming them on the way.
5211
    while test "$#" -gt 0; do
5212
      arg="$1"
5213
      shift
5214
      func_quote_for_eval "$arg"
5215
      qarg=$func_quote_for_eval_unquoted_result
5216
      func_append libtool_args " $func_quote_for_eval_result"
5217
5218
      # If the previous option needs an argument, assign it.
5219
      if test -n "$prev"; then
5220
	case $prev in
5221
	output)
5222
	  func_append compile_command " @OUTPUT@"
5223
	  func_append finalize_command " @OUTPUT@"
5224
	  ;;
5225
	esac
5226
5227
	case $prev in
5228
	bindir)
5229
	  bindir="$arg"
5230
	  prev=
5231
	  continue
5232
	  ;;
5233
	dlfiles|dlprefiles)
5234
	  if test "$preload" = no; then
5235
	    # Add the symbol object into the linking commands.
5236
	    func_append compile_command " @SYMFILE@"
5237
	    func_append finalize_command " @SYMFILE@"
5238
	    preload=yes
5239
	  fi
5240
	  case $arg in
5241
	  *.la | *.lo) ;;  # We handle these cases below.
5242
	  force)
5243
	    if test "$dlself" = no; then
5244
	      dlself=needless
5245
	      export_dynamic=yes
5246
	    fi
5247
	    prev=
5248
	    continue
5249
	    ;;
5250
	  self)
5251
	    if test "$prev" = dlprefiles; then
5252
	      dlself=yes
5253
	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5254
	      dlself=yes
5255
	    else
5256
	      dlself=needless
5257
	      export_dynamic=yes
5258
	    fi
5259
	    prev=
5260
	    continue
5261
	    ;;
5262
	  *)
5263
	    if test "$prev" = dlfiles; then
5264
	      func_append dlfiles " $arg"
5265
	    else
5266
	      func_append dlprefiles " $arg"
5267
	    fi
5268
	    prev=
5269
	    continue
5270
	    ;;
5271
	  esac
5272
	  ;;
5273
	expsyms)
5274
	  export_symbols="$arg"
5275
	  test -f "$arg" \
5276
	    || func_fatal_error "symbol file \`$arg' does not exist"
5277
	  prev=
5278
	  continue
5279
	  ;;
5280
	expsyms_regex)
5281
	  export_symbols_regex="$arg"
5282
	  prev=
5283
	  continue
5284
	  ;;
5285
	framework)
5286
	  case $host in
5287
	    *-*-darwin*)
5288
	      case "$deplibs " in
5289
		*" $qarg.ltframework "*) ;;
5290
		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5291
		   ;;
5292
	      esac
5293
	      ;;
5294
	  esac
5295
	  prev=
5296
	  continue
5297
	  ;;
5298
	inst_prefix)
5299
	  inst_prefix_dir="$arg"
5300
	  prev=
5301
	  continue
5302
	  ;;
5303
	objectlist)
5304
	  if test -f "$arg"; then
5305
	    save_arg=$arg
5306
	    moreargs=
5307
	    for fil in `cat "$save_arg"`
5308
	    do
5309
#	      func_append moreargs " $fil"
5310
	      arg=$fil
5311
	      # A libtool-controlled object.
5312
5313
	      # Check to see that this really is a libtool object.
5314
	      if func_lalib_unsafe_p "$arg"; then
5315
		pic_object=
5316
		non_pic_object=
5317
5318
		# Read the .lo file
5319
		func_source "$arg"
5320
5321
		if test -z "$pic_object" ||
5322
		   test -z "$non_pic_object" ||
5323
		   test "$pic_object" = none &&
5324
		   test "$non_pic_object" = none; then
5325
		  func_fatal_error "cannot find name of object for \`$arg'"
5326
		fi
5327
5328
		# Extract subdirectory from the argument.
5329
		func_dirname "$arg" "/" ""
5330
		xdir="$func_dirname_result"
5331
5332
		if test "$pic_object" != none; then
5333
		  # Prepend the subdirectory the object is found in.
5334
		  pic_object="$xdir$pic_object"
5335
5336
		  if test "$prev" = dlfiles; then
5337
		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5338
		      func_append dlfiles " $pic_object"
5339
		      prev=
5340
		      continue
5341
		    else
5342
		      # If libtool objects are unsupported, then we need to preload.
5343
		      prev=dlprefiles
5344
		    fi
5345
		  fi
5346
5347
		  # CHECK ME:  I think I busted this.  -Ossama
5348
		  if test "$prev" = dlprefiles; then
5349
		    # Preload the old-style object.
5350
		    func_append dlprefiles " $pic_object"
5351
		    prev=
5352
		  fi
5353
5354
		  # A PIC object.
5355
		  func_append libobjs " $pic_object"
5356
		  arg="$pic_object"
5357
		fi
5358
5359
		# Non-PIC object.
5360
		if test "$non_pic_object" != none; then
5361
		  # Prepend the subdirectory the object is found in.
5362
		  non_pic_object="$xdir$non_pic_object"
5363
5364
		  # A standard non-PIC object
5365
		  func_append non_pic_objects " $non_pic_object"
5366
		  if test -z "$pic_object" || test "$pic_object" = none ; then
5367
		    arg="$non_pic_object"
5368
		  fi
5369
		else
5370
		  # If the PIC object exists, use it instead.
5371
		  # $xdir was prepended to $pic_object above.
5372
		  non_pic_object="$pic_object"
5373
		  func_append non_pic_objects " $non_pic_object"
5374
		fi
5375
	      else
5376
		# Only an error if not doing a dry-run.
5377
		if $opt_dry_run; then
5378
		  # Extract subdirectory from the argument.
5379
		  func_dirname "$arg" "/" ""
5380
		  xdir="$func_dirname_result"
5381
5382
		  func_lo2o "$arg"
5383
		  pic_object=$xdir$objdir/$func_lo2o_result
5384
		  non_pic_object=$xdir$func_lo2o_result
5385
		  func_append libobjs " $pic_object"
5386
		  func_append non_pic_objects " $non_pic_object"
5387
	        else
5388
		  func_fatal_error "\`$arg' is not a valid libtool object"
5389
		fi
5390
	      fi
5391
	    done
5392
	  else
5393
	    func_fatal_error "link input file \`$arg' does not exist"
5394
	  fi
5395
	  arg=$save_arg
5396
	  prev=
5397
	  continue
5398
	  ;;
5399
	precious_regex)
5400
	  precious_files_regex="$arg"
5401
	  prev=
5402
	  continue
5403
	  ;;
5404
	release)
5405
	  release="-$arg"
5406
	  prev=
5407
	  continue
5408
	  ;;
5409
	rpath | xrpath)
5410
	  # We need an absolute path.
5411
	  case $arg in
5412
	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5413
	  *)
5414
	    func_fatal_error "only absolute run-paths are allowed"
5415
	    ;;
5416
	  esac
5417
	  if test "$prev" = rpath; then
5418
	    case "$rpath " in
5419
	    *" $arg "*) ;;
5420
	    *) func_append rpath " $arg" ;;
5421
	    esac
5422
	  else
5423
	    case "$xrpath " in
5424
	    *" $arg "*) ;;
5425
	    *) func_append xrpath " $arg" ;;
5426
	    esac
5427
	  fi
5428
	  prev=
5429
	  continue
5430
	  ;;
5431
	shrext)
5432
	  shrext_cmds="$arg"
5433
	  prev=
5434
	  continue
5435
	  ;;
5436
	weak)
5437
	  func_append weak_libs " $arg"
5438
	  prev=
5439
	  continue
5440
	  ;;
5441
	xcclinker)
5442
	  func_append linker_flags " $qarg"
5443
	  func_append compiler_flags " $qarg"
5444
	  prev=
5445
	  func_append compile_command " $qarg"
5446
	  func_append finalize_command " $qarg"
5447
	  continue
5448
	  ;;
5449
	xcompiler)
5450
	  func_append compiler_flags " $qarg"
5451
	  prev=
5452
	  func_append compile_command " $qarg"
5453
	  func_append finalize_command " $qarg"
5454
	  continue
5455
	  ;;
5456
	xlinker)
5457
	  func_append linker_flags " $qarg"
5458
	  func_append compiler_flags " $wl$qarg"
5459
	  prev=
5460
	  func_append compile_command " $wl$qarg"
5461
	  func_append finalize_command " $wl$qarg"
5462
	  continue
5463
	  ;;
5464
	*)
5465
	  eval "$prev=\"\$arg\""
5466
	  prev=
5467
	  continue
5468
	  ;;
5469
	esac
5470
      fi # test -n "$prev"
5471
5472
      prevarg="$arg"
5473
5474
      case $arg in
5475
      -all-static)
5476
	if test -n "$link_static_flag"; then
5477
	  # See comment for -static flag below, for more details.
5478
	  func_append compile_command " $link_static_flag"
5479
	  func_append finalize_command " $link_static_flag"
5480
	fi
5481
	continue
5482
	;;
5483
5484
      -allow-undefined)
5485
	# FIXME: remove this flag sometime in the future.
5486
	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5487
	;;
5488
5489
      -avoid-version)
5490
	avoid_version=yes
5491
	continue
5492
	;;
5493
5494
      -bindir)
5495
	prev=bindir
5496
	continue
5497
	;;
5498
5499
      -dlopen)
5500
	prev=dlfiles
5501
	continue
5502
	;;
5503
5504
      -dlpreopen)
5505
	prev=dlprefiles
5506
	continue
5507
	;;
5508
5509
      -export-dynamic)
5510
	export_dynamic=yes
5511
	continue
5512
	;;
5513
5514
      -export-symbols | -export-symbols-regex)
5515
	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5516
	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5517
	fi
5518
	if test "X$arg" = "X-export-symbols"; then
5519
	  prev=expsyms
5520
	else
5521
	  prev=expsyms_regex
5522
	fi
5523
	continue
5524
	;;
5525
5526
      -framework)
5527
	prev=framework
5528
	continue
5529
	;;
5530
5531
      -inst-prefix-dir)
5532
	prev=inst_prefix
5533
	continue
5534
	;;
5535
5536
      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5537
      # so, if we see these flags be careful not to treat them like -L
5538
      -L[A-Z][A-Z]*:*)
5539
	case $with_gcc/$host in
5540
	no/*-*-irix* | /*-*-irix*)
5541
	  func_append compile_command " $arg"
5542
	  func_append finalize_command " $arg"
5543
	  ;;
5544
	esac
5545
	continue
5546
	;;
5547
5548
      -L*)
5549
	func_stripname "-L" '' "$arg"
5550
	if test -z "$func_stripname_result"; then
5551
	  if test "$#" -gt 0; then
5552
	    func_fatal_error "require no space between \`-L' and \`$1'"
5553
	  else
5554
	    func_fatal_error "need path for \`-L' option"
5555
	  fi
5556
	fi
5557
	func_resolve_sysroot "$func_stripname_result"
5558
	dir=$func_resolve_sysroot_result
5559
	# We need an absolute path.
5560
	case $dir in
5561
	[\\/]* | [A-Za-z]:[\\/]*) ;;
5562
	*)
5563
	  absdir=`cd "$dir" && pwd`
5564
	  test -z "$absdir" && \
5565
	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5566
	  dir="$absdir"
5567
	  ;;
5568
	esac
5569
	case "$deplibs " in
5570
	*" -L$dir "* | *" $arg "*)
5571
	  # Will only happen for absolute or sysroot arguments
5572
	  ;;
5573
	*)
5574
	  # Preserve sysroot, but never include relative directories
5575
	  case $dir in
5576
	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5577
	    *) func_append deplibs " -L$dir" ;;
5578
	  esac
5579
	  func_append lib_search_path " $dir"
5580
	  ;;
5581
	esac
5582
	case $host in
5583
	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5584
	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5585
	  case :$dllsearchpath: in
5586
	  *":$dir:"*) ;;
5587
	  ::) dllsearchpath=$dir;;
5588
	  *) func_append dllsearchpath ":$dir";;
5589
	  esac
5590
	  case :$dllsearchpath: in
5591
	  *":$testbindir:"*) ;;
5592
	  ::) dllsearchpath=$testbindir;;
5593
	  *) func_append dllsearchpath ":$testbindir";;
5594
	  esac
5595
	  ;;
5596
	esac
5597
	continue
5598
	;;
5599
5600
      -l*)
5601
	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5602
	  case $host in
5603
	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5604
	    # These systems don't actually have a C or math library (as such)
5605
	    continue
5606
	    ;;
5607
	  *-*-os2*)
5608
	    # These systems don't actually have a C library (as such)
5609
	    test "X$arg" = "X-lc" && continue
5610
	    ;;
5611
	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5612
	    # Do not include libc due to us having libc/libc_r.
5613
	    test "X$arg" = "X-lc" && continue
5614
	    ;;
5615
	  *-*-rhapsody* | *-*-darwin1.[012])
5616
	    # Rhapsody C and math libraries are in the System framework
5617
	    func_append deplibs " System.ltframework"
5618
	    continue
5619
	    ;;
5620
	  *-*-sco3.2v5* | *-*-sco5v6*)
5621
	    # Causes problems with __ctype
5622
	    test "X$arg" = "X-lc" && continue
5623
	    ;;
5624
	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5625
	    # Compiler inserts libc in the correct place for threads to work
5626
	    test "X$arg" = "X-lc" && continue
5627
	    ;;
5628
	  esac
5629
	elif test "X$arg" = "X-lc_r"; then
5630
	 case $host in
5631
	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5632
	   # Do not include libc_r directly, use -pthread flag.
5633
	   continue
5634
	   ;;
5635
	 esac
5636
	fi
5637
	func_append deplibs " $arg"
5638
	continue
5639
	;;
5640
5641
      -module)
5642
	module=yes
5643
	continue
5644
	;;
5645
5646
      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5647
      # classes, name mangling, and exception handling.
5648
      # Darwin uses the -arch flag to determine output architecture.
5649
      -model|-arch|-isysroot|--sysroot)
5650
	func_append compiler_flags " $arg"
5651
	func_append compile_command " $arg"
5652
	func_append finalize_command " $arg"
5653
	prev=xcompiler
5654
	continue
5655
	;;
5656
5657
      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
5658
      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5659
	func_append compiler_flags " $arg"
5660
	func_append compile_command " $arg"
5661
	func_append finalize_command " $arg"
5662
	case "$new_inherited_linker_flags " in
5663
	    *" $arg "*) ;;
5664
	    * ) func_append new_inherited_linker_flags " $arg" ;;
5665
	esac
5666
	continue
5667
	;;
5668
5669
      -multi_module)
5670
	single_module="${wl}-multi_module"
5671
	continue
5672
	;;
5673
5674
      -no-fast-install)
5675
	fast_install=no
5676
	continue
5677
	;;
5678
5679
      -no-install)
5680
	case $host in
5681
	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5682
	  # The PATH hackery in wrapper scripts is required on Windows
5683
	  # and Darwin in order for the loader to find any dlls it needs.
5684
	  func_warning "\`-no-install' is ignored for $host"
5685
	  func_warning "assuming \`-no-fast-install' instead"
5686
	  fast_install=no
5687
	  ;;
5688
	*) no_install=yes ;;
5689
	esac
5690
	continue
5691
	;;
5692
5693
      -no-undefined)
5694
	allow_undefined=no
5695
	continue
5696
	;;
5697
5698
      -objectlist)
5699
	prev=objectlist
5700
	continue
5701
	;;
5702
5703
      -o) prev=output ;;
5704
5705
      -precious-files-regex)
5706
	prev=precious_regex
5707
	continue
5708
	;;
5709
5710
      -release)
5711
	prev=release
5712
	continue
5713
	;;
5714
5715
      -rpath)
5716
	prev=rpath
5717
	continue
5718
	;;
5719
5720
      -R)
5721
	prev=xrpath
5722
	continue
5723
	;;
5724
5725
      -R*)
5726
	func_stripname '-R' '' "$arg"
5727
	dir=$func_stripname_result
5728
	# We need an absolute path.
5729
	case $dir in
5730
	[\\/]* | [A-Za-z]:[\\/]*) ;;
5731
	=*)
5732
	  func_stripname '=' '' "$dir"
5733
	  dir=$lt_sysroot$func_stripname_result
5734
	  ;;
5735
	*)
5736
	  func_fatal_error "only absolute run-paths are allowed"
5737
	  ;;
5738
	esac
5739
	case "$xrpath " in
5740
	*" $dir "*) ;;
5741
	*) func_append xrpath " $dir" ;;
5742
	esac
5743
	continue
5744
	;;
5745
5746
      -shared)
5747
	# The effects of -shared are defined in a previous loop.
5748
	continue
5749
	;;
5750
5751
      -shrext)
5752
	prev=shrext
5753
	continue
5754
	;;
5755
5756
      -static | -static-libtool-libs)
5757
	# The effects of -static are defined in a previous loop.
5758
	# We used to do the same as -all-static on platforms that
5759
	# didn't have a PIC flag, but the assumption that the effects
5760
	# would be equivalent was wrong.  It would break on at least
5761
	# Digital Unix and AIX.
5762
	continue
5763
	;;
5764
5765
      -thread-safe)
5766
	thread_safe=yes
5767
	continue
5768
	;;
5769
5770
      -version-info)
5771
	prev=vinfo
5772
	continue
5773
	;;
5774
5775
      -version-number)
5776
	prev=vinfo
5777
	vinfo_number=yes
5778
	continue
5779
	;;
5780
5781
      -weak)
5782
        prev=weak
5783
	continue
5784
	;;
5785
5786
      -Wc,*)
5787
	func_stripname '-Wc,' '' "$arg"
5788
	args=$func_stripname_result
5789
	arg=
5790
	save_ifs="$IFS"; IFS=','
5791
	for flag in $args; do
5792
	  IFS="$save_ifs"
5793
          func_quote_for_eval "$flag"
5794
	  func_append arg " $func_quote_for_eval_result"
5795
	  func_append compiler_flags " $func_quote_for_eval_result"
5796
	done
5797
	IFS="$save_ifs"
5798
	func_stripname ' ' '' "$arg"
5799
	arg=$func_stripname_result
5800
	;;
5801
5802
      -Wl,*)
5803
	func_stripname '-Wl,' '' "$arg"
5804
	args=$func_stripname_result
5805
	arg=
5806
	save_ifs="$IFS"; IFS=','
5807
	for flag in $args; do
5808
	  IFS="$save_ifs"
5809
          func_quote_for_eval "$flag"
5810
	  func_append arg " $wl$func_quote_for_eval_result"
5811
	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5812
	  func_append linker_flags " $func_quote_for_eval_result"
5813
	done
5814
	IFS="$save_ifs"
5815
	func_stripname ' ' '' "$arg"
5816
	arg=$func_stripname_result
5817
	;;
5818
5819
      -Xcompiler)
5820
	prev=xcompiler
5821
	continue
5822
	;;
5823
5824
      -Xlinker)
5825
	prev=xlinker
5826
	continue
5827
	;;
5828
5829
      -XCClinker)
5830
	prev=xcclinker
5831
	continue
5832
	;;
5833
5834
      # -msg_* for osf cc
5835
      -msg_*)
5836
	func_quote_for_eval "$arg"
5837
	arg="$func_quote_for_eval_result"
5838
	;;
5839
5840
      # Flags to be passed through unchanged, with rationale:
5841
      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5842
      # -r[0-9][0-9]*        specify processor for the SGI compiler
5843
      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5844
      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5845
      # -q*                  compiler args for the IBM compiler
5846
      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5847
      # -F/path              path to uninstalled frameworks, gcc on darwin
5848
      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5849
      # @file                GCC response files
5850
      # -tp=*                Portland pgcc target processor selection
5851
      # --sysroot=*          for sysroot support
5852
      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5853
      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5854
      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5855
      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5856
        func_quote_for_eval "$arg"
5857
	arg="$func_quote_for_eval_result"
5858
        func_append compile_command " $arg"
5859
        func_append finalize_command " $arg"
5860
        func_append compiler_flags " $arg"
5861
        continue
5862
        ;;
5863
5864
      # Some other compiler flag.
5865
      -* | +*)
5866
        func_quote_for_eval "$arg"
5867
	arg="$func_quote_for_eval_result"
5868
	;;
5869
5870
      *.$objext)
5871
	# A standard object.
5872
	func_append objs " $arg"
5873
	;;
5874
5875
      *.lo)
5876
	# A libtool-controlled object.
5877
5878
	# Check to see that this really is a libtool object.
5879
	if func_lalib_unsafe_p "$arg"; then
5880
	  pic_object=
5881
	  non_pic_object=
5882
5883
	  # Read the .lo file
5884
	  func_source "$arg"
5885
5886
	  if test -z "$pic_object" ||
5887
	     test -z "$non_pic_object" ||
5888
	     test "$pic_object" = none &&
5889
	     test "$non_pic_object" = none; then
5890
	    func_fatal_error "cannot find name of object for \`$arg'"
5891
	  fi
5892
5893
	  # Extract subdirectory from the argument.
5894
	  func_dirname "$arg" "/" ""
5895
	  xdir="$func_dirname_result"
5896
5897
	  if test "$pic_object" != none; then
5898
	    # Prepend the subdirectory the object is found in.
5899
	    pic_object="$xdir$pic_object"
5900
5901
	    if test "$prev" = dlfiles; then
5902
	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5903
		func_append dlfiles " $pic_object"
5904
		prev=
5905
		continue
5906
	      else
5907
		# If libtool objects are unsupported, then we need to preload.
5908
		prev=dlprefiles
5909
	      fi
5910
	    fi
5911
5912
	    # CHECK ME:  I think I busted this.  -Ossama
5913
	    if test "$prev" = dlprefiles; then
5914
	      # Preload the old-style object.
5915
	      func_append dlprefiles " $pic_object"
5916
	      prev=
5917
	    fi
5918
5919
	    # A PIC object.
5920
	    func_append libobjs " $pic_object"
5921
	    arg="$pic_object"
5922
	  fi
5923
5924
	  # Non-PIC object.
5925
	  if test "$non_pic_object" != none; then
5926
	    # Prepend the subdirectory the object is found in.
5927
	    non_pic_object="$xdir$non_pic_object"
5928
5929
	    # A standard non-PIC object
5930
	    func_append non_pic_objects " $non_pic_object"
5931
	    if test -z "$pic_object" || test "$pic_object" = none ; then
5932
	      arg="$non_pic_object"
5933
	    fi
5934
	  else
5935
	    # If the PIC object exists, use it instead.
5936
	    # $xdir was prepended to $pic_object above.
5937
	    non_pic_object="$pic_object"
5938
	    func_append non_pic_objects " $non_pic_object"
5939
	  fi
5940
	else
5941
	  # Only an error if not doing a dry-run.
5942
	  if $opt_dry_run; then
5943
	    # Extract subdirectory from the argument.
5944
	    func_dirname "$arg" "/" ""
5945
	    xdir="$func_dirname_result"
5946
5947
	    func_lo2o "$arg"
5948
	    pic_object=$xdir$objdir/$func_lo2o_result
5949
	    non_pic_object=$xdir$func_lo2o_result
5950
	    func_append libobjs " $pic_object"
5951
	    func_append non_pic_objects " $non_pic_object"
5952
	  else
5953
	    func_fatal_error "\`$arg' is not a valid libtool object"
5954
	  fi
5955
	fi
5956
	;;
5957
5958
      *.$libext)
5959
	# An archive.
5960
	func_append deplibs " $arg"
5961
	func_append old_deplibs " $arg"
5962
	continue
5963
	;;
5964
5965
      *.la)
5966
	# A libtool-controlled library.
5967
5968
	func_resolve_sysroot "$arg"
5969
	if test "$prev" = dlfiles; then
5970
	  # This library was specified with -dlopen.
5971
	  func_append dlfiles " $func_resolve_sysroot_result"
5972
	  prev=
5973
	elif test "$prev" = dlprefiles; then
5974
	  # The library was specified with -dlpreopen.
5975
	  func_append dlprefiles " $func_resolve_sysroot_result"
5976
	  prev=
5977
	else
5978
	  func_append deplibs " $func_resolve_sysroot_result"
5979
	fi
5980
	continue
5981
	;;
5982
5983
      # Some other compiler argument.
5984
      *)
5985
	# Unknown arguments in both finalize_command and compile_command need
5986
	# to be aesthetically quoted because they are evaled later.
5987
	func_quote_for_eval "$arg"
5988
	arg="$func_quote_for_eval_result"
5989
	;;
5990
      esac # arg
5991
5992
      # Now actually substitute the argument into the commands.
5993
      if test -n "$arg"; then
5994
	func_append compile_command " $arg"
5995
	func_append finalize_command " $arg"
5996
      fi
5997
    done # argument parsing loop
5998
5999
    test -n "$prev" && \
6000
      func_fatal_help "the \`$prevarg' option requires an argument"
6001
6002
    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
6003
      eval arg=\"$export_dynamic_flag_spec\"
6004
      func_append compile_command " $arg"
6005
      func_append finalize_command " $arg"
6006
    fi
6007
6008
    oldlibs=
6009
    # calculate the name of the file, without its directory
6010
    func_basename "$output"
6011
    outputname="$func_basename_result"
6012
    libobjs_save="$libobjs"
6013
6014
    if test -n "$shlibpath_var"; then
6015
      # get the directories listed in $shlibpath_var
6016
      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6017
    else
6018
      shlib_search_path=
6019
    fi
6020
    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6021
    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6022
6023
    func_dirname "$output" "/" ""
6024
    output_objdir="$func_dirname_result$objdir"
6025
    func_to_tool_file "$output_objdir/"
6026
    tool_output_objdir=$func_to_tool_file_result
6027
    # Create the object directory.
6028
    func_mkdir_p "$output_objdir"
6029
6030
    # Determine the type of output
6031
    case $output in
6032
    "")
6033
      func_fatal_help "you must specify an output file"
6034
      ;;
6035
    *.$libext) linkmode=oldlib ;;
6036
    *.lo | *.$objext) linkmode=obj ;;
6037
    *.la) linkmode=lib ;;
6038
    *) linkmode=prog ;; # Anything else should be a program.
6039
    esac
6040
6041
    specialdeplibs=
6042
6043
    libs=
6044
    # Find all interdependent deplibs by searching for libraries
6045
    # that are linked more than once (e.g. -la -lb -la)
6046
    for deplib in $deplibs; do
6047
      if $opt_preserve_dup_deps ; then
6048
	case "$libs " in
6049
	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6050
	esac
6051
      fi
6052
      func_append libs " $deplib"
6053
    done
6054
6055
    if test "$linkmode" = lib; then
6056
      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6057
6058
      # Compute libraries that are listed more than once in $predeps
6059
      # $postdeps and mark them as special (i.e., whose duplicates are
6060
      # not to be eliminated).
6061
      pre_post_deps=
6062
      if $opt_duplicate_compiler_generated_deps; then
6063
	for pre_post_dep in $predeps $postdeps; do
6064
	  case "$pre_post_deps " in
6065
	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6066
	  esac
6067
	  func_append pre_post_deps " $pre_post_dep"
6068
	done
6069
      fi
6070
      pre_post_deps=
6071
    fi
6072
6073
    deplibs=
6074
    newdependency_libs=
6075
    newlib_search_path=
6076
    need_relink=no # whether we're linking any uninstalled libtool libraries
6077
    notinst_deplibs= # not-installed libtool libraries
6078
    notinst_path= # paths that contain not-installed libtool libraries
6079
6080
    case $linkmode in
6081
    lib)
6082
	passes="conv dlpreopen link"
6083
	for file in $dlfiles $dlprefiles; do
6084
	  case $file in
6085
	  *.la) ;;
6086
	  *)
6087
	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6088
	    ;;
6089
	  esac
6090
	done
6091
	;;
6092
    prog)
6093
	compile_deplibs=
6094
	finalize_deplibs=
6095
	alldeplibs=no
6096
	newdlfiles=
6097
	newdlprefiles=
6098
	passes="conv scan dlopen dlpreopen link"
6099
	;;
6100
    *)  passes="conv"
6101
	;;
6102
    esac
6103
6104
    for pass in $passes; do
6105
      # The preopen pass in lib mode reverses $deplibs; put it back here
6106
      # so that -L comes before libs that need it for instance...
6107
      if test "$linkmode,$pass" = "lib,link"; then
6108
	## FIXME: Find the place where the list is rebuilt in the wrong
6109
	##        order, and fix it there properly
6110
        tmp_deplibs=
6111
	for deplib in $deplibs; do
6112
	  tmp_deplibs="$deplib $tmp_deplibs"
6113
	done
6114
	deplibs="$tmp_deplibs"
6115
      fi
6116
6117
      if test "$linkmode,$pass" = "lib,link" ||
6118
	 test "$linkmode,$pass" = "prog,scan"; then
6119
	libs="$deplibs"
6120
	deplibs=
6121
      fi
6122
      if test "$linkmode" = prog; then
6123
	case $pass in
6124
	dlopen) libs="$dlfiles" ;;
6125
	dlpreopen) libs="$dlprefiles" ;;
6126
	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
6127
	esac
6128
      fi
6129
      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6130
	# Collect and forward deplibs of preopened libtool libs
6131
	for lib in $dlprefiles; do
6132
	  # Ignore non-libtool-libs
6133
	  dependency_libs=
6134
	  func_resolve_sysroot "$lib"
6135
	  case $lib in
6136
	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6137
	  esac
6138
6139
	  # Collect preopened libtool deplibs, except any this library
6140
	  # has declared as weak libs
6141
	  for deplib in $dependency_libs; do
6142
	    func_basename "$deplib"
6143
            deplib_base=$func_basename_result
6144
	    case " $weak_libs " in
6145
	    *" $deplib_base "*) ;;
6146
	    *) func_append deplibs " $deplib" ;;
6147
	    esac
6148
	  done
6149
	done
6150
	libs="$dlprefiles"
6151
      fi
6152
      if test "$pass" = dlopen; then
6153
	# Collect dlpreopened libraries
6154
	save_deplibs="$deplibs"
6155
	deplibs=
6156
      fi
6157
6158
      for deplib in $libs; do
6159
	lib=
6160
	found=no
6161
	case $deplib in
6162
	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6163
        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6164
	  if test "$linkmode,$pass" = "prog,link"; then
6165
	    compile_deplibs="$deplib $compile_deplibs"
6166
	    finalize_deplibs="$deplib $finalize_deplibs"
6167
	  else
6168
	    func_append compiler_flags " $deplib"
6169
	    if test "$linkmode" = lib ; then
6170
		case "$new_inherited_linker_flags " in
6171
		    *" $deplib "*) ;;
6172
		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6173
		esac
6174
	    fi
6175
	  fi
6176
	  continue
6177
	  ;;
6178
	-l*)
6179
	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6180
	    func_warning "\`-l' is ignored for archives/objects"
6181
	    continue
6182
	  fi
6183
	  func_stripname '-l' '' "$deplib"
6184
	  name=$func_stripname_result
6185
	  if test "$linkmode" = lib; then
6186
	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6187
	  else
6188
	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6189
	  fi
6190
	  for searchdir in $searchdirs; do
6191
	    for search_ext in .la $std_shrext .so .a; do
6192
	      # Search the libtool library
6193
	      lib="$searchdir/lib${name}${search_ext}"
6194
	      if test -f "$lib"; then
6195
		if test "$search_ext" = ".la"; then
6196
		  found=yes
6197
		else
6198
		  found=no
6199
		fi
6200
		break 2
6201
	      fi
6202
	    done
6203
	  done
6204
	  if test "$found" != yes; then
6205
	    # deplib doesn't seem to be a libtool library
6206
	    if test "$linkmode,$pass" = "prog,link"; then
6207
	      compile_deplibs="$deplib $compile_deplibs"
6208
	      finalize_deplibs="$deplib $finalize_deplibs"
6209
	    else
6210
	      deplibs="$deplib $deplibs"
6211
	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6212
	    fi
6213
	    continue
6214
	  else # deplib is a libtool library
6215
	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6216
	    # We need to do some special things here, and not later.
6217
	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6218
	      case " $predeps $postdeps " in
6219
	      *" $deplib "*)
6220
		if func_lalib_p "$lib"; then
6221
		  library_names=
6222
		  old_library=
6223
		  func_source "$lib"
6224
		  for l in $old_library $library_names; do
6225
		    ll="$l"
6226
		  done
6227
		  if test "X$ll" = "X$old_library" ; then # only static version available
6228
		    found=no
6229
		    func_dirname "$lib" "" "."
6230
		    ladir="$func_dirname_result"
6231
		    lib=$ladir/$old_library
6232
		    if test "$linkmode,$pass" = "prog,link"; then
6233
		      compile_deplibs="$deplib $compile_deplibs"
6234
		      finalize_deplibs="$deplib $finalize_deplibs"
6235
		    else
6236
		      deplibs="$deplib $deplibs"
6237
		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6238
		    fi
6239
		    continue
6240
		  fi
6241
		fi
6242
		;;
6243
	      *) ;;
6244
	      esac
6245
	    fi
6246
	  fi
6247
	  ;; # -l
6248
	*.ltframework)
6249
	  if test "$linkmode,$pass" = "prog,link"; then
6250
	    compile_deplibs="$deplib $compile_deplibs"
6251
	    finalize_deplibs="$deplib $finalize_deplibs"
6252
	  else
6253
	    deplibs="$deplib $deplibs"
6254
	    if test "$linkmode" = lib ; then
6255
		case "$new_inherited_linker_flags " in
6256
		    *" $deplib "*) ;;
6257
		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6258
		esac
6259
	    fi
6260
	  fi
6261
	  continue
6262
	  ;;
6263
	-L*)
6264
	  case $linkmode in
6265
	  lib)
6266
	    deplibs="$deplib $deplibs"
6267
	    test "$pass" = conv && continue
6268
	    newdependency_libs="$deplib $newdependency_libs"
6269
	    func_stripname '-L' '' "$deplib"
6270
	    func_resolve_sysroot "$func_stripname_result"
6271
	    func_append newlib_search_path " $func_resolve_sysroot_result"
6272
	    ;;
6273
	  prog)
6274
	    if test "$pass" = conv; then
6275
	      deplibs="$deplib $deplibs"
6276
	      continue
6277
	    fi
6278
	    if test "$pass" = scan; then
6279
	      deplibs="$deplib $deplibs"
6280
	    else
6281
	      compile_deplibs="$deplib $compile_deplibs"
6282
	      finalize_deplibs="$deplib $finalize_deplibs"
6283
	    fi
6284
	    func_stripname '-L' '' "$deplib"
6285
	    func_resolve_sysroot "$func_stripname_result"
6286
	    func_append newlib_search_path " $func_resolve_sysroot_result"
6287
	    ;;
6288
	  *)
6289
	    func_warning "\`-L' is ignored for archives/objects"
6290
	    ;;
6291
	  esac # linkmode
6292
	  continue
6293
	  ;; # -L
6294
	-R*)
6295
	  if test "$pass" = link; then
6296
	    func_stripname '-R' '' "$deplib"
6297
	    func_resolve_sysroot "$func_stripname_result"
6298
	    dir=$func_resolve_sysroot_result
6299
	    # Make sure the xrpath contains only unique directories.
6300
	    case "$xrpath " in
6301
	    *" $dir "*) ;;
6302
	    *) func_append xrpath " $dir" ;;
6303
	    esac
6304
	  fi
6305
	  deplibs="$deplib $deplibs"
6306
	  continue
6307
	  ;;
6308
	*.la)
6309
	  func_resolve_sysroot "$deplib"
6310
	  lib=$func_resolve_sysroot_result
6311
	  ;;
6312
	*.$libext)
6313
	  if test "$pass" = conv; then
6314
	    deplibs="$deplib $deplibs"
6315
	    continue
6316
	  fi
6317
	  case $linkmode in
6318
	  lib)
6319
	    # Linking convenience modules into shared libraries is allowed,
6320
	    # but linking other static libraries is non-portable.
6321
	    case " $dlpreconveniencelibs " in
6322
	    *" $deplib "*) ;;
6323
	    *)
6324
	      valid_a_lib=no
6325
	      case $deplibs_check_method in
6326
		match_pattern*)
6327
		  set dummy $deplibs_check_method; shift
6328
		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6329
		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6330
		    | $EGREP "$match_pattern_regex" > /dev/null; then
6331
		    valid_a_lib=yes
6332
		  fi
6333
		;;
6334
		pass_all)
6335
		  valid_a_lib=yes
6336
		;;
6337
	      esac
6338
	      if test "$valid_a_lib" != yes; then
6339
		echo
6340
		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
6341
		echo "*** I have the capability to make that library automatically link in when"
6342
		echo "*** you link to this library.  But I can only do this if you have a"
6343
		echo "*** shared version of the library, which you do not appear to have"
6344
		echo "*** because the file extensions .$libext of this argument makes me believe"
6345
		echo "*** that it is just a static archive that I should not use here."
6346
	      else
6347
		echo
6348
		$ECHO "*** Warning: Linking the shared library $output against the"
6349
		$ECHO "*** static library $deplib is not portable!"
6350
		deplibs="$deplib $deplibs"
6351
	      fi
6352
	      ;;
6353
	    esac
6354
	    continue
6355
	    ;;
6356
	  prog)
6357
	    if test "$pass" != link; then
6358
	      deplibs="$deplib $deplibs"
6359
	    else
6360
	      compile_deplibs="$deplib $compile_deplibs"
6361
	      finalize_deplibs="$deplib $finalize_deplibs"
6362
	    fi
6363
	    continue
6364
	    ;;
6365
	  esac # linkmode
6366
	  ;; # *.$libext
6367
	*.lo | *.$objext)
6368
	  if test "$pass" = conv; then
6369
	    deplibs="$deplib $deplibs"
6370
	  elif test "$linkmode" = prog; then
6371
	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6372
	      # If there is no dlopen support or we're linking statically,
6373
	      # we need to preload.
6374
	      func_append newdlprefiles " $deplib"
6375
	      compile_deplibs="$deplib $compile_deplibs"
6376
	      finalize_deplibs="$deplib $finalize_deplibs"
6377
	    else
6378
	      func_append newdlfiles " $deplib"
6379
	    fi
6380
	  fi
6381
	  continue
6382
	  ;;
6383
	%DEPLIBS%)
6384
	  alldeplibs=yes
6385
	  continue
6386
	  ;;
6387
	esac # case $deplib
6388
6389
	if test "$found" = yes || test -f "$lib"; then :
6390
	else
6391
	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6392
	fi
6393
6394
	# Check to see that this really is a libtool archive.
6395
	func_lalib_unsafe_p "$lib" \
6396
	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6397
6398
	func_dirname "$lib" "" "."
6399
	ladir="$func_dirname_result"
6400
6401
	dlname=
6402
	dlopen=
6403
	dlpreopen=
6404
	libdir=
6405
	library_names=
6406
	old_library=
6407
	inherited_linker_flags=
6408
	# If the library was installed with an old release of libtool,
6409
	# it will not redefine variables installed, or shouldnotlink
6410
	installed=yes
6411
	shouldnotlink=no
6412
	avoidtemprpath=
6413
6414
6415
	# Read the .la file
6416
	func_source "$lib"
6417
6418
	# Convert "-framework foo" to "foo.ltframework"
6419
	if test -n "$inherited_linker_flags"; then
6420
	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6421
	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6422
	    case " $new_inherited_linker_flags " in
6423
	      *" $tmp_inherited_linker_flag "*) ;;
6424
	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6425
	    esac
6426
	  done
6427
	fi
6428
	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6429
	if test "$linkmode,$pass" = "lib,link" ||
6430
	   test "$linkmode,$pass" = "prog,scan" ||
6431
	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6432
	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6433
	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6434
	fi
6435
6436
	if test "$pass" = conv; then
6437
	  # Only check for convenience libraries
6438
	  deplibs="$lib $deplibs"
6439
	  if test -z "$libdir"; then
6440
	    if test -z "$old_library"; then
6441
	      func_fatal_error "cannot find name of link library for \`$lib'"
6442
	    fi
6443
	    # It is a libtool convenience library, so add in its objects.
6444
	    func_append convenience " $ladir/$objdir/$old_library"
6445
	    func_append old_convenience " $ladir/$objdir/$old_library"
6446
	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6447
	    func_fatal_error "\`$lib' is not a convenience library"
6448
	  fi
6449
	  tmp_libs=
6450
	  for deplib in $dependency_libs; do
6451
	    deplibs="$deplib $deplibs"
6452
	    if $opt_preserve_dup_deps ; then
6453
	      case "$tmp_libs " in
6454
	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6455
	      esac
6456
	    fi
6457
	    func_append tmp_libs " $deplib"
6458
	  done
6459
	  continue
6460
	fi # $pass = conv
6461
6462
6463
	# Get the name of the library we link against.
6464
	linklib=
6465
	if test -n "$old_library" &&
6466
	   { test "$prefer_static_libs" = yes ||
6467
	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6468
	  linklib=$old_library
6469
	else
6470
	  for l in $old_library $library_names; do
6471
	    linklib="$l"
6472
	  done
6473
	fi
6474
	if test -z "$linklib"; then
6475
	  func_fatal_error "cannot find name of link library for \`$lib'"
6476
	fi
6477
6478
	# This library was specified with -dlopen.
6479
	if test "$pass" = dlopen; then
6480
	  if test -z "$libdir"; then
6481
	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6482
	  fi
6483
	  if test -z "$dlname" ||
6484
	     test "$dlopen_support" != yes ||
6485
	     test "$build_libtool_libs" = no; then
6486
	    # If there is no dlname, no dlopen support or we're linking
6487
	    # statically, we need to preload.  We also need to preload any
6488
	    # dependent libraries so libltdl's deplib preloader doesn't
6489
	    # bomb out in the load deplibs phase.
6490
	    func_append dlprefiles " $lib $dependency_libs"
6491
	  else
6492
	    func_append newdlfiles " $lib"
6493
	  fi
6494
	  continue
6495
	fi # $pass = dlopen
6496
6497
	# We need an absolute path.
6498
	case $ladir in
6499
	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6500
	*)
6501
	  abs_ladir=`cd "$ladir" && pwd`
6502
	  if test -z "$abs_ladir"; then
6503
	    func_warning "cannot determine absolute directory name of \`$ladir'"
6504
	    func_warning "passing it literally to the linker, although it might fail"
6505
	    abs_ladir="$ladir"
6506
	  fi
6507
	  ;;
6508
	esac
6509
	func_basename "$lib"
6510
	laname="$func_basename_result"
6511
6512
	# Find the relevant object directory and library name.
6513
	if test "X$installed" = Xyes; then
6514
	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6515
	    func_warning "library \`$lib' was moved."
6516
	    dir="$ladir"
6517
	    absdir="$abs_ladir"
6518
	    libdir="$abs_ladir"
6519
	  else
6520
	    dir="$lt_sysroot$libdir"
6521
	    absdir="$lt_sysroot$libdir"
6522
	  fi
6523
	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6524
	else
6525
	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6526
	    dir="$ladir"
6527
	    absdir="$abs_ladir"
6528
	    # Remove this search path later
6529
	    func_append notinst_path " $abs_ladir"
6530
	  else
6531
	    dir="$ladir/$objdir"
6532
	    absdir="$abs_ladir/$objdir"
6533
	    # Remove this search path later
6534
	    func_append notinst_path " $abs_ladir"
6535
	  fi
6536
	fi # $installed = yes
6537
	func_stripname 'lib' '.la' "$laname"
6538
	name=$func_stripname_result
6539
6540
	# This library was specified with -dlpreopen.
6541
	if test "$pass" = dlpreopen; then
6542
	  if test -z "$libdir" && test "$linkmode" = prog; then
6543
	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6544
	  fi
6545
	  case "$host" in
6546
	    # special handling for platforms with PE-DLLs.
6547
	    *cygwin* | *mingw* | *cegcc* )
6548
	      # Linker will automatically link against shared library if both
6549
	      # static and shared are present.  Therefore, ensure we extract
6550
	      # symbols from the import library if a shared library is present
6551
	      # (otherwise, the dlopen module name will be incorrect).  We do
6552
	      # this by putting the import library name into $newdlprefiles.
6553
	      # We recover the dlopen module name by 'saving' the la file
6554
	      # name in a special purpose variable, and (later) extracting the
6555
	      # dlname from the la file.
6556
	      if test -n "$dlname"; then
6557
	        func_tr_sh "$dir/$linklib"
6558
	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6559
	        func_append newdlprefiles " $dir/$linklib"
6560
	      else
6561
	        func_append newdlprefiles " $dir/$old_library"
6562
	        # Keep a list of preopened convenience libraries to check
6563
	        # that they are being used correctly in the link pass.
6564
	        test -z "$libdir" && \
6565
	          func_append dlpreconveniencelibs " $dir/$old_library"
6566
	      fi
6567
	    ;;
6568
	    * )
6569
	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6570
	      # are required to link).
6571
	      if test -n "$old_library"; then
6572
	        func_append newdlprefiles " $dir/$old_library"
6573
	        # Keep a list of preopened convenience libraries to check
6574
	        # that they are being used correctly in the link pass.
6575
	        test -z "$libdir" && \
6576
	          func_append dlpreconveniencelibs " $dir/$old_library"
6577
	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6578
	      elif test -n "$dlname"; then
6579
	        func_append newdlprefiles " $dir/$dlname"
6580
	      else
6581
	        func_append newdlprefiles " $dir/$linklib"
6582
	      fi
6583
	    ;;
6584
	  esac
6585
	fi # $pass = dlpreopen
6586
6587
	if test -z "$libdir"; then
6588
	  # Link the convenience library
6589
	  if test "$linkmode" = lib; then
6590
	    deplibs="$dir/$old_library $deplibs"
6591
	  elif test "$linkmode,$pass" = "prog,link"; then
6592
	    compile_deplibs="$dir/$old_library $compile_deplibs"
6593
	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6594
	  else
6595
	    deplibs="$lib $deplibs" # used for prog,scan pass
6596
	  fi
6597
	  continue
6598
	fi
6599
6600
6601
	if test "$linkmode" = prog && test "$pass" != link; then
6602
	  func_append newlib_search_path " $ladir"
6603
	  deplibs="$lib $deplibs"
6604
6605
	  linkalldeplibs=no
6606
	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6607
	     test "$build_libtool_libs" = no; then
6608
	    linkalldeplibs=yes
6609
	  fi
6610
6611
	  tmp_libs=
6612
	  for deplib in $dependency_libs; do
6613
	    case $deplib in
6614
	    -L*) func_stripname '-L' '' "$deplib"
6615
	         func_resolve_sysroot "$func_stripname_result"
6616
	         func_append newlib_search_path " $func_resolve_sysroot_result"
6617
		 ;;
6618
	    esac
6619
	    # Need to link against all dependency_libs?
6620
	    if test "$linkalldeplibs" = yes; then
6621
	      deplibs="$deplib $deplibs"
6622
	    else
6623
	      # Need to hardcode shared library paths
6624
	      # or/and link against static libraries
6625
	      newdependency_libs="$deplib $newdependency_libs"
6626
	    fi
6627
	    if $opt_preserve_dup_deps ; then
6628
	      case "$tmp_libs " in
6629
	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6630
	      esac
6631
	    fi
6632
	    func_append tmp_libs " $deplib"
6633
	  done # for deplib
6634
	  continue
6635
	fi # $linkmode = prog...
6636
6637
	if test "$linkmode,$pass" = "prog,link"; then
6638
	  if test -n "$library_names" &&
6639
	     { { test "$prefer_static_libs" = no ||
6640
	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6641
	       test -z "$old_library"; }; then
6642
	    # We need to hardcode the library path
6643
	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6644
	      # Make sure the rpath contains only unique directories.
6645
	      case "$temp_rpath:" in
6646
	      *"$absdir:"*) ;;
6647
	      *) func_append temp_rpath "$absdir:" ;;
6648
	      esac
6649
	    fi
6650
6651
	    # Hardcode the library path.
6652
	    # Skip directories that are in the system default run-time
6653
	    # search path.
6654
	    case " $sys_lib_dlsearch_path " in
6655
	    *" $absdir "*) ;;
6656
	    *)
6657
	      case "$compile_rpath " in
6658
	      *" $absdir "*) ;;
6659
	      *) func_append compile_rpath " $absdir" ;;
6660
	      esac
6661
	      ;;
6662
	    esac
6663
	    case " $sys_lib_dlsearch_path " in
6664
	    *" $libdir "*) ;;
6665
	    *)
6666
	      case "$finalize_rpath " in
6667
	      *" $libdir "*) ;;
6668
	      *) func_append finalize_rpath " $libdir" ;;
6669
	      esac
6670
	      ;;
6671
	    esac
6672
	  fi # $linkmode,$pass = prog,link...
6673
6674
	  if test "$alldeplibs" = yes &&
6675
	     { test "$deplibs_check_method" = pass_all ||
6676
	       { test "$build_libtool_libs" = yes &&
6677
		 test -n "$library_names"; }; }; then
6678
	    # We only need to search for static libraries
6679
	    continue
6680
	  fi
6681
	fi
6682
6683
	link_static=no # Whether the deplib will be linked statically
6684
	use_static_libs=$prefer_static_libs
6685
	if test "$use_static_libs" = built && test "$installed" = yes; then
6686
	  use_static_libs=no
6687
	fi
6688
	if test -n "$library_names" &&
6689
	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6690
	  case $host in
6691
	  *cygwin* | *mingw* | *cegcc*)
6692
	      # No point in relinking DLLs because paths are not encoded
6693
	      func_append notinst_deplibs " $lib"
6694
	      need_relink=no
6695
	    ;;
6696
	  *)
6697
	    if test "$installed" = no; then
6698
	      func_append notinst_deplibs " $lib"
6699
	      need_relink=yes
6700
	    fi
6701
	    ;;
6702
	  esac
6703
	  # This is a shared library
6704
6705
	  # Warn about portability, can't link against -module's on some
6706
	  # systems (darwin).  Don't bleat about dlopened modules though!
6707
	  dlopenmodule=""
6708
	  for dlpremoduletest in $dlprefiles; do
6709
	    if test "X$dlpremoduletest" = "X$lib"; then
6710
	      dlopenmodule="$dlpremoduletest"
6711
	      break
6712
	    fi
6713
	  done
6714
	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6715
	    echo
6716
	    if test "$linkmode" = prog; then
6717
	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6718
	    else
6719
	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6720
	    fi
6721
	    $ECHO "*** $linklib is not portable!"
6722
	  fi
6723
	  if test "$linkmode" = lib &&
6724
	     test "$hardcode_into_libs" = yes; then
6725
	    # Hardcode the library path.
6726
	    # Skip directories that are in the system default run-time
6727
	    # search path.
6728
	    case " $sys_lib_dlsearch_path " in
6729
	    *" $absdir "*) ;;
6730
	    *)
6731
	      case "$compile_rpath " in
6732
	      *" $absdir "*) ;;
6733
	      *) func_append compile_rpath " $absdir" ;;
6734
	      esac
6735
	      ;;
6736
	    esac
6737
	    case " $sys_lib_dlsearch_path " in
6738
	    *" $libdir "*) ;;
6739
	    *)
6740
	      case "$finalize_rpath " in
6741
	      *" $libdir "*) ;;
6742
	      *) func_append finalize_rpath " $libdir" ;;
6743
	      esac
6744
	      ;;
6745
	    esac
6746
	  fi
6747
6748
	  if test -n "$old_archive_from_expsyms_cmds"; then
6749
	    # figure out the soname
6750
	    set dummy $library_names
6751
	    shift
6752
	    realname="$1"
6753
	    shift
6754
	    libname=`eval "\\$ECHO \"$libname_spec\""`
6755
	    # use dlname if we got it. it's perfectly good, no?
6756
	    if test -n "$dlname"; then
6757
	      soname="$dlname"
6758
	    elif test -n "$soname_spec"; then
6759
	      # bleh windows
6760
	      case $host in
6761
	      *cygwin* | mingw* | *cegcc*)
6762
	        func_arith $current - $age
6763
		major=$func_arith_result
6764
		versuffix="-$major"
6765
		;;
6766
	      esac
6767
	      eval soname=\"$soname_spec\"
6768
	    else
6769
	      soname="$realname"
6770
	    fi
6771
6772
	    # Make a new name for the extract_expsyms_cmds to use
6773
	    soroot="$soname"
6774
	    func_basename "$soroot"
6775
	    soname="$func_basename_result"
6776
	    func_stripname 'lib' '.dll' "$soname"
6777
	    newlib=libimp-$func_stripname_result.a
6778
6779
	    # If the library has no export list, then create one now
6780
	    if test -f "$output_objdir/$soname-def"; then :
6781
	    else
6782
	      func_verbose "extracting exported symbol list from \`$soname'"
6783
	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6784
	    fi
6785
6786
	    # Create $newlib
6787
	    if test -f "$output_objdir/$newlib"; then :; else
6788
	      func_verbose "generating import library for \`$soname'"
6789
	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6790
	    fi
6791
	    # make sure the library variables are pointing to the new library
6792
	    dir=$output_objdir
6793
	    linklib=$newlib
6794
	  fi # test -n "$old_archive_from_expsyms_cmds"
6795
6796
	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6797
	    add_shlibpath=
6798
	    add_dir=
6799
	    add=
6800
	    lib_linked=yes
6801
	    case $hardcode_action in
6802
	    immediate | unsupported)
6803
	      if test "$hardcode_direct" = no; then
6804
		add="$dir/$linklib"
6805
		case $host in
6806
		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6807
		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6808
		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6809
		    *-*-unixware7*) add_dir="-L$dir" ;;
6810
		  *-*-darwin* )
6811
		    # if the lib is a (non-dlopened) module then we can not
6812
		    # link against it, someone is ignoring the earlier warnings
6813
		    if /usr/bin/file -L $add 2> /dev/null |
6814
			 $GREP ": [^:]* bundle" >/dev/null ; then
6815
		      if test "X$dlopenmodule" != "X$lib"; then
6816
			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6817
			if test -z "$old_library" ; then
6818
			  echo
6819
			  echo "*** And there doesn't seem to be a static archive available"
6820
			  echo "*** The link will probably fail, sorry"
6821
			else
6822
			  add="$dir/$old_library"
6823
			fi
6824
		      elif test -n "$old_library"; then
6825
			add="$dir/$old_library"
6826
		      fi
6827
		    fi
6828
		esac
6829
	      elif test "$hardcode_minus_L" = no; then
6830
		case $host in
6831
		*-*-sunos*) add_shlibpath="$dir" ;;
6832
		esac
6833
		add_dir="-L$dir"
6834
		add="-l$name"
6835
	      elif test "$hardcode_shlibpath_var" = no; then
6836
		add_shlibpath="$dir"
6837
		add="-l$name"
6838
	      else
6839
		lib_linked=no
6840
	      fi
6841
	      ;;
6842
	    relink)
6843
	      if test "$hardcode_direct" = yes &&
6844
	         test "$hardcode_direct_absolute" = no; then
6845
		add="$dir/$linklib"
6846
	      elif test "$hardcode_minus_L" = yes; then
6847
		add_dir="-L$absdir"
6848
		# Try looking first in the location we're being installed to.
6849
		if test -n "$inst_prefix_dir"; then
6850
		  case $libdir in
6851
		    [\\/]*)
6852
		      func_append add_dir " -L$inst_prefix_dir$libdir"
6853
		      ;;
6854
		  esac
6855
		fi
6856
		add="-l$name"
6857
	      elif test "$hardcode_shlibpath_var" = yes; then
6858
		add_shlibpath="$dir"
6859
		add="-l$name"
6860
	      else
6861
		lib_linked=no
6862
	      fi
6863
	      ;;
6864
	    *) lib_linked=no ;;
6865
	    esac
6866
6867
	    if test "$lib_linked" != yes; then
6868
	      func_fatal_configuration "unsupported hardcode properties"
6869
	    fi
6870
6871
	    if test -n "$add_shlibpath"; then
6872
	      case :$compile_shlibpath: in
6873
	      *":$add_shlibpath:"*) ;;
6874
	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6875
	      esac
6876
	    fi
6877
	    if test "$linkmode" = prog; then
6878
	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6879
	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6880
	    else
6881
	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6882
	      test -n "$add" && deplibs="$add $deplibs"
6883
	      if test "$hardcode_direct" != yes &&
6884
		 test "$hardcode_minus_L" != yes &&
6885
		 test "$hardcode_shlibpath_var" = yes; then
6886
		case :$finalize_shlibpath: in
6887
		*":$libdir:"*) ;;
6888
		*) func_append finalize_shlibpath "$libdir:" ;;
6889
		esac
6890
	      fi
6891
	    fi
6892
	  fi
6893
6894
	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6895
	    add_shlibpath=
6896
	    add_dir=
6897
	    add=
6898
	    # Finalize command for both is simple: just hardcode it.
6899
	    if test "$hardcode_direct" = yes &&
6900
	       test "$hardcode_direct_absolute" = no; then
6901
	      add="$libdir/$linklib"
6902
	    elif test "$hardcode_minus_L" = yes; then
6903
	      add_dir="-L$libdir"
6904
	      add="-l$name"
6905
	    elif test "$hardcode_shlibpath_var" = yes; then
6906
	      case :$finalize_shlibpath: in
6907
	      *":$libdir:"*) ;;
6908
	      *) func_append finalize_shlibpath "$libdir:" ;;
6909
	      esac
6910
	      add="-l$name"
6911
	    elif test "$hardcode_automatic" = yes; then
6912
	      if test -n "$inst_prefix_dir" &&
6913
		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6914
		add="$inst_prefix_dir$libdir/$linklib"
6915
	      else
6916
		add="$libdir/$linklib"
6917
	      fi
6918
	    else
6919
	      # We cannot seem to hardcode it, guess we'll fake it.
6920
	      add_dir="-L$libdir"
6921
	      # Try looking first in the location we're being installed to.
6922
	      if test -n "$inst_prefix_dir"; then
6923
		case $libdir in
6924
		  [\\/]*)
6925
		    func_append add_dir " -L$inst_prefix_dir$libdir"
6926
		    ;;
6927
		esac
6928
	      fi
6929
	      add="-l$name"
6930
	    fi
6931
6932
	    if test "$linkmode" = prog; then
6933
	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6934
	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6935
	    else
6936
	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6937
	      test -n "$add" && deplibs="$add $deplibs"
6938
	    fi
6939
	  fi
6940
	elif test "$linkmode" = prog; then
6941
	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6942
	  # is not unsupported.  This is valid on all known static and
6943
	  # shared platforms.
6944
	  if test "$hardcode_direct" != unsupported; then
6945
	    test -n "$old_library" && linklib="$old_library"
6946
	    compile_deplibs="$dir/$linklib $compile_deplibs"
6947
	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6948
	  else
6949
	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6950
	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6951
	  fi
6952
	elif test "$build_libtool_libs" = yes; then
6953
	  # Not a shared library
6954
	  if test "$deplibs_check_method" != pass_all; then
6955
	    # We're trying link a shared library against a static one
6956
	    # but the system doesn't support it.
6957
6958
	    # Just print a warning and add the library to dependency_libs so
6959
	    # that the program can be linked against the static library.
6960
	    echo
6961
	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
6962
	    echo "*** I have the capability to make that library automatically link in when"
6963
	    echo "*** you link to this library.  But I can only do this if you have a"
6964
	    echo "*** shared version of the library, which you do not appear to have."
6965
	    if test "$module" = yes; then
6966
	      echo "*** But as you try to build a module library, libtool will still create "
6967
	      echo "*** a static module, that should work as long as the dlopening application"
6968
	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6969
	      if test -z "$global_symbol_pipe"; then
6970
		echo
6971
		echo "*** However, this would only work if libtool was able to extract symbol"
6972
		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6973
		echo "*** not find such a program.  So, this module is probably useless."
6974
		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6975
	      fi
6976
	      if test "$build_old_libs" = no; then
6977
		build_libtool_libs=module
6978
		build_old_libs=yes
6979
	      else
6980
		build_libtool_libs=no
6981
	      fi
6982
	    fi
6983
	  else
6984
	    deplibs="$dir/$old_library $deplibs"
6985
	    link_static=yes
6986
	  fi
6987
	fi # link shared/static library?
6988
6989
	if test "$linkmode" = lib; then
6990
	  if test -n "$dependency_libs" &&
6991
	     { test "$hardcode_into_libs" != yes ||
6992
	       test "$build_old_libs" = yes ||
6993
	       test "$link_static" = yes; }; then
6994
	    # Extract -R from dependency_libs
6995
	    temp_deplibs=
6996
	    for libdir in $dependency_libs; do
6997
	      case $libdir in
6998
	      -R*) func_stripname '-R' '' "$libdir"
6999
	           temp_xrpath=$func_stripname_result
7000
		   case " $xrpath " in
7001
		   *" $temp_xrpath "*) ;;
7002
		   *) func_append xrpath " $temp_xrpath";;
7003
		   esac;;
7004
	      *) func_append temp_deplibs " $libdir";;
7005
	      esac
7006
	    done
7007
	    dependency_libs="$temp_deplibs"
7008
	  fi
7009
7010
	  func_append newlib_search_path " $absdir"
7011
	  # Link against this library
7012
	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7013
	  # ... and its dependency_libs
7014
	  tmp_libs=
7015
	  for deplib in $dependency_libs; do
7016
	    newdependency_libs="$deplib $newdependency_libs"
7017
	    case $deplib in
7018
              -L*) func_stripname '-L' '' "$deplib"
7019
                   func_resolve_sysroot "$func_stripname_result";;
7020
              *) func_resolve_sysroot "$deplib" ;;
7021
            esac
7022
	    if $opt_preserve_dup_deps ; then
7023
	      case "$tmp_libs " in
7024
	      *" $func_resolve_sysroot_result "*)
7025
                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7026
	      esac
7027
	    fi
7028
	    func_append tmp_libs " $func_resolve_sysroot_result"
7029
	  done
7030
7031
	  if test "$link_all_deplibs" != no; then
7032
	    # Add the search paths of all dependency libraries
7033
	    for deplib in $dependency_libs; do
7034
	      path=
7035
	      case $deplib in
7036
	      -L*) path="$deplib" ;;
7037
	      *.la)
7038
	        func_resolve_sysroot "$deplib"
7039
	        deplib=$func_resolve_sysroot_result
7040
	        func_dirname "$deplib" "" "."
7041
		dir=$func_dirname_result
7042
		# We need an absolute path.
7043
		case $dir in
7044
		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7045
		*)
7046
		  absdir=`cd "$dir" && pwd`
7047
		  if test -z "$absdir"; then
7048
		    func_warning "cannot determine absolute directory name of \`$dir'"
7049
		    absdir="$dir"
7050
		  fi
7051
		  ;;
7052
		esac
7053
		if $GREP "^installed=no" $deplib > /dev/null; then
7054
		case $host in
7055
		*-*-darwin*)
7056
		  depdepl=
7057
		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7058
		  if test -n "$deplibrary_names" ; then
7059
		    for tmp in $deplibrary_names ; do
7060
		      depdepl=$tmp
7061
		    done
7062
		    if test -f "$absdir/$objdir/$depdepl" ; then
7063
		      depdepl="$absdir/$objdir/$depdepl"
7064
		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7065
                      if test -z "$darwin_install_name"; then
7066
                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7067
                      fi
7068
		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7069
		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7070
		      path=
7071
		    fi
7072
		  fi
7073
		  ;;
7074
		*)
7075
		  path="-L$absdir/$objdir"
7076
		  ;;
7077
		esac
7078
		else
7079
		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7080
		  test -z "$libdir" && \
7081
		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7082
		  test "$absdir" != "$libdir" && \
7083
		    func_warning "\`$deplib' seems to be moved"
7084
7085
		  path="-L$absdir"
7086
		fi
7087
		;;
7088
	      esac
7089
	      case " $deplibs " in
7090
	      *" $path "*) ;;
7091
	      *) deplibs="$path $deplibs" ;;
7092
	      esac
7093
	    done
7094
	  fi # link_all_deplibs != no
7095
	fi # linkmode = lib
7096
      done # for deplib in $libs
7097
      if test "$pass" = link; then
7098
	if test "$linkmode" = "prog"; then
7099
	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7100
	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7101
	else
7102
	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7103
	fi
7104
      fi
7105
      dependency_libs="$newdependency_libs"
7106
      if test "$pass" = dlpreopen; then
7107
	# Link the dlpreopened libraries before other libraries
7108
	for deplib in $save_deplibs; do
7109
	  deplibs="$deplib $deplibs"
7110
	done
7111
      fi
7112
      if test "$pass" != dlopen; then
7113
	if test "$pass" != conv; then
7114
	  # Make sure lib_search_path contains only unique directories.
7115
	  lib_search_path=
7116
	  for dir in $newlib_search_path; do
7117
	    case "$lib_search_path " in
7118
	    *" $dir "*) ;;
7119
	    *) func_append lib_search_path " $dir" ;;
7120
	    esac
7121
	  done
7122
	  newlib_search_path=
7123
	fi
7124
7125
	if test "$linkmode,$pass" != "prog,link"; then
7126
	  vars="deplibs"
7127
	else
7128
	  vars="compile_deplibs finalize_deplibs"
7129
	fi
7130
	for var in $vars dependency_libs; do
7131
	  # Add libraries to $var in reverse order
7132
	  eval tmp_libs=\"\$$var\"
7133
	  new_libs=
7134
	  for deplib in $tmp_libs; do
7135
	    # FIXME: Pedantically, this is the right thing to do, so
7136
	    #        that some nasty dependency loop isn't accidentally
7137
	    #        broken:
7138
	    #new_libs="$deplib $new_libs"
7139
	    # Pragmatically, this seems to cause very few problems in
7140
	    # practice:
7141
	    case $deplib in
7142
	    -L*) new_libs="$deplib $new_libs" ;;
7143
	    -R*) ;;
7144
	    *)
7145
	      # And here is the reason: when a library appears more
7146
	      # than once as an explicit dependence of a library, or
7147
	      # is implicitly linked in more than once by the
7148
	      # compiler, it is considered special, and multiple
7149
	      # occurrences thereof are not removed.  Compare this
7150
	      # with having the same library being listed as a
7151
	      # dependency of multiple other libraries: in this case,
7152
	      # we know (pedantically, we assume) the library does not
7153
	      # need to be listed more than once, so we keep only the
7154
	      # last copy.  This is not always right, but it is rare
7155
	      # enough that we require users that really mean to play
7156
	      # such unportable linking tricks to link the library
7157
	      # using -Wl,-lname, so that libtool does not consider it
7158
	      # for duplicate removal.
7159
	      case " $specialdeplibs " in
7160
	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7161
	      *)
7162
		case " $new_libs " in
7163
		*" $deplib "*) ;;
7164
		*) new_libs="$deplib $new_libs" ;;
7165
		esac
7166
		;;
7167
	      esac
7168
	      ;;
7169
	    esac
7170
	  done
7171
	  tmp_libs=
7172
	  for deplib in $new_libs; do
7173
	    case $deplib in
7174
	    -L*)
7175
	      case " $tmp_libs " in
7176
	      *" $deplib "*) ;;
7177
	      *) func_append tmp_libs " $deplib" ;;
7178
	      esac
7179
	      ;;
7180
	    *) func_append tmp_libs " $deplib" ;;
7181
	    esac
7182
	  done
7183
	  eval $var=\"$tmp_libs\"
7184
	done # for var
7185
      fi
7186
      # Last step: remove runtime libs from dependency_libs
7187
      # (they stay in deplibs)
7188
      tmp_libs=
7189
      for i in $dependency_libs ; do
7190
	case " $predeps $postdeps $compiler_lib_search_path " in
7191
	*" $i "*)
7192
	  i=""
7193
	  ;;
7194
	esac
7195
	if test -n "$i" ; then
7196
	  func_append tmp_libs " $i"
7197
	fi
7198
      done
7199
      dependency_libs=$tmp_libs
7200
    done # for pass
7201
    if test "$linkmode" = prog; then
7202
      dlfiles="$newdlfiles"
7203
    fi
7204
    if test "$linkmode" = prog || test "$linkmode" = lib; then
7205
      dlprefiles="$newdlprefiles"
7206
    fi
7207
7208
    case $linkmode in
7209
    oldlib)
7210
      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7211
	func_warning "\`-dlopen' is ignored for archives"
7212
      fi
7213
7214
      case " $deplibs" in
7215
      *\ -l* | *\ -L*)
7216
	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7217
      esac
7218
7219
      test -n "$rpath" && \
7220
	func_warning "\`-rpath' is ignored for archives"
7221
7222
      test -n "$xrpath" && \
7223
	func_warning "\`-R' is ignored for archives"
7224
7225
      test -n "$vinfo" && \
7226
	func_warning "\`-version-info/-version-number' is ignored for archives"
7227
7228
      test -n "$release" && \
7229
	func_warning "\`-release' is ignored for archives"
7230
7231
      test -n "$export_symbols$export_symbols_regex" && \
7232
	func_warning "\`-export-symbols' is ignored for archives"
7233
7234
      # Now set the variables for building old libraries.
7235
      build_libtool_libs=no
7236
      oldlibs="$output"
7237
      func_append objs "$old_deplibs"
7238
      ;;
7239
7240
    lib)
7241
      # Make sure we only generate libraries of the form `libNAME.la'.
7242
      case $outputname in
7243
      lib*)
7244
	func_stripname 'lib' '.la' "$outputname"
7245
	name=$func_stripname_result
7246
	eval shared_ext=\"$shrext_cmds\"
7247
	eval libname=\"$libname_spec\"
7248
	;;
7249
      *)
7250
	test "$module" = no && \
7251
	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7252
7253
	if test "$need_lib_prefix" != no; then
7254
	  # Add the "lib" prefix for modules if required
7255
	  func_stripname '' '.la' "$outputname"
7256
	  name=$func_stripname_result
7257
	  eval shared_ext=\"$shrext_cmds\"
7258
	  eval libname=\"$libname_spec\"
7259
	else
7260
	  func_stripname '' '.la' "$outputname"
7261
	  libname=$func_stripname_result
7262
	fi
7263
	;;
7264
      esac
7265
7266
      if test -n "$objs"; then
7267
	if test "$deplibs_check_method" != pass_all; then
7268
	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7269
	else
7270
	  echo
7271
	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7272
	  $ECHO "*** objects $objs is not portable!"
7273
	  func_append libobjs " $objs"
7274
	fi
7275
      fi
7276
7277
      test "$dlself" != no && \
7278
	func_warning "\`-dlopen self' is ignored for libtool libraries"
7279
7280
      set dummy $rpath
7281
      shift
7282
      test "$#" -gt 1 && \
7283
	func_warning "ignoring multiple \`-rpath's for a libtool library"
7284
7285
      install_libdir="$1"
7286
7287
      oldlibs=
7288
      if test -z "$rpath"; then
7289
	if test "$build_libtool_libs" = yes; then
7290
	  # Building a libtool convenience library.
7291
	  # Some compilers have problems with a `.al' extension so
7292
	  # convenience libraries should have the same extension an
7293
	  # archive normally would.
7294
	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7295
	  build_libtool_libs=convenience
7296
	  build_old_libs=yes
7297
	fi
7298
7299
	test -n "$vinfo" && \
7300
	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7301
7302
	test -n "$release" && \
7303
	  func_warning "\`-release' is ignored for convenience libraries"
7304
      else
7305
7306
	# Parse the version information argument.
7307
	save_ifs="$IFS"; IFS=':'
7308
	set dummy $vinfo 0 0 0
7309
	shift
7310
	IFS="$save_ifs"
7311
7312
	test -n "$7" && \
7313
	  func_fatal_help "too many parameters to \`-version-info'"
7314
7315
	# convert absolute version numbers to libtool ages
7316
	# this retains compatibility with .la files and attempts
7317
	# to make the code below a bit more comprehensible
7318
7319
	case $vinfo_number in
7320
	yes)
7321
	  number_major="$1"
7322
	  number_minor="$2"
7323
	  number_revision="$3"
7324
	  #
7325
	  # There are really only two kinds -- those that
7326
	  # use the current revision as the major version
7327
	  # and those that subtract age and use age as
7328
	  # a minor version.  But, then there is irix
7329
	  # which has an extra 1 added just for fun
7330
	  #
7331
	  case $version_type in
7332
	  # correct linux to gnu/linux during the next big refactor
7333
	  darwin|linux|osf|windows|none)
7334
	    func_arith $number_major + $number_minor
7335
	    current=$func_arith_result
7336
	    age="$number_minor"
7337
	    revision="$number_revision"
7338
	    ;;
7339
	  freebsd-aout|freebsd-elf|qnx|sunos)
7340
	    current="$number_major"
7341
	    revision="$number_minor"
7342
	    age="0"
7343
	    ;;
7344
	  irix|nonstopux)
7345
	    func_arith $number_major + $number_minor
7346
	    current=$func_arith_result
7347
	    age="$number_minor"
7348
	    revision="$number_minor"
7349
	    lt_irix_increment=no
7350
	    ;;
7351
	  esac
7352
	  ;;
7353
	no)
7354
	  current="$1"
7355
	  revision="$2"
7356
	  age="$3"
7357
	  ;;
7358
	esac
7359
7360
	# Check that each of the things are valid numbers.
7361
	case $current in
7362
	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
7363
	*)
7364
	  func_error "CURRENT \`$current' must be a nonnegative integer"
7365
	  func_fatal_error "\`$vinfo' is not valid version information"
7366
	  ;;
7367
	esac
7368
7369
	case $revision in
7370
	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
7371
	*)
7372
	  func_error "REVISION \`$revision' must be a nonnegative integer"
7373
	  func_fatal_error "\`$vinfo' is not valid version information"
7374
	  ;;
7375
	esac
7376
7377
	case $age in
7378
	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
7379
	*)
7380
	  func_error "AGE \`$age' must be a nonnegative integer"
7381
	  func_fatal_error "\`$vinfo' is not valid version information"
7382
	  ;;
7383
	esac
7384
7385
	if test "$age" -gt "$current"; then
7386
	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7387
	  func_fatal_error "\`$vinfo' is not valid version information"
7388
	fi
7389
7390
	# Calculate the version variables.
7391
	major=
7392
	versuffix=
7393
	verstring=
7394
	case $version_type in
7395
	none) ;;
7396
7397
	darwin)
7398
	  # Like Linux, but with the current version available in
7399
	  # verstring for coding it into the library header
7400
	  func_arith $current - $age
7401
	  major=.$func_arith_result
7402
	  versuffix="$major.$age.$revision"
7403
	  # Darwin ld doesn't like 0 for these options...
7404
	  func_arith $current + 1
7405
	  minor_current=$func_arith_result
7406
	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7407
	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7408
	  ;;
7409
7410
	freebsd-aout)
7411
	  major=".$current"
7412
	  versuffix=".$current.$revision";
7413
	  ;;
7414
7415
	freebsd-elf)
7416
	  major=".$current"
7417
	  versuffix=".$current"
7418
	  ;;
7419
7420
	irix | nonstopux)
7421
	  if test "X$lt_irix_increment" = "Xno"; then
7422
	    func_arith $current - $age
7423
	  else
7424
	    func_arith $current - $age + 1
7425
	  fi
7426
	  major=$func_arith_result
7427
7428
	  case $version_type in
7429
	    nonstopux) verstring_prefix=nonstopux ;;
7430
	    *)         verstring_prefix=sgi ;;
7431
	  esac
7432
	  verstring="$verstring_prefix$major.$revision"
7433
7434
	  # Add in all the interfaces that we are compatible with.
7435
	  loop=$revision
7436
	  while test "$loop" -ne 0; do
7437
	    func_arith $revision - $loop
7438
	    iface=$func_arith_result
7439
	    func_arith $loop - 1
7440
	    loop=$func_arith_result
7441
	    verstring="$verstring_prefix$major.$iface:$verstring"
7442
	  done
7443
7444
	  # Before this point, $major must not contain `.'.
7445
	  major=.$major
7446
	  versuffix="$major.$revision"
7447
	  ;;
7448
7449
	linux) # correct to gnu/linux during the next big refactor
7450
	  func_arith $current - $age
7451
	  major=.$func_arith_result
7452
	  versuffix="$major.$age.$revision"
7453
	  ;;
7454
7455
	osf)
7456
	  func_arith $current - $age
7457
	  major=.$func_arith_result
7458
	  versuffix=".$current.$age.$revision"
7459
	  verstring="$current.$age.$revision"
7460
7461
	  # Add in all the interfaces that we are compatible with.
7462
	  loop=$age
7463
	  while test "$loop" -ne 0; do
7464
	    func_arith $current - $loop
7465
	    iface=$func_arith_result
7466
	    func_arith $loop - 1
7467
	    loop=$func_arith_result
7468
	    verstring="$verstring:${iface}.0"
7469
	  done
7470
7471
	  # Make executables depend on our current version.
7472
	  func_append verstring ":${current}.0"
7473
	  ;;
7474
7475
	qnx)
7476
	  major=".$current"
7477
	  versuffix=".$current"
7478
	  ;;
7479
7480
	sunos)
7481
	  major=".$current"
7482
	  versuffix=".$current.$revision"
7483
	  ;;
7484
7485
	windows)
7486
	  # Use '-' rather than '.', since we only want one
7487
	  # extension on DOS 8.3 filesystems.
7488
	  func_arith $current - $age
7489
	  major=$func_arith_result
7490
	  versuffix="-$major"
7491
	  ;;
7492
7493
	*)
7494
	  func_fatal_configuration "unknown library version type \`$version_type'"
7495
	  ;;
7496
	esac
7497
7498
	# Clear the version info if we defaulted, and they specified a release.
7499
	if test -z "$vinfo" && test -n "$release"; then
7500
	  major=
7501
	  case $version_type in
7502
	  darwin)
7503
	    # we can't check for "0.0" in archive_cmds due to quoting
7504
	    # problems, so we reset it completely
7505
	    verstring=
7506
	    ;;
7507
	  *)
7508
	    verstring="0.0"
7509
	    ;;
7510
	  esac
7511
	  if test "$need_version" = no; then
7512
	    versuffix=
7513
	  else
7514
	    versuffix=".0.0"
7515
	  fi
7516
	fi
7517
7518
	# Remove version info from name if versioning should be avoided
7519
	if test "$avoid_version" = yes && test "$need_version" = no; then
7520
	  major=
7521
	  versuffix=
7522
	  verstring=""
7523
	fi
7524
7525
	# Check to see if the archive will have undefined symbols.
7526
	if test "$allow_undefined" = yes; then
7527
	  if test "$allow_undefined_flag" = unsupported; then
7528
	    func_warning "undefined symbols not allowed in $host shared libraries"
7529
	    build_libtool_libs=no
7530
	    build_old_libs=yes
7531
	  fi
7532
	else
7533
	  # Don't allow undefined symbols.
7534
	  allow_undefined_flag="$no_undefined_flag"
7535
	fi
7536
7537
      fi
7538
7539
      func_generate_dlsyms "$libname" "$libname" "yes"
7540
      func_append libobjs " $symfileobj"
7541
      test "X$libobjs" = "X " && libobjs=
7542
7543
      if test "$opt_mode" != relink; then
7544
	# Remove our outputs, but don't remove object files since they
7545
	# may have been created when compiling PIC objects.
7546
	removelist=
7547
	tempremovelist=`$ECHO "$output_objdir/*"`
7548
	for p in $tempremovelist; do
7549
	  case $p in
7550
	    *.$objext | *.gcno)
7551
	       ;;
7552
	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7553
	       if test "X$precious_files_regex" != "X"; then
7554
		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7555
		 then
7556
		   continue
7557
		 fi
7558
	       fi
7559
	       func_append removelist " $p"
7560
	       ;;
7561
	    *) ;;
7562
	  esac
7563
	done
7564
	test -n "$removelist" && \
7565
	  func_show_eval "${RM}r \$removelist"
7566
      fi
7567
7568
      # Now set the variables for building old libraries.
7569
      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7570
	func_append oldlibs " $output_objdir/$libname.$libext"
7571
7572
	# Transform .lo files to .o files.
7573
	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7574
      fi
7575
7576
      # Eliminate all temporary directories.
7577
      #for path in $notinst_path; do
7578
      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7579
      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7580
      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7581
      #done
7582
7583
      if test -n "$xrpath"; then
7584
	# If the user specified any rpath flags, then add them.
7585
	temp_xrpath=
7586
	for libdir in $xrpath; do
7587
	  func_replace_sysroot "$libdir"
7588
	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7589
	  case "$finalize_rpath " in
7590
	  *" $libdir "*) ;;
7591
	  *) func_append finalize_rpath " $libdir" ;;
7592
	  esac
7593
	done
7594
	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7595
	  dependency_libs="$temp_xrpath $dependency_libs"
7596
	fi
7597
      fi
7598
7599
      # Make sure dlfiles contains only unique files that won't be dlpreopened
7600
      old_dlfiles="$dlfiles"
7601
      dlfiles=
7602
      for lib in $old_dlfiles; do
7603
	case " $dlprefiles $dlfiles " in
7604
	*" $lib "*) ;;
7605
	*) func_append dlfiles " $lib" ;;
7606
	esac
7607
      done
7608
7609
      # Make sure dlprefiles contains only unique files
7610
      old_dlprefiles="$dlprefiles"
7611
      dlprefiles=
7612
      for lib in $old_dlprefiles; do
7613
	case "$dlprefiles " in
7614
	*" $lib "*) ;;
7615
	*) func_append dlprefiles " $lib" ;;
7616
	esac
7617
      done
7618
7619
      if test "$build_libtool_libs" = yes; then
7620
	if test -n "$rpath"; then
7621
	  case $host in
7622
	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7623
	    # these systems don't actually have a c library (as such)!
7624
	    ;;
7625
	  *-*-rhapsody* | *-*-darwin1.[012])
7626
	    # Rhapsody C library is in the System framework
7627
	    func_append deplibs " System.ltframework"
7628
	    ;;
7629
	  *-*-netbsd*)
7630
	    # Don't link with libc until the a.out ld.so is fixed.
7631
	    ;;
7632
	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7633
	    # Do not include libc due to us having libc/libc_r.
7634
	    ;;
7635
	  *-*-sco3.2v5* | *-*-sco5v6*)
7636
	    # Causes problems with __ctype
7637
	    ;;
7638
	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7639
	    # Compiler inserts libc in the correct place for threads to work
7640
	    ;;
7641
	  *)
7642
	    # Add libc to deplibs on all other systems if necessary.
7643
	    if test "$build_libtool_need_lc" = "yes"; then
7644
	      func_append deplibs " -lc"
7645
	    fi
7646
	    ;;
7647
	  esac
7648
	fi
7649
7650
	# Transform deplibs into only deplibs that can be linked in shared.
7651
	name_save=$name
7652
	libname_save=$libname
7653
	release_save=$release
7654
	versuffix_save=$versuffix
7655
	major_save=$major
7656
	# I'm not sure if I'm treating the release correctly.  I think
7657
	# release should show up in the -l (ie -lgmp5) so we don't want to
7658
	# add it in twice.  Is that correct?
7659
	release=""
7660
	versuffix=""
7661
	major=""
7662
	newdeplibs=
7663
	droppeddeps=no
7664
	case $deplibs_check_method in
7665
	pass_all)
7666
	  # Don't check for shared/static.  Everything works.
7667
	  # This might be a little naive.  We might want to check
7668
	  # whether the library exists or not.  But this is on
7669
	  # osf3 & osf4 and I'm not really sure... Just
7670
	  # implementing what was already the behavior.
7671
	  newdeplibs=$deplibs
7672
	  ;;
7673
	test_compile)
7674
	  # This code stresses the "libraries are programs" paradigm to its
7675
	  # limits. Maybe even breaks it.  We compile a program, linking it
7676
	  # against the deplibs as a proxy for the library.  Then we can check
7677
	  # whether they linked in statically or dynamically with ldd.
7678
	  $opt_dry_run || $RM conftest.c
7679
	  cat > conftest.c <<EOF
7680
	  int main() { return 0; }
7681
EOF
7682
	  $opt_dry_run || $RM conftest
7683
	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7684
	    ldd_output=`ldd conftest`
7685
	    for i in $deplibs; do
7686
	      case $i in
7687
	      -l*)
7688
		func_stripname -l '' "$i"
7689
		name=$func_stripname_result
7690
		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7691
		  case " $predeps $postdeps " in
7692
		  *" $i "*)
7693
		    func_append newdeplibs " $i"
7694
		    i=""
7695
		    ;;
7696
		  esac
7697
		fi
7698
		if test -n "$i" ; then
7699
		  libname=`eval "\\$ECHO \"$libname_spec\""`
7700
		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7701
		  set dummy $deplib_matches; shift
7702
		  deplib_match=$1
7703
		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7704
		    func_append newdeplibs " $i"
7705
		  else
7706
		    droppeddeps=yes
7707
		    echo
7708
		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7709
		    echo "*** I have the capability to make that library automatically link in when"
7710
		    echo "*** you link to this library.  But I can only do this if you have a"
7711
		    echo "*** shared version of the library, which I believe you do not have"
7712
		    echo "*** because a test_compile did reveal that the linker did not use it for"
7713
		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7714
		  fi
7715
		fi
7716
		;;
7717
	      *)
7718
		func_append newdeplibs " $i"
7719
		;;
7720
	      esac
7721
	    done
7722
	  else
7723
	    # Error occurred in the first compile.  Let's try to salvage
7724
	    # the situation: Compile a separate program for each library.
7725
	    for i in $deplibs; do
7726
	      case $i in
7727
	      -l*)
7728
		func_stripname -l '' "$i"
7729
		name=$func_stripname_result
7730
		$opt_dry_run || $RM conftest
7731
		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7732
		  ldd_output=`ldd conftest`
7733
		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7734
		    case " $predeps $postdeps " in
7735
		    *" $i "*)
7736
		      func_append newdeplibs " $i"
7737
		      i=""
7738
		      ;;
7739
		    esac
7740
		  fi
7741
		  if test -n "$i" ; then
7742
		    libname=`eval "\\$ECHO \"$libname_spec\""`
7743
		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7744
		    set dummy $deplib_matches; shift
7745
		    deplib_match=$1
7746
		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7747
		      func_append newdeplibs " $i"
7748
		    else
7749
		      droppeddeps=yes
7750
		      echo
7751
		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7752
		      echo "*** I have the capability to make that library automatically link in when"
7753
		      echo "*** you link to this library.  But I can only do this if you have a"
7754
		      echo "*** shared version of the library, which you do not appear to have"
7755
		      echo "*** because a test_compile did reveal that the linker did not use this one"
7756
		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7757
		    fi
7758
		  fi
7759
		else
7760
		  droppeddeps=yes
7761
		  echo
7762
		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
7763
		  echo "*** make it link in!  You will probably need to install it or some"
7764
		  echo "*** library that it depends on before this library will be fully"
7765
		  echo "*** functional.  Installing it before continuing would be even better."
7766
		fi
7767
		;;
7768
	      *)
7769
		func_append newdeplibs " $i"
7770
		;;
7771
	      esac
7772
	    done
7773
	  fi
7774
	  ;;
7775
	file_magic*)
7776
	  set dummy $deplibs_check_method; shift
7777
	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7778
	  for a_deplib in $deplibs; do
7779
	    case $a_deplib in
7780
	    -l*)
7781
	      func_stripname -l '' "$a_deplib"
7782
	      name=$func_stripname_result
7783
	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7784
		case " $predeps $postdeps " in
7785
		*" $a_deplib "*)
7786
		  func_append newdeplibs " $a_deplib"
7787
		  a_deplib=""
7788
		  ;;
7789
		esac
7790
	      fi
7791
	      if test -n "$a_deplib" ; then
7792
		libname=`eval "\\$ECHO \"$libname_spec\""`
7793
		if test -n "$file_magic_glob"; then
7794
		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7795
		else
7796
		  libnameglob=$libname
7797
		fi
7798
		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7799
		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7800
		  if test "$want_nocaseglob" = yes; then
7801
		    shopt -s nocaseglob
7802
		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7803
		    $nocaseglob
7804
		  else
7805
		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7806
		  fi
7807
		  for potent_lib in $potential_libs; do
7808
		      # Follow soft links.
7809
		      if ls -lLd "$potent_lib" 2>/dev/null |
7810
			 $GREP " -> " >/dev/null; then
7811
			continue
7812
		      fi
7813
		      # The statement above tries to avoid entering an
7814
		      # endless loop below, in case of cyclic links.
7815
		      # We might still enter an endless loop, since a link
7816
		      # loop can be closed while we follow links,
7817
		      # but so what?
7818
		      potlib="$potent_lib"
7819
		      while test -h "$potlib" 2>/dev/null; do
7820
			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7821
			case $potliblink in
7822
			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7823
			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7824
			esac
7825
		      done
7826
		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7827
			 $SED -e 10q |
7828
			 $EGREP "$file_magic_regex" > /dev/null; then
7829
			func_append newdeplibs " $a_deplib"
7830
			a_deplib=""
7831
			break 2
7832
		      fi
7833
		  done
7834
		done
7835
	      fi
7836
	      if test -n "$a_deplib" ; then
7837
		droppeddeps=yes
7838
		echo
7839
		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7840
		echo "*** I have the capability to make that library automatically link in when"
7841
		echo "*** you link to this library.  But I can only do this if you have a"
7842
		echo "*** shared version of the library, which you do not appear to have"
7843
		echo "*** because I did check the linker path looking for a file starting"
7844
		if test -z "$potlib" ; then
7845
		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7846
		else
7847
		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7848
		  $ECHO "*** using a file magic. Last file checked: $potlib"
7849
		fi
7850
	      fi
7851
	      ;;
7852
	    *)
7853
	      # Add a -L argument.
7854
	      func_append newdeplibs " $a_deplib"
7855
	      ;;
7856
	    esac
7857
	  done # Gone through all deplibs.
7858
	  ;;
7859
	match_pattern*)
7860
	  set dummy $deplibs_check_method; shift
7861
	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7862
	  for a_deplib in $deplibs; do
7863
	    case $a_deplib in
7864
	    -l*)
7865
	      func_stripname -l '' "$a_deplib"
7866
	      name=$func_stripname_result
7867
	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7868
		case " $predeps $postdeps " in
7869
		*" $a_deplib "*)
7870
		  func_append newdeplibs " $a_deplib"
7871
		  a_deplib=""
7872
		  ;;
7873
		esac
7874
	      fi
7875
	      if test -n "$a_deplib" ; then
7876
		libname=`eval "\\$ECHO \"$libname_spec\""`
7877
		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7878
		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7879
		  for potent_lib in $potential_libs; do
7880
		    potlib="$potent_lib" # see symlink-check above in file_magic test
7881
		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7882
		       $EGREP "$match_pattern_regex" > /dev/null; then
7883
		      func_append newdeplibs " $a_deplib"
7884
		      a_deplib=""
7885
		      break 2
7886
		    fi
7887
		  done
7888
		done
7889
	      fi
7890
	      if test -n "$a_deplib" ; then
7891
		droppeddeps=yes
7892
		echo
7893
		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7894
		echo "*** I have the capability to make that library automatically link in when"
7895
		echo "*** you link to this library.  But I can only do this if you have a"
7896
		echo "*** shared version of the library, which you do not appear to have"
7897
		echo "*** because I did check the linker path looking for a file starting"
7898
		if test -z "$potlib" ; then
7899
		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7900
		else
7901
		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7902
		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7903
		fi
7904
	      fi
7905
	      ;;
7906
	    *)
7907
	      # Add a -L argument.
7908
	      func_append newdeplibs " $a_deplib"
7909
	      ;;
7910
	    esac
7911
	  done # Gone through all deplibs.
7912
	  ;;
7913
	none | unknown | *)
7914
	  newdeplibs=""
7915
	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7916
	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7917
	    for i in $predeps $postdeps ; do
7918
	      # can't use Xsed below, because $i might contain '/'
7919
	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7920
	    done
7921
	  fi
7922
	  case $tmp_deplibs in
7923
	  *[!\	\ ]*)
7924
	    echo
7925
	    if test "X$deplibs_check_method" = "Xnone"; then
7926
	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7927
	    else
7928
	      echo "*** Warning: inter-library dependencies are not known to be supported."
7929
	    fi
7930
	    echo "*** All declared inter-library dependencies are being dropped."
7931
	    droppeddeps=yes
7932
	    ;;
7933
	  esac
7934
	  ;;
7935
	esac
7936
	versuffix=$versuffix_save
7937
	major=$major_save
7938
	release=$release_save
7939
	libname=$libname_save
7940
	name=$name_save
7941
7942
	case $host in
7943
	*-*-rhapsody* | *-*-darwin1.[012])
7944
	  # On Rhapsody replace the C library with the System framework
7945
	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7946
	  ;;
7947
	esac
7948
7949
	if test "$droppeddeps" = yes; then
7950
	  if test "$module" = yes; then
7951
	    echo
7952
	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7953
	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
7954
	    echo "*** a static module, that should work as long as the dlopening"
7955
	    echo "*** application is linked with the -dlopen flag."
7956
	    if test -z "$global_symbol_pipe"; then
7957
	      echo
7958
	      echo "*** However, this would only work if libtool was able to extract symbol"
7959
	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7960
	      echo "*** not find such a program.  So, this module is probably useless."
7961
	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7962
	    fi
7963
	    if test "$build_old_libs" = no; then
7964
	      oldlibs="$output_objdir/$libname.$libext"
7965
	      build_libtool_libs=module
7966
	      build_old_libs=yes
7967
	    else
7968
	      build_libtool_libs=no
7969
	    fi
7970
	  else
7971
	    echo "*** The inter-library dependencies that have been dropped here will be"
7972
	    echo "*** automatically added whenever a program is linked with this library"
7973
	    echo "*** or is declared to -dlopen it."
7974
7975
	    if test "$allow_undefined" = no; then
7976
	      echo
7977
	      echo "*** Since this library must not contain undefined symbols,"
7978
	      echo "*** because either the platform does not support them or"
7979
	      echo "*** it was explicitly requested with -no-undefined,"
7980
	      echo "*** libtool will only create a static version of it."
7981
	      if test "$build_old_libs" = no; then
7982
		oldlibs="$output_objdir/$libname.$libext"
7983
		build_libtool_libs=module
7984
		build_old_libs=yes
7985
	      else
7986
		build_libtool_libs=no
7987
	      fi
7988
	    fi
7989
	  fi
7990
	fi
7991
	# Done checking deplibs!
7992
	deplibs=$newdeplibs
7993
      fi
7994
      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7995
      case $host in
7996
	*-*-darwin*)
7997
	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7998
	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7999
	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8000
	  ;;
8001
      esac
8002
8003
      # move library search paths that coincide with paths to not yet
8004
      # installed libraries to the beginning of the library search list
8005
      new_libs=
8006
      for path in $notinst_path; do
8007
	case " $new_libs " in
8008
	*" -L$path/$objdir "*) ;;
8009
	*)
8010
	  case " $deplibs " in
8011
	  *" -L$path/$objdir "*)
8012
	    func_append new_libs " -L$path/$objdir" ;;
8013
	  esac
8014
	  ;;
8015
	esac
8016
      done
8017
      for deplib in $deplibs; do
8018
	case $deplib in
8019
	-L*)
8020
	  case " $new_libs " in
8021
	  *" $deplib "*) ;;
8022
	  *) func_append new_libs " $deplib" ;;
8023
	  esac
8024
	  ;;
8025
	*) func_append new_libs " $deplib" ;;
8026
	esac
8027
      done
8028
      deplibs="$new_libs"
8029
8030
      # All the library-specific variables (install_libdir is set above).
8031
      library_names=
8032
      old_library=
8033
      dlname=
8034
8035
      # Test again, we may have decided not to build it any more
8036
      if test "$build_libtool_libs" = yes; then
8037
	# Remove ${wl} instances when linking with ld.
8038
	# FIXME: should test the right _cmds variable.
8039
	case $archive_cmds in
8040
	  *\$LD\ *) wl= ;;
8041
        esac
8042
	if test "$hardcode_into_libs" = yes; then
8043
	  # Hardcode the library paths
8044
	  hardcode_libdirs=
8045
	  dep_rpath=
8046
	  rpath="$finalize_rpath"
8047
	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8048
	  for libdir in $rpath; do
8049
	    if test -n "$hardcode_libdir_flag_spec"; then
8050
	      if test -n "$hardcode_libdir_separator"; then
8051
		func_replace_sysroot "$libdir"
8052
		libdir=$func_replace_sysroot_result
8053
		if test -z "$hardcode_libdirs"; then
8054
		  hardcode_libdirs="$libdir"
8055
		else
8056
		  # Just accumulate the unique libdirs.
8057
		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8058
		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8059
		    ;;
8060
		  *)
8061
		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8062
		    ;;
8063
		  esac
8064
		fi
8065
	      else
8066
		eval flag=\"$hardcode_libdir_flag_spec\"
8067
		func_append dep_rpath " $flag"
8068
	      fi
8069
	    elif test -n "$runpath_var"; then
8070
	      case "$perm_rpath " in
8071
	      *" $libdir "*) ;;
8072
	      *) func_append perm_rpath " $libdir" ;;
8073
	      esac
8074
	    fi
8075
	  done
8076
	  # Substitute the hardcoded libdirs into the rpath.
8077
	  if test -n "$hardcode_libdir_separator" &&
8078
	     test -n "$hardcode_libdirs"; then
8079
	    libdir="$hardcode_libdirs"
8080
	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8081
	  fi
8082
	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8083
	    # We should set the runpath_var.
8084
	    rpath=
8085
	    for dir in $perm_rpath; do
8086
	      func_append rpath "$dir:"
8087
	    done
8088
	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8089
	  fi
8090
	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8091
	fi
8092
8093
	shlibpath="$finalize_shlibpath"
8094
	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8095
	if test -n "$shlibpath"; then
8096
	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8097
	fi
8098
8099
	# Get the real and link names of the library.
8100
	eval shared_ext=\"$shrext_cmds\"
8101
	eval library_names=\"$library_names_spec\"
8102
	set dummy $library_names
8103
	shift
8104
	realname="$1"
8105
	shift
8106
8107
	if test -n "$soname_spec"; then
8108
	  eval soname=\"$soname_spec\"
8109
	else
8110
	  soname="$realname"
8111
	fi
8112
	if test -z "$dlname"; then
8113
	  dlname=$soname
8114
	fi
8115
8116
	lib="$output_objdir/$realname"
8117
	linknames=
8118
	for link
8119
	do
8120
	  func_append linknames " $link"
8121
	done
8122
8123
	# Use standard objects if they are pic
8124
	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8125
	test "X$libobjs" = "X " && libobjs=
8126
8127
	delfiles=
8128
	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8129
	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8130
	  export_symbols="$output_objdir/$libname.uexp"
8131
	  func_append delfiles " $export_symbols"
8132
	fi
8133
8134
	orig_export_symbols=
8135
	case $host_os in
8136
	cygwin* | mingw* | cegcc*)
8137
	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8138
	    # exporting using user supplied symfile
8139
	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8140
	      # and it's NOT already a .def file. Must figure out
8141
	      # which of the given symbols are data symbols and tag
8142
	      # them as such. So, trigger use of export_symbols_cmds.
8143
	      # export_symbols gets reassigned inside the "prepare
8144
	      # the list of exported symbols" if statement, so the
8145
	      # include_expsyms logic still works.
8146
	      orig_export_symbols="$export_symbols"
8147
	      export_symbols=
8148
	      always_export_symbols=yes
8149
	    fi
8150
	  fi
8151
	  ;;
8152
	esac
8153
8154
	# Prepare the list of exported symbols
8155
	if test -z "$export_symbols"; then
8156
	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8157
	    func_verbose "generating symbol list for \`$libname.la'"
8158
	    export_symbols="$output_objdir/$libname.exp"
8159
	    $opt_dry_run || $RM $export_symbols
8160
	    cmds=$export_symbols_cmds
8161
	    save_ifs="$IFS"; IFS='~'
8162
	    for cmd1 in $cmds; do
8163
	      IFS="$save_ifs"
8164
	      # Take the normal branch if the nm_file_list_spec branch
8165
	      # doesn't work or if tool conversion is not needed.
8166
	      case $nm_file_list_spec~$to_tool_file_cmd in
8167
		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8168
		  try_normal_branch=yes
8169
		  eval cmd=\"$cmd1\"
8170
		  func_len " $cmd"
8171
		  len=$func_len_result
8172
		  ;;
8173
		*)
8174
		  try_normal_branch=no
8175
		  ;;
8176
	      esac
8177
	      if test "$try_normal_branch" = yes \
8178
		 && { test "$len" -lt "$max_cmd_len" \
8179
		      || test "$max_cmd_len" -le -1; }
8180
	      then
8181
		func_show_eval "$cmd" 'exit $?'
8182
		skipped_export=false
8183
	      elif test -n "$nm_file_list_spec"; then
8184
		func_basename "$output"
8185
		output_la=$func_basename_result
8186
		save_libobjs=$libobjs
8187
		save_output=$output
8188
		output=${output_objdir}/${output_la}.nm
8189
		func_to_tool_file "$output"
8190
		libobjs=$nm_file_list_spec$func_to_tool_file_result
8191
		func_append delfiles " $output"
8192
		func_verbose "creating $NM input file list: $output"
8193
		for obj in $save_libobjs; do
8194
		  func_to_tool_file "$obj"
8195
		  $ECHO "$func_to_tool_file_result"
8196
		done > "$output"
8197
		eval cmd=\"$cmd1\"
8198
		func_show_eval "$cmd" 'exit $?'
8199
		output=$save_output
8200
		libobjs=$save_libobjs
8201
		skipped_export=false
8202
	      else
8203
		# The command line is too long to execute in one step.
8204
		func_verbose "using reloadable object file for export list..."
8205
		skipped_export=:
8206
		# Break out early, otherwise skipped_export may be
8207
		# set to false by a later but shorter cmd.
8208
		break
8209
	      fi
8210
	    done
8211
	    IFS="$save_ifs"
8212
	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8213
	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8214
	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8215
	    fi
8216
	  fi
8217
	fi
8218
8219
	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8220
	  tmp_export_symbols="$export_symbols"
8221
	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8222
	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8223
	fi
8224
8225
	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8226
	  # The given exports_symbols file has to be filtered, so filter it.
8227
	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8228
	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8229
	  # 's' commands which not all seds can handle. GNU sed should be fine
8230
	  # though. Also, the filter scales superlinearly with the number of
8231
	  # global variables. join(1) would be nice here, but unfortunately
8232
	  # isn't a blessed tool.
8233
	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8234
	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8235
	  export_symbols=$output_objdir/$libname.def
8236
	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8237
	fi
8238
8239
	tmp_deplibs=
8240
	for test_deplib in $deplibs; do
8241
	  case " $convenience " in
8242
	  *" $test_deplib "*) ;;
8243
	  *)
8244
	    func_append tmp_deplibs " $test_deplib"
8245
	    ;;
8246
	  esac
8247
	done
8248
	deplibs="$tmp_deplibs"
8249
8250
	if test -n "$convenience"; then
8251
	  if test -n "$whole_archive_flag_spec" &&
8252
	    test "$compiler_needs_object" = yes &&
8253
	    test -z "$libobjs"; then
8254
	    # extract the archives, so we have objects to list.
8255
	    # TODO: could optimize this to just extract one archive.
8256
	    whole_archive_flag_spec=
8257
	  fi
8258
	  if test -n "$whole_archive_flag_spec"; then
8259
	    save_libobjs=$libobjs
8260
	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8261
	    test "X$libobjs" = "X " && libobjs=
8262
	  else
8263
	    gentop="$output_objdir/${outputname}x"
8264
	    func_append generated " $gentop"
8265
8266
	    func_extract_archives $gentop $convenience
8267
	    func_append libobjs " $func_extract_archives_result"
8268
	    test "X$libobjs" = "X " && libobjs=
8269
	  fi
8270
	fi
8271
8272
	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8273
	  eval flag=\"$thread_safe_flag_spec\"
8274
	  func_append linker_flags " $flag"
8275
	fi
8276
8277
	# Make a backup of the uninstalled library when relinking
8278
	if test "$opt_mode" = relink; then
8279
	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8280
	fi
8281
8282
	# Do each of the archive commands.
8283
	if test "$module" = yes && test -n "$module_cmds" ; then
8284
	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8285
	    eval test_cmds=\"$module_expsym_cmds\"
8286
	    cmds=$module_expsym_cmds
8287
	  else
8288
	    eval test_cmds=\"$module_cmds\"
8289
	    cmds=$module_cmds
8290
	  fi
8291
	else
8292
	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8293
	    eval test_cmds=\"$archive_expsym_cmds\"
8294
	    cmds=$archive_expsym_cmds
8295
	  else
8296
	    eval test_cmds=\"$archive_cmds\"
8297
	    cmds=$archive_cmds
8298
	  fi
8299
	fi
8300
8301
	if test "X$skipped_export" != "X:" &&
8302
	   func_len " $test_cmds" &&
8303
	   len=$func_len_result &&
8304
	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8305
	  :
8306
	else
8307
	  # The command line is too long to link in one step, link piecewise
8308
	  # or, if using GNU ld and skipped_export is not :, use a linker
8309
	  # script.
8310
8311
	  # Save the value of $output and $libobjs because we want to
8312
	  # use them later.  If we have whole_archive_flag_spec, we
8313
	  # want to use save_libobjs as it was before
8314
	  # whole_archive_flag_spec was expanded, because we can't
8315
	  # assume the linker understands whole_archive_flag_spec.
8316
	  # This may have to be revisited, in case too many
8317
	  # convenience libraries get linked in and end up exceeding
8318
	  # the spec.
8319
	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8320
	    save_libobjs=$libobjs
8321
	  fi
8322
	  save_output=$output
8323
	  func_basename "$output"
8324
	  output_la=$func_basename_result
8325
8326
	  # Clear the reloadable object creation command queue and
8327
	  # initialize k to one.
8328
	  test_cmds=
8329
	  concat_cmds=
8330
	  objlist=
8331
	  last_robj=
8332
	  k=1
8333
8334
	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8335
	    output=${output_objdir}/${output_la}.lnkscript
8336
	    func_verbose "creating GNU ld script: $output"
8337
	    echo 'INPUT (' > $output
8338
	    for obj in $save_libobjs
8339
	    do
8340
	      func_to_tool_file "$obj"
8341
	      $ECHO "$func_to_tool_file_result" >> $output
8342
	    done
8343
	    echo ')' >> $output
8344
	    func_append delfiles " $output"
8345
	    func_to_tool_file "$output"
8346
	    output=$func_to_tool_file_result
8347
	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8348
	    output=${output_objdir}/${output_la}.lnk
8349
	    func_verbose "creating linker input file list: $output"
8350
	    : > $output
8351
	    set x $save_libobjs
8352
	    shift
8353
	    firstobj=
8354
	    if test "$compiler_needs_object" = yes; then
8355
	      firstobj="$1 "
8356
	      shift
8357
	    fi
8358
	    for obj
8359
	    do
8360
	      func_to_tool_file "$obj"
8361
	      $ECHO "$func_to_tool_file_result" >> $output
8362
	    done
8363
	    func_append delfiles " $output"
8364
	    func_to_tool_file "$output"
8365
	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8366
	  else
8367
	    if test -n "$save_libobjs"; then
8368
	      func_verbose "creating reloadable object files..."
8369
	      output=$output_objdir/$output_la-${k}.$objext
8370
	      eval test_cmds=\"$reload_cmds\"
8371
	      func_len " $test_cmds"
8372
	      len0=$func_len_result
8373
	      len=$len0
8374
8375
	      # Loop over the list of objects to be linked.
8376
	      for obj in $save_libobjs
8377
	      do
8378
		func_len " $obj"
8379
		func_arith $len + $func_len_result
8380
		len=$func_arith_result
8381
		if test "X$objlist" = X ||
8382
		   test "$len" -lt "$max_cmd_len"; then
8383
		  func_append objlist " $obj"
8384
		else
8385
		  # The command $test_cmds is almost too long, add a
8386
		  # command to the queue.
8387
		  if test "$k" -eq 1 ; then
8388
		    # The first file doesn't have a previous command to add.
8389
		    reload_objs=$objlist
8390
		    eval concat_cmds=\"$reload_cmds\"
8391
		  else
8392
		    # All subsequent reloadable object files will link in
8393
		    # the last one created.
8394
		    reload_objs="$objlist $last_robj"
8395
		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8396
		  fi
8397
		  last_robj=$output_objdir/$output_la-${k}.$objext
8398
		  func_arith $k + 1
8399
		  k=$func_arith_result
8400
		  output=$output_objdir/$output_la-${k}.$objext
8401
		  objlist=" $obj"
8402
		  func_len " $last_robj"
8403
		  func_arith $len0 + $func_len_result
8404
		  len=$func_arith_result
8405
		fi
8406
	      done
8407
	      # Handle the remaining objects by creating one last
8408
	      # reloadable object file.  All subsequent reloadable object
8409
	      # files will link in the last one created.
8410
	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8411
	      reload_objs="$objlist $last_robj"
8412
	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8413
	      if test -n "$last_robj"; then
8414
	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8415
	      fi
8416
	      func_append delfiles " $output"
8417
8418
	    else
8419
	      output=
8420
	    fi
8421
8422
	    if ${skipped_export-false}; then
8423
	      func_verbose "generating symbol list for \`$libname.la'"
8424
	      export_symbols="$output_objdir/$libname.exp"
8425
	      $opt_dry_run || $RM $export_symbols
8426
	      libobjs=$output
8427
	      # Append the command to create the export file.
8428
	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8429
	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8430
	      if test -n "$last_robj"; then
8431
		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8432
	      fi
8433
	    fi
8434
8435
	    test -n "$save_libobjs" &&
8436
	      func_verbose "creating a temporary reloadable object file: $output"
8437
8438
	    # Loop through the commands generated above and execute them.
8439
	    save_ifs="$IFS"; IFS='~'
8440
	    for cmd in $concat_cmds; do
8441
	      IFS="$save_ifs"
8442
	      $opt_silent || {
8443
		  func_quote_for_expand "$cmd"
8444
		  eval "func_echo $func_quote_for_expand_result"
8445
	      }
8446
	      $opt_dry_run || eval "$cmd" || {
8447
		lt_exit=$?
8448
8449
		# Restore the uninstalled library and exit
8450
		if test "$opt_mode" = relink; then
8451
		  ( cd "$output_objdir" && \
8452
		    $RM "${realname}T" && \
8453
		    $MV "${realname}U" "$realname" )
8454
		fi
8455
8456
		exit $lt_exit
8457
	      }
8458
	    done
8459
	    IFS="$save_ifs"
8460
8461
	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8462
	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8463
	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8464
	    fi
8465
	  fi
8466
8467
          if ${skipped_export-false}; then
8468
	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8469
	      tmp_export_symbols="$export_symbols"
8470
	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8471
	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8472
	    fi
8473
8474
	    if test -n "$orig_export_symbols"; then
8475
	      # The given exports_symbols file has to be filtered, so filter it.
8476
	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8477
	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8478
	      # 's' commands which not all seds can handle. GNU sed should be fine
8479
	      # though. Also, the filter scales superlinearly with the number of
8480
	      # global variables. join(1) would be nice here, but unfortunately
8481
	      # isn't a blessed tool.
8482
	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8483
	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8484
	      export_symbols=$output_objdir/$libname.def
8485
	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8486
	    fi
8487
	  fi
8488
8489
	  libobjs=$output
8490
	  # Restore the value of output.
8491
	  output=$save_output
8492
8493
	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8494
	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8495
	    test "X$libobjs" = "X " && libobjs=
8496
	  fi
8497
	  # Expand the library linking commands again to reset the
8498
	  # value of $libobjs for piecewise linking.
8499
8500
	  # Do each of the archive commands.
8501
	  if test "$module" = yes && test -n "$module_cmds" ; then
8502
	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8503
	      cmds=$module_expsym_cmds
8504
	    else
8505
	      cmds=$module_cmds
8506
	    fi
8507
	  else
8508
	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8509
	      cmds=$archive_expsym_cmds
8510
	    else
8511
	      cmds=$archive_cmds
8512
	    fi
8513
	  fi
8514
	fi
8515
8516
	if test -n "$delfiles"; then
8517
	  # Append the command to remove temporary files to $cmds.
8518
	  eval cmds=\"\$cmds~\$RM $delfiles\"
8519
	fi
8520
8521
	# Add any objects from preloaded convenience libraries
8522
	if test -n "$dlprefiles"; then
8523
	  gentop="$output_objdir/${outputname}x"
8524
	  func_append generated " $gentop"
8525
8526
	  func_extract_archives $gentop $dlprefiles
8527
	  func_append libobjs " $func_extract_archives_result"
8528
	  test "X$libobjs" = "X " && libobjs=
8529
	fi
8530
8531
	save_ifs="$IFS"; IFS='~'
8532
	for cmd in $cmds; do
8533
	  IFS="$save_ifs"
8534
	  eval cmd=\"$cmd\"
8535
	  $opt_silent || {
8536
	    func_quote_for_expand "$cmd"
8537
	    eval "func_echo $func_quote_for_expand_result"
8538
	  }
8539
	  $opt_dry_run || eval "$cmd" || {
8540
	    lt_exit=$?
8541
8542
	    # Restore the uninstalled library and exit
8543
	    if test "$opt_mode" = relink; then
8544
	      ( cd "$output_objdir" && \
8545
	        $RM "${realname}T" && \
8546
		$MV "${realname}U" "$realname" )
8547
	    fi
8548
8549
	    exit $lt_exit
8550
	  }
8551
	done
8552
	IFS="$save_ifs"
8553
8554
	# Restore the uninstalled library and exit
8555
	if test "$opt_mode" = relink; then
8556
	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8557
8558
	  if test -n "$convenience"; then
8559
	    if test -z "$whole_archive_flag_spec"; then
8560
	      func_show_eval '${RM}r "$gentop"'
8561
	    fi
8562
	  fi
8563
8564
	  exit $EXIT_SUCCESS
8565
	fi
8566
8567
	# Create links to the real library.
8568
	for linkname in $linknames; do
8569
	  if test "$realname" != "$linkname"; then
8570
	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8571
	  fi
8572
	done
8573
8574
	# If -module or -export-dynamic was specified, set the dlname.
8575
	if test "$module" = yes || test "$export_dynamic" = yes; then
8576
	  # On all known operating systems, these are identical.
8577
	  dlname="$soname"
8578
	fi
8579
      fi
8580
      ;;
8581
8582
    obj)
8583
      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8584
	func_warning "\`-dlopen' is ignored for objects"
8585
      fi
8586
8587
      case " $deplibs" in
8588
      *\ -l* | *\ -L*)
8589
	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8590
      esac
8591
8592
      test -n "$rpath" && \
8593
	func_warning "\`-rpath' is ignored for objects"
8594
8595
      test -n "$xrpath" && \
8596
	func_warning "\`-R' is ignored for objects"
8597
8598
      test -n "$vinfo" && \
8599
	func_warning "\`-version-info' is ignored for objects"
8600
8601
      test -n "$release" && \
8602
	func_warning "\`-release' is ignored for objects"
8603
8604
      case $output in
8605
      *.lo)
8606
	test -n "$objs$old_deplibs" && \
8607
	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8608
8609
	libobj=$output
8610
	func_lo2o "$libobj"
8611
	obj=$func_lo2o_result
8612
	;;
8613
      *)
8614
	libobj=
8615
	obj="$output"
8616
	;;
8617
      esac
8618
8619
      # Delete the old objects.
8620
      $opt_dry_run || $RM $obj $libobj
8621
8622
      # Objects from convenience libraries.  This assumes
8623
      # single-version convenience libraries.  Whenever we create
8624
      # different ones for PIC/non-PIC, this we'll have to duplicate
8625
      # the extraction.
8626
      reload_conv_objs=
8627
      gentop=
8628
      # reload_cmds runs $LD directly, so let us get rid of
8629
      # -Wl from whole_archive_flag_spec and hope we can get by with
8630
      # turning comma into space..
8631
      wl=
8632
8633
      if test -n "$convenience"; then
8634
	if test -n "$whole_archive_flag_spec"; then
8635
	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8636
	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8637
	else
8638
	  gentop="$output_objdir/${obj}x"
8639
	  func_append generated " $gentop"
8640
8641
	  func_extract_archives $gentop $convenience
8642
	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8643
	fi
8644
      fi
8645
8646
      # If we're not building shared, we need to use non_pic_objs
8647
      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8648
8649
      # Create the old-style object.
8650
      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8651
8652
      output="$obj"
8653
      func_execute_cmds "$reload_cmds" 'exit $?'
8654
8655
      # Exit if we aren't doing a library object file.
8656
      if test -z "$libobj"; then
8657
	if test -n "$gentop"; then
8658
	  func_show_eval '${RM}r "$gentop"'
8659
	fi
8660
8661
	exit $EXIT_SUCCESS
8662
      fi
8663
8664
      if test "$build_libtool_libs" != yes; then
8665
	if test -n "$gentop"; then
8666
	  func_show_eval '${RM}r "$gentop"'
8667
	fi
8668
8669
	# Create an invalid libtool object if no PIC, so that we don't
8670
	# accidentally link it into a program.
8671
	# $show "echo timestamp > $libobj"
8672
	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8673
	exit $EXIT_SUCCESS
8674
      fi
8675
8676
      if test -n "$pic_flag" || test "$pic_mode" != default; then
8677
	# Only do commands if we really have different PIC objects.
8678
	reload_objs="$libobjs $reload_conv_objs"
8679
	output="$libobj"
8680
	func_execute_cmds "$reload_cmds" 'exit $?'
8681
      fi
8682
8683
      if test -n "$gentop"; then
8684
	func_show_eval '${RM}r "$gentop"'
8685
      fi
8686
8687
      exit $EXIT_SUCCESS
8688
      ;;
8689
8690
    prog)
8691
      case $host in
8692
	*cygwin*) func_stripname '' '.exe' "$output"
8693
	          output=$func_stripname_result.exe;;
8694
      esac
8695
      test -n "$vinfo" && \
8696
	func_warning "\`-version-info' is ignored for programs"
8697
8698
      test -n "$release" && \
8699
	func_warning "\`-release' is ignored for programs"
8700
8701
      test "$preload" = yes \
8702
        && test "$dlopen_support" = unknown \
8703
	&& test "$dlopen_self" = unknown \
8704
	&& test "$dlopen_self_static" = unknown && \
8705
	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8706
8707
      case $host in
8708
      *-*-rhapsody* | *-*-darwin1.[012])
8709
	# On Rhapsody replace the C library is the System framework
8710
	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8711
	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8712
	;;
8713
      esac
8714
8715
      case $host in
8716
      *-*-darwin*)
8717
	# Don't allow lazy linking, it breaks C++ global constructors
8718
	# But is supposedly fixed on 10.4 or later (yay!).
8719
	if test "$tagname" = CXX ; then
8720
	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8721
	    10.[0123])
8722
	      func_append compile_command " ${wl}-bind_at_load"
8723
	      func_append finalize_command " ${wl}-bind_at_load"
8724
	    ;;
8725
	  esac
8726
	fi
8727
	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
8728
	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8729
	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8730
	;;
8731
      esac
8732
8733
8734
      # move library search paths that coincide with paths to not yet
8735
      # installed libraries to the beginning of the library search list
8736
      new_libs=
8737
      for path in $notinst_path; do
8738
	case " $new_libs " in
8739
	*" -L$path/$objdir "*) ;;
8740
	*)
8741
	  case " $compile_deplibs " in
8742
	  *" -L$path/$objdir "*)
8743
	    func_append new_libs " -L$path/$objdir" ;;
8744
	  esac
8745
	  ;;
8746
	esac
8747
      done
8748
      for deplib in $compile_deplibs; do
8749
	case $deplib in
8750
	-L*)
8751
	  case " $new_libs " in
8752
	  *" $deplib "*) ;;
8753
	  *) func_append new_libs " $deplib" ;;
8754
	  esac
8755
	  ;;
8756
	*) func_append new_libs " $deplib" ;;
8757
	esac
8758
      done
8759
      compile_deplibs="$new_libs"
8760
8761
8762
      func_append compile_command " $compile_deplibs"
8763
      func_append finalize_command " $finalize_deplibs"
8764
8765
      if test -n "$rpath$xrpath"; then
8766
	# If the user specified any rpath flags, then add them.
8767
	for libdir in $rpath $xrpath; do
8768
	  # This is the magic to use -rpath.
8769
	  case "$finalize_rpath " in
8770
	  *" $libdir "*) ;;
8771
	  *) func_append finalize_rpath " $libdir" ;;
8772
	  esac
8773
	done
8774
      fi
8775
8776
      # Now hardcode the library paths
8777
      rpath=
8778
      hardcode_libdirs=
8779
      for libdir in $compile_rpath $finalize_rpath; do
8780
	if test -n "$hardcode_libdir_flag_spec"; then
8781
	  if test -n "$hardcode_libdir_separator"; then
8782
	    if test -z "$hardcode_libdirs"; then
8783
	      hardcode_libdirs="$libdir"
8784
	    else
8785
	      # Just accumulate the unique libdirs.
8786
	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8787
	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8788
		;;
8789
	      *)
8790
		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8791
		;;
8792
	      esac
8793
	    fi
8794
	  else
8795
	    eval flag=\"$hardcode_libdir_flag_spec\"
8796
	    func_append rpath " $flag"
8797
	  fi
8798
	elif test -n "$runpath_var"; then
8799
	  case "$perm_rpath " in
8800
	  *" $libdir "*) ;;
8801
	  *) func_append perm_rpath " $libdir" ;;
8802
	  esac
8803
	fi
8804
	case $host in
8805
	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8806
	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8807
	  case :$dllsearchpath: in
8808
	  *":$libdir:"*) ;;
8809
	  ::) dllsearchpath=$libdir;;
8810
	  *) func_append dllsearchpath ":$libdir";;
8811
	  esac
8812
	  case :$dllsearchpath: in
8813
	  *":$testbindir:"*) ;;
8814
	  ::) dllsearchpath=$testbindir;;
8815
	  *) func_append dllsearchpath ":$testbindir";;
8816
	  esac
8817
	  ;;
8818
	esac
8819
      done
8820
      # Substitute the hardcoded libdirs into the rpath.
8821
      if test -n "$hardcode_libdir_separator" &&
8822
	 test -n "$hardcode_libdirs"; then
8823
	libdir="$hardcode_libdirs"
8824
	eval rpath=\" $hardcode_libdir_flag_spec\"
8825
      fi
8826
      compile_rpath="$rpath"
8827
8828
      rpath=
8829
      hardcode_libdirs=
8830
      for libdir in $finalize_rpath; do
8831
	if test -n "$hardcode_libdir_flag_spec"; then
8832
	  if test -n "$hardcode_libdir_separator"; then
8833
	    if test -z "$hardcode_libdirs"; then
8834
	      hardcode_libdirs="$libdir"
8835
	    else
8836
	      # Just accumulate the unique libdirs.
8837
	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8838
	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8839
		;;
8840
	      *)
8841
		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8842
		;;
8843
	      esac
8844
	    fi
8845
	  else
8846
	    eval flag=\"$hardcode_libdir_flag_spec\"
8847
	    func_append rpath " $flag"
8848
	  fi
8849
	elif test -n "$runpath_var"; then
8850
	  case "$finalize_perm_rpath " in
8851
	  *" $libdir "*) ;;
8852
	  *) func_append finalize_perm_rpath " $libdir" ;;
8853
	  esac
8854
	fi
8855
      done
8856
      # Substitute the hardcoded libdirs into the rpath.
8857
      if test -n "$hardcode_libdir_separator" &&
8858
	 test -n "$hardcode_libdirs"; then
8859
	libdir="$hardcode_libdirs"
8860
	eval rpath=\" $hardcode_libdir_flag_spec\"
8861
      fi
8862
      finalize_rpath="$rpath"
8863
8864
      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8865
	# Transform all the library objects into standard objects.
8866
	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8867
	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8868
      fi
8869
8870
      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8871
8872
      # template prelinking step
8873
      if test -n "$prelink_cmds"; then
8874
	func_execute_cmds "$prelink_cmds" 'exit $?'
8875
      fi
8876
8877
      wrappers_required=yes
8878
      case $host in
8879
      *cegcc* | *mingw32ce*)
8880
        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8881
        wrappers_required=no
8882
        ;;
8883
      *cygwin* | *mingw* )
8884
        if test "$build_libtool_libs" != yes; then
8885
          wrappers_required=no
8886
        fi
8887
        ;;
8888
      *)
8889
        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8890
          wrappers_required=no
8891
        fi
8892
        ;;
8893
      esac
8894
      if test "$wrappers_required" = no; then
8895
	# Replace the output file specification.
8896
	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8897
	link_command="$compile_command$compile_rpath"
8898
8899
	# We have no uninstalled library dependencies, so finalize right now.
8900
	exit_status=0
8901
	func_show_eval "$link_command" 'exit_status=$?'
8902
8903
	if test -n "$postlink_cmds"; then
8904
	  func_to_tool_file "$output"
8905
	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8906
	  func_execute_cmds "$postlink_cmds" 'exit $?'
8907
	fi
8908
8909
	# Delete the generated files.
8910
	if test -f "$output_objdir/${outputname}S.${objext}"; then
8911
	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8912
	fi
8913
8914
	exit $exit_status
8915
      fi
8916
8917
      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8918
	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8919
      fi
8920
      if test -n "$finalize_shlibpath"; then
8921
	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8922
      fi
8923
8924
      compile_var=
8925
      finalize_var=
8926
      if test -n "$runpath_var"; then
8927
	if test -n "$perm_rpath"; then
8928
	  # We should set the runpath_var.
8929
	  rpath=
8930
	  for dir in $perm_rpath; do
8931
	    func_append rpath "$dir:"
8932
	  done
8933
	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8934
	fi
8935
	if test -n "$finalize_perm_rpath"; then
8936
	  # We should set the runpath_var.
8937
	  rpath=
8938
	  for dir in $finalize_perm_rpath; do
8939
	    func_append rpath "$dir:"
8940
	  done
8941
	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8942
	fi
8943
      fi
8944
8945
      if test "$no_install" = yes; then
8946
	# We don't need to create a wrapper script.
8947
	link_command="$compile_var$compile_command$compile_rpath"
8948
	# Replace the output file specification.
8949
	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8950
	# Delete the old output file.
8951
	$opt_dry_run || $RM $output
8952
	# Link the executable and exit
8953
	func_show_eval "$link_command" 'exit $?'
8954
8955
	if test -n "$postlink_cmds"; then
8956
	  func_to_tool_file "$output"
8957
	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8958
	  func_execute_cmds "$postlink_cmds" 'exit $?'
8959
	fi
8960
8961
	exit $EXIT_SUCCESS
8962
      fi
8963
8964
      if test "$hardcode_action" = relink; then
8965
	# Fast installation is not supported
8966
	link_command="$compile_var$compile_command$compile_rpath"
8967
	relink_command="$finalize_var$finalize_command$finalize_rpath"
8968
8969
	func_warning "this platform does not like uninstalled shared libraries"
8970
	func_warning "\`$output' will be relinked during installation"
8971
      else
8972
	if test "$fast_install" != no; then
8973
	  link_command="$finalize_var$compile_command$finalize_rpath"
8974
	  if test "$fast_install" = yes; then
8975
	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8976
	  else
8977
	    # fast_install is set to needless
8978
	    relink_command=
8979
	  fi
8980
	else
8981
	  link_command="$compile_var$compile_command$compile_rpath"
8982
	  relink_command="$finalize_var$finalize_command$finalize_rpath"
8983
	fi
8984
      fi
8985
8986
      # Replace the output file specification.
8987
      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
8988
8989
      # Delete the old output files.
8990
      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
8991
8992
      func_show_eval "$link_command" 'exit $?'
8993
8994
      if test -n "$postlink_cmds"; then
8995
	func_to_tool_file "$output_objdir/$outputname"
8996
	postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8997
	func_execute_cmds "$postlink_cmds" 'exit $?'
8998
      fi
8999
9000
      # Now create the wrapper script.
9001
      func_verbose "creating $output"
9002
9003
      # Quote the relink command for shipping.
9004
      if test -n "$relink_command"; then
9005
	# Preserve any variables that may affect compiler behavior
9006
	for var in $variables_saved_for_relink; do
9007
	  if eval test -z \"\${$var+set}\"; then
9008
	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9009
	  elif eval var_value=\$$var; test -z "$var_value"; then
9010
	    relink_command="$var=; export $var; $relink_command"
9011
	  else
9012
	    func_quote_for_eval "$var_value"
9013
	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9014
	  fi
9015
	done
9016
	relink_command="(cd `pwd`; $relink_command)"
9017
	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9018
      fi
9019
9020
      # Only actually do things if not in dry run mode.
9021
      $opt_dry_run || {
9022
	# win32 will think the script is a binary if it has
9023
	# a .exe suffix, so we strip it off here.
9024
	case $output in
9025
	  *.exe) func_stripname '' '.exe' "$output"
9026
	         output=$func_stripname_result ;;
9027
	esac
9028
	# test for cygwin because mv fails w/o .exe extensions
9029
	case $host in
9030
	  *cygwin*)
9031
	    exeext=.exe
9032
	    func_stripname '' '.exe' "$outputname"
9033
	    outputname=$func_stripname_result ;;
9034
	  *) exeext= ;;
9035
	esac
9036
	case $host in
9037
	  *cygwin* | *mingw* )
9038
	    func_dirname_and_basename "$output" "" "."
9039
	    output_name=$func_basename_result
9040
	    output_path=$func_dirname_result
9041
	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9042
	    cwrapper="$output_path/$output_name.exe"
9043
	    $RM $cwrappersource $cwrapper
9044
	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9045
9046
	    func_emit_cwrapperexe_src > $cwrappersource
9047
9048
	    # The wrapper executable is built using the $host compiler,
9049
	    # because it contains $host paths and files. If cross-
9050
	    # compiling, it, like the target executable, must be
9051
	    # executed on the $host or under an emulation environment.
9052
	    $opt_dry_run || {
9053
	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9054
	      $STRIP $cwrapper
9055
	    }
9056
9057
	    # Now, create the wrapper script for func_source use:
9058
	    func_ltwrapper_scriptname $cwrapper
9059
	    $RM $func_ltwrapper_scriptname_result
9060
	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9061
	    $opt_dry_run || {
9062
	      # note: this script will not be executed, so do not chmod.
9063
	      if test "x$build" = "x$host" ; then
9064
		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9065
	      else
9066
		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9067
	      fi
9068
	    }
9069
	  ;;
9070
	  * )
9071
	    $RM $output
9072
	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9073
9074
	    func_emit_wrapper no > $output
9075
	    chmod +x $output
9076
	  ;;
9077
	esac
9078
      }
9079
      exit $EXIT_SUCCESS
9080
      ;;
9081
    esac
9082
9083
    # See if we need to build an old-fashioned archive.
9084
    for oldlib in $oldlibs; do
9085
9086
      if test "$build_libtool_libs" = convenience; then
9087
	oldobjs="$libobjs_save $symfileobj"
9088
	addlibs="$convenience"
9089
	build_libtool_libs=no
9090
      else
9091
	if test "$build_libtool_libs" = module; then
9092
	  oldobjs="$libobjs_save"
9093
	  build_libtool_libs=no
9094
	else
9095
	  oldobjs="$old_deplibs $non_pic_objects"
9096
	  if test "$preload" = yes && test -f "$symfileobj"; then
9097
	    func_append oldobjs " $symfileobj"
9098
	  fi
9099
	fi
9100
	addlibs="$old_convenience"
9101
      fi
9102
9103
      if test -n "$addlibs"; then
9104
	gentop="$output_objdir/${outputname}x"
9105
	func_append generated " $gentop"
9106
9107
	func_extract_archives $gentop $addlibs
9108
	func_append oldobjs " $func_extract_archives_result"
9109
      fi
9110
9111
      # Do each command in the archive commands.
9112
      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9113
	cmds=$old_archive_from_new_cmds
9114
      else
9115
9116
	# Add any objects from preloaded convenience libraries
9117
	if test -n "$dlprefiles"; then
9118
	  gentop="$output_objdir/${outputname}x"
9119
	  func_append generated " $gentop"
9120
9121
	  func_extract_archives $gentop $dlprefiles
9122
	  func_append oldobjs " $func_extract_archives_result"
9123
	fi
9124
9125
	# POSIX demands no paths to be encoded in archives.  We have
9126
	# to avoid creating archives with duplicate basenames if we
9127
	# might have to extract them afterwards, e.g., when creating a
9128
	# static archive out of a convenience library, or when linking
9129
	# the entirety of a libtool archive into another (currently
9130
	# not supported by libtool).
9131
	if (for obj in $oldobjs
9132
	    do
9133
	      func_basename "$obj"
9134
	      $ECHO "$func_basename_result"
9135
	    done | sort | sort -uc >/dev/null 2>&1); then
9136
	  :
9137
	else
9138
	  echo "copying selected object files to avoid basename conflicts..."
9139
	  gentop="$output_objdir/${outputname}x"
9140
	  func_append generated " $gentop"
9141
	  func_mkdir_p "$gentop"
9142
	  save_oldobjs=$oldobjs
9143
	  oldobjs=
9144
	  counter=1
9145
	  for obj in $save_oldobjs
9146
	  do
9147
	    func_basename "$obj"
9148
	    objbase="$func_basename_result"
9149
	    case " $oldobjs " in
9150
	    " ") oldobjs=$obj ;;
9151
	    *[\ /]"$objbase "*)
9152
	      while :; do
9153
		# Make sure we don't pick an alternate name that also
9154
		# overlaps.
9155
		newobj=lt$counter-$objbase
9156
		func_arith $counter + 1
9157
		counter=$func_arith_result
9158
		case " $oldobjs " in
9159
		*[\ /]"$newobj "*) ;;
9160
		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9161
		esac
9162
	      done
9163
	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9164
	      func_append oldobjs " $gentop/$newobj"
9165
	      ;;
9166
	    *) func_append oldobjs " $obj" ;;
9167
	    esac
9168
	  done
9169
	fi
9170
	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9171
	tool_oldlib=$func_to_tool_file_result
9172
	eval cmds=\"$old_archive_cmds\"
9173
9174
	func_len " $cmds"
9175
	len=$func_len_result
9176
	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9177
	  cmds=$old_archive_cmds
9178
	elif test -n "$archiver_list_spec"; then
9179
	  func_verbose "using command file archive linking..."
9180
	  for obj in $oldobjs
9181
	  do
9182
	    func_to_tool_file "$obj"
9183
	    $ECHO "$func_to_tool_file_result"
9184
	  done > $output_objdir/$libname.libcmd
9185
	  func_to_tool_file "$output_objdir/$libname.libcmd"
9186
	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9187
	  cmds=$old_archive_cmds
9188
	else
9189
	  # the command line is too long to link in one step, link in parts
9190
	  func_verbose "using piecewise archive linking..."
9191
	  save_RANLIB=$RANLIB
9192
	  RANLIB=:
9193
	  objlist=
9194
	  concat_cmds=
9195
	  save_oldobjs=$oldobjs
9196
	  oldobjs=
9197
	  # Is there a better way of finding the last object in the list?
9198
	  for obj in $save_oldobjs
9199
	  do
9200
	    last_oldobj=$obj
9201
	  done
9202
	  eval test_cmds=\"$old_archive_cmds\"
9203
	  func_len " $test_cmds"
9204
	  len0=$func_len_result
9205
	  len=$len0
9206
	  for obj in $save_oldobjs
9207
	  do
9208
	    func_len " $obj"
9209
	    func_arith $len + $func_len_result
9210
	    len=$func_arith_result
9211
	    func_append objlist " $obj"
9212
	    if test "$len" -lt "$max_cmd_len"; then
9213
	      :
9214
	    else
9215
	      # the above command should be used before it gets too long
9216
	      oldobjs=$objlist
9217
	      if test "$obj" = "$last_oldobj" ; then
9218
		RANLIB=$save_RANLIB
9219
	      fi
9220
	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9221
	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9222
	      objlist=
9223
	      len=$len0
9224
	    fi
9225
	  done
9226
	  RANLIB=$save_RANLIB
9227
	  oldobjs=$objlist
9228
	  if test "X$oldobjs" = "X" ; then
9229
	    eval cmds=\"\$concat_cmds\"
9230
	  else
9231
	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9232
	  fi
9233
	fi
9234
      fi
9235
      func_execute_cmds "$cmds" 'exit $?'
9236
    done
9237
9238
    test -n "$generated" && \
9239
      func_show_eval "${RM}r$generated"
9240
9241
    # Now create the libtool archive.
9242
    case $output in
9243
    *.la)
9244
      old_library=
9245
      test "$build_old_libs" = yes && old_library="$libname.$libext"
9246
      func_verbose "creating $output"
9247
9248
      # Preserve any variables that may affect compiler behavior
9249
      for var in $variables_saved_for_relink; do
9250
	if eval test -z \"\${$var+set}\"; then
9251
	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9252
	elif eval var_value=\$$var; test -z "$var_value"; then
9253
	  relink_command="$var=; export $var; $relink_command"
9254
	else
9255
	  func_quote_for_eval "$var_value"
9256
	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9257
	fi
9258
      done
9259
      # Quote the link command for shipping.
9260
      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9261
      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9262
      if test "$hardcode_automatic" = yes ; then
9263
	relink_command=
9264
      fi
9265
9266
      # Only create the output if not a dry run.
9267
      $opt_dry_run || {
9268
	for installed in no yes; do
9269
	  if test "$installed" = yes; then
9270
	    if test -z "$install_libdir"; then
9271
	      break
9272
	    fi
9273
	    output="$output_objdir/$outputname"i
9274
	    # Replace all uninstalled libtool libraries with the installed ones
9275
	    newdependency_libs=
9276
	    for deplib in $dependency_libs; do
9277
	      case $deplib in
9278
	      *.la)
9279
		func_basename "$deplib"
9280
		name="$func_basename_result"
9281
		func_resolve_sysroot "$deplib"
9282
		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9283
		test -z "$libdir" && \
9284
		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9285
		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9286
		;;
9287
	      -L*)
9288
		func_stripname -L '' "$deplib"
9289
		func_replace_sysroot "$func_stripname_result"
9290
		func_append newdependency_libs " -L$func_replace_sysroot_result"
9291
		;;
9292
	      -R*)
9293
		func_stripname -R '' "$deplib"
9294
		func_replace_sysroot "$func_stripname_result"
9295
		func_append newdependency_libs " -R$func_replace_sysroot_result"
9296
		;;
9297
	      *) func_append newdependency_libs " $deplib" ;;
9298
	      esac
9299
	    done
9300
	    dependency_libs="$newdependency_libs"
9301
	    newdlfiles=
9302
9303
	    for lib in $dlfiles; do
9304
	      case $lib in
9305
	      *.la)
9306
	        func_basename "$lib"
9307
		name="$func_basename_result"
9308
		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9309
		test -z "$libdir" && \
9310
		  func_fatal_error "\`$lib' is not a valid libtool archive"
9311
		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9312
		;;
9313
	      *) func_append newdlfiles " $lib" ;;
9314
	      esac
9315
	    done
9316
	    dlfiles="$newdlfiles"
9317
	    newdlprefiles=
9318
	    for lib in $dlprefiles; do
9319
	      case $lib in
9320
	      *.la)
9321
		# Only pass preopened files to the pseudo-archive (for
9322
		# eventual linking with the app. that links it) if we
9323
		# didn't already link the preopened objects directly into
9324
		# the library:
9325
		func_basename "$lib"
9326
		name="$func_basename_result"
9327
		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9328
		test -z "$libdir" && \
9329
		  func_fatal_error "\`$lib' is not a valid libtool archive"
9330
		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9331
		;;
9332
	      esac
9333
	    done
9334
	    dlprefiles="$newdlprefiles"
9335
	  else
9336
	    newdlfiles=
9337
	    for lib in $dlfiles; do
9338
	      case $lib in
9339
		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9340
		*) abs=`pwd`"/$lib" ;;
9341
	      esac
9342
	      func_append newdlfiles " $abs"
9343
	    done
9344
	    dlfiles="$newdlfiles"
9345
	    newdlprefiles=
9346
	    for lib in $dlprefiles; do
9347
	      case $lib in
9348
		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9349
		*) abs=`pwd`"/$lib" ;;
9350
	      esac
9351
	      func_append newdlprefiles " $abs"
9352
	    done
9353
	    dlprefiles="$newdlprefiles"
9354
	  fi
9355
	  $RM $output
9356
	  # place dlname in correct position for cygwin
9357
	  # In fact, it would be nice if we could use this code for all target
9358
	  # systems that can't hard-code library paths into their executables
9359
	  # and that have no shared library path variable independent of PATH,
9360
	  # but it turns out we can't easily determine that from inspecting
9361
	  # libtool variables, so we have to hard-code the OSs to which it
9362
	  # applies here; at the moment, that means platforms that use the PE
9363
	  # object format with DLL files.  See the long comment at the top of
9364
	  # tests/bindir.at for full details.
9365
	  tdlname=$dlname
9366
	  case $host,$output,$installed,$module,$dlname in
9367
	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9368
	      # If a -bindir argument was supplied, place the dll there.
9369
	      if test "x$bindir" != x ;
9370
	      then
9371
		func_relative_path "$install_libdir" "$bindir"
9372
		tdlname=$func_relative_path_result$dlname
9373
	      else
9374
		# Otherwise fall back on heuristic.
9375
		tdlname=../bin/$dlname
9376
	      fi
9377
	      ;;
9378
	  esac
9379
	  $ECHO > $output "\
9380
# $outputname - a libtool library file
9381
# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9382
#
9383
# Please DO NOT delete this file!
9384
# It is necessary for linking the library.
9385
9386
# The name that we can dlopen(3).
9387
dlname='$tdlname'
9388
9389
# Names of this library.
9390
library_names='$library_names'
9391
9392
# The name of the static archive.
9393
old_library='$old_library'
9394
9395
# Linker flags that can not go in dependency_libs.
9396
inherited_linker_flags='$new_inherited_linker_flags'
9397
9398
# Libraries that this one depends upon.
9399
dependency_libs='$dependency_libs'
9400
9401
# Names of additional weak libraries provided by this library
9402
weak_library_names='$weak_libs'
9403
9404
# Version information for $libname.
9405
current=$current
9406
age=$age
9407
revision=$revision
9408
9409
# Is this an already installed library?
9410
installed=$installed
9411
9412
# Should we warn about portability when linking against -modules?
9413
shouldnotlink=$module
9414
9415
# Files to dlopen/dlpreopen
9416
dlopen='$dlfiles'
9417
dlpreopen='$dlprefiles'
9418
9419
# Directory that this library needs to be installed in:
9420
libdir='$install_libdir'"
9421
	  if test "$installed" = no && test "$need_relink" = yes; then
9422
	    $ECHO >> $output "\
9423
relink_command=\"$relink_command\""
9424
	  fi
9425
	done
9426
      }
9427
9428
      # Do a symbolic link so that the libtool archive can be found in
9429
      # LD_LIBRARY_PATH before the program is installed.
9430
      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9431
      ;;
9432
    esac
9433
    exit $EXIT_SUCCESS
9434
}
9435
9436
{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9437
    func_mode_link ${1+"$@"}
9438
9439
9440
# func_mode_uninstall arg...
9441
func_mode_uninstall ()
9442
{
9443
    $opt_debug
9444
    RM="$nonopt"
9445
    files=
9446
    rmforce=
9447
    exit_status=0
9448
9449
    # This variable tells wrapper scripts just to set variables rather
9450
    # than running their programs.
9451
    libtool_install_magic="$magic"
9452
9453
    for arg
9454
    do
9455
      case $arg in
9456
      -f) func_append RM " $arg"; rmforce=yes ;;
9457
      -*) func_append RM " $arg" ;;
9458
      *) func_append files " $arg" ;;
9459
      esac
9460
    done
9461
9462
    test -z "$RM" && \
9463
      func_fatal_help "you must specify an RM program"
9464
9465
    rmdirs=
9466
9467
    for file in $files; do
9468
      func_dirname "$file" "" "."
9469
      dir="$func_dirname_result"
9470
      if test "X$dir" = X.; then
9471
	odir="$objdir"
9472
      else
9473
	odir="$dir/$objdir"
9474
      fi
9475
      func_basename "$file"
9476
      name="$func_basename_result"
9477
      test "$opt_mode" = uninstall && odir="$dir"
9478
9479
      # Remember odir for removal later, being careful to avoid duplicates
9480
      if test "$opt_mode" = clean; then
9481
	case " $rmdirs " in
9482
	  *" $odir "*) ;;
9483
	  *) func_append rmdirs " $odir" ;;
9484
	esac
9485
      fi
9486
9487
      # Don't error if the file doesn't exist and rm -f was used.
9488
      if { test -L "$file"; } >/dev/null 2>&1 ||
9489
	 { test -h "$file"; } >/dev/null 2>&1 ||
9490
	 test -f "$file"; then
9491
	:
9492
      elif test -d "$file"; then
9493
	exit_status=1
9494
	continue
9495
      elif test "$rmforce" = yes; then
9496
	continue
9497
      fi
9498
9499
      rmfiles="$file"
9500
9501
      case $name in
9502
      *.la)
9503
	# Possibly a libtool archive, so verify it.
9504
	if func_lalib_p "$file"; then
9505
	  func_source $dir/$name
9506
9507
	  # Delete the libtool libraries and symlinks.
9508
	  for n in $library_names; do
9509
	    func_append rmfiles " $odir/$n"
9510
	  done
9511
	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9512
9513
	  case "$opt_mode" in
9514
	  clean)
9515
	    case " $library_names " in
9516
	    *" $dlname "*) ;;
9517
	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9518
	    esac
9519
	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9520
	    ;;
9521
	  uninstall)
9522
	    if test -n "$library_names"; then
9523
	      # Do each command in the postuninstall commands.
9524
	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9525
	    fi
9526
9527
	    if test -n "$old_library"; then
9528
	      # Do each command in the old_postuninstall commands.
9529
	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9530
	    fi
9531
	    # FIXME: should reinstall the best remaining shared library.
9532
	    ;;
9533
	  esac
9534
	fi
9535
	;;
9536
9537
      *.lo)
9538
	# Possibly a libtool object, so verify it.
9539
	if func_lalib_p "$file"; then
9540
9541
	  # Read the .lo file
9542
	  func_source $dir/$name
9543
9544
	  # Add PIC object to the list of files to remove.
9545
	  if test -n "$pic_object" &&
9546
	     test "$pic_object" != none; then
9547
	    func_append rmfiles " $dir/$pic_object"
9548
	  fi
9549
9550
	  # Add non-PIC object to the list of files to remove.
9551
	  if test -n "$non_pic_object" &&
9552
	     test "$non_pic_object" != none; then
9553
	    func_append rmfiles " $dir/$non_pic_object"
9554
	  fi
9555
	fi
9556
	;;
9557
9558
      *)
9559
	if test "$opt_mode" = clean ; then
9560
	  noexename=$name
9561
	  case $file in
9562
	  *.exe)
9563
	    func_stripname '' '.exe' "$file"
9564
	    file=$func_stripname_result
9565
	    func_stripname '' '.exe' "$name"
9566
	    noexename=$func_stripname_result
9567
	    # $file with .exe has already been added to rmfiles,
9568
	    # add $file without .exe
9569
	    func_append rmfiles " $file"
9570
	    ;;
9571
	  esac
9572
	  # Do a test to see if this is a libtool program.
9573
	  if func_ltwrapper_p "$file"; then
9574
	    if func_ltwrapper_executable_p "$file"; then
9575
	      func_ltwrapper_scriptname "$file"
9576
	      relink_command=
9577
	      func_source $func_ltwrapper_scriptname_result
9578
	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9579
	    else
9580
	      relink_command=
9581
	      func_source $dir/$noexename
9582
	    fi
9583
9584
	    # note $name still contains .exe if it was in $file originally
9585
	    # as does the version of $file that was added into $rmfiles
9586
	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9587
	    if test "$fast_install" = yes && test -n "$relink_command"; then
9588
	      func_append rmfiles " $odir/lt-$name"
9589
	    fi
9590
	    if test "X$noexename" != "X$name" ; then
9591
	      func_append rmfiles " $odir/lt-${noexename}.c"
9592
	    fi
9593
	  fi
9594
	fi
9595
	;;
9596
      esac
9597
      func_show_eval "$RM $rmfiles" 'exit_status=1'
9598
    done
9599
9600
    # Try to remove the ${objdir}s in the directories where we deleted files
9601
    for dir in $rmdirs; do
9602
      if test -d "$dir"; then
9603
	func_show_eval "rmdir $dir >/dev/null 2>&1"
9604
      fi
9605
    done
9606
9607
    exit $exit_status
9608
}
9609
9610
{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9611
    func_mode_uninstall ${1+"$@"}
9612
9613
test -z "$opt_mode" && {
9614
  help="$generic_help"
9615
  func_fatal_help "you must specify a MODE"
9616
}
9617
9618
test -z "$exec_cmd" && \
9619
  func_fatal_help "invalid operation mode \`$opt_mode'"
9620
9621
if test -n "$exec_cmd"; then
9622
  eval exec "$exec_cmd"
9623
  exit $EXIT_FAILURE
9624
fi
9625
9626
exit $exit_status
9627
9628
9629
# The TAGs below are defined such that we never get into a situation
9630
# in which we disable both kinds of libraries.  Given conflicting
9631
# choices, we go for a static library, that is the most portable,
9632
# since we can't tell whether shared libraries were disabled because
9633
# the user asked for that or because the platform doesn't support
9634
# them.  This is particularly important on AIX, because we don't
9635
# support having both static and shared libraries enabled at the same
9636
# time on that platform, so we default to a shared-only configuration.
9637
# If a disable-shared tag is given, we'll fallback to a static-only
9638
# configuration.  But we'll never go from static-only to shared-only.
9639
9640
# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9641
build_libtool_libs=no
9642
build_old_libs=yes
9643
# ### END LIBTOOL TAG CONFIG: disable-shared
9644
9645
# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9646
build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9647
# ### END LIBTOOL TAG CONFIG: disable-static
9648
9649
# Local Variables:
9650
# mode:shell-script
9651
# sh-indentation:2
9652
# End:
9653
# vi:sw=2
9654
9655