ltmain.sh 191 KB
Newer Older
Lynn Garren's avatar
Lynn Garren committed
1
2
3
4
5
6
7
8
9
# Generated from ltmain.in; do not edit by hand

# ltmain.sh (GNU libtool) 1.9b
# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996

# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
# This is free software; see the source for copying conditions.  There is NO
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.

Lynn Garren's avatar
Lynn Garren committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Usage: $progname [OPTION]... [MODE-ARG]...
#
# Provide generalized library-building support services.
#
#     --config             show all configuration variables
#     --debug              enable verbose shell tracing
# -n, --dry-run            display commands without modifying any files
#     --features           display basic configuration information and exit
#     --mode=MODE          use operation mode MODE
#     --preserve-dup-deps  don't remove duplicate dependency libraries
#     --quiet, --silent    don't print informational messages
#     --tag=TAG            use configuration variables from tag TAG
#     --version            print version information
# -h, --help               print short or long help message
#
# MODE must be one of the following:
#
#       clean              remove files from the build directory
#       compile            compile a source file into a libtool object
#       execute            automatically set library path, then run a program
#       finish             complete the installation of libtool libraries
#       install            install libraries or executables
#       link               create a library or an executable
#       uninstall          remove libraries from an installed directory
#
# MODE-ARGS vary depending on the MODE.
# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
#
# When reporting a bug, please describe a test case to reproduce it and
# include the following information:
#
#       host-triplet:	powerpc-apple-darwin7.5.0
#       shell:		$SHELL
#       compiler:		$LTCC
#       linker:		$LD (gnu? $with_gnu_ld)
#       $progname:		(GNU libtool) 1.9b
#       automake:		$automake_version
#       autoconf:		$autoconf_version
#
# Report bugs to <bug-libtool@gnu.org>.

# Be Bourne compatible
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
  emulate sh
  NULLCMD=:
  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
  # is contrary to our usage.  Disable this feature.
  alias -g '${1+"$@"}'='"$@"'
  setopt NO_GLOB_SUBST
elif test -n "${BASH_VERSION+set}${KSH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
  set -o posix
fi
DUALCASE=1; export DUALCASE # for MKS sh

dirname="s,/[^/]*$,,"
basename="s,^.*/,,g"

# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
# is ksh but when the shell is invoked as "sh" and the current value of
# the _XPG environment variable is not equal to 1 (one), the special
# positional parameter $0, within a function call, is the name of the
# function.
progpath="$0"

# The name of this program:
PROGRAM=ltmain.sh
progname=`echo "$progpath" | $SED "$basename"`

# Make sure we have an absolute path for reexecution:
case $progpath in
  [\\/]*|[A-Za-z]:\\*) ;;
  *) progdir=`echo "$progpath" | $SED "$dirname"`
     progdir=`cd "$progdir" && pwd`
     progpath="$progdir/$progname"
     ;;
esac

# Global variables:
EXIT_SUCCESS=0
EXIT_FAILURE=1
EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.

PROGRAM=ltmain.sh
PACKAGE=libtool
VERSION=1.9b
TIMESTAMP=""
package_revision=1.1571

117
118
119
120
121
122
123
124
125
126
127
128
# Check that we have a working $echo.
if test "X$1" = X--no-reexec; then
  # Discard the --no-reexec flag, and continue.
  shift
elif test "X$1" = X--fallback-echo; then
  # Avoid inline document here, it may be left over
  :
elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
  # Yippee, $echo works!
  :
else
  # Restart under the correct shell, and then maybe $echo will work.
Lynn Garren's avatar
Lynn Garren committed
129
  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
130
131
132
133
134
135
136
137
fi

if test "X$1" = X--fallback-echo; then
  # used as fallback echo
  shift
  cat <<EOF
$*
EOF
Lynn Garren's avatar
Lynn Garren committed
138
  exit $EXIT_SUCCESS
139
140
141
142
143
144
145
146
147
148
149
150
151
152
fi

default_mode=
help="Try \`$progname --help' for more information."
magic="%%%MAGIC variable%%%"
mkdir="mkdir"
mv="mv -f"
rm="rm -f"

# Sed substitution that helps us do robust quoting.  It backslashifies
# metacharacters that are still active within double-quoted strings.
Xsed="${SED}"' -e 1s/^X//'
sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
# test EBCDIC or ASCII
Lynn Garren's avatar
Lynn Garren committed
153
154
case `echo A|tr A '\301'` in
 A) # EBCDIC based system
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
  SP2NL="tr '\100' '\n'"
  NL2SP="tr '\r\n' '\100\100'"
  ;;
 *) # Assume ASCII based system
  SP2NL="tr '\040' '\012'"
  NL2SP="tr '\015\012' '\040\040'"
  ;;
esac

# NLS nuisances.
# Only set LANG and LC_ALL to C if already set.
# These must not be set unconditionally because not all systems understand
# e.g. LANG=C (notably SCO).
# We save the old values to restore during execute mode.
if test "${LC_ALL+set}" = set; then
  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
fi
if test "${LANG+set}" = set; then
  save_LANG="$LANG"; LANG=C; export LANG
fi

# Make sure IFS has a sensible default
Lynn Garren's avatar
Lynn Garren committed
177
178
: ${IFS="
 	"}
179
180
181
182
183
184
185
186
187
188

# Global variables.
mode=$default_mode
nonopt=
run=
show="$echo"
execute_dlfiles=
lo2o="s/\\.lo\$/.${objext}/"
o2lo="s/\\.${objext}\$/.lo/"

Lynn Garren's avatar
Lynn Garren committed
189
190
opt_help=false
opt_duplicate_deps=false
191

Lynn Garren's avatar
Lynn Garren committed
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# If this variable is set in any of the actions, the command in it
# will be execed at the end.  This prevents here-documents from being
# left over by shells.
exec_cmd=

# func_echo arg...
# Echo program name prefixed message, along with the current mode
# name if it has been set yet.
func_echo ()
{
    $echo $progname${mode+: }$mode: ${1+"$@"}
}

# func_verbose arg...
# Echo program name prefixed message in verbose mode only.
func_verbose ()
{
    $opt_verbose && func_echo ${1+"$@"}
210
211
}

Lynn Garren's avatar
Lynn Garren committed
212
213
214
215
216
217
# func_error arg...
# Echo program name prefixed message to standard error.
func_error ()
{
    $echo $progname${mode+: }$mode: ${1+"$@"} 1>&2
}
218

Lynn Garren's avatar
Lynn Garren committed
219
220
221
222
223
224
# func_warning arg...
# Echo program name prefixed warning message to standard error.
func_warning ()
{
    $echo $progname${mode+: }$mode: warning: ${1+"$@"} 1>&2
}
225

Lynn Garren's avatar
Lynn Garren committed
226
227
228
229
230
231
232
# func_fatal_error arg...
# Echo program name prefixed message to standard error, and exit.
func_fatal_error ()
{
    func_error ${1+"$@"}
    exit $EXIT_FAILURE
}
233

Lynn Garren's avatar
Lynn Garren committed
234
235
236
237
238
239
240
241
242
# func_fatal_configuration arg...
# Echo program name prefixed message to standard error, followed by
# a configuration failure hint, and exit.
func_fatal_configuration ()
{
    func_error ${1+"$@"}
    func_error "See the $PACKAGE documentation for more information."
    func_fatal_error "Fatal configuration error."
}
243

Lynn Garren's avatar
Lynn Garren committed
244
245
246
247
248
249
250
251
# func_fatal_help arg...
# Echo program name prefixed message to standard error, followed by
# a help hint, and exit.
func_fatal_help ()
{
    func_error ${1+"$@"}
    func_fatal_error "$help"
}
252

Lynn Garren's avatar
Lynn Garren committed
253
254
255
256
257
258
259
260
# func_missing_arg argname
# Echo program name prefixed message to standard error and set global
# exit_cmd.
func_missing_arg ()
{
    func_error "missing argument for $1"
    exit_cmd=exit
}
261

Lynn Garren's avatar
Lynn Garren committed
262
263
264
265
266
267
268
269
270
271
272
# func_version
# Echo version message to standard output and exit.
func_version ()
{
    $SED '/^# '$PROGRAM' (GNU /,/# warranty; / {
        s/^# //; s/^# *$//;
        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/;
        p;
     }; d' < "$progpath"
     exit $EXIT_SUCCESS
}
273

Lynn Garren's avatar
Lynn Garren committed
274
275
276
277
278
279
280
281
282
283
284
285
286
# func_usage
# Echo short help message to standard output and exit.
func_usage ()
{
    $SED '/^# Usage:/,/# -h/ {
        s/^# //; s/^# *$//;
	s/\$progname/'$progname'/;
	p;
    }; d' < "$progpath"
    echo
    echo "run \`$progname --help | more' for full usage"
    exit $EXIT_SUCCESS
}
287

Lynn Garren's avatar
Lynn Garren committed
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# func_help
# Echo long help message to standard output and exit.
func_help ()
{
    $SED '/^# Usage:/,/# Report bugs to/ {
        s/^# //; s/^# *$//;
	s:\$progname:'$progname':;
	s:\$SHELL:'"$SHELL"':;
	s:\$LTCC:'"$LTCC"':;
	s:\$LD:'"$LD"':;
	s/\$with_gnu_ld/'"$with_gnu_ld"'/;
	s/\$automake_version/'"`automake --version 2>/dev/null |$SED 1q`"'/;
	s/\$autoconf_version/'"`autoconf --version 2>/dev/null |$SED 1q`"'/;
	p;
     }; d' < "$progpath"
    exit $EXIT_SUCCESS
}

# func_config
# Display the configuration for all the tags in this script.
func_config ()
{
    re_begincf='^# ### BEGIN LIBTOOL'
    re_endcf='^# ### END LIBTOOL'

    # Default configuration.
    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
315
316
317

    # Now print the configurations for the tags.
    for tagname in $taglist; do
Lynn Garren's avatar
Lynn Garren committed
318
      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
319
320
    done

Lynn Garren's avatar
Lynn Garren committed
321
322
    exit $EXIT_SUCCESS
}
323

Lynn Garren's avatar
Lynn Garren committed
324
325
326
327
# func_features
# Display the features supported by this script.
func_features ()
{
328
329
330
331
332
333
334
335
336
337
338
339
    $echo "host: $host"
    if test "$build_libtool_libs" = yes; then
      $echo "enable shared libraries"
    else
      $echo "disable shared libraries"
    fi
    if test "$build_old_libs" = yes; then
      $echo "enable static libraries"
    else
      $echo "disable static libraries"
    fi

Lynn Garren's avatar
Lynn Garren committed
340
341
    exit $EXIT_SUCCESS
}
342

Lynn Garren's avatar
Lynn Garren committed
343
344
345
346
347
348
349
350
# func_enable_tag tagname
# Verify that TAGNAME is valid, and either flag an error and exit, or
# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
# variable here.
func_enable_tag ()
{
  # Global variable:
  tagname="$1"
351

Lynn Garren's avatar
Lynn Garren committed
352
353
354
  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
  sed_extractcf="/$re_begincf/,/$re_endcf/p"
355

Lynn Garren's avatar
Lynn Garren committed
356
357
358
359
360
361
  # Validate tagname.
  case $tagname in
    *[!-_A-Za-z0-9,/]*)
      func_fatal_error "invalid tag name: $tagname"
      ;;
  esac
362

Lynn Garren's avatar
Lynn Garren committed
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
  # Don't test for the "default" C tag, as we know it's
  # there but not specially marked.
  case $tagname in
    CC) ;;
    *)
      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
	taglist="$taglist $tagname"

	# Evaluate the configuration.  Be careful to quote the path
	# and the sed script, to avoid splitting on whitespace, but
	# also don't use non-portable "`\"foo\"`", so we have to do
	# it in 2 steps:
	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
	eval "$extractedcf"
      else
	func_error "ignoring unknown tag $tagname"
      fi
      ;;
  esac
}
383
384


Lynn Garren's avatar
Lynn Garren committed
385
386
387
388
389
390
391
392
393
func_mode_help ()
{
    # We need to display help for each of the modes.
    case $mode in
      "")
        # Generic help is extracted from the usage comments
        # at the start of this file.
        func_help
        ;;
394

Lynn Garren's avatar
Lynn Garren committed
395
396
397
      clean)
        $echo \
"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
398

Lynn Garren's avatar
Lynn Garren committed
399
Remove files from the build directory.
400

Lynn Garren's avatar
Lynn Garren committed
401
402
403
RM is the name of the program to use to delete files associated with each FILE
(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
to RM.
404

Lynn Garren's avatar
Lynn Garren committed
405
406
407
If FILE is a libtool library, object or program, all the files associated
with it are deleted. Otherwise, only FILE itself is deleted using RM."
        ;;
408

Lynn Garren's avatar
Lynn Garren committed
409
410
411
      compile)
      $echo \
"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
412

Lynn Garren's avatar
Lynn Garren committed
413
Compile a source file into a libtool library object.
414

Lynn Garren's avatar
Lynn Garren committed
415
This mode accepts the following additional options:
416

Lynn Garren's avatar
Lynn Garren committed
417
418
419
420
421
422
  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
  -no-suppress      do not suppress compiler output for multiple passes
  -prefer-pic       try to building PIC objects only
  -prefer-non-pic   try to building non-PIC objects only
  -shared           do not build a \`.o' file suitable for static linking
  -static           only build a \`.o' file suitable for static linking
423

Lynn Garren's avatar
Lynn Garren committed
424
425
COMPILE-COMMAND is a command to be used in creating a \`standard' object file
from the given SOURCEFILE.
426

Lynn Garren's avatar
Lynn Garren committed
427
428
429
430
The output file name is determined by removing the directory component from
SOURCEFILE, then substituting the C source code suffix \`.c' with the
library object suffix, \`.lo'."
        ;;
431

Lynn Garren's avatar
Lynn Garren committed
432
433
434
      execute)
        $echo \
"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
435

Lynn Garren's avatar
Lynn Garren committed
436
Automatically set library path, then run a program.
437

Lynn Garren's avatar
Lynn Garren committed
438
This mode accepts the following additional options:
439

Lynn Garren's avatar
Lynn Garren committed
440
  -dlopen FILE      add the directory containing FILE to the library path
441

Lynn Garren's avatar
Lynn Garren committed
442
443
This mode sets the library path environment variable according to \`-dlopen'
flags.
444

Lynn Garren's avatar
Lynn Garren committed
445
446
447
If any of the ARGS are libtool executable wrappers, then they are translated
into their corresponding uninstalled binary, and any of their required library
directories are added to the library path.
448

Lynn Garren's avatar
Lynn Garren committed
449
450
Then, COMMAND is executed, with ARGS as arguments."
        ;;
451

Lynn Garren's avatar
Lynn Garren committed
452
453
454
      finish)
        $echo \
"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
455

Lynn Garren's avatar
Lynn Garren committed
456
Complete the installation of libtool libraries.
457

Lynn Garren's avatar
Lynn Garren committed
458
Each LIBDIR is a directory that contains libtool libraries.
459

Lynn Garren's avatar
Lynn Garren committed
460
461
462
The commands that this mode executes may require superuser privileges.  Use
the \`--dry-run' option if you just want to see what would be executed."
        ;;
463

Lynn Garren's avatar
Lynn Garren committed
464
465
466
      install)
        $echo \
"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
467

Lynn Garren's avatar
Lynn Garren committed
468
Install executables or libraries.
469

Lynn Garren's avatar
Lynn Garren committed
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
INSTALL-COMMAND is the installation command.  The first component should be
either the \`install' or \`cp' program.

The following components of INSTALL-COMMAND are treated specially:

  -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation

The rest of the components are interpreted as arguments to that command (only
BSD-compatible install options are recognized)."
        ;;

      link)
        $echo \
"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...

Link object files or libraries together to form another library, or to
create an executable program.

LINK-COMMAND is a command using the C compiler that you would use to create
a program from several object files.

The following components of LINK-COMMAND are treated specially:

  -all-static       do not do any dynamic linking at all
  -avoid-version    do not add a version suffix if possible
  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
  -export-symbols SYMFILE
		    try to export only the symbols listed in SYMFILE
  -export-symbols-regex REGEX
		    try to export only the symbols matching REGEX
  -LLIBDIR          search LIBDIR for required installed libraries
  -lNAME            OUTPUT-FILE requires the installed library libNAME
  -module           build a library that can dlopened
  -no-fast-install  disable the fast-install mode
  -no-install       link a not-installable executable
  -no-undefined     declare that a library does not refer to external symbols
  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
  -objectlist FILE  Use a list of object files found in FILE to specify objects
  -precious-files-regex REGEX
                    don't remove output files matching REGEX
  -release RELEASE  specify package release information
  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
  -shared           only do dynamic linking of libtool libraries
  -shrext SUFFIX    override the standard shared library file extension
  -static           do not do any dynamic linking of libtool libraries
  -version-info CURRENT[:REVISION[:AGE]]
		    specify library version info [each variable defaults to 0]
  -weak LIBNAME     declare that the target provides the LIBNAME interface

All other options (arguments beginning with \`-') are ignored.

Every other argument is treated as a filename.  Files ending in \`.la' are
treated as uninstalled libtool libraries, other files are standard or library
object files.

If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
only library objects (\`.lo' files) may be specified, and \`-rpath' is
required, except when creating a convenience library.

If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
using \`ar' and \`ranlib', or on Windows using \`lib'.

If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
is created, otherwise an executable program is created."
        ;;

      uninstall)
        $echo \
"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...

Remove libraries from an installation directory.

RM is the name of the program to use to delete files associated with each FILE
(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
to RM.

If FILE is a libtool library, all the files associated with it are deleted.
Otherwise, only FILE itself is deleted using RM."
        ;;

      *)
        func_fatal_help "invalid operation mode \`$mode'"
        ;;
556
557
    esac

Lynn Garren's avatar
Lynn Garren committed
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
    $echo
    $echo "Try \`$progname --help' for more information about other modes."

    exit $EXIT_SUCCESS
}

# Parse options once, thoroughly.  This comes as soon as possible in
# the script to make things like `libtool --version' happen quickly.
{
  # sed scripts:
  my_sed_single_opt='1s/^\(..\).*$/\1/;q'
  my_sed_single_rest='1s/^..\(.*\)$/\1/;q'
  my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
  my_sed_long_arg='1s/^--[^=]*=//'

  exit_cmd=:

  # Shorthand for --mode=foo, only valid as the first argument
  case $1 in
  clean|clea|cle|cl)
    shift; set -- --mode clean ${1+"$@"}
    ;;
  compile|compil|compi|comp|com|co|c)
    shift; set -- --mode compile ${1+"$@"}
    ;;
  execute|execut|execu|exec|exe|ex|e)
    shift; set -- --mode execute ${1+"$@"}
    ;;
  finish|finis|fini|fin|fi|f)
    shift; set -- --mode finish ${1+"$@"}
    ;;
  install|instal|insta|inst|ins|in|i)
    shift; set -- --mode install ${1+"$@"}
    ;;
  link|lin|li|l)
    shift; set -- --mode link ${1+"$@"}
    ;;
  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
    shift; set -- --mode uninstall ${1+"$@"}
    ;;
  esac

  # Parse non-mode specific arguments:
  while test "$#" -gt 0; do
    opt="$1"
    shift

    case $opt in
      --config)		func_config 					;;

      --debug)		preserve_args="$preserve_args $opt"
	    		func_echo "enabling shell trace mode"
	    		set -x
			;;

      --dlopen)		test $# -eq 0 && func_missing_arg "$opt" && break
			execute_dlfiles="$execute_dlfiles $1"
			;;

      --dry-run | -n)	run=:						;;
      --features)       func_features					;;
      --finish)		mode="finish"					;;

      --mode)		test $# -eq 0 && func_missing_arg "$opt" && break
	    		case $1 in
			  # Valid mode arguments:
			  clean)	;;
			  compile)	;;
			  execute)	;;
			  finish)	;;
			  install)	;;
			  link)		;;
			  uninstall)	;;

			  # Catch anything else as an error
			  *) func_error "invalid argument for $opt"
			     exit_cmd=exit
			     break
			     ;;
		        esac

	    		mode="$1"
			shift
			;;

      --preserve-dup-deps)
      			opt_duplicate_deps=:				;;

      --quiet|--silent)	preserve_args="$preserve_args $opt"
    			show=:
			;;

      --tag)		test $# -eq 0 && func_missing_arg "$opt" && break
			preserve_args="$preserve_args $opt $1"
			func_enable_tag "$1"	# tagname is set here
			shift
			;;

      # Separate optargs to long options:
      --dlopen=*|--mode=*|--tag=*)
			arg=`echo "$opt" | $SED "$my_sed_long_arg"`
			opt=`echo "$opt" | $SED "$my_sed_long_opt"`
			set -- "$opt" "$arg" ${1+"$@"}
			;;

      # Separate optargs to short options:
#      -x*|-y*)
#			arg=`echo "$opt" |$SED "$my_sed_single_rest"`
#			opt=`echo "$opt" |$SED "$my_sed_single_opt"`
#			set -- "$opt" "$arg" ${1+"$@"}
#			;;

      # Separate non-argument short options:
#      -z*|-z*|-y*)
#			rest=`echo "$opt" |$SED "$my_sed_single_rest"`
#			opt=`echo "$opt" |$SED "$my_sed_single_opt"`
#			set -- "$opt" "-$rest" ${1+"$@"}
#			;;

      -\?|-h)		func_usage					;;
      --help)		opt_help=:					;;
      --version)	func_version					;;

      -*)		func_fatal_help "unrecognized option \`$opt'"	;;

      *)		nonopt="$opt"
      			break
			;;
686
    esac
Lynn Garren's avatar
Lynn Garren committed
687
  done
688

Lynn Garren's avatar
Lynn Garren committed
689
690
  # Now that we've collected a possible --mode arg, show help if necessary
  $opt_help && func_mode_help
691

Lynn Garren's avatar
Lynn Garren committed
692
693
694
695
696
  case $host in
    *cygwin* | *mingw* | *pw32*)
      # don't eliminate duplications in $postdeps and $predeps
      opt_duplicate_compiler_generated_deps=:
      ;;
697
    *)
Lynn Garren's avatar
Lynn Garren committed
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
      ;;
  esac

  # Having warned about all mis-specified options, bail out if
  # anything was wrong.
  $exit_cmd $EXIT_FAILURE
}


# func_check_version_match
# Ensure that we are using m4 macros, and libtool script from the same
# release of libtool.
func_check_version_match ()
{
  if test "$package_revision" != "$macro_revision"; then
    if test "$VERSION" != "$macro_version"; then
      if test -z "$macro_version"; then
        cat >&2 <<_LT_EOF
$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
$progname: definition of this LT_INIT comes from an older release.
$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
$progname: and run autoconf again.
_LT_EOF
      else
        cat >&2 <<_LT_EOF
$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
$progname: and run autoconf again.
_LT_EOF
      fi
    else
      cat >&2 <<_LT_EOF
$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
$progname: but the definition of this LT_INIT comes from revision $macro_revision.
$progname: You should recreate aclocal.m4 with macros from revision $package_revision
$progname: of $PACKAGE $VERSION and run autoconf again.
_LT_EOF
    fi

    exit $EXIT_MISMATCH
  fi
}

# func_win32_libid arg
# return the library type of file 'arg'
#
# Need a lot of goo to handle *both* DLLs and import libs
# Has to be a shell function in order to 'eat' the argument
# that is supplied when $file_magic_command is called.
func_win32_libid () {
  win32_libid_type="unknown"
  win32_fileres=`file -L $1 2>/dev/null`
  case $win32_fileres in
  *ar\ archive\ import\ library*) # definitely import
    win32_libid_type="x86 archive import"
    ;;
  *ar\ archive*) # could be an import, or static
    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
       $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
      win32_nmres=`eval $NM -f posix -A $1 |
	sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
      if test "X$win32_nmres" = "Ximport" ; then
	win32_libid_type="x86 archive import"
      else
	win32_libid_type="x86 archive static"
      fi
    fi
    ;;
  *DLL*)
    win32_libid_type="x86 DLL"
    ;;
  *executable*) # but shell scripts are "executable" too...
    case $win32_fileres in
    *MS\ Windows\ PE\ Intel*)
      win32_libid_type="x86 DLL"
775
776
      ;;
    esac
Lynn Garren's avatar
Lynn Garren committed
777
778
779
780
781
    ;;
  esac
  $echo $win32_libid_type
}

782

Lynn Garren's avatar
Lynn Garren committed
783
784
785
786
787
788
789
790

# func_infer_tag arg
# Infer tagged configuration to use if any are available and
# if one wasn't chosen via the "--tag" command line option.
# Only attempt this if the compiler in the base compile
# command doesn't match the default compiler.
# arg is usually of the form 'gcc ...'
func_infer_tag () {
791
    if test -n "$available_tags" && test -z "$tagname"; then
Lynn Garren's avatar
Lynn Garren committed
792
793
794
795
796
797
798
799
800
801
      CC_quoted=
      for arg in $CC; do
	case $arg in
	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
	  arg="\"$arg\""
	  ;;
	esac
	CC_quoted="$CC_quoted $arg"
      done
      case $@ in
802
803
      # Blanks in the command may have been stripped by the calling shell,
      # but not from the CC environment variable when configure was run.
Lynn Garren's avatar
Lynn Garren committed
804
      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
805
806
807
808
      # Blanks at the start of $base_compile will cause this to fail
      # if we don't check for them as well.
      *)
	for z in $available_tags; do
Lynn Garren's avatar
Lynn Garren committed
809
	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
810
	    # Evaluate the configuration.
Lynn Garren's avatar
Lynn Garren committed
811
812
813
814
815
816
817
818
819
820
821
822
823
	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
	    CC_quoted=
	    for arg in $CC; do
	    # Double-quote args containing other shell metacharacters.
	    case $arg in
	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
	      arg="\"$arg\""
	      ;;
	    esac
	    CC_quoted="$CC_quoted $arg"
	  done
	    case "$@ " in
	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
824
825
826
827
828
829
830
831
832
833
834
835
836
	      # The compiler in the base compile command matches
	      # the one in the tagged configuration.
	      # Assume this is the tagged configuration we want.
	      tagname=$z
	      break
	      ;;
	    esac
	  fi
	done
	# If $tagname still isn't set, then no tagged configuration
	# was found and let the user know that the "--tag" command
	# line option must be used.
	if test -z "$tagname"; then
Lynn Garren's avatar
Lynn Garren committed
837
838
839
840
	  func_echo "unable to infer tagged configuration"
	  func_fatal_error "specify a tag with \`--tag'"
#	else
#	  func_verbose "using $tagname tagged configuration"
841
842
843
844
	fi
	;;
      esac
    fi
Lynn Garren's avatar
Lynn Garren committed
845
}
846
847
848



Lynn Garren's avatar
Lynn Garren committed
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
# func_generate_dlsyms outputname originator pic_p
# Extract symbols from dlprefiles and create ${outputname}S.o with
# a dlpreopen symbol table.
func_generate_dlsyms () {
    my_outputname="$1"
    my_originator="$2"
    my_pic_p="${3-no}"
    my_prefix=`echo "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
    my_dlsyms=

    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
      if test -n "$NM" && test -n "$global_symbol_pipe"; then
	my_dlsyms="${my_outputname}S.c"
      else
	func_error "not configured to extract global symbols from dlpreopened files"
      fi
865
866
    fi

Lynn Garren's avatar
Lynn Garren committed
867
868
869
870
871
872
    if test -n "$my_dlsyms"; then
      case $my_dlsyms in
      "") ;;
      *.c)
	# Discover the nlist of each of the dlfiles.
	nlist="$output_objdir/${my_outputname}.nm"
873

Lynn Garren's avatar
Lynn Garren committed
874
875
	$show "$rm $nlist ${nlist}S ${nlist}T"
	$run $rm "$nlist" "${nlist}S" "${nlist}T"
876

Lynn Garren's avatar
Lynn Garren committed
877
878
	# Parse the name list into a source file.
	$show "creating $output_objdir/$my_dlsyms"
879

Lynn Garren's avatar
Lynn Garren committed
880
881
882
	test -z "$run" && $echo > "$output_objdir/$my_dlsyms" "\
/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
883

Lynn Garren's avatar
Lynn Garren committed
884
885
886
#ifdef __cplusplus
extern \"C\" {
#endif
887

Lynn Garren's avatar
Lynn Garren committed
888
889
/* External symbol declarations for the compiler. */\
"
890

Lynn Garren's avatar
Lynn Garren committed
891
892
	if test "$dlself" = yes; then
	  $show "generating symbol list for \`$output'"
893

Lynn Garren's avatar
Lynn Garren committed
894
	  test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
895

Lynn Garren's avatar
Lynn Garren committed
896
897
898
899
900
901
	  # Add our own program objects to the symbol list.
	  progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
	  for progfile in $progfiles; do
	    $show "extracting global C symbols from \`$progfile'"
	    $run eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
	  done
902

Lynn Garren's avatar
Lynn Garren committed
903
904
905
906
	  if test -n "$exclude_expsyms"; then
	    $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
	    $run eval '$mv "$nlist"T "$nlist"'
	  fi
907

Lynn Garren's avatar
Lynn Garren committed
908
909
910
911
	  if test -n "$export_symbols_regex"; then
	    $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
	    $run eval '$mv "$nlist"T "$nlist"'
	  fi
912

Lynn Garren's avatar
Lynn Garren committed
913
914
915
916
917
918
919
920
921
922
	  # Prepare the list of exported symbols
	  if test -z "$export_symbols"; then
	    export_symbols="$output_objdir/$output.exp"
	    $run $rm $export_symbols
	    $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
	  else
	    $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
	    $run eval '$GREP -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
	    $run eval 'mv "$nlist"T "$nlist"'
	  fi
923
924
	fi

Lynn Garren's avatar
Lynn Garren committed
925
926
927
928
929
930
	for dlprefile in $dlprefiles; do
	  $show "extracting global C symbols from \`$dlprefile'"
	  name=`$echo "$dlprefile" | ${SED} -e 's%^.*/%%'`
	  $run eval '$echo ": $name " >> "$nlist"'
	  $run eval "$NM $dlprefile | $global_symbol_pipe >> '$nlist'"
	done
931

Lynn Garren's avatar
Lynn Garren committed
932
933
934
	if test -z "$run"; then
	  # Make sure we have at least an empty file.
	  test -f "$nlist" || : > "$nlist"
935

Lynn Garren's avatar
Lynn Garren committed
936
937
938
939
	  if test -n "$exclude_expsyms"; then
	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
	    $mv "$nlist"T "$nlist"
	  fi
940

Lynn Garren's avatar
Lynn Garren committed
941
942
943
944
945
946
947
948
949
950
951
952
	  # Try sorting and uniquifying the output.
	  if $GREP -v "^: " < "$nlist" |
	      if sort -k 3 </dev/null >/dev/null 2>&1; then
		sort -k 3
	      else
		sort +2
	      fi |
	      uniq > "$nlist"S; then
	    :
	  else
	    $GREP -v "^: " < "$nlist" > "$nlist"S
	  fi
953

Lynn Garren's avatar
Lynn Garren committed
954
955
956
957
958
	  if test -f "$nlist"S; then
	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
	  else
	    $echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
	  fi
959

Lynn Garren's avatar
Lynn Garren committed
960
	  $echo >> "$output_objdir/$my_dlsyms" "\
961

Lynn Garren's avatar
Lynn Garren committed
962
963
964
965
966
967
968
969
970
971
972
973
974
/* The mapping between symbol names and symbols.  */
const struct {
  const char *originator;
  const struct {
    const char *name;
    void *address;
  } symbols[];
}
lt_${my_prefix}_LTX_preloaded_symbols =
{\
  \"$my_originator\",
  {
"
975

Lynn Garren's avatar
Lynn Garren committed
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
	  eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"

	  $echo >> "$output_objdir/$my_dlsyms" "\
  {0, (void *) 0}
  }
};

/* This works around a problem in FreeBSD linker */
#ifdef FREEBSD_WORKAROUND
static const void *lt_preloaded_setup() {
  return lt_${my_prefix}_LTX_preloaded_symbols;
}
#endif

#ifdef __cplusplus
}
#endif\
"
994
995
	fi

Lynn Garren's avatar
Lynn Garren committed
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
  	pic_flag_for_symtable=
	case "$compile_command " in
	*" -static "*) ;;
	*)
	  case $host in
	  # compiling the symbol table file with pic_flag works around
	  # a FreeBSD bug that causes programs to crash when -lm is
	  # linked before any other PIC object.  But we must not use
	  # pic_flag when linking with -static.  The problem exists in
	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
	  *-*-hpux*)
	    pic_flag_for_symtable=" $pic_flag"  ;;
	  *)
	    if test "X$my_pic_p" != Xno; then
	      pic_flag_for_symtable=" $pic_flag"
	    fi
	    ;;
	  esac
	  ;;
	esac
1018

Lynn Garren's avatar
Lynn Garren committed
1019
1020
1021
	# Now compile the dynamic symbol file.
	$show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$my_dlsyms\")"
	$run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' || exit $?
1022

Lynn Garren's avatar
Lynn Garren committed
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
	# Clean up the generated files.
	$show "$rm $output_objdir/$my_dlsyms $nlist ${nlist}S ${nlist}T"
	$run $rm "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"

	# Transform the symbol file into the correct name.
	symfileobj="$output_objdir/${my_outputname}S.$objext"
	compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
	;;
      *)
	func_fatal_error "unknown suffix for \`$my_dlsyms'"
	;;
      esac
1036
    else
Lynn Garren's avatar
Lynn Garren committed
1037
1038
1039
      # We keep going just in case the user didn't refer to
      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
      # really was required.
1040

Lynn Garren's avatar
Lynn Garren committed
1041
1042
1043
      # Nullify the symbol file.
      compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
      finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
1044
    fi
Lynn Garren's avatar
Lynn Garren committed
1045
}
1046
1047
1048



Lynn Garren's avatar
Lynn Garren committed
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
# func_extract_archives gentop oldlib ...
func_extract_archives () {
    my_gentop="$1"; shift
    my_oldlibs=${1+"$@"}
    my_oldobjs=""
    my_xlib=""
    my_xabs=""
    my_xdir=""
    my_status=""

    $show "${rm}r $my_gentop"
    $run ${rm}r "$my_gentop"
    $show "$mkdir $my_gentop"
    $run $mkdir "$my_gentop"
    my_status=$?
    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
      exit $my_status
    fi
1067

Lynn Garren's avatar
Lynn Garren committed
1068
1069
1070
1071
1072
1073
1074
1075
    for my_xlib in $my_oldlibs; do
      # Extract the objects.
      case $my_xlib in
	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
	*) my_xabs=`pwd`"/$my_xlib" ;;
      esac
      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
      my_xdir="$my_gentop/$my_xlib"
1076

Lynn Garren's avatar
Lynn Garren committed
1077
1078
1079
1080
1081
1082
1083
      $show "${rm}r $my_xdir"
      $run ${rm}r "$my_xdir"
      $show "$mkdir $my_xdir"
      $run $mkdir "$my_xdir"
      status=$?
      if test "$status" -ne 0 && test ! -d "$my_xdir"; then
	exit $status
1084
      fi
Lynn Garren's avatar
Lynn Garren committed
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
      case $host in
      *-darwin*)
	$show "Extracting $my_xabs"
	# Do not bother doing anything if just a dry run
	if test -z "$run"; then
	  darwin_orig_dir=`pwd`
	  cd $my_xdir || exit $?
	  darwin_archive=$my_xabs
	  darwin_curdir=`pwd`
	  darwin_base_archive=`basename $darwin_archive`
	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null`
	  if test -n "$darwin_arches"; then
	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
	    darwin_arch=
	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
	    for darwin_arch in  $darwin_arches ; do
	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
	      # Remove the table of contents from the thin files.
	      $AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF 2>/dev/null || true
	      $AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF\ SORTED 2>/dev/null || true
	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
	      $AR -xo "${darwin_base_archive}"
	      rm "${darwin_base_archive}"
	      cd "$darwin_curdir"
	    done # $darwin_arches
      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
	    darwin_filelist=`find unfat-$$ -type f | xargs basename | sort -u | $NL2SP`
	    darwin_file=
	    darwin_files=
	    for darwin_file in $darwin_filelist; do
	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
	      lipo -create -output "$darwin_file" $darwin_files
	    done # $darwin_filelist
	    rm -rf unfat-$$
	    cd "$darwin_orig_dir"
	  else
	    cd $darwin_orig_dir
	    (cd $my_xdir && $AR x $my_xabs) || exit $?
	  fi # $darwin_arches
	fi # $run
      ;;
      *)
	# We will extract separately just the conflicting names and we will
	# no longer touch any unique names. It is faster to leave these
	# extract automatically by $AR in one run.
	$show "(cd $my_xdir && $AR x $my_xabs)"
	$run eval "(cd \$my_xdir && $AR x \$my_xabs)" || exit $?
	if ($AR t "$my_xabs" | sort | sort -uc >/dev/null 2>&1); then
	  :
1135
	else
Lynn Garren's avatar
Lynn Garren committed
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
	  func_warning "object name conflicts; renaming object files"
	  func_warning "to ensure that they will not overwrite"
	  $AR t "$my_xabs" | sort | uniq -cd | while read -r count name
	  do
	    i=1
	    while test "$i" -le "$count"
	    do
	      # Put our $i before any first dot (extension)
	      # Never overwrite any file
	      name_to="$name"
	      while test "X$name_to" = "X$name" || test -f "$my_xdir/$name_to"
	      do
		name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
	      done
	      $show "(cd $my_xdir && $AR xN $i $my_xabs '$name' && $mv '$name' '$name_to')"
	      $run eval "(cd \$my_xdir && $AR xN $i \$my_xabs '$name' && $mv '$name' '$name_to')" || exit $?
	      i=`expr $i + 1`
	    done
	  done
1155
	fi
Lynn Garren's avatar
Lynn Garren committed
1156
1157
1158
1159
	;;
      esac
      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
    done
1160

Lynn Garren's avatar
Lynn Garren committed
1161
1162
    func_extract_archives_result="$my_oldobjs"
}
1163
1164


Lynn Garren's avatar
Lynn Garren committed
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
# func_mode_compile arg...
func_mode_compile ()
{
    # Get the compilation command and the source file.
    base_compile=
    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
    suppress_opt=yes
    suppress_output=
    arg_mode=normal
    libobj=
    later=
1176
1177
1178

    for arg
    do
Lynn Garren's avatar
Lynn Garren committed
1179
1180
1181
1182
1183
      case "$arg_mode" in
      arg  )
	# do not "continue".  Instead, add this to base_compile
	lastarg="$arg"
	arg_mode=normal
1184
1185
	;;

Lynn Garren's avatar
Lynn Garren committed
1186
1187
1188
1189
      target )
	libobj="$arg"
	arg_mode=normal
	continue
1190
1191
	;;

Lynn Garren's avatar
Lynn Garren committed
1192
1193
1194
1195
1196
1197
1198
      normal )
	# Accept any command-line options.
	case $arg in
	-o)
	  test -n "$libobj" && \
	    func_fatal_error "you cannot specify \`-o' more than once"
	  arg_mode=target
1199
1200
	  continue
	  ;;
Lynn Garren's avatar
Lynn Garren committed
1201
1202
1203

	-shared | -static | -prefer-pic | -prefer-non-pic)
	  later="$later $arg"
1204
1205
	  continue
	  ;;
Lynn Garren's avatar
Lynn Garren committed
1206
1207
1208

	-no-suppress)
	  suppress_opt=no
1209
1210
	  continue
	  ;;
Lynn Garren's avatar
Lynn Garren committed
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238

	-Xcompiler)
	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
	  continue      #  The current "srcfile" will either be retained or
	  ;;            #  replaced later.  I would guess that would be a bug.

	-Wc,*)
	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
	  lastarg=
	  save_ifs="$IFS"; IFS=','
	  for arg in $args; do
	    IFS="$save_ifs"

	    # Double-quote args containing other shell metacharacters.
	    # Many Bourne shells cannot handle close brackets correctly
	    # in scan sets, so we specify it separately.
	    case $arg in
	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
	      arg="\"$arg\""
	      ;;
	    esac
	    lastarg="$lastarg $arg"
	  done
	  IFS="$save_ifs"
	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`

	  # Add the arguments to base_compile.
	  base_compile="$base_compile $lastarg"
1239
1240
1241
	  continue
	  ;;

Lynn Garren's avatar
Lynn Garren committed
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
	*)
	  # Accept the current argument as the source file.
	  # The previous "srcfile" becomes the current argument.
	  #
	  lastarg="$srcfile"
	  srcfile="$arg"
	  ;;
	esac  #  case $arg
	;;
      esac    #  case $arg_mode
1252

Lynn Garren's avatar
Lynn Garren committed
1253
1254
      # Aesthetically quote the previous argument.
      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
1255

Lynn Garren's avatar
Lynn Garren committed
1256
1257
1258
1259
1260
1261
1262
1263
      case $lastarg in
      # Double-quote args containing other shell metacharacters.
      # Many Bourne shells cannot handle close brackets correctly
      # in scan sets, so we specify it separately.
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
	lastarg="\"$lastarg\""
	;;
      esac
1264

Lynn Garren's avatar
Lynn Garren committed
1265
1266
      base_compile="$base_compile $lastarg"
    done # for arg
1267

Lynn Garren's avatar
Lynn Garren committed
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
    case $arg_mode in
    arg)
      func_fatal_error "you must specify an argument for -Xcompile"
      ;;
    target)
      func_fatal_error "you must specify a target with \`-o'"
      ;;
    *)
      # Get the name of the library object.
      test -z "$libobj" && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
      ;;
    esac
1280

Lynn Garren's avatar
Lynn Garren committed
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
    # Recognize several different file suffixes.
    # If the user specifies -o file.o, it is replaced with file.lo
    xform='[cCFSifmso]'
    case $libobj in
    *.ada) xform=ada ;;
    *.adb) xform=adb ;;
    *.ads) xform=ads ;;
    *.asm) xform=asm ;;
    *.c++) xform=c++ ;;
    *.cc) xform=cc ;;
    *.ii) xform=ii ;;
    *.class) xform=class ;;
    *.cpp) xform=cpp ;;
    *.cxx) xform=cxx ;;
    *.f90) xform=f90 ;;
    *.for) xform=for ;;
    *.java) xform=java ;;
    esac
1299

Lynn Garren's avatar
Lynn Garren committed
1300
    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
1301

Lynn Garren's avatar
Lynn Garren committed
1302
1303
1304
1305
1306
1307
    case $libobj in
    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
    *)
      func_fatal_error "cannot determine name of library object from \`$libobj'"
      ;;
    esac
1308

Lynn Garren's avatar
Lynn Garren committed
1309
    func_infer_tag $base_compile
1310

Lynn Garren's avatar
Lynn Garren committed
1311
    for arg in $later; do
1312
      case $arg in
Lynn Garren's avatar
Lynn Garren committed
1313
1314
1315
1316
      -shared)
	test "$build_libtool_libs" != yes && \
	  func_fatal_configuration "can not build a shared library"
	build_old_libs=no
1317
1318
1319
	continue
	;;

Lynn Garren's avatar
Lynn Garren committed
1320
1321
1322
      -static)
	build_libtool_libs=no
	build_old_libs=yes
1323
1324
1325
	continue
	;;

Lynn Garren's avatar
Lynn Garren committed
1326
1327
      -prefer-pic)
	pic_mode=yes
1328
1329
1330
	continue
	;;

Lynn Garren's avatar
Lynn Garren committed
1331
1332
      -prefer-non-pic)
	pic_mode=no
1333
1334
	continue
	;;
Lynn Garren's avatar
Lynn Garren committed
1335
1336
      esac
    done
1337

Lynn Garren's avatar
Lynn Garren committed
1338
1339
1340
1341
1342
1343
1344
1345
    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
    if test "X$xdir" = "X$obj"; then
      xdir=
    else
      xdir=$xdir/
    fi
    lobj=${xdir}$objdir/$objname
1346

Lynn Garren's avatar
Lynn Garren committed
1347
1348
    test -z "$base_compile" && \
      func_fatal_help "you must specify a compilation command"
1349

Lynn Garren's avatar
Lynn Garren committed
1350
1351
1352
1353
1354
1355
    # Delete any leftover library objects.
    if test "$build_old_libs" = yes; then
      removelist="$obj $lobj $libobj ${libobj}T"
    else
      removelist="$lobj $libobj ${libobj}T"
    fi
1356

Lynn Garren's avatar
Lynn Garren committed
1357
1358
    $run $rm $removelist
    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
1359

Lynn Garren's avatar
Lynn Garren committed
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
    # On Cygwin there's no "real" PIC flag so we must build both object types
    case $host_os in
    cygwin* | mingw* | pw32* | os2*)
      pic_mode=default
      ;;
    esac
    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
      # non-PIC code in shared libraries is not supported
      pic_mode=default
    fi
1370

Lynn Garren's avatar
Lynn Garren committed
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
    # Calculate the filename of the output object if compiler does
    # not support -o with -c
    if test "$compiler_c_o" = no; then
      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
      lockfile="$output_obj.lock"
      removelist="$removelist $output_obj $lockfile"
      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
    else
      output_obj=
      need_locks=no
      lockfile=
    fi
1383

Lynn Garren's avatar
Lynn Garren committed
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
    # Lock this critical section if it is needed
    # We use this script file to make the link, it avoids creating a new file
    if test "$need_locks" = yes; then
      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
	$show "Waiting for $lockfile to be removed"
	sleep 2
      done
    elif test "$need_locks" = warn; then
      if test -f "$lockfile"; then
	$echo "\
*** ERROR, $lockfile exists and contains:
`cat $lockfile 2>/dev/null`
1396

Lynn Garren's avatar
Lynn Garren committed
1397
1398
1399
1400
1401
1402
This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together.  If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."
1403

Lynn Garren's avatar
Lynn Garren committed
1404
1405
1406
1407
1408
	$run $rm $removelist
	exit $EXIT_FAILURE
      fi
      $echo $srcfile > "$lockfile"
    fi
1409

Lynn Garren's avatar
Lynn Garren committed
1410
1411
1412
    if test -n "$fix_srcfile_path"; then
      eval srcfile=\"$fix_srcfile_path\"
    fi
1413

Lynn Garren's avatar
Lynn Garren committed
1414
    $run $rm "$libobj" "${libobj}T"
1415

Lynn Garren's avatar
Lynn Garren committed
1416
1417
1418
1419
1420
1421
1422
1423
    # Create a libtool object file (analogous to a ".la" file),
    # but don't create it if we're doing a dry run.
    test -z "$run" && cat > ${libobj}T <<EOF
# $libobj - a libtool object file
# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
1424

Lynn Garren's avatar
Lynn Garren committed
1425
1426
# Name of the PIC object.
EOF
1427

Lynn Garren's avatar
Lynn Garren committed
1428
1429
1430
1431
    # Only build a PIC object if we are building libtool libraries.
    if test "$build_libtool_libs" = yes; then
      # Without this assignment, base_compile gets emptied.
      fbsd_hideous_sh_bug=$base_compile
1432

Lynn Garren's avatar
Lynn Garren committed
1433
1434
1435
1436
1437
1438
      if test "$pic_mode" != no; then
	command="$base_compile $srcfile $pic_flag"
      else
	# Don't build PIC code
	command="$base_compile $srcfile"
      fi
1439

Lynn Garren's avatar
Lynn Garren committed
1440
1441
1442
1443
1444
1445
1446
1447
      if test ! -d "${xdir}$objdir"; then
	$show "$mkdir ${xdir}$objdir"
	$run $mkdir ${xdir}$objdir
	status=$?
	if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then
	  exit $status
	fi
      fi
1448

Lynn Garren's avatar
Lynn Garren committed
1449
1450
1451
1452
      if test -z "$output_obj"; then
	# Place PIC objects in $objdir
	command="$command -o $lobj"
      fi
1453

Lynn Garren's avatar
Lynn Garren committed
1454
      $run $rm "$lobj" "$output_obj"
1455

Lynn Garren's avatar
Lynn Garren committed
1456
1457
1458
1459
1460
1461
      $show "$command"
      if $run eval "$command"; then :
      else
	test -n "$output_obj" && $run $rm $removelist
	exit $EXIT_FAILURE
      fi
1462

Lynn Garren's avatar
Lynn Garren committed
1463
1464
1465
1466
1467
      if test "$need_locks" = warn &&
	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
	$echo "\
*** ERROR, $lockfile contains:
`cat $lockfile 2>/dev/null`
1468

Lynn Garren's avatar
Lynn Garren committed
1469
1470
but it should contain:
$srcfile
1471

Lynn Garren's avatar
Lynn Garren committed
1472
1473
1474
1475
1476
1477
This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together.  If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."
1478

Lynn Garren's avatar
Lynn Garren committed
1479
1480
1481
	$run $rm $removelist
	exit $EXIT_FAILURE
      fi
1482

Lynn Garren's avatar
Lynn Garren committed
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
      # Just move the object if needed, then go on to compile the next one
      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
	$show "$mv $output_obj $lobj"
	if $run $mv $output_obj $lobj; then :
	else
	  error=$?
	  $run $rm $removelist
	  exit $error
	fi
      fi
1493

Lynn Garren's avatar
Lynn Garren committed
1494
1495
1496
      # Append the name of the PIC object to the libtool object file.
      test -z "$run" && cat >> ${libobj}T <<EOF
pic_object='$objdir/$objname'
1497

Lynn Garren's avatar
Lynn Garren committed
1498
EOF
1499

Lynn Garren's avatar
Lynn Garren committed
1500
1501
1502
1503
1504
1505
1506
1507
1508
      # Allow error messages only from the first compilation.
      if test "$suppress_opt" = yes; then
	suppress_output=' >/dev/null 2>&1'
      fi
    else
      # No PIC object so indicate it doesn't exist in the libtool
      # object file.
      test -z "$run" && cat >> ${libobj}T <<EOF
pic_object=none
1509

Lynn Garren's avatar
Lynn Garren committed
1510
1511
EOF
    fi
1512

Lynn Garren's avatar
Lynn Garren committed
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
    # Only build a position-dependent object if we build old libraries.
    if test "$build_old_libs" = yes; then
      if test "$pic_mode" != yes; then
	# Don't build PIC code
	command="$base_compile $srcfile"
      else
	command="$base_compile $srcfile $pic_flag"
      fi
      if test "$compiler_c_o" = yes; then
	command="$command -o $obj"
      fi
1524

Lynn Garren's avatar
Lynn Garren committed
1525
1526
1527
1528
1529
1530
1531
1532
1533
      # Suppress compiler output if we already did a PIC compilation.
      command="$command$suppress_output"
      $run $rm "$obj" "$output_obj"
      $show "$command"
      if $run eval "$command"; then :
      else
	$run $rm $removelist
	exit $EXIT_FAILURE
      fi
1534

Lynn Garren's avatar
Lynn Garren committed
1535
1536
1537
1538
1539
      if test "$need_locks" = warn &&
	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
	$echo "\
*** ERROR, $lockfile contains:
`cat $lockfile 2>/dev/null`
1540

Lynn Garren's avatar
Lynn Garren committed
1541
1542
but it should contain:
$srcfile
1543

Lynn Garren's avatar
Lynn Garren committed
1544
1545
1546
1547
1548
1549
This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together.  If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."
1550

Lynn Garren's avatar
Lynn Garren committed
1551
1552
1553
	$run $rm $removelist
	exit $EXIT_FAILURE
      fi
1554

Lynn Garren's avatar
Lynn Garren committed
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
      # Just move the object if needed
      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
	$show "$mv $output_obj $obj"
	if $run $mv $output_obj $obj; then :
	else
	  error=$?
	  $run $rm $removelist
	  exit $error
	fi
      fi
1565

Lynn Garren's avatar
Lynn Garren committed
1566
1567
1568
1569
1570
      # Append the name of the non-PIC object the libtool object file.
      # Only append if the libtool object file exists.
      test -z "$run" && cat >> ${libobj}T <<EOF
# Name of the non-PIC object.
non_pic_object='$objname'
1571

Lynn Garren's avatar
Lynn Garren committed
1572
1573
1574
1575
1576
1577
1578
EOF
    else
      # Append the name of the non-PIC object the libtool object file.
      # Only append if the libtool object file exists.
      test -z "$run" && cat >> ${libobj}T <<EOF
# Name of the non-PIC object.
non_pic_object=none
1579

Lynn Garren's avatar
Lynn Garren committed
1580
1581
EOF
    fi
1582

Lynn Garren's avatar
Lynn Garren committed
1583
    $run $mv "${libobj}T" "${libobj}"
1584

Lynn Garren's avatar
Lynn Garren committed
1585
1586
1587
1588
    # Unlock the critical section if it was locked
    if test "$need_locks" != no; then
      $run $rm "$lockfile"
    fi
1589

Lynn Garren's avatar
Lynn Garren committed
1590
1591
    exit $EXIT_SUCCESS
}
1592
1593


Lynn Garren's avatar
Lynn Garren committed
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
# func_mode_execute arg...
func_mode_execute ()