* libltdl/config/ltmain.m4sh (link mode): Pass through -isysroot
[libtool.git] / libltdl / config / ltmain.m4sh
blobcbeebfcd4361a44ee0238024329ecf39874912eb
1 m4_define([_m4_divert(SCRIPT)], 100)
2 m4_divert_push([SCRIPT])# @configure_input@
4 # ltmain.sh (GNU @PACKAGE@@TIMESTAMP@) @VERSION@
5 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
7 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
8 # This is free software; see the source for copying conditions.  There is NO
9 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 # General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 # As a special exception to the GNU General Public License, if you
26 # distribute this file as part of a program that contains a
27 # configuration script generated by Autoconf, you may include it under
28 # the same distribution terms that you use for the rest of that program.
30 # Usage: $progname [OPTION]... [MODE-ARG]...
32 # Provide generalized library-building support services.
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 #     --tag=TAG            use configuration variables from tag TAG
42 # -v, --verbose            print informational messages (default)
43 #     --version            print version information
44 # -h, --help               print short or long help message
46 # MODE must be one of the following:
48 #       clean              remove files from the build directory
49 #       compile            compile a source file into a libtool object
50 #       execute            automatically set library path, then run a program
51 #       finish             complete the installation of libtool libraries
52 #       install            install libraries or executables
53 #       link               create a library or an executable
54 #       uninstall          remove libraries from an installed directory
56 # MODE-ARGS vary depending on the MODE.
57 # Try `$progname --help --mode=MODE' for a more detailed description of MODE.
59 # When reporting a bug, please describe a test case to reproduce it and
60 # include the following information:
62 #       host-triplet:   @host_triplet@
63 #       shell:          $SHELL
64 #       compiler:               $LTCC
65 #       compiler flags:         $LTCFLAGS
66 #       linker:         $LD (gnu? $with_gnu_ld)
67 #       $progname:              (GNU @PACKAGE@@TIMESTAMP@) @VERSION@
68 #       automake:               $automake_version
69 #       autoconf:               $autoconf_version
71 # Report bugs to <bug-libtool@gnu.org>.
73 PROGRAM=ltmain.sh
74 PACKAGE=@PACKAGE@
75 VERSION=@VERSION@
76 TIMESTAMP="@TIMESTAMP@"
77 package_revision=@package_revision@
79 AS_SHELL_SANITIZE
80 $as_unset CDPATH
82 m4_include([getopt.m4sh])
84 # Check that we have a working $ECHO.
85 if test "X$1" = X--no-reexec; then
86   # Discard the --no-reexec flag, and continue.
87   shift
88 elif test "X$1" = X--fallback-echo; then
89   # Avoid inline document here, it may be left over
90   :
91 elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
92   # Yippee, $ECHO works!
93   :
94 else
95   # Restart under the correct shell, and then maybe $ECHO will work.
96   exec $SHELL "$progpath" --no-reexec ${1+"$@"}
99 if test "X$1" = X--fallback-echo; then
100   # used as fallback echo
101   shift
102   cat <<EOF
105   exit $EXIT_SUCCESS
108 magic="%%%MAGIC variable%%%"
111 # Global variables.
112 # $mode is unset
113 nonopt=
114 execute_dlfiles=
115 lo2o="s/\\.lo\$/.${objext}/"
116 o2lo="s/\\.${objext}\$/.lo/"
118 opt_dry_run=false
119 opt_duplicate_deps=false
120 opt_silent=false
121 opt_debug=:
123 # If this variable is set in any of the actions, the command in it
124 # will be execed at the end.  This prevents here-documents from being
125 # left over by shells.
126 exec_cmd=
128 # func_fatal_configuration arg...
129 # Echo program name prefixed message to standard error, followed by
130 # a configuration failure hint, and exit.
131 func_fatal_configuration ()
133     func_error ${1+"$@"}
134     func_error "See the $PACKAGE documentation for more information."
135     func_fatal_error "Fatal configuration error."
139 # func_config
140 # Display the configuration for all the tags in this script.
141 func_config ()
143     re_begincf='^# ### BEGIN LIBTOOL'
144     re_endcf='^# ### END LIBTOOL'
146     # Default configuration.
147     $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
149     # Now print the configurations for the tags.
150     for tagname in $taglist; do
151       $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
152     done
154     exit $?
157 # func_features
158 # Display the features supported by this script.
159 func_features ()
161     $ECHO "host: $host"
162     if test "$build_libtool_libs" = yes; then
163       $ECHO "enable shared libraries"
164     else
165       $ECHO "disable shared libraries"
166     fi
167     if test "$build_old_libs" = yes; then
168       $ECHO "enable static libraries"
169     else
170       $ECHO "disable static libraries"
171     fi
173     exit $?
176 # func_enable_tag tagname
177 # Verify that TAGNAME is valid, and either flag an error and exit, or
178 # enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
179 # variable here.
180 func_enable_tag ()
182   # Global variable:
183   tagname="$1"
185   re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
186   re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
187   sed_extractcf="/$re_begincf/,/$re_endcf/p"
189   # Validate tagname.
190   case $tagname in
191     *[[!-_A-Za-z0-9,/]]*)
192       func_fatal_error "invalid tag name: $tagname"
193       ;;
194   esac
196   # Don't test for the "default" C tag, as we know it's
197   # there but not specially marked.
198   case $tagname in
199     CC) ;;
200     *)
201       if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
202         taglist="$taglist $tagname"
204         # Evaluate the configuration.  Be careful to quote the path
205         # and the sed script, to avoid splitting on whitespace, but
206         # also don't use non-portable quotes within backquotes within
207         # quotes we have to do it in 2 steps:
208         extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
209         eval "$extractedcf"
210       else
211         func_error "ignoring unknown tag $tagname"
212       fi
213       ;;
214   esac
218 func_mode_help ()
220     # We need to display help for each of the modes.
221     case $mode in
222       "")
223         # Generic help is extracted from the usage comments
224         # at the start of this file.
225         func_help
226         ;;
228       clean)
229         $ECHO \
230 "Usage: $progname [[OPTION]]... --mode=clean RM [[RM-OPTION]]... FILE...
232 Remove files from the build directory.
234 RM is the name of the program to use to delete files associated with each FILE
235 (typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
236 to RM.
238 If FILE is a libtool library, object or program, all the files associated
239 with it are deleted. Otherwise, only FILE itself is deleted using RM."
240         ;;
242       compile)
243       $ECHO \
244 "Usage: $progname [[OPTION]]... --mode=compile COMPILE-COMMAND... SOURCEFILE
246 Compile a source file into a libtool library object.
248 This mode accepts the following additional options:
250   -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
251   -no-suppress      do not suppress compiler output for multiple passes
252   -prefer-pic       try to building PIC objects only
253   -prefer-non-pic   try to building non-PIC objects only
254   -shared           do not build a \`.o' file suitable for static linking
255   -static           only build a \`.o' file suitable for static linking
257 COMPILE-COMMAND is a command to be used in creating a \`standard' object file
258 from the given SOURCEFILE.
260 The output file name is determined by removing the directory component from
261 SOURCEFILE, then substituting the C source code suffix \`.c' with the
262 library object suffix, \`.lo'."
263         ;;
265       execute)
266         $ECHO \
267 "Usage: $progname [[OPTION]]... --mode=execute COMMAND [[ARGS]]...
269 Automatically set library path, then run a program.
271 This mode accepts the following additional options:
273   -dlopen FILE      add the directory containing FILE to the library path
275 This mode sets the library path environment variable according to \`-dlopen'
276 flags.
278 If any of the ARGS are libtool executable wrappers, then they are translated
279 into their corresponding uninstalled binary, and any of their required library
280 directories are added to the library path.
282 Then, COMMAND is executed, with ARGS as arguments."
283         ;;
285       finish)
286         $ECHO \
287 "Usage: $progname [[OPTION]]... --mode=finish [[LIBDIR]]...
289 Complete the installation of libtool libraries.
291 Each LIBDIR is a directory that contains libtool libraries.
293 The commands that this mode executes may require superuser privileges.  Use
294 the \`--dry-run' option if you just want to see what would be executed."
295         ;;
297       install)
298         $ECHO \
299 "Usage: $progname [[OPTION]]... --mode=install INSTALL-COMMAND...
301 Install executables or libraries.
303 INSTALL-COMMAND is the installation command.  The first component should be
304 either the \`install' or \`cp' program.
306 The following components of INSTALL-COMMAND are treated specially:
308   -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
310 The rest of the components are interpreted as arguments to that command (only
311 BSD-compatible install options are recognized)."
312         ;;
314       link)
315         $ECHO \
316 "Usage: $progname [[OPTION]]... --mode=link LINK-COMMAND...
318 Link object files or libraries together to form another library, or to
319 create an executable program.
321 LINK-COMMAND is a command using the C compiler that you would use to create
322 a program from several object files.
324 The following components of LINK-COMMAND are treated specially:
326   -all-static       do not do any dynamic linking at all
327   -avoid-version    do not add a version suffix if possible
328   -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
329   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
330   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
331   -export-symbols SYMFILE
332                     try to export only the symbols listed in SYMFILE
333   -export-symbols-regex REGEX
334                     try to export only the symbols matching REGEX
335   -LLIBDIR          search LIBDIR for required installed libraries
336   -lNAME            OUTPUT-FILE requires the installed library libNAME
337   -module           build a library that can dlopened
338   -no-fast-install  disable the fast-install mode
339   -no-install       link a not-installable executable
340   -no-undefined     declare that a library does not refer to external symbols
341   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
342   -objectlist FILE  Use a list of object files found in FILE to specify objects
343   -precious-files-regex REGEX
344                     don't remove output files matching REGEX
345   -release RELEASE  specify package release information
346   -rpath LIBDIR     the created library will eventually be installed in LIBDIR
347   -R[[ ]]LIBDIR       add LIBDIR to the runtime path of programs and libraries
348   -shared           only do dynamic linking of libtool libraries
349   -shrext SUFFIX    override the standard shared library file extension
350   -static           do not do any dynamic linking of libtool libraries
351   -version-info CURRENT[[:REVISION[:AGE]]]
352                     specify library version info [[each variable defaults to 0]]
353   -weak LIBNAME     declare that the target provides the LIBNAME interface
355 All other options (arguments beginning with \`-') are ignored.
357 Every other argument is treated as a filename.  Files ending in \`.la' are
358 treated as uninstalled libtool libraries, other files are standard or library
359 object files.
361 If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
362 only library objects (\`.lo' files) may be specified, and \`-rpath' is
363 required, except when creating a convenience library.
365 If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
366 using \`ar' and \`ranlib', or on Windows using \`lib'.
368 If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
369 is created, otherwise an executable program is created."
370         ;;
372       uninstall)
373         $ECHO \
374 "Usage: $progname [[OPTION]]... --mode=uninstall RM [[RM-OPTION]]... FILE...
376 Remove libraries from an installation directory.
378 RM is the name of the program to use to delete files associated with each FILE
379 (typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
380 to RM.
382 If FILE is a libtool library, all the files associated with it are deleted.
383 Otherwise, only FILE itself is deleted using RM."
384         ;;
386       *)
387         func_fatal_help "invalid operation mode \`$mode'"
388         ;;
389     esac
391     $ECHO
392     $ECHO "Try \`$progname --help' for more information about other modes."
394     exit $?
397 # TEST SUITE MARKER ## NON-FUNCTION
398 # Parse options once, thoroughly.  This comes as soon as possible in
399 # the script to make things like `libtool --version' happen quickly.
401   # sed scripts:
402   my_sed_single_opt='1s/^\(..\).*$/\1/;q'
403   my_sed_single_rest='1s/^..\(.*\)$/\1/;q'
404   my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
405   my_sed_long_arg='1s/^-[[^=]]*=//'
407   # Shorthand for --mode=foo, only valid as the first argument
408   case $1 in
409   clean|clea|cle|cl)
410     shift; set dummy --mode clean ${1+"$@"}; shift
411     ;;
412   compile|compil|compi|comp|com|co|c)
413     shift; set dummy --mode compile ${1+"$@"}; shift
414     ;;
415   execute|execut|execu|exec|exe|ex|e)
416     shift; set dummy --mode execute ${1+"$@"}; shift
417     ;;
418   finish|finis|fini|fin|fi|f)
419     shift; set dummy --mode finish ${1+"$@"}; shift
420     ;;
421   install|instal|insta|inst|ins|in|i)
422     shift; set dummy --mode install ${1+"$@"}; shift
423     ;;
424   link|lin|li|l)
425     shift; set dummy --mode link ${1+"$@"}; shift
426     ;;
427   uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
428     shift; set dummy --mode uninstall ${1+"$@"}; shift
429     ;;
430   esac
432   # Parse non-mode specific arguments:
433   while test "$#" -gt 0; do
434     opt="$1"
435     shift
437     case $opt in
438       --config)         func_config                                     ;;
440       --debug)          preserve_args="$preserve_args $opt"
441                         func_echo "enabling shell trace mode"
442                         opt_debug='set -x'
443                         $opt_debug
444                         ;;
446       -dlopen)          test "$#" -eq 0 && func_missing_arg "$opt" && break
447                         execute_dlfiles="$execute_dlfiles $1"
448                         shift
449                         ;;
451       --dry-run | -n)   opt_dry_run=:                                   ;;
452       --features)       func_features                                   ;;
453       --finish)         mode="finish"                                   ;;
455       --mode)           test "$#" -eq 0 && func_missing_arg "$opt" && break
456                         case $1 in
457                           # Valid mode arguments:
458                           clean)        ;;
459                           compile)      ;;
460                           execute)      ;;
461                           finish)       ;;
462                           install)      ;;
463                           link)         ;;
464                           relink)       ;;
465                           uninstall)    ;;
467                           # Catch anything else as an error
468                           *) func_error "invalid argument for $opt"
469                              exit_cmd=exit
470                              break
471                              ;;
472                         esac
474                         mode="$1"
475                         shift
476                         ;;
478       --preserve-dup-deps)
479                         opt_duplicate_deps=:                            ;;
481       --quiet|--silent) preserve_args="$preserve_args $opt"
482                         opt_silent=:
483                         ;;
485       --verbose| -v)    preserve_args="$preserve_args $opt"
486                         opt_silent=false
487                         ;;
489       --tag)            test "$#" -eq 0 && func_missing_arg "$opt" && break
490                         preserve_args="$preserve_args $opt $1"
491                         func_enable_tag "$1"    # tagname is set here
492                         shift
493                         ;;
495       # Separate optargs to long options:
496       -dlopen=*|--mode=*|--tag=*)
497                         arg=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_arg"`
498                         opt=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_opt"`
499                         set dummy "$opt" "$arg" ${1+"$@"}
500                         shift
501                         ;;
503       # Separate optargs to short options:
504 #      -x*|-y*)
505 #                       arg=`$ECHO "X$opt" |$Xsed -e "$my_sed_single_rest"`
506 #                       opt=`$ECHO "X$opt" |$Xsed -e "$my_sed_single_opt"`
507 #                       set dummy "$opt" "$arg" ${1+"$@"}
508 #                       shift
509 #                       ;;
511       # Separate non-argument short options:
512 #      -z*|-z*|-y*)
513 #                       rest=`$ECHO "X$opt" |$Xsed -e "$my_sed_single_rest"`
514 #                       opt=`$ECHO "X$opt" |$Xsed -e "$my_sed_single_opt"`
515 #                       set dummy "$opt" "-$rest" ${1+"$@"}
516 #                       shift
517 #                       ;;
519       -\?|-h)           func_usage                                      ;;
520       --help)           opt_help=:                                      ;;
521       --version)        func_version                                    ;;
523       -*)               func_fatal_help "unrecognized option \`$opt'"   ;;
525       *)                nonopt="$opt"
526                         break
527                         ;;
528     esac
529   done
531   # Now that we've collected a possible --mode arg, show help if necessary
532   $opt_help && func_mode_help
534   case $host in
535     *cygwin* | *mingw* | *pw32*)
536       # don't eliminate duplications in $postdeps and $predeps
537       opt_duplicate_compiler_generated_deps=:
538       ;;
539     *)
540       opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
541       ;;
542   esac
544   # Having warned about all mis-specified options, bail out if
545   # anything was wrong.
546   $exit_cmd $EXIT_FAILURE
548 # TEST SUITE MARKER ## BEGIN SOURCABLE
550 # func_check_version_match
551 # Ensure that we are using m4 macros, and libtool script from the same
552 # release of libtool.
553 func_check_version_match ()
555   if test "$package_revision" != "$macro_revision"; then
556     if test "$VERSION" != "$macro_version"; then
557       if test -z "$macro_version"; then
558         cat >&2 <<_LT_EOF
559 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
560 $progname: definition of this LT_INIT comes from an older release.
561 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
562 $progname: and run autoconf again.
563 _LT_EOF
564       else
565         cat >&2 <<_LT_EOF
566 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
567 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
568 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
569 $progname: and run autoconf again.
570 _LT_EOF
571       fi
572     else
573       cat >&2 <<_LT_EOF
574 $progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
575 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
576 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
577 $progname: of $PACKAGE $VERSION and run autoconf again.
578 _LT_EOF
579     fi
581     exit $EXIT_MISMATCH
582   fi
586 # func_lalib_p file
587 # True iff FILE is a libtool `.la' library or `.lo' object file.
588 # This function is only a basic sanity check; it will hardly flush out
589 # determined imposters.
590 func_lalib_p ()
592     $SED -e 4q "$1" 2>/dev/null \
593       | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
596 # func_lalib_unsafe_p file
597 # True iff FILE is a libtool `.la' library or `.lo' object file.
598 # This function implements the same check as func_lalib_p without
599 # resorting to external programs.  To this end, it redirects stdin and
600 # closes it afterwards, without saving the original file descriptor.
601 # As a safety measure, use it only where a negative result would be
602 # fatal anyway.  Works if `file' does not exist.
603 func_lalib_unsafe_p ()
605     lalib_p=no
606     if test -r "$1" && exec 5<&1 <"$1"; then
607         for lalib_p_l in 1 2 3 4
608         do
609             read lalib_p_line
610             case "$lalib_p_line" in
611                 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
612             esac
613         done
614         exec 1<&5 5<&-
615     fi
616     test "$lalib_p" = yes
619 # func_ltwrapper_p file
620 # True iff FILE is a libtool wrapper script.
621 # This function is only a basic sanity check; it will hardly flush out
622 # determined imposters.
623 func_ltwrapper_p ()
625     func_lalib_p "$1"
629 # func_execute_cmds commands fail_cmd
630 # Execute tilde-delimited COMMANDS.
631 # If FAIL_CMD is given, eval that upon failure.
632 # FAIL_CMD may read-access the current command in variable CMD!
633 func_execute_cmds ()
635     $opt_debug
636     save_ifs=$IFS; IFS='~'
637     for cmd in $1; do
638       IFS=$save_ifs
639       eval cmd=\"$cmd\"
640       func_show_eval "$cmd" "${2-:}"
641     done
642     IFS=$save_ifs
646 # func_source file
647 # Source FILE, adding directory component if necessary.
648 # Note that it is not necessary on cygwin/mingw to append a dot to
649 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
650 # behavior happens only for exec(3), not for open(2)!  Also, sourcing
651 # `FILE.' does not work on cygwin managed mounts.
652 func_source ()
654     $opt_debug
655     case $1 in
656     */* | *\\*) . "$1" ;;
657     *)          . "./$1" ;;
658     esac
662 # Generated shell functions inserted here.
665 # func_win32_libid arg
666 # return the library type of file 'arg'
668 # Need a lot of goo to handle *both* DLLs and import libs
669 # Has to be a shell function in order to 'eat' the argument
670 # that is supplied when $file_magic_command is called.
671 func_win32_libid ()
673   $opt_debug
674   win32_libid_type="unknown"
675   win32_fileres=`file -L $1 2>/dev/null`
676   case $win32_fileres in
677   *ar\ archive\ import\ library*) # definitely import
678     win32_libid_type="x86 archive import"
679     ;;
680   *ar\ archive*) # could be an import, or static
681     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
682        $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
683       win32_nmres=`eval $NM -f posix -A $1 |
684         $SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
685       case $win32_nmres in
686       import*)  win32_libid_type="x86 archive import";;
687       *)        win32_libid_type="x86 archive static";;
688       esac
689     fi
690     ;;
691   *DLL*)
692     win32_libid_type="x86 DLL"
693     ;;
694   *executable*) # but shell scripts are "executable" too...
695     case $win32_fileres in
696     *MS\ Windows\ PE\ Intel*)
697       win32_libid_type="x86 DLL"
698       ;;
699     esac
700     ;;
701   esac
702   $ECHO "$win32_libid_type"
707 # func_infer_tag arg
708 # Infer tagged configuration to use if any are available and
709 # if one wasn't chosen via the "--tag" command line option.
710 # Only attempt this if the compiler in the base compile
711 # command doesn't match the default compiler.
712 # arg is usually of the form 'gcc ...'
713 func_infer_tag ()
715     $opt_debug
716     if test -n "$available_tags" && test -z "$tagname"; then
717       CC_quoted=
718       for arg in $CC; do
719         func_quote_for_eval "$arg"
720         CC_quoted="$CC_quoted $func_quote_for_eval_result"
721       done
722       case $@ in
723       # Blanks in the command may have been stripped by the calling shell,
724       # but not from the CC environment variable when configure was run.
725       " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
726       # Blanks at the start of $base_compile will cause this to fail
727       # if we don't check for them as well.
728       *)
729         for z in $available_tags; do
730           if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
731             # Evaluate the configuration.
732             eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
733             CC_quoted=
734             for arg in $CC; do
735               # Double-quote args containing other shell metacharacters.
736               func_quote_for_eval "$arg"
737               CC_quoted="$CC_quoted $func_quote_for_eval_result"
738             done
739             case "$@ " in
740               " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
741               # The compiler in the base compile command matches
742               # the one in the tagged configuration.
743               # Assume this is the tagged configuration we want.
744               tagname=$z
745               break
746               ;;
747             esac
748           fi
749         done
750         # If $tagname still isn't set, then no tagged configuration
751         # was found and let the user know that the "--tag" command
752         # line option must be used.
753         if test -z "$tagname"; then
754           func_echo "unable to infer tagged configuration"
755           func_fatal_error "specify a tag with \`--tag'"
756 #       else
757 #         func_verbose "using $tagname tagged configuration"
758         fi
759         ;;
760       esac
761     fi
766 # func_generate_dlsyms outputname originator pic_p
767 # Extract symbols from dlprefiles and create ${outputname}S.o with
768 # a dlpreopen symbol table.
769 func_generate_dlsyms ()
771     $opt_debug
772     my_outputname="$1"
773     my_originator="$2"
774     my_pic_p="${3-no}"
775     my_prefix=`$ECHO "$my_originator" | sed 's%[[^a-zA-Z0-9]]%_%g'`
776     my_dlsyms=
778     if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
779       if test -n "$NM" && test -n "$global_symbol_pipe"; then
780         my_dlsyms="${my_outputname}S.c"
781       else
782         func_error "not configured to extract global symbols from dlpreopened files"
783       fi
784     fi
786     if test -n "$my_dlsyms"; then
787       case $my_dlsyms in
788       "") ;;
789       *.c)
790         # Discover the nlist of each of the dlfiles.
791         nlist="$output_objdir/${my_outputname}.nm"
793         func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
795         # Parse the name list into a source file.
796         func_echo "creating $output_objdir/$my_dlsyms"
798         $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
799 /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
800 /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
802 #ifdef __cplusplus
803 extern \"C\" {
804 #endif
806 /* External symbol declarations for the compiler. */\
809         if test "$dlself" = yes; then
810           func_echo "generating symbol list for \`$output'"
812           $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
814           # Add our own program objects to the symbol list.
815           progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
816           for progfile in $progfiles; do
817             func_echo "extracting global C symbols from \`$progfile'"
818             $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
819           done
821           if test -n "$exclude_expsyms"; then
822             $opt_dry_run || {
823               eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
824               eval '$MV "$nlist"T "$nlist"'
825             }
826           fi
828           if test -n "$export_symbols_regex"; then
829             $opt_dry_run || {
830               eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
831               eval '$MV "$nlist"T "$nlist"'
832             }
833           fi
835           # Prepare the list of exported symbols
836           if test -z "$export_symbols"; then
837             export_symbols="$output_objdir/$outputname.exp"
838             $opt_dry_run || {
839               $RM $export_symbols
840               eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
841               case $host in
842               *cygwin* | *mingw* )
843                 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
844                 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
845                 ;;
846               esac
847             }
848           else
849             $opt_dry_run || {
850               eval "${SED} -e 's/\([[].[*^$]]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
851               eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
852               eval '$MV "$nlist"T "$nlist"'
853               case $host in
854                 *cygwin | *mingw* )
855                   eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
856                   eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
857                   ;;
858               esac
859             }
860           fi
861         fi
863         for dlprefile in $dlprefiles; do
864           func_echo "extracting global C symbols from \`$dlprefile'"
865           func_basename "$dlprefile"
866           name="$func_basename_result"
867           $opt_dry_run || {
868             eval '$ECHO ": $name " >> "$nlist"'
869             eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
870           }
871         done
873         $opt_dry_run || {
874           # Make sure we have at least an empty file.
875           test -f "$nlist" || : > "$nlist"
877           if test -n "$exclude_expsyms"; then
878             $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
879             $MV "$nlist"T "$nlist"
880           fi
882           # Try sorting and uniquifying the output.
883           if $GREP -v "^: " < "$nlist" |
884               if sort -k 3 </dev/null >/dev/null 2>&1; then
885                 sort -k 3
886               else
887                 sort +2
888               fi |
889               uniq > "$nlist"S; then
890             :
891           else
892             $GREP -v "^: " < "$nlist" > "$nlist"S
893           fi
895           if test -f "$nlist"S; then
896             eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
897           else
898             $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
899           fi
901           $ECHO >> "$output_objdir/$my_dlsyms" "\
903 /* The mapping between symbol names and symbols.  */
905           case $host in
906           *cygwin* | *mingw* )
907             $ECHO >> "$output_objdir/$my_dlsyms" "\
908 /* DATA imports from DLLs on WIN32 con't be const, because
909    runtime relocations are performed -- see ld's documentation
910    on pseudo-relocs.  */
911    struct {
913             ;;
914           *)
915             $ECHO >> "$output_objdir/$my_dlsyms" "\
916 const struct {
918             ;;
919           esac
921           $ECHO >> "$output_objdir/$my_dlsyms" "\
922    const char *name;
923    void *address;
925 lt_${my_prefix}_LTX_preloaded_symbols[[]] =
927   { \"$my_originator\", (void *) 0 },
930           eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
932           $ECHO >> "$output_objdir/$my_dlsyms" "\
933   {0, (void *) 0}
936 /* This works around a problem in FreeBSD linker */
937 #ifdef FREEBSD_WORKAROUND
938 static const void *lt_preloaded_setup() {
939   return lt_${my_prefix}_LTX_preloaded_symbols;
941 #endif
943 #ifdef __cplusplus
945 #endif\
947         } # !$opt_dry_run
949         pic_flag_for_symtable=
950         case "$compile_command " in
951         *" -static "*) ;;
952         *)
953           case $host in
954           # compiling the symbol table file with pic_flag works around
955           # a FreeBSD bug that causes programs to crash when -lm is
956           # linked before any other PIC object.  But we must not use
957           # pic_flag when linking with -static.  The problem exists in
958           # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
959           *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
960             pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
961           *-*-hpux*)
962             pic_flag_for_symtable=" $pic_flag"  ;;
963           *)
964             if test "X$my_pic_p" != Xno; then
965               pic_flag_for_symtable=" $pic_flag"
966             fi
967             ;;
968           esac
969           ;;
970         esac
972         # Now compile the dynamic symbol file.
973         func_show_eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
975         # Clean up the generated files.
976         func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
978         # Transform the symbol file into the correct name.
979         symfileobj="$output_objdir/${my_outputname}S.$objext"
980         case $host in
981         *cygwin* | *mingw* )
982           if test -f "$output_objdir/$my_outputname.def"; then
983             compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
984             finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
985           else
986             compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
987             finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
988           fi
989           ;;
990         *)
991           compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
992           finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
993           ;;
994         esac
995         ;;
996       *)
997         func_fatal_error "unknown suffix for \`$my_dlsyms'"
998         ;;
999       esac
1000     else
1001       # We keep going just in case the user didn't refer to
1002       # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
1003       # really was required.
1005       # Nullify the symbol file.
1006       compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
1007       finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
1008     fi
1011 # func_extract_an_archive dir oldlib
1012 func_extract_an_archive ()
1014     $opt_debug
1015     f_ex_an_ar_dir="$1"; shift
1016     f_ex_an_ar_oldlib="$1"
1017     func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
1018     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
1019      :
1020     else
1021       func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
1022     fi
1026 # func_extract_archives gentop oldlib ...
1027 func_extract_archives ()
1029     $opt_debug
1030     my_gentop="$1"; shift
1031     my_oldlibs=${1+"$@"}
1032     my_oldobjs=""
1033     my_xlib=""
1034     my_xabs=""
1035     my_xdir=""
1037     for my_xlib in $my_oldlibs; do
1038       # Extract the objects.
1039       case $my_xlib in
1040         [[\\/]]* | [[A-Za-z]]:[[\\/]]*) my_xabs="$my_xlib" ;;
1041         *) my_xabs=`pwd`"/$my_xlib" ;;
1042       esac
1043       func_basename "$my_xlib"
1044       my_xlib="$func_basename_result"
1045       my_xdir="$my_gentop/$my_xlib"
1047       func_mkdir_p "$my_xdir"
1049       case $host in
1050       *-darwin*)
1051         func_echo "Extracting $my_xabs"
1052         # Do not bother doing anything if just a dry run
1053         $opt_dry_run || {
1054           darwin_orig_dir=`pwd`
1055           cd $my_xdir || exit $?
1056           darwin_archive=$my_xabs
1057           darwin_curdir=`pwd`
1058           darwin_base_archive=`basename $darwin_archive`
1059           darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
1060           if test -n "$darwin_arches"; then
1061             darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
1062             darwin_arch=
1063             func_echo "$darwin_base_archive has multiple architectures $darwin_arches"
1064             for darwin_arch in  $darwin_arches ; do
1065               func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
1066               lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
1067               cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
1068               func_extract_an_archive "`pwd`" "${darwin_base_archive}"
1069               cd "$darwin_curdir"
1070               $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
1071             done # $darwin_arches
1072             ## Okay now we've a bunch of thin objects, gotta fatten them up :)
1073             darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
1074             darwin_file=
1075             darwin_files=
1076             for darwin_file in $darwin_filelist; do
1077               darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
1078               lipo -create -output "$darwin_file" $darwin_files
1079             done # $darwin_filelist
1080             $RM -rf unfat-$$
1081             cd "$darwin_orig_dir"
1082           else
1083             cd $darwin_orig_dir
1084             func_extract_an_archive "$my_xdir" "$my_xabs"
1085           fi # $darwin_arches
1086         } # !$opt_dry_run
1087         ;;
1088       *)
1089         func_extract_an_archive "$my_xdir" "$my_xabs"
1090         ;;
1091       esac
1092       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
1093     done
1095     func_extract_archives_result="$my_oldobjs"
1099 # func_mode_compile arg...
1100 func_mode_compile ()
1102     $opt_debug
1103     # Get the compilation command and the source file.
1104     base_compile=
1105     srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1106     suppress_opt=yes
1107     suppress_output=
1108     arg_mode=normal
1109     libobj=
1110     later=
1112     for arg
1113     do
1114       case $arg_mode in
1115       arg  )
1116         # do not "continue".  Instead, add this to base_compile
1117         lastarg="$arg"
1118         arg_mode=normal
1119         ;;
1121       target )
1122         libobj="$arg"
1123         arg_mode=normal
1124         continue
1125         ;;
1127       normal )
1128         # Accept any command-line options.
1129         case $arg in
1130         -o)
1131           test -n "$libobj" && \
1132             func_fatal_error "you cannot specify \`-o' more than once"
1133           arg_mode=target
1134           continue
1135           ;;
1137         -shared | -static | -prefer-pic | -prefer-non-pic)
1138           later="$later $arg"
1139           continue
1140           ;;
1142         -no-suppress)
1143           suppress_opt=no
1144           continue
1145           ;;
1147         -Xcompiler)
1148           arg_mode=arg  #  the next one goes into the "base_compile" arg list
1149           continue      #  The current "srcfile" will either be retained or
1150           ;;            #  replaced later.  I would guess that would be a bug.
1152         -Wc,*)
1153           func_stripname '-Wc,' '' "$arg"
1154           args=$func_stripname_result
1155           lastarg=
1156           save_ifs="$IFS"; IFS=','
1157           for arg in $args; do
1158             IFS="$save_ifs"
1159             func_quote_for_eval "$arg"
1160             lastarg="$lastarg $func_quote_for_eval_result"
1161           done
1162           IFS="$save_ifs"
1163           func_stripname ' ' '' "$lastarg"
1164           lastarg=$func_stripname_result
1166           # Add the arguments to base_compile.
1167           base_compile="$base_compile $lastarg"
1168           continue
1169           ;;
1171         *)
1172           # Accept the current argument as the source file.
1173           # The previous "srcfile" becomes the current argument.
1174           #
1175           lastarg="$srcfile"
1176           srcfile="$arg"
1177           ;;
1178         esac  #  case $arg
1179         ;;
1180       esac    #  case $arg_mode
1182       # Aesthetically quote the previous argument.
1183       func_quote_for_eval "$lastarg"
1184       base_compile="$base_compile $func_quote_for_eval_result"
1185     done # for arg
1187     case $arg_mode in
1188     arg)
1189       func_fatal_error "you must specify an argument for -Xcompile"
1190       ;;
1191     target)
1192       func_fatal_error "you must specify a target with \`-o'"
1193       ;;
1194     *)
1195       # Get the name of the library object.
1196       test -z "$libobj" && {
1197         func_basename "$srcfile"
1198         libobj="$func_basename_result"
1199       }
1200       ;;
1201     esac
1203     # Recognize several different file suffixes.
1204     # If the user specifies -o file.o, it is replaced with file.lo
1205     xform='[[cCFSifmso]]'
1206     case $libobj in
1207     *.ada) xform=ada ;;
1208     *.adb) xform=adb ;;
1209     *.ads) xform=ads ;;
1210     *.asm) xform=asm ;;
1211     *.c++) xform=c++ ;;
1212     *.cc) xform=cc ;;
1213     *.ii) xform=ii ;;
1214     *.class) xform=class ;;
1215     *.cpp) xform=cpp ;;
1216     *.cxx) xform=cxx ;;
1217     *.f90) xform=f90 ;;
1218     *.for) xform=for ;;
1219     *.java) xform=java ;;
1220     esac
1222     libobj=`$ECHO "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
1224     case $libobj in
1225     *.lo) obj=`$ECHO "X$libobj" | $Xsed -e "$lo2o"` ;;
1226     *)
1227       func_fatal_error "cannot determine name of library object from \`$libobj'"
1228       ;;
1229     esac
1231     func_infer_tag $base_compile
1233     for arg in $later; do
1234       case $arg in
1235       -shared)
1236         test "$build_libtool_libs" != yes && \
1237           func_fatal_configuration "can not build a shared library"
1238         build_old_libs=no
1239         continue
1240         ;;
1242       -static)
1243         build_libtool_libs=no
1244         build_old_libs=yes
1245         continue
1246         ;;
1248       -prefer-pic)
1249         pic_mode=yes
1250         continue
1251         ;;
1253       -prefer-non-pic)
1254         pic_mode=no
1255         continue
1256         ;;
1257       esac
1258     done
1260     func_quote_for_eval "$libobj"
1261     test "X$libobj" != "X$func_quote_for_eval_result" \
1262       && $ECHO "X$libobj" | $GREP ['[@:>@~#^*{};<>?"'"'"'       &()|`$@<:@]'] \
1263       && func_warning "libobj name \`$libobj' may not contain shell special characters."
1264     func_basename "$obj"
1265     objname="$func_basename_result"
1266     func_dirname "$obj" "/" ""
1267     xdir="$func_dirname_result"
1268     lobj=${xdir}$objdir/$objname
1270     test -z "$base_compile" && \
1271       func_fatal_help "you must specify a compilation command"
1273     # Delete any leftover library objects.
1274     if test "$build_old_libs" = yes; then
1275       removelist="$obj $lobj $libobj ${libobj}T"
1276     else
1277       removelist="$lobj $libobj ${libobj}T"
1278     fi
1280     $opt_dry_run || $RM $removelist
1281     trap "$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE" 1 2 15
1283     # On Cygwin there's no "real" PIC flag so we must build both object types
1284     case $host_os in
1285     cygwin* | mingw* | pw32* | os2*)
1286       pic_mode=default
1287       ;;
1288     esac
1289     if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
1290       # non-PIC code in shared libraries is not supported
1291       pic_mode=default
1292     fi
1294     # Calculate the filename of the output object if compiler does
1295     # not support -o with -c
1296     if test "$compiler_c_o" = no; then
1297       output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[[^.]]*$%%'`.${objext}
1298       lockfile="$output_obj.lock"
1299       removelist="$removelist $output_obj $lockfile"
1300       trap "$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE" 1 2 15
1301     else
1302       output_obj=
1303       need_locks=no
1304       lockfile=
1305     fi
1307     # Lock this critical section if it is needed
1308     # We use this script file to make the link, it avoids creating a new file
1309     if test "$need_locks" = yes; then
1310       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
1311         func_echo "Waiting for $lockfile to be removed"
1312         sleep 2
1313       done
1314     elif test "$need_locks" = warn; then
1315       if test -f "$lockfile"; then
1316         $ECHO "\
1317 *** ERROR, $lockfile exists and contains:
1318 `cat $lockfile 2>/dev/null`
1320 This indicates that another process is trying to use the same
1321 temporary object file, and libtool could not work around it because
1322 your compiler does not support \`-c' and \`-o' together.  If you
1323 repeat this compilation, it may succeed, by chance, but you had better
1324 avoid parallel builds (make -j) in this platform, or get a better
1325 compiler."
1327         $opt_dry_run || $RM $removelist
1328         exit $EXIT_FAILURE
1329       fi
1330       $ECHO "$srcfile" > "$lockfile"
1331     fi
1333     if test -n "$fix_srcfile_path"; then
1334       eval srcfile=\"$fix_srcfile_path\"
1335     fi
1336     func_quote_for_eval "$srcfile"
1337     qsrcfile=$func_quote_for_eval_result
1339     $opt_dry_run || $RM "$libobj" "${libobj}T"
1341     # Create a libtool object file (analogous to a ".la" file),
1342     # but don't create it if we're doing a dry run.
1343     $opt_dry_run || cat > ${libobj}T <<EOF
1344 # $libobj - a libtool object file
1345 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1347 # Please DO NOT delete this file!
1348 # It is necessary for linking the library.
1350 # Name of the PIC object.
1353     # Only build a PIC object if we are building libtool libraries.
1354     if test "$build_libtool_libs" = yes; then
1355       # Without this assignment, base_compile gets emptied.
1356       fbsd_hideous_sh_bug=$base_compile
1358       if test "$pic_mode" != no; then
1359         command="$base_compile $qsrcfile $pic_flag"
1360       else
1361         # Don't build PIC code
1362         command="$base_compile $qsrcfile"
1363       fi
1365       func_mkdir_p "$xdir$objdir"
1367       if test -z "$output_obj"; then
1368         # Place PIC objects in $objdir
1369         command="$command -o $lobj"
1370       fi
1372       $opt_dry_run || $RM "$lobj" "$output_obj"
1374       func_show_eval "$command" \
1375           'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
1377       if test "$need_locks" = warn &&
1378          test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1379         $ECHO "\
1380 *** ERROR, $lockfile contains:
1381 `cat $lockfile 2>/dev/null`
1383 but it should contain:
1384 $srcfile
1386 This indicates that another process is trying to use the same
1387 temporary object file, and libtool could not work around it because
1388 your compiler does not support \`-c' and \`-o' together.  If you
1389 repeat this compilation, it may succeed, by chance, but you had better
1390 avoid parallel builds (make -j) in this platform, or get a better
1391 compiler."
1393         $opt_dry_run || $RM $removelist
1394         exit $EXIT_FAILURE
1395       fi
1397       # Just move the object if needed, then go on to compile the next one
1398       if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1399         func_show_eval '$MV "$output_obj" "$lobj"' \
1400           'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1401       fi
1403       # Append the name of the PIC object to the libtool object file.
1404       $opt_dry_run || cat >> ${libobj}T <<EOF
1405 pic_object='$objdir/$objname'
1409       # Allow error messages only from the first compilation.
1410       if test "$suppress_opt" = yes; then
1411         suppress_output=' >/dev/null 2>&1'
1412       fi
1413     else
1414       # No PIC object so indicate it doesn't exist in the libtool
1415       # object file.
1416       $opt_dry_run || cat >> ${libobj}T <<EOF
1417 pic_object=none
1420     fi
1422     # Only build a position-dependent object if we build old libraries.
1423     if test "$build_old_libs" = yes; then
1424       if test "$pic_mode" != yes; then
1425         # Don't build PIC code
1426         command="$base_compile $qsrcfile"
1427       else
1428         command="$base_compile $qsrcfile $pic_flag"
1429       fi
1430       if test "$compiler_c_o" = yes; then
1431         command="$command -o $obj"
1432       fi
1434       # Suppress compiler output if we already did a PIC compilation.
1435       command="$command$suppress_output"
1436       $opt_dry_run || $RM "$obj" "$output_obj"
1437       func_show_eval "$command" \
1438         '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
1440       if test "$need_locks" = warn &&
1441          test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1442         $ECHO "\
1443 *** ERROR, $lockfile contains:
1444 `cat $lockfile 2>/dev/null`
1446 but it should contain:
1447 $srcfile
1449 This indicates that another process is trying to use the same
1450 temporary object file, and libtool could not work around it because
1451 your compiler does not support \`-c' and \`-o' together.  If you
1452 repeat this compilation, it may succeed, by chance, but you had better
1453 avoid parallel builds (make -j) in this platform, or get a better
1454 compiler."
1456         $opt_dry_run || $RM $removelist
1457         exit $EXIT_FAILURE
1458       fi
1460       # Just move the object if needed
1461       if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1462         func_show_eval '$MV "$output_obj" "$obj"' \
1463           'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1464       fi
1466       # Append the name of the non-PIC object the libtool object file.
1467       # Only append if the libtool object file exists.
1468       $opt_dry_run || cat >> ${libobj}T <<EOF
1469 # Name of the non-PIC object.
1470 non_pic_object='$objname'
1473     else
1474       # Append the name of the non-PIC object the libtool object file.
1475       # Only append if the libtool object file exists.
1476       $opt_dry_run || cat >> ${libobj}T <<EOF
1477 # Name of the non-PIC object.
1478 non_pic_object=none
1481     fi
1483     $opt_dry_run || {
1484       $MV "${libobj}T" "${libobj}"
1486       # Unlock the critical section if it was locked
1487       if test "$need_locks" != no; then
1488         $RM "$lockfile"
1489       fi
1490     }
1492     exit $EXIT_SUCCESS
1496 # func_mode_execute arg...
1497 func_mode_execute ()
1499     $opt_debug
1500     # The first argument is the command name.
1501     cmd="$nonopt"
1502     test -z "$cmd" && \
1503       func_fatal_help "you must specify a COMMAND"
1505     # Handle -dlopen flags immediately.
1506     for file in $execute_dlfiles; do
1507       test -f "$file" \
1508         || func_fatal_help "\`$file' is not a file"
1510       dir=
1511       case $file in
1512       *.la)
1513         # Check to see that this really is a libtool archive.
1514         func_lalib_unsafe_p "$file" \
1515           || func_fatal_help "\`$lib' is not a valid libtool archive"
1517         # Read the libtool library.
1518         dlname=
1519         library_names=
1520         func_source "$file"
1522         # Skip this library if it cannot be dlopened.
1523         if test -z "$dlname"; then
1524           # Warn if it was a shared library.
1525           test -n "$library_names" && \
1526             func_warning "\`$file' was not linked with \`-export-dynamic'"
1527           continue
1528         fi
1530         func_dirname "$file" "" "."
1531         dir="$func_dirname_result"
1533         if test -f "$dir/$objdir/$dlname"; then
1534           dir="$dir/$objdir"
1535         else
1536           func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
1537         fi
1538         ;;
1540       *.lo)
1541         # Just add the directory containing the .lo file.
1542         func_dirname "$file" "" "."
1543         dir="$func_dirname_result"
1544         ;;
1546       *)
1547         func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
1548         continue
1549         ;;
1550       esac
1552       # Get the absolute pathname.
1553       absdir=`cd "$dir" && pwd`
1554       test -n "$absdir" && dir="$absdir"
1556       # Now add the directory to shlibpath_var.
1557       if eval "test -z \"\$$shlibpath_var\""; then
1558         eval "$shlibpath_var=\"\$dir\""
1559       else
1560         eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
1561       fi
1562     done
1564     # This variable tells wrapper scripts just to set shlibpath_var
1565     # rather than running their programs.
1566     libtool_execute_magic="$magic"
1568     # Check if any of the arguments is a wrapper script.
1569     args=
1570     for file
1571     do
1572       case $file in
1573       -*) ;;
1574       *)
1575         # Do a test to see if this is really a libtool program.
1576         if func_ltwrapper_p "$file"; then
1577           func_source "$file"
1579           # Transform arg to wrapped name.
1580           file="$progdir/$program"
1581         fi
1582         ;;
1583       esac
1584       # Quote arguments (to preserve shell metacharacters).
1585       func_quote_for_eval "$file"
1586       args="$args $func_quote_for_eval_result"
1587     done
1589     if test "X$opt_dry_run" = Xfalse; then
1590       if test -n "$shlibpath_var"; then
1591         # Export the shlibpath_var.
1592         eval "export $shlibpath_var"
1593       fi
1595       # Restore saved environment variables
1596       if test "${save_LC_ALL+set}" = set; then
1597         LC_ALL="$save_LC_ALL"; export LC_ALL
1598       fi
1599       if test "${save_LANG+set}" = set; then
1600         LANG="$save_LANG"; export LANG
1601       fi
1603       # Now prepare to actually exec the command.
1604       exec_cmd="\$cmd$args"
1605     else
1606       # Display what would be done.
1607       if test -n "$shlibpath_var"; then
1608         eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
1609         $ECHO "export $shlibpath_var"
1610       fi
1611       $ECHO "$cmd$args"
1612       exit $EXIT_SUCCESS
1613     fi
1617 # func_mode_finish arg...
1618 func_mode_finish ()
1620     $opt_debug
1621     libdirs="$nonopt"
1622     admincmds=
1624     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
1625       for dir
1626       do
1627         libdirs="$libdirs $dir"
1628       done
1630       for libdir in $libdirs; do
1631         if test -n "$finish_cmds"; then
1632           # Do each command in the finish commands.
1633           func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
1634 '"$cmd"'"'
1635         fi
1636         if test -n "$finish_eval"; then
1637           # Do the single finish_eval.
1638           eval cmds=\"$finish_eval\"
1639           $opt_dry_run || eval "$cmds" || admincmds="$admincmds
1640        $cmds"
1641         fi
1642       done
1643     fi
1645     # Exit here if they wanted silent mode.
1646     $opt_silent && exit $EXIT_SUCCESS
1648     $ECHO "X----------------------------------------------------------------------" | $Xsed
1649     $ECHO "Libraries have been installed in:"
1650     for libdir in $libdirs; do
1651       $ECHO "   $libdir"
1652     done
1653     $ECHO
1654     $ECHO "If you ever happen to want to link against installed libraries"
1655     $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
1656     $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
1657     $ECHO "flag during linking and do at least one of the following:"
1658     if test -n "$shlibpath_var"; then
1659       $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
1660       $ECHO "     during execution"
1661     fi
1662     if test -n "$runpath_var"; then
1663       $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
1664       $ECHO "     during linking"
1665     fi
1666     if test -n "$hardcode_libdir_flag_spec"; then
1667       libdir=LIBDIR
1668       eval flag=\"$hardcode_libdir_flag_spec\"
1670       $ECHO "   - use the \`$flag' linker flag"
1671     fi
1672     if test -n "$admincmds"; then
1673       $ECHO "   - have your system administrator run these commands:$admincmds"
1674     fi
1675     if test -f /etc/ld.so.conf; then
1676       $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
1677     fi
1678     $ECHO
1680     $ECHO "See any operating system documentation about shared libraries for"
1681     case $host in
1682       solaris2.[[6789]]|solaris2.1[[0-9]])
1683         $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
1684         $ECHO "pages."
1685         ;;
1686       *)
1687         $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
1688         ;;
1689     esac
1690     $ECHO "X----------------------------------------------------------------------" | $Xsed
1691     exit $EXIT_SUCCESS
1695 # func_mode_install arg...
1696 func_mode_install ()
1698     $opt_debug
1699     # There may be an optional sh(1) argument at the beginning of
1700     # install_prog (especially on Windows NT).
1701     if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
1702        # Allow the use of GNU shtool's install command.
1703        $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
1704       # Aesthetically quote it.
1705       func_quote_for_eval "$nonopt"
1706       install_prog="$func_quote_for_eval_result "
1707       arg=$1
1708       shift
1709     else
1710       install_prog=
1711       arg=$nonopt
1712     fi
1714     # The real first argument should be the name of the installation program.
1715     # Aesthetically quote it.
1716     func_quote_for_eval "$arg"
1717     install_prog="$install_prog$func_quote_for_eval_result"
1719     # We need to accept at least all the BSD install flags.
1720     dest=
1721     files=
1722     opts=
1723     prev=
1724     install_type=
1725     isdir=no
1726     stripme=
1727     for arg
1728     do
1729       if test -n "$dest"; then
1730         files="$files $dest"
1731         dest=$arg
1732         continue
1733       fi
1735       case $arg in
1736       -d) isdir=yes ;;
1737       -f)
1738         case " $install_prog " in
1739         *[[\\\ /]]cp\ *) ;;
1740         *) prev=$arg ;;
1741         esac
1742         ;;
1743       -g | -m | -o)
1744         prev=$arg
1745         ;;
1746       -s)
1747         stripme=" -s"
1748         continue
1749         ;;
1750       -*)
1751         ;;
1752       *)
1753         # If the previous option needed an argument, then skip it.
1754         if test -n "$prev"; then
1755           prev=
1756         else
1757           dest=$arg
1758           continue
1759         fi
1760         ;;
1761       esac
1763       # Aesthetically quote the argument.
1764       func_quote_for_eval "$arg"
1765       install_prog="$install_prog $func_quote_for_eval_result"
1766     done
1768     test -z "$install_prog" && \
1769       func_fatal_help "you must specify an install program"
1771     test -n "$prev" && \
1772       func_fatal_help "the \`$prev' option requires an argument"
1774     if test -z "$files"; then
1775       if test -z "$dest"; then
1776         func_fatal_help "no file or destination specified"
1777       else
1778         func_fatal_help "you must specify a destination"
1779       fi
1780     fi
1782     # Strip any trailing slash from the destination.
1783     func_stripname '' '/' "$dest"
1784     dest=$func_stripname_result
1786     # Check to see that the destination is a directory.
1787     test -d "$dest" && isdir=yes
1788     if test "$isdir" = yes; then
1789       destdir="$dest"
1790       destname=
1791     else
1792       func_dirname "$dest" "" "."
1793       destdir="$func_dirname_result"
1794       func_basename "$dest"
1795       destname="$func_basename_result"
1797       # Not a directory, so check to see that there is only one file specified.
1798       set dummy $files; shift
1799       test "$#" -gt 1 && \
1800         func_fatal_help "\`$dest' is not a directory"
1801     fi
1802     case $destdir in
1803     [[\\/]]* | [[A-Za-z]]:[[\\/]]*) ;;
1804     *)
1805       for file in $files; do
1806         case $file in
1807         *.lo) ;;
1808         *)
1809           func_fatal_help "\`$destdir' must be an absolute directory name"
1810           ;;
1811         esac
1812       done
1813       ;;
1814     esac
1816     # This variable tells wrapper scripts just to set variables rather
1817     # than running their programs.
1818     libtool_install_magic="$magic"
1820     staticlibs=
1821     future_libdirs=
1822     current_libdirs=
1823     for file in $files; do
1825       # Do each installation.
1826       case $file in
1827       *.$libext)
1828         # Do the static libraries later.
1829         staticlibs="$staticlibs $file"
1830         ;;
1832       *.la)
1833         # Check to see that this really is a libtool archive.
1834         func_lalib_unsafe_p "$file" \
1835           || func_fatal_help "\`$file' is not a valid libtool archive"
1837         library_names=
1838         old_library=
1839         relink_command=
1840         func_source "$file"
1842         # Add the libdir to current_libdirs if it is the destination.
1843         if test "X$destdir" = "X$libdir"; then
1844           case "$current_libdirs " in
1845           *" $libdir "*) ;;
1846           *) current_libdirs="$current_libdirs $libdir" ;;
1847           esac
1848         else
1849           # Note the libdir as a future libdir.
1850           case "$future_libdirs " in
1851           *" $libdir "*) ;;
1852           *) future_libdirs="$future_libdirs $libdir" ;;
1853           esac
1854         fi
1856         func_dirname "$file" "/" ""
1857         dir="$func_dirname_result"
1858         dir="$dir$objdir"
1860         if test -n "$relink_command"; then
1861           # Determine the prefix the user has applied to our future dir.
1862           inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
1864           # Don't allow the user to place us outside of our expected
1865           # location b/c this prevents finding dependent libraries that
1866           # are installed to the same prefix.
1867           # At present, this check doesn't affect windows .dll's that
1868           # are installed into $libdir/../bin (currently, that works fine)
1869           # but it's something to keep an eye on.
1870           test "$inst_prefix_dir" = "$destdir" && \
1871             func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
1873           if test -n "$inst_prefix_dir"; then
1874             # Stick the inst_prefix_dir data into the link command.
1875             relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
1876           else
1877             relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
1878           fi
1880           func_warning "relinking \`$file'"
1881           func_show_eval "$relink_command" \
1882             'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
1883         fi
1885         # See the names of the shared library.
1886         set dummy $library_names; shift
1887         if test -n "$1"; then
1888           realname="$1"
1889           shift
1891           srcname="$realname"
1892           test -n "$relink_command" && srcname="$realname"T
1894           # Install the shared library and build the symlinks.
1895           func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
1896               'exit $?'
1897           tstripme="$stripme"
1898           case $host_os in
1899           cygwin* | mingw* | pw32*)
1900             case $realname in
1901             *.dll.a)
1902               tstripme=""
1903               ;;
1904             esac
1905             ;;
1906           esac
1907           if test -n "$tstripme" && test -n "$striplib"; then
1908             func_show_eval "$striplib $destdir/$realname" 'exit $?'
1909           fi
1911           if test "$#" -gt 0; then
1912             # Delete the old symlinks, and create new ones.
1913             # Try `ln -sf' first, because the `ln' binary might depend on
1914             # the symlink we replace!  Solaris /bin/ln does not understand -f,
1915             # so we also need to try rm && ln -s.
1916             for linkname
1917             do
1918               test "$linkname" != "$realname" \
1919                 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
1920             done
1921           fi
1923           # Do each command in the postinstall commands.
1924           lib="$destdir/$realname"
1925           func_execute_cmds "$postinstall_cmds" 'exit $?'
1926         fi
1928         # Install the pseudo-library for information purposes.
1929         func_basename "$file"
1930         name="$func_basename_result"
1931         instname="$dir/$name"i
1932         func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
1934         # Maybe install the static library, too.
1935         test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
1936         ;;
1938       *.lo)
1939         # Install (i.e. copy) a libtool object.
1941         # Figure out destination file name, if it wasn't already specified.
1942         if test -n "$destname"; then
1943           destfile="$destdir/$destname"
1944         else
1945           func_basename "$file"
1946           destfile="$func_basename_result"
1947           destfile="$destdir/$destfile"
1948         fi
1950         # Deduce the name of the destination old-style object file.
1951         case $destfile in
1952         *.lo)
1953           staticdest=`$ECHO "X$destfile" | $Xsed -e "$lo2o"`
1954           ;;
1955         *.$objext)
1956           staticdest="$destfile"
1957           destfile=
1958           ;;
1959         *)
1960           func_fatal_help "cannot copy a libtool object to \`$destfile'"
1961           ;;
1962         esac
1964         # Install the libtool object if requested.
1965         test -n "$destfile" && \
1966           func_show_eval "$install_prog $file $destfile" 'exit $?'
1968         # Install the old object if enabled.
1969         if test "$build_old_libs" = yes; then
1970           # Deduce the name of the old-style object file.
1971           staticobj=`$ECHO "X$file" | $Xsed -e "$lo2o"`
1972           func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
1973         fi
1974         exit $EXIT_SUCCESS
1975         ;;
1977       *)
1978         # Figure out destination file name, if it wasn't already specified.
1979         if test -n "$destname"; then
1980           destfile="$destdir/$destname"
1981         else
1982           func_basename "$file"
1983           destfile="$func_basename_result"
1984           destfile="$destdir/$destfile"
1985         fi
1987         # If the file is missing, and there is a .exe on the end, strip it
1988         # because it is most likely a libtool script we actually want to
1989         # install
1990         stripped_ext=""
1991         case $file in
1992           *.exe)
1993             if test ! -f "$file"; then
1994               func_stripname '' '.exe' "$file"
1995               file=$func_stripname_result
1996               stripped_ext=".exe"
1997             fi
1998             ;;
1999         esac
2001         # Do a test to see if this is really a libtool program.
2002         case $host in
2003         *cygwin*|*mingw*)
2004             func_stripname '' '.exe' "$file"
2005             wrapper=$func_stripname_result
2006             ;;
2007         *)
2008             wrapper=$file
2009             ;;
2010         esac
2011         if func_ltwrapper_p "$wrapper"; then
2012           notinst_deplibs=
2013           relink_command=
2015           func_source "$wrapper"
2017           # Check the variables that should have been set.
2018           test -z "$generated_by_libtool_version" && \
2019             func_fatal_error "invalid libtool wrapper script \`$wrapper'"
2021           finalize=yes
2022           for lib in $notinst_deplibs; do
2023             # Check to see that each library is installed.
2024             libdir=
2025             if test -f "$lib"; then
2026               func_source "$lib"
2027             fi
2028             libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
2029             if test -n "$libdir" && test ! -f "$libfile"; then
2030               func_warning "\`$lib' has not been installed in \`$libdir'"
2031               finalize=no
2032             fi
2033           done
2035           relink_command=
2036           func_source "$wrapper"
2038           outputname=
2039           if test "$fast_install" = no && test -n "$relink_command"; then
2040             $opt_dry_run || {
2041               if test "$finalize" = yes; then
2042                 tmpdir=`func_mktempdir`
2043                 func_basename "$file$stripped_ext"
2044                 file="$func_basename_result"
2045                 outputname="$tmpdir/$file"
2046                 # Replace the output file specification.
2047                 relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
2049                 $opt_silent || {
2050                   func_quote_for_expand "$relink_command"
2051                   eval "func_echo $func_quote_for_expand_result"
2052                 }
2053                 if eval "$relink_command"; then :
2054                   else
2055                   func_error "error: relink \`$file' with the above command before installing it"
2056                   $opt_dry_run || ${RM}r "$tmpdir"
2057                   continue
2058                 fi
2059                 file="$outputname"
2060               else
2061                 func_warning "cannot relink \`$file'"
2062               fi
2063             }
2064           else
2065             # Install the binary that we compiled earlier.
2066             file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([[^/]]*\)$%$objdir/\1%"`
2067           fi
2068         fi
2070         # remove .exe since cygwin /usr/bin/install will append another
2071         # one anyway
2072         case $install_prog,$host in
2073         */usr/bin/install*,*cygwin*)
2074           case $file:$destfile in
2075           *.exe:*.exe)
2076             # this is ok
2077             ;;
2078           *.exe:*)
2079             destfile=$destfile.exe
2080             ;;
2081           *:*.exe)
2082             func_stripname '' '.exe' "$destfile"
2083             destfile=$func_stripname_result
2084             ;;
2085           esac
2086           ;;
2087         esac
2088         func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
2089         $opt_dry_run || if test -n "$outputname"; then
2090           ${RM}r "$tmpdir"
2091         fi
2092         ;;
2093       esac
2094     done
2096     for file in $staticlibs; do
2097       func_basename "$file"
2098       name="$func_basename_result"
2100       # Set up the ranlib parameters.
2101       oldlib="$destdir/$name"
2103       func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2105       if test -n "$stripme" && test -n "$old_striplib"; then
2106         func_show_eval "$old_striplib $oldlib" 'exit $?'
2107       fi
2109       # Do each command in the postinstall commands.
2110       func_execute_cmds "$old_postinstall_cmds" 'exit $?'
2111     done
2113     test -n "$future_libdirs" && \
2114       func_warning "remember to run \`$progname --finish$future_libdirs'"
2116     if test -n "$current_libdirs"; then
2117       # Maybe just do a dry run.
2118       $opt_dry_run && current_libdirs=" -n$current_libdirs"
2119       exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
2120     else
2121       exit $EXIT_SUCCESS
2122     fi
2126 # func_mode_link arg...
2127 func_mode_link ()
2129     $opt_debug
2130     case $host in
2131     *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
2132       # It is impossible to link a dll without this setting, and
2133       # we shouldn't force the makefile maintainer to figure out
2134       # which system we are compiling for in order to pass an extra
2135       # flag for every libtool invocation.
2136       # allow_undefined=no
2138       # FIXME: Unfortunately, there are problems with the above when trying
2139       # to make a dll which has undefined symbols, in which case not
2140       # even a static library is built.  For now, we need to specify
2141       # -no-undefined on the libtool link line when we can be certain
2142       # that all symbols are satisfied, otherwise we get a static library.
2143       allow_undefined=yes
2144       ;;
2145     *)
2146       allow_undefined=yes
2147       ;;
2148     esac
2149     libtool_args="$nonopt"
2150     base_compile="$nonopt $@"
2151     compile_command="$nonopt"
2152     finalize_command="$nonopt"
2154     compile_rpath=
2155     finalize_rpath=
2156     compile_shlibpath=
2157     finalize_shlibpath=
2158     convenience=
2159     old_convenience=
2160     deplibs=
2161     old_deplibs=
2162     compiler_flags=
2163     linker_flags=
2164     dllsearchpath=
2165     lib_search_path=`pwd`
2166     inst_prefix_dir=
2167     new_inherited_linker_flags=
2169     avoid_version=no
2170     dlfiles=
2171     dlprefiles=
2172     dlself=no
2173     export_dynamic=no
2174     export_symbols=
2175     export_symbols_regex=
2176     generated=
2177     libobjs=
2178     ltlibs=
2179     module=no
2180     no_install=no
2181     objs=
2182     non_pic_objects=
2183     precious_files_regex=
2184     prefer_static_libs=no
2185     preload=no
2186     prev=
2187     prevarg=
2188     release=
2189     rpath=
2190     xrpath=
2191     perm_rpath=
2192     temp_rpath=
2193     thread_safe=no
2194     vinfo=
2195     vinfo_number=no
2196     weak_libs=
2198     func_infer_tag $base_compile
2200     # We need to know -static, to get the right output filenames.
2201     for arg
2202     do
2203       case $arg in
2204       -shared)
2205         test "$build_libtool_libs" != yes && \
2206           func_fatal_configuration "can not build a shared library"
2207         build_old_libs=no
2208         break
2209         ;;
2210       -all-static | -static)
2211         if test "X$arg" = "X-all-static"; then
2212           if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
2213             func_warning "complete static linking is impossible in this configuration"
2214           fi
2215           if test -n "$link_static_flag"; then
2216             dlopen_self=$dlopen_self_static
2217             # See comment for -static flag below, for more details.
2218             compile_command="$compile_command $link_static_flag"
2219             finalize_command="$finalize_command $link_static_flag"
2220           fi
2221           prefer_static_libs=yes
2222         else
2223           if test -z "$pic_flag" && test -n "$link_static_flag"; then
2224             dlopen_self=$dlopen_self_static
2225           fi
2226           prefer_static_libs=built
2227         fi
2228         build_libtool_libs=no
2229         build_old_libs=yes
2230         break
2231         ;;
2232       esac
2233     done
2235     # See if our shared archives depend on static archives.
2236     test -n "$old_archive_from_new_cmds" && build_old_libs=yes
2238     # Go through the arguments, transforming them on the way.
2239     while test "$#" -gt 0; do
2240       arg="$1"
2241       shift
2242       func_quote_for_eval "$arg"
2243       qarg="$func_quote_for_eval_unquoted_result"
2244       libtool_args="$libtool_args $func_quote_for_eval_result"
2246       # If the previous option needs an argument, assign it.
2247       if test -n "$prev"; then
2248         case $prev in
2249         output)
2250           compile_command="$compile_command @OUTPUT@"
2251           finalize_command="$finalize_command @OUTPUT@"
2252           ;;
2253         esac
2255         case $prev in
2256         dlfiles|dlprefiles)
2257           if test "$preload" = no; then
2258             # Add the symbol object into the linking commands.
2259             compile_command="$compile_command @SYMFILE@"
2260             finalize_command="$finalize_command @SYMFILE@"
2261             preload=yes
2262           fi
2263           case $arg in
2264           *.la | *.lo) ;;  # We handle these cases below.
2265           force)
2266             if test "$dlself" = no; then
2267               dlself=needless
2268               export_dynamic=yes
2269             fi
2270             prev=
2271             continue
2272             ;;
2273           self)
2274             if test "$prev" = dlprefiles; then
2275               dlself=yes
2276             elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
2277               dlself=yes
2278             else
2279               dlself=needless
2280               export_dynamic=yes
2281             fi
2282             prev=
2283             continue
2284             ;;
2285           *)
2286             if test "$prev" = dlfiles; then
2287               dlfiles="$dlfiles $arg"
2288             else
2289               dlprefiles="$dlprefiles $arg"
2290             fi
2291             prev=
2292             continue
2293             ;;
2294           esac
2295           ;;
2296         expsyms)
2297           export_symbols="$arg"
2298           test -f "$arg" \
2299             || func_fatal_error "symbol file \`$arg' does not exist"
2300           prev=
2301           continue
2302           ;;
2303         expsyms_regex)
2304           export_symbols_regex="$arg"
2305           prev=
2306           continue
2307           ;;
2308         framework)
2309           case $host in
2310             *-*-darwin*)
2311               case "$deplibs " in
2312                 *" $qarg.ltframework "*) ;;
2313                 *) deplibs="$deplibs $qarg.ltframework" # this is fixed later
2314                    ;;
2315               esac
2316               ;;
2317           esac
2318           prev=
2319           continue
2320           ;;
2321         inst_prefix)
2322           inst_prefix_dir="$arg"
2323           prev=
2324           continue
2325           ;;
2326         objectlist)
2327           if test -f "$arg"; then
2328             save_arg=$arg
2329             moreargs=
2330             for fil in `cat "$save_arg"`
2331             do
2332 #             moreargs="$moreargs $fil"
2333               arg=$fil
2334               # A libtool-controlled object.
2336               # Check to see that this really is a libtool object.
2337               if func_lalib_unsafe_p "$arg"; then
2338                 pic_object=
2339                 non_pic_object=
2341                 # Read the .lo file
2342                 func_source "$arg"
2344                 if test -z "$pic_object" ||
2345                    test -z "$non_pic_object" ||
2346                    test "$pic_object" = none &&
2347                    test "$non_pic_object" = none; then
2348                   func_fatal_error "cannot find name of object for \`$arg'"
2349                 fi
2351                 # Extract subdirectory from the argument.
2352                 func_dirname "$arg" "/" ""
2353                 xdir="$func_dirname_result"
2355                 if test "$pic_object" != none; then
2356                   # Prepend the subdirectory the object is found in.
2357                   pic_object="$xdir$pic_object"
2359                   if test "$prev" = dlfiles; then
2360                     if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
2361                       dlfiles="$dlfiles $pic_object"
2362                       prev=
2363                       continue
2364                     else
2365                       # If libtool objects are unsupported, then we need to preload.
2366                       prev=dlprefiles
2367                     fi
2368                   fi
2370                   # CHECK ME:  I think I busted this.  -Ossama
2371                   if test "$prev" = dlprefiles; then
2372                     # Preload the old-style object.
2373                     dlprefiles="$dlprefiles $pic_object"
2374                     prev=
2375                   fi
2377                   # A PIC object.
2378                   libobjs="$libobjs $pic_object"
2379                   arg="$pic_object"
2380                 fi
2382                 # Non-PIC object.
2383                 if test "$non_pic_object" != none; then
2384                   # Prepend the subdirectory the object is found in.
2385                   non_pic_object="$xdir$non_pic_object"
2387                   # A standard non-PIC object
2388                   non_pic_objects="$non_pic_objects $non_pic_object"
2389                   if test -z "$pic_object" || test "$pic_object" = none ; then
2390                     arg="$non_pic_object"
2391                   fi
2392                 else
2393                   # If the PIC object exists, use it instead.
2394                   # $xdir was prepended to $pic_object above.
2395                   non_pic_object="$pic_object"
2396                   non_pic_objects="$non_pic_objects $non_pic_object"
2397                 fi
2398               else
2399                 # Only an error if not doing a dry-run.
2400                 if $opt_dry_run; then
2401                   # Extract subdirectory from the argument.
2402                   func_dirname "$arg" "/" ""
2403                   xdir="$func_dirname_result"
2405                   pic_object=`$ECHO "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
2406                   non_pic_object=`$ECHO "X${xdir}${arg}" | $Xsed -e "$lo2o"`
2407                   libobjs="$libobjs $pic_object"
2408                   non_pic_objects="$non_pic_objects $non_pic_object"
2409                 else
2410                   func_fatal_error "\`$arg' is not a valid libtool object"
2411                 fi
2412               fi
2413             done
2414           else
2415             func_fatal_error "link input file \`$arg' does not exist"
2416           fi
2417           arg=$save_arg
2418           prev=
2419           continue
2420           ;;
2421         precious_regex)
2422           precious_files_regex="$arg"
2423           prev=
2424           continue
2425           ;;
2426         release)
2427           release="-$arg"
2428           prev=
2429           continue
2430           ;;
2431         rpath | xrpath)
2432           # We need an absolute path.
2433           case $arg in
2434           [[\\/]]* | [[A-Za-z]]:[[\\/]]*) ;;
2435           *)
2436             func_fatal_error "only absolute run-paths are allowed"
2437             ;;
2438           esac
2439           if test "$prev" = rpath; then
2440             case "$rpath " in
2441             *" $arg "*) ;;
2442             *) rpath="$rpath $arg" ;;
2443             esac
2444           else
2445             case "$xrpath " in
2446             *" $arg "*) ;;
2447             *) xrpath="$xrpath $arg" ;;
2448             esac
2449           fi
2450           prev=
2451           continue
2452           ;;
2453         shrext)
2454           shrext_cmds="$arg"
2455           prev=
2456           continue
2457           ;;
2458         weak)
2459           weak_libs="$weak_libs $arg"
2460           prev=
2461           continue
2462           ;;
2463         xcclinker)
2464           linker_flags="$linker_flags $qarg"
2465           compiler_flags="$compiler_flags $qarg"
2466           prev=
2467           compile_command="$compile_command $qarg"
2468           finalize_command="$finalize_command $qarg"
2469           continue
2470           ;;
2471         xcompiler)
2472           compiler_flags="$compiler_flags $qarg"
2473           prev=
2474           compile_command="$compile_command $qarg"
2475           finalize_command="$finalize_command $qarg"
2476           continue
2477           ;;
2478         xlinker)
2479           linker_flags="$linker_flags $qarg"
2480           compiler_flags="$compiler_flags $wl$qarg"
2481           prev=
2482           compile_command="$compile_command $wl$qarg"
2483           finalize_command="$finalize_command $wl$qarg"
2484           continue
2485           ;;
2486         *)
2487           eval "$prev=\"\$arg\""
2488           prev=
2489           continue
2490           ;;
2491         esac
2492       fi # test -n "$prev"
2494       prevarg="$arg"
2496       case $arg in
2497       -all-static)
2498         # The effects of -all-static are defined in a previous loop.
2499         continue
2500         ;;
2502       -allow-undefined)
2503         # FIXME: remove this flag sometime in the future.
2504         func_fatal_error "\`-allow-undefined' must not be used because it is the default"
2505         ;;
2507       -avoid-version)
2508         avoid_version=yes
2509         continue
2510         ;;
2512       -dlopen)
2513         prev=dlfiles
2514         continue
2515         ;;
2517       -dlpreopen)
2518         prev=dlprefiles
2519         continue
2520         ;;
2522       -export-dynamic)
2523         export_dynamic=yes
2524         continue
2525         ;;
2527       -export-symbols | -export-symbols-regex)
2528         if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
2529           func_fatal_error "more than one -exported-symbols argument is not allowed"
2530         fi
2531         if test "X$arg" = "X-export-symbols"; then
2532           prev=expsyms
2533         else
2534           prev=expsyms_regex
2535         fi
2536         continue
2537         ;;
2539       -framework)
2540         prev=framework
2541         continue
2542         ;;
2544       -inst-prefix-dir)
2545         prev=inst_prefix
2546         continue
2547         ;;
2549       # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
2550       # so, if we see these flags be careful not to treat them like -L
2551       -L[[A-Z]][[A-Z]]*:*)
2552         case $with_gcc/$host in
2553         no/*-*-irix* | /*-*-irix*)
2554           compile_command="$compile_command $arg"
2555           finalize_command="$finalize_command $arg"
2556           ;;
2557         esac
2558         continue
2559         ;;
2561       -L*)
2562         func_stripname '-L' '' "$arg"
2563         dir=$func_stripname_result
2564         # We need an absolute path.
2565         case $dir in
2566         [[\\/]]* | [[A-Za-z]]:[[\\/]]*) ;;
2567         *)
2568           absdir=`cd "$dir" && pwd`
2569           test -z "$absdir" && \
2570             func_fatal_error "cannot determine absolute directory name of \`$dir'"
2571           dir="$absdir"
2572           ;;
2573         esac
2574         case "$deplibs " in
2575         *" -L$dir "*) ;;
2576         *)
2577           deplibs="$deplibs -L$dir"
2578           lib_search_path="$lib_search_path $dir"
2579           ;;
2580         esac
2581         case $host in
2582         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
2583           testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
2584           case :$dllsearchpath: in
2585           *":$dir:"*) ;;
2586           *) dllsearchpath="$dllsearchpath:$dir";;
2587           esac
2588           case :$dllsearchpath: in
2589           *":$testbindir:"*) ;;
2590           *) dllsearchpath="$dllsearchpath:$testbindir";;
2591           esac
2592           ;;
2593         esac
2594         continue
2595         ;;
2597       -l*)
2598         if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
2599           case $host in
2600           *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
2601             # These systems don't actually have a C or math library (as such)
2602             continue
2603             ;;
2604           *-*-os2*)
2605             # These systems don't actually have a C library (as such)
2606             test "X$arg" = "X-lc" && continue
2607             ;;
2608           *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
2609             # Do not include libc due to us having libc/libc_r.
2610             test "X$arg" = "X-lc" && continue
2611             ;;
2612           *-*-rhapsody* | *-*-darwin1.[[012]])
2613             # Rhapsody C and math libraries are in the System framework
2614             deplibs="$deplibs System.ltframework"
2615             continue
2616             ;;
2617           *-*-sco3.2v5* | *-*-sco5v6*)
2618             # Causes problems with __ctype
2619             test "X$arg" = "X-lc" && continue
2620             ;;
2621           *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
2622             # Compiler inserts libc in the correct place for threads to work
2623             test "X$arg" = "X-lc" && continue
2624             ;;
2625           esac
2626         elif test "X$arg" = "X-lc_r"; then
2627          case $host in
2628          *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
2629            # Do not include libc_r directly, use -pthread flag.
2630            continue
2631            ;;
2632          esac
2633         fi
2634         deplibs="$deplibs $arg"
2635         continue
2636         ;;
2638       -module)
2639         module=yes
2640         continue
2641         ;;
2643       # Tru64 UNIX uses -model [arg] to determine the layout of C++
2644       # classes, name mangling, and exception handling.
2645       # Darwin uses the -arch flag to determine output architecture.
2646       -model|-arch|-isysroot)
2647         compile_command="$compile_command $arg"
2648         compiler_flags="$compiler_flags $arg"
2649         finalize_command="$finalize_command $arg"
2650         prev=xcompiler
2651         continue
2652         ;;
2654       -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
2655         compiler_flags="$compiler_flags $arg"
2656         compile_command="$compile_command $arg"
2657         finalize_command="$finalize_command $arg"
2658         case "$new_inherited_linker_flags " in
2659             *" $arg "*) ;;
2660             * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
2661         esac
2662         continue
2663         ;;
2665       -no-fast-install)
2666         fast_install=no
2667         continue
2668         ;;
2670       -no-install)
2671         case $host in
2672         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
2673           # The PATH hackery in wrapper scripts is required on Windows
2674           # in order for the loader to find any dlls it needs.
2675           func_warning "\`-no-install' is ignored for $host"
2676           func_warning "assuming \`-no-fast-install' instead"
2677           fast_install=no
2678           ;;
2679         *) no_install=yes ;;
2680         esac
2681         continue
2682         ;;
2684       -no-undefined)
2685         allow_undefined=no
2686         continue
2687         ;;
2689       -objectlist)
2690         prev=objectlist
2691         continue
2692         ;;
2694       -o) prev=output ;;
2696       -precious-files-regex)
2697         prev=precious_regex
2698         continue
2699         ;;
2701       -release)
2702         prev=release
2703         continue
2704         ;;
2706       -rpath)
2707         prev=rpath
2708         continue
2709         ;;
2711       -R)
2712         prev=xrpath
2713         continue
2714         ;;
2716       -R*)
2717         func_stripname '-R' '' "$arg"
2718         dir=$func_stripname_result
2719         # We need an absolute path.
2720         case $dir in
2721         [[\\/]]* | [[A-Za-z]]:[[\\/]]*) ;;
2722         *)
2723           func_fatal_error "only absolute run-paths are allowed"
2724           ;;
2725         esac
2726         case "$xrpath " in
2727         *" $dir "*) ;;
2728         *) xrpath="$xrpath $dir" ;;
2729         esac
2730         continue
2731         ;;
2733       -shared)
2734         # The effects of -shared are defined in a previous loop.
2735         continue
2736         ;;
2738       -shrext)
2739         prev=shrext
2740         continue
2741         ;;
2743       -static)
2744         # The effects of -static are defined in a previous loop.
2745         # We used to do the same as -all-static on platforms that
2746         # didn't have a PIC flag, but the assumption that the effects
2747         # would be equivalent was wrong.  It would break on at least
2748         # Digital Unix and AIX.
2749         continue
2750         ;;
2752       -thread-safe)
2753         thread_safe=yes
2754         continue
2755         ;;
2757       -version-info)
2758         prev=vinfo
2759         continue
2760         ;;
2762       -version-number)
2763         prev=vinfo
2764         vinfo_number=yes
2765         continue
2766         ;;
2768       -weak)
2769         prev=weak
2770         continue
2771         ;;
2773       -Wc,*)
2774         func_stripname '-Wc,' '' "$arg"
2775         args=$func_stripname_result
2776         arg=
2777         save_ifs="$IFS"; IFS=','
2778         for flag in $args; do
2779           IFS="$save_ifs"
2780           func_quote_for_eval "$flag"
2781           arg="$arg $wl$func_quote_for_eval_result"
2782           compiler_flags="$compiler_flags $func_quote_for_eval_result"
2783         done
2784         IFS="$save_ifs"
2785         func_stripname ' ' '' "$arg"
2786         arg=$func_stripname_result
2787         ;;
2789       -Wl,*)
2790         func_stripname '-Wl,' '' "$arg"
2791         args=$func_stripname_result
2792         arg=
2793         save_ifs="$IFS"; IFS=','
2794         for flag in $args; do
2795           IFS="$save_ifs"
2796           func_quote_for_eval "$flag"
2797           arg="$arg $wl$func_quote_for_eval_result"
2798           compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
2799           linker_flags="$linker_flags $func_quote_for_eval_result"
2800         done
2801         IFS="$save_ifs"
2802         func_stripname ' ' '' "$arg"
2803         arg=$func_stripname_result
2804         ;;
2806       -Xcompiler)
2807         prev=xcompiler
2808         continue
2809         ;;
2811       -Xlinker)
2812         prev=xlinker
2813         continue
2814         ;;
2816       -XCClinker)
2817         prev=xcclinker
2818         continue
2819         ;;
2821       # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
2822       # -r[0-9][0-9]* specifies the processor on the SGI compiler
2823       # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
2824       # +DA*, +DD* enable 64-bit mode on the HP compiler
2825       # -q* pass through compiler args for the IBM compiler
2826       # -m*, -t[45]*, -txscale* pass through architecture-specific
2827       # compiler args for GCC
2828       -64|-mips[[0-9]]|-r[[0-9]][[0-9]]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
2829       -t[[45]]*|-txscale*)
2830         func_quote_for_eval "$arg"
2831         arg="$func_quote_for_eval_result"
2832         compile_command="$compile_command $arg"
2833         finalize_command="$finalize_command $arg"
2834         compiler_flags="$compiler_flags $arg"
2835         continue
2836         ;;
2838       # Some other compiler flag.
2839       -* | +*)
2840         func_quote_for_eval "$arg"
2841         arg="$func_quote_for_eval_result"
2842         ;;
2844       *.$objext)
2845         # A standard object.
2846         objs="$objs $arg"
2847         ;;
2849       *.lo)
2850         # A libtool-controlled object.
2852         # Check to see that this really is a libtool object.
2853         if func_lalib_unsafe_p "$arg"; then
2854           pic_object=
2855           non_pic_object=
2857           # Read the .lo file
2858           func_source "$arg"
2860           if test -z "$pic_object" ||
2861              test -z "$non_pic_object" ||
2862              test "$pic_object" = none &&
2863              test "$non_pic_object" = none; then
2864             func_fatal_error "cannot find name of object for \`$arg'"
2865           fi
2867           # Extract subdirectory from the argument.
2868           func_dirname "$arg" "/" ""
2869           xdir="$func_dirname_result"
2871           if test "$pic_object" != none; then
2872             # Prepend the subdirectory the object is found in.
2873             pic_object="$xdir$pic_object"
2875             if test "$prev" = dlfiles; then
2876               if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
2877                 dlfiles="$dlfiles $pic_object"
2878                 prev=
2879                 continue
2880               else
2881                 # If libtool objects are unsupported, then we need to preload.
2882                 prev=dlprefiles
2883               fi
2884             fi
2886             # CHECK ME:  I think I busted this.  -Ossama
2887             if test "$prev" = dlprefiles; then
2888               # Preload the old-style object.
2889               dlprefiles="$dlprefiles $pic_object"
2890               prev=
2891             fi
2893             # A PIC object.
2894             libobjs="$libobjs $pic_object"
2895             arg="$pic_object"
2896           fi
2898           # Non-PIC object.
2899           if test "$non_pic_object" != none; then
2900             # Prepend the subdirectory the object is found in.
2901             non_pic_object="$xdir$non_pic_object"
2903             # A standard non-PIC object
2904             non_pic_objects="$non_pic_objects $non_pic_object"
2905             if test -z "$pic_object" || test "$pic_object" = none ; then
2906               arg="$non_pic_object"
2907             fi
2908           else
2909             # If the PIC object exists, use it instead.
2910             # $xdir was prepended to $pic_object above.
2911             non_pic_object="$pic_object"
2912             non_pic_objects="$non_pic_objects $non_pic_object"
2913           fi
2914         else
2915           # Only an error if not doing a dry-run.
2916           if $opt_dry_run; then
2917             # Extract subdirectory from the argument.
2918             func_dirname "$arg" "/" ""
2919             xdir="$func_dirname_result"
2921             pic_object=`$ECHO "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
2922             non_pic_object=`$ECHO "X${xdir}${arg}" | $Xsed -e "$lo2o"`
2923             libobjs="$libobjs $pic_object"
2924             non_pic_objects="$non_pic_objects $non_pic_object"
2925           else
2926             func_fatal_error "\`$arg' is not a valid libtool object"
2927           fi
2928         fi
2929         ;;
2931       *.$libext)
2932         # An archive.
2933         deplibs="$deplibs $arg"
2934         old_deplibs="$old_deplibs $arg"
2935         continue
2936         ;;
2938       *.la)
2939         # A libtool-controlled library.
2941         if test "$prev" = dlfiles; then
2942           # This library was specified with -dlopen.
2943           dlfiles="$dlfiles $arg"
2944           prev=
2945         elif test "$prev" = dlprefiles; then
2946           # The library was specified with -dlpreopen.
2947           dlprefiles="$dlprefiles $arg"
2948           prev=
2949         else
2950           deplibs="$deplibs $arg"
2951         fi
2952         continue
2953         ;;
2955       # Some other compiler argument.
2956       *)
2957         # Unknown arguments in both finalize_command and compile_command need
2958         # to be aesthetically quoted because they are evaled later.
2959         func_quote_for_eval "$arg"
2960         arg="$func_quote_for_eval_result"
2961         ;;
2962       esac # arg
2964       # Now actually substitute the argument into the commands.
2965       if test -n "$arg"; then
2966         compile_command="$compile_command $arg"
2967         finalize_command="$finalize_command $arg"
2968       fi
2969     done # argument parsing loop
2971     test -n "$prev" && \
2972       func_fatal_help "the \`$prevarg' option requires an argument"
2974     if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
2975       eval arg=\"$export_dynamic_flag_spec\"
2976       compile_command="$compile_command $arg"
2977       finalize_command="$finalize_command $arg"
2978     fi
2980     oldlibs=
2981     # calculate the name of the file, without its directory
2982     func_basename "$output"
2983     outputname="$func_basename_result"
2984     libobjs_save="$libobjs"
2986     if test -n "$shlibpath_var"; then
2987       # get the directories listed in $shlibpath_var
2988       eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
2989     else
2990       shlib_search_path=
2991     fi
2992     eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
2993     eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
2995     func_dirname "$output" "/" ""
2996     output_objdir="$func_dirname_result$objdir"
2997     # Create the object directory.
2998     func_mkdir_p "$output_objdir"
3000     # Determine the type of output
3001     case $output in
3002     "")
3003       func_fatal_help "you must specify an output file"
3004       ;;
3005     *.$libext) linkmode=oldlib ;;
3006     *.lo | *.$objext) linkmode=obj ;;
3007     *.la) linkmode=lib ;;
3008     *) linkmode=prog ;; # Anything else should be a program.
3009     esac
3011     specialdeplibs=
3013     libs=
3014     # Find all interdependent deplibs by searching for libraries
3015     # that are linked more than once (e.g. -la -lb -la)
3016     for deplib in $deplibs; do
3017       if $opt_duplicate_deps ; then
3018         case "$libs " in
3019         *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
3020         esac
3021       fi
3022       libs="$libs $deplib"
3023     done
3025     if test "$linkmode" = lib; then
3026       libs="$predeps $libs $compiler_lib_search_path $postdeps"
3028       # Compute libraries that are listed more than once in $predeps
3029       # $postdeps and mark them as special (i.e., whose duplicates are
3030       # not to be eliminated).
3031       pre_post_deps=
3032       if $opt_duplicate_compiler_generated_deps; then
3033         for pre_post_dep in $predeps $postdeps; do
3034           case "$pre_post_deps " in
3035           *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
3036           esac
3037           pre_post_deps="$pre_post_deps $pre_post_dep"
3038         done
3039       fi
3040       pre_post_deps=
3041     fi
3043     deplibs=
3044     newdependency_libs=
3045     newlib_search_path=
3046     need_relink=no # whether we're linking any uninstalled libtool libraries
3047     notinst_deplibs= # not-installed libtool libraries
3048     notinst_path= # paths that contain not-installed libtool libraries
3050     case $linkmode in
3051     lib)
3052         passes="conv dlpreopen link"
3053         for file in $dlfiles $dlprefiles; do
3054           case $file in
3055           *.la) ;;
3056           *)
3057             func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
3058             ;;
3059           esac
3060         done
3061         ;;
3062     prog)
3063         compile_deplibs=
3064         finalize_deplibs=
3065         alldeplibs=no
3066         newdlfiles=
3067         newdlprefiles=
3068         passes="conv scan dlopen dlpreopen link"
3069         ;;
3070     *)  passes="conv"
3071         ;;
3072     esac
3074     for pass in $passes; do
3075       # The preopen pass in lib mode reverses $deplibs; put it back here
3076       # so that -L comes before libs that need it for instance...
3077       if test "$linkmode,$pass" = "lib,link"; then
3078         ## FIXME: Find the place where the list is rebuilt in the wrong
3079         ##        order, and fix it there properly
3080         tmp_deplibs=
3081         for deplib in $deplibs; do
3082           tmp_deplibs="$deplib $tmp_deplibs"
3083         done
3084         deplibs="$tmp_deplibs"
3085       fi
3087       if test "$linkmode,$pass" = "lib,link" ||
3088          test "$linkmode,$pass" = "prog,scan"; then
3089         libs="$deplibs"
3090         deplibs=
3091       fi
3092       if test "$linkmode" = prog; then
3093         case $pass in
3094         dlopen) libs="$dlfiles" ;;
3095         dlpreopen) libs="$dlprefiles" ;;
3096         link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
3097         esac
3098       fi
3099       if test "$linkmode,$pass" = "lib,dlpreopen"; then
3100         # Collect and forward deplibs of preopened libtool libs
3101         for lib in $dlprefiles; do
3102           # Ignore non-libtool-libs
3103           dependency_libs=
3104           case $lib in
3105           *.la) func_source "$lib" ;;
3106           esac
3108           # Collect preopened libtool deplibs, except any this library
3109           # has declared as weak libs
3110           for deplib in $dependency_libs; do
3111             deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
3112             case " $weak_libs " in
3113             *" $deplib_base "*) ;;
3114             *) deplibs="$deplibs $deplib" ;;
3115             esac
3116           done
3117         done
3118         libs="$dlprefiles"
3119       fi
3120       if test "$pass" = dlopen; then
3121         # Collect dlpreopened libraries
3122         save_deplibs="$deplibs"
3123         deplibs=
3124       fi
3126       for deplib in $libs; do
3127         lib=
3128         found=no
3129         case $deplib in
3130         -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
3131           if test "$linkmode,$pass" = "prog,link"; then
3132             compile_deplibs="$deplib $compile_deplibs"
3133             finalize_deplibs="$deplib $finalize_deplibs"
3134           else
3135             compiler_flags="$compiler_flags $deplib"
3136             if test "$linkmode" = lib ; then
3137                 case "$new_inherited_linker_flags " in
3138                     *" $deplib "*) ;;
3139                     * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
3140                 esac
3141             fi
3142           fi
3143           continue
3144           ;;
3145         -l*)
3146           if test "$linkmode" != lib && test "$linkmode" != prog; then
3147             func_warning "\`-l' is ignored for archives/objects"
3148             continue
3149           fi
3150           func_stripname '-l' '' "$deplib"
3151           name=$func_stripname_result
3152           for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
3153             for search_ext in .la $std_shrext .so .a; do
3154               # Search the libtool library
3155               lib="$searchdir/lib${name}${search_ext}"
3156               if test -f "$lib"; then
3157                 if test "$search_ext" = ".la"; then
3158                   found=yes
3159                 else
3160                   found=no
3161                 fi
3162                 break 2
3163               fi
3164             done
3165           done
3166           if test "$found" != yes; then
3167             # deplib doesn't seem to be a libtool library
3168             if test "$linkmode,$pass" = "prog,link"; then
3169               compile_deplibs="$deplib $compile_deplibs"
3170               finalize_deplibs="$deplib $finalize_deplibs"
3171             else
3172               deplibs="$deplib $deplibs"
3173               test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
3174             fi
3175             continue
3176           else # deplib is a libtool library
3177             # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
3178             # We need to do some special things here, and not later.
3179             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3180               case " $predeps $postdeps " in
3181               *" $deplib "*)
3182                 if func_lalib_p "$lib"; then
3183                   library_names=
3184                   old_library=
3185                   func_source "$lib"
3186                   for l in $old_library $library_names; do
3187                     ll="$l"
3188                   done
3189                   if test "X$ll" = "X$old_library" ; then # only static version available
3190                     found=no
3191                     func_dirname "$lib" "" "."
3192                     ladir="$func_dirname_result"
3193                     lib=$ladir/$old_library
3194                     if test "$linkmode,$pass" = "prog,link"; then
3195                       compile_deplibs="$deplib $compile_deplibs"
3196                       finalize_deplibs="$deplib $finalize_deplibs"
3197                     else
3198                       deplibs="$deplib $deplibs"
3199                       test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
3200                     fi
3201                     continue
3202                   fi
3203                 fi
3204                 ;;
3205               *) ;;
3206               esac
3207             fi
3208           fi
3209           ;; # -l
3210         *.ltframework)
3211           if test "$linkmode,$pass" = "prog,link"; then
3212             compile_deplibs="$deplib $compile_deplibs"
3213             finalize_deplibs="$deplib $finalize_deplibs"
3214           else
3215             deplibs="$deplib $deplibs"
3216             if test "$linkmode" = lib ; then
3217                 case "$new_inherited_linker_flags " in
3218                     *" $deplib "*) ;;
3219                     * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
3220                 esac
3221             fi
3222           fi
3223           continue
3224           ;;
3225         -L*)
3226           case $linkmode in
3227           lib)
3228             deplibs="$deplib $deplibs"
3229             test "$pass" = conv && continue
3230             newdependency_libs="$deplib $newdependency_libs"
3231             func_stripname '-L' '' "$deplib"
3232             newlib_search_path="$newlib_search_path $func_stripname_result"
3233             ;;
3234           prog)
3235             if test "$pass" = conv; then
3236               deplibs="$deplib $deplibs"
3237               continue
3238             fi
3239             if test "$pass" = scan; then
3240               deplibs="$deplib $deplibs"
3241             else
3242               compile_deplibs="$deplib $compile_deplibs"
3243               finalize_deplibs="$deplib $finalize_deplibs"
3244             fi
3245             func_stripname '-L' '' "$deplib"
3246             newlib_search_path="$newlib_search_path $func_stripname_result"
3247             ;;
3248           *)
3249             func_warning "\`-L' is ignored for archives/objects"
3250             ;;
3251           esac # linkmode
3252           continue
3253           ;; # -L
3254         -R*)
3255           if test "$pass" = link; then
3256             func_stripname '-R' '' "$deplib"
3257             dir=$func_stripname_result
3258             # Make sure the xrpath contains only unique directories.
3259             case "$xrpath " in
3260             *" $dir "*) ;;
3261             *) xrpath="$xrpath $dir" ;;
3262             esac
3263           fi
3264           deplibs="$deplib $deplibs"
3265           continue
3266           ;;
3267         *.la) lib="$deplib" ;;
3268         *.$libext)
3269           if test "$pass" = conv; then
3270             deplibs="$deplib $deplibs"
3271             continue
3272           fi
3273           case $linkmode in
3274           lib)
3275             # Linking convenience modules into shared libraries is allowed,
3276             # but linking other static libraries is non-portable.
3277             case " $dlpreconveniencelibs " in
3278             *" $lib "*) ;;
3279             *)
3280               valid_a_lib=no
3281               case $deplibs_check_method in
3282                 match_pattern*)
3283                   set dummy $deplibs_check_method; shift
3284                   match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
3285                   if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
3286                     | $EGREP "$match_pattern_regex" > /dev/null; then
3287                     valid_a_lib=yes
3288                   fi
3289                 ;;
3290                 pass_all)
3291                   valid_a_lib=yes
3292                 ;;
3293               esac
3294               if test "$valid_a_lib" != yes; then
3295                 $ECHO
3296                 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
3297                 $ECHO "*** I have the capability to make that library automatically link in when"
3298                 $ECHO "*** you link to this library.  But I can only do this if you have a"
3299                 $ECHO "*** shared version of the library, which you do not appear to have"
3300                 $ECHO "*** because the file extensions .$libext of this argument makes me believe"
3301                 $ECHO "*** that it is just a static archive that I should not use here."
3302               else
3303                 $ECHO
3304                 $ECHO "*** Warning: Linking the shared library $output against the"
3305                 $ECHO "*** static library $deplib is not portable!"
3306                 deplibs="$deplib $deplibs"
3307               fi
3308               ;;
3309             esac
3310             continue
3311             ;;
3312           prog)
3313             if test "$pass" != link; then
3314               deplibs="$deplib $deplibs"
3315             else
3316               compile_deplibs="$deplib $compile_deplibs"
3317               finalize_deplibs="$deplib $finalize_deplibs"
3318             fi
3319             continue
3320             ;;
3321           esac # linkmode
3322           ;; # *.$libext
3323         *.lo | *.$objext)
3324           if test "$pass" = conv; then
3325             deplibs="$deplib $deplibs"
3326           elif test "$linkmode" = prog; then
3327             if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
3328               # If there is no dlopen support or we're linking statically,
3329               # we need to preload.
3330               newdlprefiles="$newdlprefiles $deplib"
3331               compile_deplibs="$deplib $compile_deplibs"
3332               finalize_deplibs="$deplib $finalize_deplibs"
3333             else
3334               newdlfiles="$newdlfiles $deplib"
3335             fi
3336           fi
3337           continue
3338           ;;
3339         %DEPLIBS%)
3340           alldeplibs=yes
3341           continue
3342           ;;
3343         esac # case $deplib
3345         if test "$found" = yes || test -f "$lib"; then :
3346         else
3347           func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
3348         fi
3350         # Check to see that this really is a libtool archive.
3351         func_lalib_unsafe_p "$lib" \
3352           || func_fatal_error "\`$lib' is not a valid libtool archive"
3354         func_dirname "$lib" "" "."
3355         ladir="$func_dirname_result"
3357         dlname=
3358         dlopen=
3359         dlpreopen=
3360         libdir=
3361         library_names=
3362         old_library=
3363         inherited_linker_flags=
3364         # If the library was installed with an old release of libtool,
3365         # it will not redefine variables installed, or shouldnotlink
3366         installed=yes
3367         shouldnotlink=no
3368         avoidtemprpath=
3371         # Read the .la file
3372         func_source "$lib"
3374         # Convert "-framework foo" to "foo.ltframework"
3375         if test -n "$inherited_linker_flags"; then
3376           tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([[^ $]]*\)/\1.ltframework/g'`
3377           for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
3378             case " $new_inherited_linker_flags " in
3379               *" $tmp_inherited_linker_flag "*) ;;
3380               *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
3381             esac
3382           done
3383         fi
3384         dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([[^ $]]*\).ltframework% -framework \1%g'`
3385         if test "$linkmode,$pass" = "prog,link"; then
3386           compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
3387           finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
3388         else
3389           compiler_flags="$compiler_flags $inherited_linker_flags"
3390         fi
3391         if test "$linkmode,$pass" = "lib,link" ||
3392            test "$linkmode,$pass" = "prog,scan" ||
3393            { test "$linkmode" != prog && test "$linkmode" != lib; }; then
3394           test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
3395           test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
3396         fi
3398         if test "$pass" = conv; then
3399           # Only check for convenience libraries
3400           deplibs="$lib $deplibs"
3401           if test -z "$libdir"; then
3402             if test -z "$old_library"; then
3403               func_fatal_error "cannot find name of link library for \`$lib'"
3404             fi
3405             # It is a libtool convenience library, so add in its objects.
3406             convenience="$convenience $ladir/$objdir/$old_library"
3407             old_convenience="$old_convenience $ladir/$objdir/$old_library"
3408           elif test "$linkmode" != prog && test "$linkmode" != lib; then
3409             func_fatal_error "\`$lib' is not a convenience library"
3410           fi
3411           tmp_libs=
3412           for deplib in $dependency_libs; do
3413             deplibs="$deplib $deplibs"
3414             if $opt_duplicate_deps ; then
3415               case "$tmp_libs " in
3416               *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
3417               esac
3418             fi
3419             tmp_libs="$tmp_libs $deplib"
3420           done
3421           continue
3422         fi # $pass = conv
3425         # Get the name of the library we link against.
3426         linklib=
3427         for l in $old_library $library_names; do
3428           linklib="$l"
3429         done
3430         if test -z "$linklib"; then
3431           func_fatal_error "cannot find name of link library for \`$lib'"
3432         fi
3434         # This library was specified with -dlopen.
3435         if test "$pass" = dlopen; then
3436           if test -z "$libdir"; then
3437             func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
3438           fi
3439           if test -z "$dlname" ||
3440              test "$dlopen_support" != yes ||
3441              test "$build_libtool_libs" = no; then
3442             # If there is no dlname, no dlopen support or we're linking
3443             # statically, we need to preload.  We also need to preload any
3444             # dependent libraries so libltdl's deplib preloader doesn't
3445             # bomb out in the load deplibs phase.
3446             dlprefiles="$dlprefiles $lib $dependency_libs"
3447           else
3448             newdlfiles="$newdlfiles $lib"
3449           fi
3450           continue
3451         fi # $pass = dlopen
3453         # We need an absolute path.
3454         case $ladir in
3455         [[\\/]]* | [[A-Za-z]]:[[\\/]]*) abs_ladir="$ladir" ;;
3456         *)
3457           abs_ladir=`cd "$ladir" && pwd`
3458           if test -z "$abs_ladir"; then
3459             func_warning "cannot determine absolute directory name of \`$ladir'"
3460             func_warning "passing it literally to the linker, although it might fail"
3461             abs_ladir="$ladir"
3462           fi
3463           ;;
3464         esac
3465         func_basename "$lib"
3466         laname="$func_basename_result"
3468         # Find the relevant object directory and library name.
3469         if test "X$installed" = Xyes; then
3470           if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
3471             func_warning "library \`$lib' was moved."
3472             dir="$ladir"
3473             absdir="$abs_ladir"
3474             libdir="$abs_ladir"
3475           else
3476             dir="$libdir"
3477             absdir="$libdir"
3478           fi
3479           test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
3480         else
3481           if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
3482             dir="$ladir"
3483             absdir="$abs_ladir"
3484             # Remove this search path later
3485             notinst_path="$notinst_path $abs_ladir"
3486           else
3487             dir="$ladir/$objdir"
3488             absdir="$abs_ladir/$objdir"
3489             # Remove this search path later
3490             notinst_path="$notinst_path $abs_ladir"
3491           fi
3492         fi # $installed = yes
3493         func_stripname 'lib' '.la' "$laname"
3494         name=$func_stripname_result
3496         # This library was specified with -dlpreopen.
3497         if test "$pass" = dlpreopen; then
3498           if test -z "$libdir" && test "$linkmode" = prog; then
3499             func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
3500           fi
3501           # Prefer using a static library (so that no silly _DYNAMIC symbols
3502           # are required to link).
3503           if test -n "$old_library"; then
3504             newdlprefiles="$newdlprefiles $dir/$old_library"
3505             # Keep a list of preopened convenience libraries to check
3506             # that they are being used correctly in the link pass.
3507             test -z "$libdir" && \
3508                 dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
3509           # Otherwise, use the dlname, so that lt_dlopen finds it.
3510           elif test -n "$dlname"; then
3511             newdlprefiles="$newdlprefiles $dir/$dlname"
3512           else
3513             newdlprefiles="$newdlprefiles $dir/$linklib"
3514           fi
3515         fi # $pass = dlpreopen
3517         if test -z "$libdir"; then
3518           # Link the convenience library
3519           if test "$linkmode" = lib; then
3520             deplibs="$dir/$old_library $deplibs"
3521           elif test "$linkmode,$pass" = "prog,link"; then
3522             compile_deplibs="$dir/$old_library $compile_deplibs"
3523             finalize_deplibs="$dir/$old_library $finalize_deplibs"
3524           else
3525             deplibs="$lib $deplibs" # used for prog,scan pass
3526           fi
3527           continue
3528         fi
3531         if test "$linkmode" = prog && test "$pass" != link; then
3532           newlib_search_path="$newlib_search_path $ladir"
3533           deplibs="$lib $deplibs"
3535           linkalldeplibs=no
3536           if test "$link_all_deplibs" != no || test -z "$library_names" ||
3537              test "$build_libtool_libs" = no; then
3538             linkalldeplibs=yes
3539           fi
3541           tmp_libs=
3542           for deplib in $dependency_libs; do
3543             case $deplib in
3544             -L*) func_stripname '-L' '' "$deplib"
3545                  newlib_search_path="$newlib_search_path $func_stripname_result"
3546                  ;;
3547             esac
3548             # Need to link against all dependency_libs?
3549             if test "$linkalldeplibs" = yes; then
3550               deplibs="$deplib $deplibs"
3551             else
3552               # Need to hardcode shared library paths
3553               # or/and link against static libraries
3554               newdependency_libs="$deplib $newdependency_libs"
3555             fi
3556             if $opt_duplicate_deps ; then
3557               case "$tmp_libs " in
3558               *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
3559               esac
3560             fi
3561             tmp_libs="$tmp_libs $deplib"
3562           done # for deplib
3563           continue
3564         fi # $linkmode = prog...
3566         if test "$linkmode,$pass" = "prog,link"; then
3567           if test -n "$library_names" &&
3568              { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
3569             # We need to hardcode the library path
3570             if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
3571               # Make sure the rpath contains only unique directories.
3572               case "$temp_rpath " in
3573               *"$absdir:"*) ;;
3574               *) temp_rpath="$temp_rpath:$absdir" ;;
3575               esac
3576             fi
3578             # Hardcode the library path.
3579             # Skip directories that are in the system default run-time
3580             # search path.
3581             case " $sys_lib_dlsearch_path " in
3582             *" $absdir "*) ;;
3583             *)
3584               case "$compile_rpath " in
3585               *" $absdir "*) ;;
3586               *) compile_rpath="$compile_rpath $absdir"
3587               esac
3588               ;;
3589             esac
3590             case " $sys_lib_dlsearch_path " in
3591             *" $libdir "*) ;;
3592             *)
3593               case "$finalize_rpath " in
3594               *" $libdir "*) ;;
3595               *) finalize_rpath="$finalize_rpath $libdir"
3596               esac
3597               ;;
3598             esac
3599           fi # $linkmode,$pass = prog,link...
3601           if test "$alldeplibs" = yes &&
3602              { test "$deplibs_check_method" = pass_all ||
3603                { test "$build_libtool_libs" = yes &&
3604                  test -n "$library_names"; }; }; then
3605             # We only need to search for static libraries
3606             continue
3607           fi
3608         fi
3610         link_static=no # Whether the deplib will be linked statically
3611         use_static_libs=$prefer_static_libs
3612         if test "$use_static_libs" = built && test "$installed" = yes; then
3613           use_static_libs=no
3614         fi
3615         if test -n "$library_names" &&
3616            { test "$use_static_libs" = no || test -z "$old_library"; }; then
3617           case $host in
3618           *cygwin* | *mingw*)
3619               # No point in relinking DLLs because paths are not encoded
3620               notinst_deplibs="$notinst_deplibs $lib"
3621               need_relink=no
3622             ;;
3623           *)
3624             if test "$installed" = no; then
3625               notinst_deplibs="$notinst_deplibs $lib"
3626               need_relink=yes
3627             fi
3628             ;;
3629           esac
3630           # This is a shared library
3632           # Warn about portability, can't link against -module's on some
3633           # systems (darwin).  Don't bleat about dlopened modules though!
3634           dlopenmodule=""
3635           for dlpremoduletest in $dlprefiles; do
3636             if test "X$dlpremoduletest" = "X$lib"; then
3637               dlopenmodule="$dlpremoduletest"
3638               break
3639             fi
3640           done
3641           if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
3642             $ECHO
3643             if test "$linkmode" = prog; then
3644               $ECHO "*** Warning: Linking the executable $output against the loadable module"
3645             else
3646               $ECHO "*** Warning: Linking the shared library $output against the loadable module"
3647             fi
3648             $ECHO "*** $linklib is not portable!"
3649           fi
3650           if test "$linkmode" = lib &&
3651              test "$hardcode_into_libs" = yes; then
3652             # Hardcode the library path.
3653             # Skip directories that are in the system default run-time
3654             # search path.
3655             case " $sys_lib_dlsearch_path " in
3656             *" $absdir "*) ;;
3657             *)
3658               case "$compile_rpath " in
3659               *" $absdir "*) ;;
3660               *) compile_rpath="$compile_rpath $absdir"
3661               esac
3662               ;;
3663             esac
3664             case " $sys_lib_dlsearch_path " in
3665             *" $libdir "*) ;;
3666             *)
3667               case "$finalize_rpath " in
3668               *" $libdir "*) ;;
3669               *) finalize_rpath="$finalize_rpath $libdir"
3670               esac
3671               ;;
3672             esac
3673           fi
3675           if test -n "$old_archive_from_expsyms_cmds"; then
3676             # figure out the soname
3677             set dummy $library_names
3678             shift
3679             realname="$1"
3680             shift
3681             libname=`eval "\\$ECHO \"$libname_spec\""`
3682             # use dlname if we got it. it's perfectly good, no?
3683             if test -n "$dlname"; then
3684               soname="$dlname"
3685             elif test -n "$soname_spec"; then
3686               # bleh windows
3687               case $host in
3688               *cygwin* | mingw*)
3689                 major=`expr $current - $age`
3690                 versuffix="-$major"
3691                 ;;
3692               esac
3693               eval soname=\"$soname_spec\"
3694             else
3695               soname="$realname"
3696             fi
3698             # Make a new name for the extract_expsyms_cmds to use
3699             soroot="$soname"
3700             func_basename "$soroot"
3701             soname="$func_basename_result"
3702             func_stripname 'lib' '.dll' "$soname"
3703             newlib=libimp-$func_stripname_result.a
3705             # If the library has no export list, then create one now
3706             if test -f "$output_objdir/$soname-def"; then :
3707             else
3708               func_echo "extracting exported symbol list from \`$soname'"
3709               func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
3710             fi
3712             # Create $newlib
3713             if test -f "$output_objdir/$newlib"; then :; else
3714               func_echo "generating import library for \`$soname'"
3715               func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
3716             fi
3717             # make sure the library variables are pointing to the new library
3718             dir=$output_objdir
3719             linklib=$newlib
3720           fi # test -n "$old_archive_from_expsyms_cmds"
3722           if test "$linkmode" = prog || test "$mode" != relink; then
3723             add_shlibpath=
3724             add_dir=
3725             add=
3726             lib_linked=yes
3727             case $hardcode_action in
3728             immediate | unsupported)
3729               if test "$hardcode_direct" = no; then
3730                 add="$dir/$linklib"
3731                 case $host in
3732                   *-*-sco3.2v5.0.[[024]]*) add_dir="-L$dir" ;;
3733                   *-*-sysv4*uw2*) add_dir="-L$dir" ;;
3734                   *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[[01]].[[10]]* | \
3735                     *-*-unixware7*) add_dir="-L$dir" ;;
3736                   *-*-darwin* )
3737                     # if the lib is a (non-dlopened) module then we can not
3738                     # link against it, someone is ignoring the earlier warnings
3739                     if /usr/bin/file -L $add 2> /dev/null |
3740                          $GREP ": [[^:]]* bundle" >/dev/null ; then
3741                       if test "X$dlopenmodule" != "X$lib"; then
3742                         $ECHO "*** Warning: lib $linklib is a module, not a shared library"
3743                         if test -z "$old_library" ; then
3744                           $ECHO
3745                           $ECHO "*** And there doesn't seem to be a static archive available"
3746                           $ECHO "*** The link will probably fail, sorry"
3747                         else
3748                           add="$dir/$old_library"
3749                         fi
3750                       elif test -n "$old_library"; then
3751                         add="$dir/$old_library"
3752                       fi
3753                     fi
3754                 esac
3755               elif test "$hardcode_minus_L" = no; then
3756                 case $host in
3757                 *-*-sunos*) add_shlibpath="$dir" ;;
3758                 esac
3759                 add_dir="-L$dir"
3760                 add="-l$name"
3761               elif test "$hardcode_shlibpath_var" = no; then
3762                 add_shlibpath="$dir"
3763                 add="-l$name"
3764               else
3765                 lib_linked=no
3766               fi
3767               ;;
3768             relink)
3769               if test "$hardcode_direct" = yes; then
3770                 add="$dir/$linklib"
3771               elif test "$hardcode_minus_L" = yes; then
3772                 add_dir="-L$dir"
3773                 # Try looking first in the location we're being installed to.
3774                 if test -n "$inst_prefix_dir"; then
3775                   case $libdir in
3776                     [[\\/]]*)
3777                       add_dir="$add_dir -L$inst_prefix_dir$libdir"
3778                       ;;
3779                   esac
3780                 fi
3781                 add="-l$name"
3782               elif test "$hardcode_shlibpath_var" = yes; then
3783                 add_shlibpath="$dir"
3784                 add="-l$name"
3785               else
3786                 lib_linked=no
3787               fi
3788               ;;
3789             *) lib_linked=no ;;
3790             esac
3792             if test "$lib_linked" != yes; then
3793               func_fatal_configuration "unsupported hardcode properties"
3794             fi
3796             if test -n "$add_shlibpath"; then
3797               case :$compile_shlibpath: in
3798               *":$add_shlibpath:"*) ;;
3799               *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
3800               esac
3801             fi
3802             if test "$linkmode" = prog; then
3803               test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
3804               test -n "$add" && compile_deplibs="$add $compile_deplibs"
3805             else
3806               test -n "$add_dir" && deplibs="$add_dir $deplibs"
3807               test -n "$add" && deplibs="$add $deplibs"
3808               if test "$hardcode_direct" != yes &&
3809                  test "$hardcode_minus_L" != yes &&
3810                  test "$hardcode_shlibpath_var" = yes; then
3811                 case :$finalize_shlibpath: in
3812                 *":$libdir:"*) ;;
3813                 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
3814                 esac
3815               fi
3816             fi
3817           fi
3819           if test "$linkmode" = prog || test "$mode" = relink; then
3820             add_shlibpath=
3821             add_dir=
3822             add=
3823             # Finalize command for both is simple: just hardcode it.
3824             if test "$hardcode_direct" = yes; then
3825               add="$libdir/$linklib"
3826             elif test "$hardcode_minus_L" = yes; then
3827               add_dir="-L$libdir"
3828               add="-l$name"
3829             elif test "$hardcode_shlibpath_var" = yes; then
3830               case :$finalize_shlibpath: in
3831               *":$libdir:"*) ;;
3832               *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
3833               esac
3834               add="-l$name"
3835             elif test "$hardcode_automatic" = yes; then
3836               if test -n "$inst_prefix_dir" &&
3837                  test -f "$inst_prefix_dir$libdir/$linklib" ; then
3838                 add="$inst_prefix_dir$libdir/$linklib"
3839               else
3840                 add="$libdir/$linklib"
3841               fi
3842             else
3843               # We cannot seem to hardcode it, guess we'll fake it.
3844               add_dir="-L$libdir"
3845               # Try looking first in the location we're being installed to.
3846               if test -n "$inst_prefix_dir"; then
3847                 case $libdir in
3848                   [[\\/]]*)
3849                     add_dir="$add_dir -L$inst_prefix_dir$libdir"
3850                     ;;
3851                 esac
3852               fi
3853               add="-l$name"
3854             fi
3856             if test "$linkmode" = prog; then
3857               test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
3858               test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
3859             else
3860               test -n "$add_dir" && deplibs="$add_dir $deplibs"
3861               test -n "$add" && deplibs="$add $deplibs"
3862             fi
3863           fi
3864         elif test "$linkmode" = prog; then
3865           # Here we assume that one of hardcode_direct or hardcode_minus_L
3866           # is not unsupported.  This is valid on all known static and
3867           # shared platforms.
3868           if test "$hardcode_direct" != unsupported; then
3869             test -n "$old_library" && linklib="$old_library"
3870             compile_deplibs="$dir/$linklib $compile_deplibs"
3871             finalize_deplibs="$dir/$linklib $finalize_deplibs"
3872           else
3873             compile_deplibs="-l$name -L$dir $compile_deplibs"
3874             finalize_deplibs="-l$name -L$dir $finalize_deplibs"
3875           fi
3876         elif test "$build_libtool_libs" = yes; then
3877           # Not a shared library
3878           if test "$deplibs_check_method" != pass_all; then
3879             # We're trying link a shared library against a static one
3880             # but the system doesn't support it.
3882             # Just print a warning and add the library to dependency_libs so
3883             # that the program can be linked against the static library.
3884             $ECHO
3885             $ECHO "*** Warning: This system can not link to static lib archive $lib."
3886             $ECHO "*** I have the capability to make that library automatically link in when"
3887             $ECHO "*** you link to this library.  But I can only do this if you have a"
3888             $ECHO "*** shared version of the library, which you do not appear to have."
3889             if test "$module" = yes; then
3890               $ECHO "*** But as you try to build a module library, libtool will still create "
3891               $ECHO "*** a static module, that should work as long as the dlopening application"
3892               $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
3893               if test -z "$global_symbol_pipe"; then
3894                 $ECHO
3895                 $ECHO "*** However, this would only work if libtool was able to extract symbol"
3896                 $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
3897                 $ECHO "*** not find such a program.  So, this module is probably useless."
3898                 $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
3899               fi
3900               if test "$build_old_libs" = no; then
3901                 build_libtool_libs=module
3902                 build_old_libs=yes
3903               else
3904                 build_libtool_libs=no
3905               fi
3906             fi
3907           else
3908             deplibs="$dir/$old_library $deplibs"
3909             link_static=yes
3910           fi
3911         fi # link shared/static library?
3913         if test "$linkmode" = lib; then
3914           if test -n "$dependency_libs" &&
3915              { test "$hardcode_into_libs" != yes ||
3916                test "$build_old_libs" = yes ||
3917                test "$link_static" = yes; }; then
3918             # Extract -R from dependency_libs
3919             temp_deplibs=
3920             for libdir in $dependency_libs; do
3921               case $libdir in
3922               -R*) func_stripname '-R' '' "$libdir"
3923                    temp_xrpath=$func_stripname_result
3924                    case " $xrpath " in
3925                    *" $temp_xrpath "*) ;;
3926                    *) xrpath="$xrpath $temp_xrpath";;
3927                    esac;;
3928               *) temp_deplibs="$temp_deplibs $libdir";;
3929               esac
3930             done
3931             dependency_libs="$temp_deplibs"
3932           fi
3934           newlib_search_path="$newlib_search_path $absdir"
3935           # Link against this library
3936           test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
3937           # ... and its dependency_libs
3938           tmp_libs=
3939           for deplib in $dependency_libs; do
3940             newdependency_libs="$deplib $newdependency_libs"
3941             if $opt_duplicate_deps ; then
3942               case "$tmp_libs " in
3943               *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
3944               esac
3945             fi
3946             tmp_libs="$tmp_libs $deplib"
3947           done
3949           if test "$link_all_deplibs" != no; then
3950             # Add the search paths of all dependency libraries
3951             for deplib in $dependency_libs; do
3952               case $deplib in
3953               -L*) path="$deplib" ;;
3954               *.la)
3955                 func_dirname "$deplib" "" "."
3956                 dir="$func_dirname_result"
3957                 # We need an absolute path.
3958                 case $dir in
3959                 [[\\/]]* | [[A-Za-z]]:[[\\/]]*) absdir="$dir" ;;
3960                 *)
3961                   absdir=`cd "$dir" && pwd`
3962                   if test -z "$absdir"; then
3963                     func_warning "cannot determine absolute directory name of \`$dir'"
3964                     absdir="$dir"
3965                   fi
3966                   ;;
3967                 esac
3968                 if $GREP "^installed=no" $deplib > /dev/null; then
3969                 case $host in
3970                 *-*-darwin*)
3971                   depdepl=
3972                   eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
3973                   if test -n "$deplibrary_names" ; then
3974                     for tmp in $deplibrary_names ; do
3975                       depdepl=$tmp
3976                     done
3977                     if test -f "$absdir/$objdir/$depdepl" ; then
3978                       depdepl="$absdir/$objdir/$depdepl"
3979                       darwin_install_name=`otool -L $depdepl | $SED -n -e '3q;2,2p' | $SED -e 's/(.*//'`
3980                       darwin_install_name=`$ECHO $darwin_install_name`
3981                       compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
3982                       linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
3983                       path=
3984                     fi
3985                   fi
3986                   ;;
3987                 *)
3988                   path="-L$absdir/$objdir"
3989                   ;;
3990                 esac
3991                 else
3992                   eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
3993                   test -z "$libdir" && \
3994                     func_fatal_error "\`$deplib' is not a valid libtool archive"
3995                   test "$absdir" != "$libdir" && \
3996                     func_warning "\`$deplib' seems to be moved"
3998                   path="-L$absdir"
3999                 fi
4000                 ;;
4001               esac
4002               case " $deplibs " in
4003               *" $path "*) ;;
4004               *) deplibs="$path $deplibs" ;;
4005               esac
4006             done
4007           fi # link_all_deplibs != no
4008         fi # linkmode = lib
4009       done # for deplib in $libs
4010       dependency_libs="$newdependency_libs"
4011       if test "$pass" = dlpreopen; then
4012         # Link the dlpreopened libraries before other libraries
4013         for deplib in $save_deplibs; do
4014           deplibs="$deplib $deplibs"
4015         done
4016       fi
4017       if test "$pass" != dlopen; then
4018         if test "$pass" != conv; then
4019           # Make sure lib_search_path contains only unique directories.
4020           lib_search_path=
4021           for dir in $newlib_search_path; do
4022             case "$lib_search_path " in
4023             *" $dir "*) ;;
4024             *) lib_search_path="$lib_search_path $dir" ;;
4025             esac
4026           done
4027           newlib_search_path=
4028         fi
4030         if test "$linkmode,$pass" != "prog,link"; then
4031           vars="deplibs"
4032         else
4033           vars="compile_deplibs finalize_deplibs"
4034         fi
4035         for var in $vars dependency_libs; do
4036           # Add libraries to $var in reverse order
4037           eval tmp_libs=\"\$$var\"
4038           new_libs=
4039           for deplib in $tmp_libs; do
4040             # FIXME: Pedantically, this is the right thing to do, so
4041             #        that some nasty dependency loop isn't accidentally
4042             #        broken:
4043             #new_libs="$deplib $new_libs"
4044             # Pragmatically, this seems to cause very few problems in
4045             # practice:
4046             case $deplib in
4047             -L*) new_libs="$deplib $new_libs" ;;
4048             -R*) ;;
4049             *)
4050               # And here is the reason: when a library appears more
4051               # than once as an explicit dependence of a library, or
4052               # is implicitly linked in more than once by the
4053               # compiler, it is considered special, and multiple
4054               # occurrences thereof are not removed.  Compare this
4055               # with having the same library being listed as a
4056               # dependency of multiple other libraries: in this case,
4057               # we know (pedantically, we assume) the library does not
4058               # need to be listed more than once, so we keep only the
4059               # last copy.  This is not always right, but it is rare
4060               # enough that we require users that really mean to play
4061               # such unportable linking tricks to link the library
4062               # using -Wl,-lname, so that libtool does not consider it
4063               # for duplicate removal.
4064               case " $specialdeplibs " in
4065               *" $deplib "*) new_libs="$deplib $new_libs" ;;
4066               *)
4067                 case " $new_libs " in
4068                 *" $deplib "*) ;;
4069                 *) new_libs="$deplib $new_libs" ;;
4070                 esac
4071                 ;;
4072               esac
4073               ;;
4074             esac
4075           done
4076           tmp_libs=
4077           for deplib in $new_libs; do
4078             case $deplib in
4079             -L*)
4080               case " $tmp_libs " in
4081               *" $deplib "*) ;;
4082               *) tmp_libs="$tmp_libs $deplib" ;;
4083               esac
4084               ;;
4085             *) tmp_libs="$tmp_libs $deplib" ;;
4086             esac
4087           done
4088           eval $var=\"$tmp_libs\"
4089         done # for var
4090       fi
4091       # Last step: remove runtime libs from dependency_libs
4092       # (they stay in deplibs)
4093       tmp_libs=
4094       for i in $dependency_libs ; do
4095         case " $predeps $postdeps $compiler_lib_search_path " in
4096         *" $i "*)
4097           i=""
4098           ;;
4099         esac
4100         if test -n "$i" ; then
4101           tmp_libs="$tmp_libs $i"
4102         fi
4103       done
4104       dependency_libs=$tmp_libs
4105     done # for pass
4106     if test "$linkmode" = prog; then
4107       dlfiles="$newdlfiles"
4108     fi
4109     if test "$linkmode" = prog || test "$linkmode" = lib; then
4110       dlprefiles="$newdlprefiles"
4111     fi
4113     case $linkmode in
4114     oldlib)
4115       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
4116         func_warning "\`-dlopen' is ignored for archives"
4117       fi
4119       test -n "$deplibs" && \
4120         func_warning "\`-l' and \`-L' are ignored for archives"
4123       test -n "$rpath" && \
4124         func_warning "\`-rpath' is ignored for archives"
4126       test -n "$xrpath" && \
4127         func_warning "\`-R' is ignored for archives"
4129       test -n "$vinfo" && \
4130         func_warning "\`-version-info/-version-number' is ignored for archives"
4132       test -n "$release" && \
4133         func_warning "\`-release' is ignored for archives"
4135       test -n "$export_symbols$export_symbols_regex" && \
4136         func_warning "\`-export-symbols' is ignored for archives"
4138       # Now set the variables for building old libraries.
4139       build_libtool_libs=no
4140       oldlibs="$output"
4141       objs="$objs$old_deplibs"
4142       ;;
4144     lib)
4145       # Make sure we only generate libraries of the form `libNAME.la'.
4146       case $outputname in
4147       lib*)
4148         func_stripname 'lib' '.la' "$outputname"
4149         name=$func_stripname_result
4150         eval shared_ext=\"$shrext_cmds\"
4151         eval libname=\"$libname_spec\"
4152         ;;
4153       *)
4154         test "$module" = no && \
4155           func_fatal_help "libtool library \`$output' must begin with \`lib'"
4157         if test "$need_lib_prefix" != no; then
4158           # Add the "lib" prefix for modules if required
4159           func_stripname '' '.la' "$outputname"
4160           name=$func_stripname_result
4161           eval shared_ext=\"$shrext_cmds\"
4162           eval libname=\"$libname_spec\"
4163         else
4164           func_stripname '' '.la' "$outputname"
4165           libname=$func_stripname_result
4166         fi
4167         ;;
4168       esac
4170       if test -n "$objs"; then
4171         if test "$deplibs_check_method" != pass_all; then
4172           func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
4173         else
4174           $ECHO
4175           $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
4176           $ECHO "*** objects $objs is not portable!"
4177           libobjs="$libobjs $objs"
4178         fi
4179       fi
4181       test "$dlself" != no && \
4182         func_warning "\`-dlopen self' is ignored for libtool libraries"
4184       set dummy $rpath
4185       shift
4186       test "$#" -gt 1 && \
4187         func_warning "ignoring multiple \`-rpath's for a libtool library"
4189       install_libdir="$1"
4191       oldlibs=
4192       if test -z "$rpath"; then
4193         if test "$build_libtool_libs" = yes; then
4194           # Building a libtool convenience library.
4195           # Some compilers have problems with a `.al' extension so
4196           # convenience libraries should have the same extension an
4197           # archive normally would.
4198           oldlibs="$output_objdir/$libname.$libext $oldlibs"
4199           build_libtool_libs=convenience
4200           build_old_libs=yes
4201         fi
4203         test -n "$vinfo" && \
4204           func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
4206         test -n "$release" && \
4207           func_warning "\`-release' is ignored for convenience libraries"
4208       else
4210         # Parse the version information argument.
4211         save_ifs="$IFS"; IFS=':'
4212         set dummy $vinfo 0 0 0
4213         shift
4214         IFS="$save_ifs"
4216         test -n "$7" && \
4217           func_fatal_help "too many parameters to \`-version-info'"
4219         # convert absolute version numbers to libtool ages
4220         # this retains compatibility with .la files and attempts
4221         # to make the code below a bit more comprehensible
4223         case $vinfo_number in
4224         yes)
4225           number_major="$1"
4226           number_minor="$2"
4227           number_revision="$3"
4228           #
4229           # There are really only two kinds -- those that
4230           # use the current revision as the major version
4231           # and those that subtract age and use age as
4232           # a minor version.  But, then there is irix
4233           # which has an extra 1 added just for fun
4234           #
4235           case $version_type in
4236           darwin|linux|osf|windows)
4237             current=`expr $number_major + $number_minor`
4238             age="$number_minor"
4239             revision="$number_revision"
4240             ;;
4241           freebsd-aout|freebsd-elf|sunos)
4242             current="$number_major"
4243             revision="$number_minor"
4244             age="0"
4245             ;;
4246           irix|nonstopux)
4247             current=`expr $number_major + $number_minor - 1`
4248             age="$number_minor"
4249             revision="$number_minor"
4250             ;;
4251           esac
4252           ;;
4253         no)
4254           current="$1"
4255           revision="$2"
4256           age="$3"
4257           ;;
4258         esac
4260         # Check that each of the things are valid numbers.
4261         case $current in
4262         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]]) ;;
4263         *)
4264           func_error "CURRENT \`$current' must be a nonnegative integer"
4265           func_fatal_error "\`$vinfo' is not valid version information"
4266           ;;
4267         esac
4269         case $revision in
4270         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]]) ;;
4271         *)
4272           func_error "REVISION \`$revision' must be a nonnegative integer"
4273           func_fatal_error "\`$vinfo' is not valid version information"
4274           ;;
4275         esac
4277         case $age in
4278         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]]) ;;
4279         *)
4280           func_error "AGE \`$age' must be a nonnegative integer"
4281           func_fatal_error "\`$vinfo' is not valid version information"
4282           ;;
4283         esac
4285         if test "$age" -gt "$current"; then
4286           func_error "AGE \`$age' is greater than the current interface number \`$current'"
4287           func_fatal_error "\`$vinfo' is not valid version information"
4288         fi
4290         # Calculate the version variables.
4291         major=
4292         versuffix=
4293         verstring=
4294         case $version_type in
4295         none) ;;
4297         darwin)
4298           # Like Linux, but with the current version available in
4299           # verstring for coding it into the library header
4300           major=.`expr $current - $age`
4301           versuffix="$major.$age.$revision"
4302           # Darwin ld doesn't like 0 for these options...
4303           minor_current=`expr $current + 1`
4304           verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
4305           ;;
4307         freebsd-aout)
4308           major=".$current"
4309           versuffix=".$current.$revision";
4310           ;;
4312         freebsd-elf)
4313           major=".$current"
4314           versuffix=".$current"
4315           ;;
4317         irix | nonstopux)
4318           major=`expr $current - $age + 1`
4320           case $version_type in
4321             nonstopux) verstring_prefix=nonstopux ;;
4322             *)         verstring_prefix=sgi ;;
4323           esac
4324           verstring="$verstring_prefix$major.$revision"
4326           # Add in all the interfaces that we are compatible with.
4327           loop=$revision
4328           while test "$loop" -ne 0; do
4329             iface=`expr $revision - $loop`
4330             loop=`expr $loop - 1`
4331             verstring="$verstring_prefix$major.$iface:$verstring"
4332           done
4334           # Before this point, $major must not contain `.'.
4335           major=.$major
4336           versuffix="$major.$revision"
4337           ;;
4339         linux)
4340           major=.`expr $current - $age`
4341           versuffix="$major.$age.$revision"
4342           ;;
4344         osf)
4345           major=.`expr $current - $age`
4346           versuffix=".$current.$age.$revision"
4347           verstring="$current.$age.$revision"
4349           # Add in all the interfaces that we are compatible with.
4350           loop=$age
4351           while test "$loop" -ne 0; do
4352             iface=`expr $current - $loop`
4353             loop=`expr $loop - 1`
4354             verstring="$verstring:${iface}.0"
4355           done
4357           # Make executables depend on our current version.
4358           verstring="$verstring:${current}.0"
4359           ;;
4361         qnx)
4362           major=".$current"
4363           versuffix=".$current"
4364           ;;
4366         sunos)
4367           major=".$current"
4368           versuffix=".$current.$revision"
4369           ;;
4371         windows)
4372           # Use '-' rather than '.', since we only want one
4373           # extension on DOS 8.3 filesystems.
4374           major=`expr $current - $age`
4375           versuffix="-$major"
4376           ;;
4378         *)
4379           func_fatal_configuration "unknown library version type \`$version_type'"
4380           ;;
4381         esac
4383         # Clear the version info if we defaulted, and they specified a release.
4384         if test -z "$vinfo" && test -n "$release"; then
4385           major=
4386           case $version_type in
4387           darwin)
4388             # we can't check for "0.0" in archive_cmds due to quoting
4389             # problems, so we reset it completely
4390             verstring=
4391             ;;
4392           *)
4393             verstring="0.0"
4394             ;;
4395           esac
4396           if test "$need_version" = no; then
4397             versuffix=
4398           else
4399             versuffix=".0.0"
4400           fi
4401         fi
4403         # Remove version info from name if versioning should be avoided
4404         if test "$avoid_version" = yes && test "$need_version" = no; then
4405           major=
4406           versuffix=
4407           verstring=""
4408         fi
4410         # Check to see if the archive will have undefined symbols.
4411         if test "$allow_undefined" = yes; then
4412           if test "$allow_undefined_flag" = unsupported; then
4413             func_warning "undefined symbols not allowed in $host shared libraries"
4414             build_libtool_libs=no
4415             build_old_libs=yes
4416           fi
4417         else
4418           # Don't allow undefined symbols.
4419           allow_undefined_flag="$no_undefined_flag"
4420         fi
4422       fi
4424       func_generate_dlsyms "$libname" "$libname" "yes"
4425       libobjs="$libobjs $symfileobj"
4427       if test "$mode" != relink; then
4428         # Remove our outputs, but don't remove object files since they
4429         # may have been created when compiling PIC objects.
4430         removelist=
4431         tempremovelist=`$ECHO "$output_objdir/*"`
4432         for p in $tempremovelist; do
4433           case $p in
4434             *.$objext)
4435                ;;
4436             $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
4437                if test "X$precious_files_regex" != "X"; then
4438                  if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
4439                  then
4440                    continue
4441                  fi
4442                fi
4443                removelist="$removelist $p"
4444                ;;
4445             *) ;;
4446           esac
4447         done
4448         test -n "$removelist" && \
4449           func_show_eval "${RM}r \$removelist"
4450       fi
4452       # Now set the variables for building old libraries.
4453       if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
4454         oldlibs="$oldlibs $output_objdir/$libname.$libext"
4456         # Transform .lo files to .o files.
4457         oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
4458       fi
4460       # Eliminate all temporary directories.
4461       for path in $notinst_path; do
4462         lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e 's% $path % %g'`
4463         deplibs=`$ECHO "X$deplibs " | $Xsed -e 's% -L$path % %g'`
4464         dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e 's% -L$path % %g'`
4465       done
4467       if test -n "$xrpath"; then
4468         # If the user specified any rpath flags, then add them.
4469         temp_xrpath=
4470         for libdir in $xrpath; do
4471           temp_xrpath="$temp_xrpath -R$libdir"
4472           case "$finalize_rpath " in
4473           *" $libdir "*) ;;
4474           *) finalize_rpath="$finalize_rpath $libdir" ;;
4475           esac
4476         done
4477         if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
4478           dependency_libs="$temp_xrpath $dependency_libs"
4479         fi
4480       fi
4482       # Make sure dlfiles contains only unique files that won't be dlpreopened
4483       old_dlfiles="$dlfiles"
4484       dlfiles=
4485       for lib in $old_dlfiles; do
4486         case " $dlprefiles $dlfiles " in
4487         *" $lib "*) ;;
4488         *) dlfiles="$dlfiles $lib" ;;
4489         esac
4490       done
4492       # Make sure dlprefiles contains only unique files
4493       old_dlprefiles="$dlprefiles"
4494       dlprefiles=
4495       for lib in $old_dlprefiles; do
4496         case "$dlprefiles " in
4497         *" $lib "*) ;;
4498         *) dlprefiles="$dlprefiles $lib" ;;
4499         esac
4500       done
4502       if test "$build_libtool_libs" = yes; then
4503         if test -n "$rpath"; then
4504           case $host in
4505           *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
4506             # these systems don't actually have a c library (as such)!
4507             ;;
4508           *-*-rhapsody* | *-*-darwin1.[[012]])
4509             # Rhapsody C library is in the System framework
4510             deplibs="$deplibs System.ltframework"
4511             ;;
4512           *-*-netbsd*)
4513             # Don't link with libc until the a.out ld.so is fixed.
4514             ;;
4515           *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4516             # Do not include libc due to us having libc/libc_r.
4517             ;;
4518           *-*-sco3.2v5* | *-*-sco5v6*)
4519             # Causes problems with __ctype
4520             ;;
4521           *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
4522             # Compiler inserts libc in the correct place for threads to work
4523             ;;
4524           *)
4525             # Add libc to deplibs on all other systems if necessary.
4526             if test "$build_libtool_need_lc" = "yes"; then
4527               deplibs="$deplibs -lc"
4528             fi
4529             ;;
4530           esac
4531         fi
4533         # Transform deplibs into only deplibs that can be linked in shared.
4534         name_save=$name
4535         libname_save=$libname
4536         release_save=$release
4537         versuffix_save=$versuffix
4538         major_save=$major
4539         # I'm not sure if I'm treating the release correctly.  I think
4540         # release should show up in the -l (ie -lgmp5) so we don't want to
4541         # add it in twice.  Is that correct?
4542         release=""
4543         versuffix=""
4544         major=""
4545         newdeplibs=
4546         droppeddeps=no
4547         case $deplibs_check_method in
4548         pass_all)
4549           # Don't check for shared/static.  Everything works.
4550           # This might be a little naive.  We might want to check
4551           # whether the library exists or not.  But this is on
4552           # osf3 & osf4 and I'm not really sure... Just
4553           # implementing what was already the behavior.
4554           newdeplibs=$deplibs
4555           ;;
4556         test_compile)
4557           # This code stresses the "libraries are programs" paradigm to its
4558           # limits. Maybe even breaks it.  We compile a program, linking it
4559           # against the deplibs as a proxy for the library.  Then we can check
4560           # whether they linked in statically or dynamically with ldd.
4561           $opt_dry_run || $RM conftest.c
4562           cat > conftest.c <<EOF
4563           int main() { return 0; }
4565           $opt_dry_run || $RM conftest
4566           $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
4567           if test "$?" -eq 0 ; then
4568             ldd_output=`ldd conftest`
4569             for i in $deplibs; do
4570               name=`expr $i : '-l\(.*\)'`
4571               # If $name is empty we are operating on a -L argument.
4572               if test "$name" != "" && test "$name" -ne "0"; then
4573                 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
4574                   case " $predeps $postdeps " in
4575                   *" $i "*)
4576                     newdeplibs="$newdeplibs $i"
4577                     i=""
4578                     ;;
4579                   esac
4580                 fi
4581                 if test -n "$i" ; then
4582                   libname=`eval "\\$ECHO \"$libname_spec\""`
4583                   deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
4584                   set dummy $deplib_matches; shift
4585                   deplib_match=$1
4586                   if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
4587                     newdeplibs="$newdeplibs $i"
4588                   else
4589                     droppeddeps=yes
4590                     $ECHO
4591                     $ECHO "*** Warning: dynamic linker does not accept needed library $i."
4592                     $ECHO "*** I have the capability to make that library automatically link in when"
4593                     $ECHO "*** you link to this library.  But I can only do this if you have a"
4594                     $ECHO "*** shared version of the library, which I believe you do not have"
4595                     $ECHO "*** because a test_compile did reveal that the linker did not use it for"
4596                     $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
4597                   fi
4598                 fi
4599               else
4600                 newdeplibs="$newdeplibs $i"
4601               fi
4602             done
4603           else
4604             # Error occurred in the first compile.  Let's try to salvage
4605             # the situation: Compile a separate program for each library.
4606             for i in $deplibs; do
4607               name=`expr $i : '-l\(.*\)'`
4608               # If $name is empty we are operating on a -L argument.
4609               if test "$name" != "" && test "$name" != "0"; then
4610                 $opt_dry_run || $RM conftest
4611                 $LTCC $LTCFLAGS -o conftest conftest.c $i
4612                 # Did it work?
4613                 if test "$?" -eq 0 ; then
4614                   ldd_output=`ldd conftest`
4615                   if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
4616                     case " $predeps $postdeps " in
4617                     *" $i "*)
4618                       newdeplibs="$newdeplibs $i"
4619                       i=""
4620                       ;;
4621                     esac
4622                   fi
4623                   if test -n "$i" ; then
4624                     libname=`eval "\\$ECHO \"$libname_spec\""`
4625                     deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
4626                     set dummy $deplib_matches; shift
4627                     deplib_match=$1
4628                     if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
4629                       newdeplibs="$newdeplibs $i"
4630                     else
4631                       droppeddeps=yes
4632                       $ECHO
4633                       $ECHO "*** Warning: dynamic linker does not accept needed library $i."
4634                       $ECHO "*** I have the capability to make that library automatically link in when"
4635                       $ECHO "*** you link to this library.  But I can only do this if you have a"
4636                       $ECHO "*** shared version of the library, which you do not appear to have"
4637                       $ECHO "*** because a test_compile did reveal that the linker did not use this one"
4638                       $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
4639                     fi
4640                   fi
4641                 else
4642                   droppeddeps=yes
4643                   $ECHO
4644                   $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
4645                   $ECHO "***  make it link in!  You will probably need to install it or some"
4646                   $ECHO "*** library that it depends on before this library will be fully"
4647                   $ECHO "*** functional.  Installing it before continuing would be even better."
4648                 fi
4649               else
4650                 newdeplibs="$newdeplibs $i"
4651               fi
4652             done
4653           fi
4654           ;;
4655         file_magic*)
4656           set dummy $deplibs_check_method; shift
4657           file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
4658           for a_deplib in $deplibs; do
4659             name=`expr $a_deplib : '-l\(.*\)'`
4660             # If $name is empty we are operating on a -L argument.
4661             if test "$name" != "" && test  "$name" != "0"; then
4662               if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
4663                 case " $predeps $postdeps " in
4664                 *" $a_deplib "*)
4665                   newdeplibs="$newdeplibs $a_deplib"
4666                   a_deplib=""
4667                   ;;
4668                 esac
4669               fi
4670               if test -n "$a_deplib" ; then
4671                 libname=`eval "\\$ECHO \"$libname_spec\""`
4672                 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
4673                   potential_libs=`ls $i/$libname[[.-]]* 2>/dev/null`
4674                   for potent_lib in $potential_libs; do
4675                       # Follow soft links.
4676                       if ls -lLd "$potent_lib" 2>/dev/null |
4677                          $GREP " -> " >/dev/null; then
4678                         continue
4679                       fi
4680                       # The statement above tries to avoid entering an
4681                       # endless loop below, in case of cyclic links.
4682                       # We might still enter an endless loop, since a link
4683                       # loop can be closed while we follow links,
4684                       # but so what?
4685                       potlib="$potent_lib"
4686                       while test -h "$potlib" 2>/dev/null; do
4687                         potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
4688                         case $potliblink in
4689                         [[\\/]]* | [[A-Za-z]]:[[\\/]]*) potlib="$potliblink";;
4690                         *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[[^/]]*$,,'`"$potliblink";;
4691                         esac
4692                       done
4693                       if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
4694                          $SED -e 10q |
4695                          $EGREP "$file_magic_regex" > /dev/null; then
4696                         newdeplibs="$newdeplibs $a_deplib"
4697                         a_deplib=""
4698                         break 2
4699                       fi
4700                   done
4701                 done
4702               fi
4703               if test -n "$a_deplib" ; then
4704                 droppeddeps=yes
4705                 $ECHO
4706                 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
4707                 $ECHO "*** I have the capability to make that library automatically link in when"
4708                 $ECHO "*** you link to this library.  But I can only do this if you have a"
4709                 $ECHO "*** shared version of the library, which you do not appear to have"
4710                 $ECHO "*** because I did check the linker path looking for a file starting"
4711                 if test -z "$potlib" ; then
4712                   $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
4713                 else
4714                   $ECHO "*** with $libname and none of the candidates passed a file format test"
4715                   $ECHO "*** using a file magic. Last file checked: $potlib"
4716                 fi
4717               fi
4718             else
4719               # Add a -L argument.
4720               newdeplibs="$newdeplibs $a_deplib"
4721             fi
4722           done # Gone through all deplibs.
4723           ;;
4724         match_pattern*)
4725           set dummy $deplibs_check_method; shift
4726           match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
4727           for a_deplib in $deplibs; do
4728             name=`expr $a_deplib : '-l\(.*\)'`
4729             # If $name is empty we are operating on a -L argument.
4730             if test -n "$name" && test "$name" != "0"; then
4731               if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
4732                 case " $predeps $postdeps " in
4733                 *" $a_deplib "*)
4734                   newdeplibs="$newdeplibs $a_deplib"
4735                   a_deplib=""
4736                   ;;
4737                 esac
4738               fi
4739               if test -n "$a_deplib" ; then
4740                 libname=`eval "\\$ECHO \"$libname_spec\""`
4741                 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
4742                   potential_libs=`ls $i/$libname[[.-]]* 2>/dev/null`
4743                   for potent_lib in $potential_libs; do
4744                     potlib="$potent_lib" # see symlink-check above in file_magic test
4745                     if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
4746                        $EGREP "$match_pattern_regex" > /dev/null; then
4747                       newdeplibs="$newdeplibs $a_deplib"
4748                       a_deplib=""
4749                       break 2
4750                     fi
4751                   done
4752                 done
4753               fi
4754               if test -n "$a_deplib" ; then
4755                 droppeddeps=yes
4756                 $ECHO
4757                 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
4758                 $ECHO "*** I have the capability to make that library automatically link in when"
4759                 $ECHO "*** you link to this library.  But I can only do this if you have a"
4760                 $ECHO "*** shared version of the library, which you do not appear to have"
4761                 $ECHO "*** because I did check the linker path looking for a file starting"
4762                 if test -z "$potlib" ; then
4763                   $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
4764                 else
4765                   $ECHO "*** with $libname and none of the candidates passed a file format test"
4766                   $ECHO "*** using a regex pattern. Last file checked: $potlib"
4767                 fi
4768               fi
4769             else
4770               # Add a -L argument.
4771               newdeplibs="$newdeplibs $a_deplib"
4772             fi
4773           done # Gone through all deplibs.
4774           ;;
4775         none | unknown | *)
4776           newdeplibs=""
4777           tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
4778               -e 's/ -lc$//' -e 's/ -[[LR]][[^ ]]*//g'`
4779           if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
4780             for i in $predeps $postdeps ; do
4781               # can't use Xsed below, because $i might contain '/'
4782               tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
4783             done
4784           fi
4785           if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[[    ]]//g' |
4786              $GREP . >/dev/null; then
4787             $ECHO
4788             if test "X$deplibs_check_method" = "Xnone"; then
4789               $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
4790             else
4791               $ECHO "*** Warning: inter-library dependencies are not known to be supported."
4792             fi
4793             $ECHO "*** All declared inter-library dependencies are being dropped."
4794             droppeddeps=yes
4795           fi
4796           ;;
4797         esac
4798         versuffix=$versuffix_save
4799         major=$major_save
4800         release=$release_save
4801         libname=$libname_save
4802         name=$name_save
4804         case $host in
4805         *-*-rhapsody* | *-*-darwin1.[[012]])
4806           # On Rhapsody replace the C library with the System framework
4807           newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
4808           ;;
4809         esac
4811         if test "$droppeddeps" = yes; then
4812           if test "$module" = yes; then
4813             $ECHO
4814             $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
4815             $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
4816             $ECHO "*** a static module, that should work as long as the dlopening"
4817             $ECHO "*** application is linked with the -dlopen flag."
4818             if test -z "$global_symbol_pipe"; then
4819               $ECHO
4820               $ECHO "*** However, this would only work if libtool was able to extract symbol"
4821               $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
4822               $ECHO "*** not find such a program.  So, this module is probably useless."
4823               $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
4824             fi
4825             if test "$build_old_libs" = no; then
4826               oldlibs="$output_objdir/$libname.$libext"
4827               build_libtool_libs=module
4828               build_old_libs=yes
4829             else
4830               build_libtool_libs=no
4831             fi
4832           else
4833             $ECHO "*** The inter-library dependencies that have been dropped here will be"
4834             $ECHO "*** automatically added whenever a program is linked with this library"
4835             $ECHO "*** or is declared to -dlopen it."
4837             if test "$allow_undefined" = no; then
4838               $ECHO
4839               $ECHO "*** Since this library must not contain undefined symbols,"
4840               $ECHO "*** because either the platform does not support them or"
4841               $ECHO "*** it was explicitly requested with -no-undefined,"
4842               $ECHO "*** libtool will only create a static version of it."
4843               if test "$build_old_libs" = no; then
4844                 oldlibs="$output_objdir/$libname.$libext"
4845                 build_libtool_libs=module
4846                 build_old_libs=yes
4847               else
4848                 build_libtool_libs=no
4849               fi
4850             fi
4851           fi
4852         fi
4853         # Done checking deplibs!
4854         deplibs=$newdeplibs
4855       fi
4856       # Time to change all our "foo.ltframework" stuff back to "-framework foo"
4857       case $host in
4858         *-*-darwin*)
4859           newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([[^ $]]*\).ltframework% -framework \1%g'`
4860           new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([[^ $]]*\).ltframework% -framework \1%g'`
4861           deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([[^ $]]*\).ltframework% -framework \1%g'`
4862           ;;
4863       esac
4865       # All the library-specific variables (install_libdir is set above).
4866       library_names=
4867       old_library=
4868       dlname=
4870       # Test again, we may have decided not to build it any more
4871       if test "$build_libtool_libs" = yes; then
4872         if test "$hardcode_into_libs" = yes; then
4873           # Hardcode the library paths
4874           hardcode_libdirs=
4875           dep_rpath=
4876           rpath="$finalize_rpath"
4877           test "$mode" != relink && rpath="$compile_rpath$rpath"
4878           for libdir in $rpath; do
4879             if test -n "$hardcode_libdir_flag_spec"; then
4880               if test -n "$hardcode_libdir_separator"; then
4881                 if test -z "$hardcode_libdirs"; then
4882                   hardcode_libdirs="$libdir"
4883                 else
4884                   # Just accumulate the unique libdirs.
4885                   case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
4886                   *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
4887                     ;;
4888                   *)
4889                     hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
4890                     ;;
4891                   esac
4892                 fi
4893               else
4894                 eval flag=\"$hardcode_libdir_flag_spec\"
4895                 dep_rpath="$dep_rpath $flag"
4896               fi
4897             elif test -n "$runpath_var"; then
4898               case "$perm_rpath " in
4899               *" $libdir "*) ;;
4900               *) perm_rpath="$perm_rpath $libdir" ;;
4901               esac
4902             fi
4903           done
4904           # Substitute the hardcoded libdirs into the rpath.
4905           if test -n "$hardcode_libdir_separator" &&
4906              test -n "$hardcode_libdirs"; then
4907             libdir="$hardcode_libdirs"
4908             if test -n "$hardcode_libdir_flag_spec_ld"; then
4909               eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
4910             else
4911               eval dep_rpath=\"$hardcode_libdir_flag_spec\"
4912             fi
4913           fi
4914           if test -n "$runpath_var" && test -n "$perm_rpath"; then
4915             # We should set the runpath_var.
4916             rpath=
4917             for dir in $perm_rpath; do
4918               rpath="$rpath$dir:"
4919             done
4920             eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
4921           fi
4922           test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
4923         fi
4925         shlibpath="$finalize_shlibpath"
4926         test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
4927         if test -n "$shlibpath"; then
4928           eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
4929         fi
4931         # Get the real and link names of the library.
4932         eval shared_ext=\"$shrext_cmds\"
4933         eval library_names=\"$library_names_spec\"
4934         set dummy $library_names
4935         shift
4936         realname="$1"
4937         shift
4939         if test -n "$soname_spec"; then
4940           eval soname=\"$soname_spec\"
4941         else
4942           soname="$realname"
4943         fi
4944         if test -z "$dlname"; then
4945           dlname=$soname
4946         fi
4948         lib="$output_objdir/$realname"
4949         for link
4950         do
4951           linknames="$linknames $link"
4952         done
4954         # Use standard objects if they are pic
4955         test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4957         delfiles=
4958         if test -n "$export_symbols" && test -n "$include_expsyms"; then
4959           $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
4960           export_symbols="$output_objdir/$libname.uexp"
4961           delfiles="$delfiles $export_symbols"
4962         fi
4964         orig_export_symbols=
4965         case $host_os in
4966         cygwin* | mingw*)
4967           if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
4968             # exporting using user supplied symfile
4969             if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
4970               # and it's NOT already a .def file. Must figure out
4971               # which of the given symbols are data symbols and tag
4972               # them as such. So, trigger use of export_symbols_cmds.
4973               # export_symbols gets reassigned inside the "prepare
4974               # the list of exported symbols" if statement, so the
4975               # include_expsyms logic still works.
4976               orig_export_symbols="$export_symbols"
4977               export_symbols=
4978               always_export_symbols=yes
4979             fi
4980           fi
4981           ;;
4982         esac
4984         # Prepare the list of exported symbols
4985         if test -z "$export_symbols"; then
4986           if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
4987             func_echo "generating symbol list for \`$libname.la'"
4988             export_symbols="$output_objdir/$libname.exp"
4989             $opt_dry_run || $RM $export_symbols
4990             cmds=$export_symbols_cmds
4991             save_ifs="$IFS"; IFS='~'
4992             for cmd in $cmds; do
4993               IFS="$save_ifs"
4994               eval cmd=\"$cmd\"
4995               if len=`expr "X$cmd" : ".*"` &&
4996                test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
4997                 func_show_eval "$cmd" 'exit $?'
4998                 skipped_export=false
4999               else
5000                 # The command line is too long to execute in one step.
5001                 func_echo "using reloadable object file for export list..."
5002                 skipped_export=:
5003                 # Break out early, otherwise skipped_export may be
5004                 # set to false by a later but shorter cmd.
5005                 break
5006               fi
5007             done
5008             IFS="$save_ifs"
5009             if test -n "$export_symbols_regex"; then
5010               func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
5011               func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
5012             fi
5013           fi
5014         fi
5016         if test -n "$export_symbols" && test -n "$include_expsyms"; then
5017           tmp_export_symbols="$export_symbols"
5018           test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
5019           $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
5020         fi
5022         if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
5023           # The given exports_symbols file has to be filtered, so filter it.
5024           func_echo "filter symbol list for \`$libname.la' to tag DATA exports"
5025           # FIXME: $output_objdir/$libname.filter potentially contains lots of
5026           # 's' commands which not all seds can handle. GNU sed should be fine
5027           # though. Also, the filter scales superlinearly with the number of
5028           # global variables. join(1) would be nice here, but unfortunately
5029           # isn't a blessed tool.
5030           $opt_dry_run || $SED -e '/[[ ,]]DATA/!d;s,\(.*\)\([[ \,]].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
5031           delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
5032           export_symbols=$output_objdir/$libname.def
5033           $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
5034         fi
5036         tmp_deplibs=
5037         for test_deplib in $deplibs; do
5038           case " $convenience " in
5039           *" $test_deplib "*) ;;
5040           *)
5041             tmp_deplibs="$tmp_deplibs $test_deplib"
5042             ;;
5043           esac
5044         done
5045         deplibs="$tmp_deplibs"
5047         if test -n "$convenience"; then
5048           if test -n "$whole_archive_flag_spec"; then
5049             save_libobjs=$libobjs
5050             eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
5051           else
5052             gentop="$output_objdir/${outputname}x"
5053             generated="$generated $gentop"
5055             func_extract_archives $gentop $convenience
5056             libobjs="$libobjs $func_extract_archives_result"
5057           fi
5058         fi
5060         if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
5061           eval flag=\"$thread_safe_flag_spec\"
5062           linker_flags="$linker_flags $flag"
5063         fi
5065         # Make a backup of the uninstalled library when relinking
5066         if test "$mode" = relink; then
5067           $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
5068         fi
5070         # Do each of the archive commands.
5071         if test "$module" = yes && test -n "$module_cmds" ; then
5072           if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
5073             eval test_cmds=\"$module_expsym_cmds\"
5074             cmds=$module_expsym_cmds
5075           else
5076             eval test_cmds=\"$module_cmds\"
5077             cmds=$module_cmds
5078           fi
5079         else
5080           if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
5081             eval test_cmds=\"$archive_expsym_cmds\"
5082             cmds=$archive_expsym_cmds
5083           else
5084             eval test_cmds=\"$archive_cmds\"
5085             cmds=$archive_cmds
5086           fi
5087         fi
5089         if test "X$skipped_export" != "X:" &&
5090            len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
5091            test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
5092           :
5093         else
5094           # The command line is too long to link in one step, link piecewise
5095           # or, if using GNU ld and skipped_export is not :, use a linker
5096           # script.
5098           # Save the value of $output and $libobjs because we want to
5099           # use them later.  If we have whole_archive_flag_spec, we
5100           # want to use save_libobjs as it was before
5101           # whole_archive_flag_spec was expanded, because we can't
5102           # assume the linker understands whole_archive_flag_spec.
5103           # This may have to be revisited, in case too many
5104           # convenience libraries get linked in and end up exceeding
5105           # the spec.
5106           if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
5107             save_libobjs=$libobjs
5108           fi
5109           save_output=$output
5110           output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
5112           # Clear the reloadable object creation command queue and
5113           # initialize k to one.
5114           test_cmds=
5115           concat_cmds=
5116           objlist=
5117           last_robj=
5118           k=1
5120           if test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
5121             output=${output_objdir}/${output_la}.lnkscript
5122             func_echo "creating GNU ld script: $output"
5123             $ECHO 'INPUT (' > $output
5124             for obj in $save_libobjs
5125             do
5126               $ECHO \""$obj"\" >> $output
5127             done
5128             $ECHO ')' >> $output
5129             delfiles="$delfiles $output"
5130           elif test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
5131             output=${output_objdir}/${output_la}.lnk
5132             func_echo "creating linker input file list: $output"
5133             : > $output
5134             for obj in $save_libobjs
5135             do
5136               $ECHO "$obj" >> $output
5137             done
5138             delfiles="$delfiles $output"
5139             output=\"$file_list_spec$output\"
5140           else
5141             func_echo "creating reloadable object files..."
5142             output=$output_objdir/$output_la-${k}.$objext
5143             # Loop over the list of objects to be linked.
5144             for obj in $save_libobjs
5145             do
5146               eval test_cmds=\"$reload_cmds $objlist $last_robj\"
5147               if test "X$objlist" = X ||
5148                  { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
5149                    test "$len" -le "$max_cmd_len"; }; then
5150                 objlist="$objlist $obj"
5151               else
5152                 # The command $test_cmds is almost too long, add a
5153                 # command to the queue.
5154                 if test "$k" -eq 1 ; then
5155                   # The first file doesn't have a previous command to add.
5156                   eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
5157                 else
5158                   # All subsequent reloadable object files will link in
5159                   # the last one created.
5160                   eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
5161                 fi
5162                 last_robj=$output_objdir/$output_la-${k}.$objext
5163                 k=`expr $k + 1`
5164                 output=$output_objdir/$output_la-${k}.$objext
5165                 objlist=$obj
5166                 len=1
5167               fi
5168             done
5169             # Handle the remaining objects by creating one last
5170             # reloadable object file.  All subsequent reloadable object
5171             # files will link in the last one created.
5172             test -z "$concat_cmds" || concat_cmds=$concat_cmds~
5173             eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
5175             if ${skipped_export-false}; then
5176               func_echo "generating symbol list for \`$libname.la'"
5177               export_symbols="$output_objdir/$libname.exp"
5178               $opt_dry_run || $RM $export_symbols
5179               libobjs=$output
5180               # Append the command to create the export file.
5181               eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
5182             fi
5184             # Set up a command to remove the reloadable object files
5185             # after they are used.
5186             i=0
5187             while test "$i" -lt "$k"
5188             do
5189               i=`expr $i + 1`
5190               delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
5191             done
5193             func_echo "creating a temporary reloadable object file: $output"
5195             # Loop through the commands generated above and execute them.
5196             save_ifs="$IFS"; IFS='~'
5197             for cmd in $concat_cmds; do
5198               IFS="$save_ifs"
5199               $opt_silent || {
5200                   func_quote_for_expand "$cmd"
5201                   eval "func_echo $func_quote_for_expand_result"
5202               }
5203               $opt_dry_run || eval "$cmd" || {
5204                 lt_exit=$?
5206                 # Restore the uninstalled library and exit
5207                 if test "$mode" = relink; then
5208                   ( cd "$output_objdir" && \
5209                     $RM "${realname}T" && \
5210                     $MV "${realname}U" "$realname" )
5211                 fi
5213                 exit $lt_exit
5214               }
5215             done
5216             IFS="$save_ifs"
5217           fi
5219           libobjs=$output
5220           # Restore the value of output.
5221           output=$save_output
5223           if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
5224             eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
5225           fi
5226           # Expand the library linking commands again to reset the
5227           # value of $libobjs for piecewise linking.
5229           # Do each of the archive commands.
5230           if test "$module" = yes && test -n "$module_cmds" ; then
5231             if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
5232               cmds=$module_expsym_cmds
5233             else
5234               cmds=$module_cmds
5235             fi
5236           else
5237             if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
5238               cmds=$archive_expsym_cmds
5239             else
5240               cmds=$archive_cmds
5241             fi
5242           fi
5243         fi
5245         if test -n "$delfiles"; then
5246           # Append the command to remove temporary files to $cmds.
5247           eval cmds=\"\$cmds~\$RM $delfiles\"
5248         fi
5250         # Add any objects from preloaded convenience libraries
5251         if test -n "$dlprefiles"; then
5252           gentop="$output_objdir/${outputname}x"
5253           generated="$generated $gentop"
5255           func_extract_archives $gentop $dlprefiles
5256           libobjs="$libobjs $func_extract_archives_result"
5257         fi
5259         save_ifs="$IFS"; IFS='~'
5260         for cmd in $cmds; do
5261           IFS="$save_ifs"
5262           eval cmd=\"$cmd\"
5263           $opt_silent || {
5264             func_quote_for_expand "$cmd"
5265             eval "func_echo $func_quote_for_expand_result"
5266           }
5267           $opt_dry_run || eval "$cmd" || {
5268             lt_exit=$?
5270             # Restore the uninstalled library and exit
5271             if test "$mode" = relink; then
5272               ( cd "$output_objdir" && \
5273                 $RM "${realname}T" && \
5274                 $MV "${realname}U" "$realname" )
5275             fi
5277             exit $lt_exit
5278           }
5279         done
5280         IFS="$save_ifs"
5282         # Restore the uninstalled library and exit
5283         if test "$mode" = relink; then
5284           $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
5286           if test -n "$convenience"; then
5287             if test -z "$whole_archive_flag_spec"; then
5288               func_show_eval '${RM}r "$gentop"'
5289             fi
5290           fi
5292           exit $EXIT_SUCCESS
5293         fi
5295         # Create links to the real library.
5296         for linkname in $linknames; do
5297           if test "$realname" != "$linkname"; then
5298             func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
5299           fi
5300         done
5302         # If -module or -export-dynamic was specified, set the dlname.
5303         if test "$module" = yes || test "$export_dynamic" = yes; then
5304           # On all known operating systems, these are identical.
5305           dlname="$soname"
5306         fi
5307       fi
5308       ;;
5310     obj)
5311       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
5312         func_warning "\`-dlopen' is ignored for objects"
5313       fi
5315       test -n "$deplibs" && \
5316         func_warning "\`-l' and \`-L' are ignored for objects"
5318       test -n "$rpath" && \
5319         func_warning "\`-rpath' is ignored for objects"
5321       test -n "$xrpath" && \
5322         func_warning "\`-R' is ignored for objects"
5324       test -n "$vinfo" && \
5325         func_warning "\`-version-info' is ignored for objects"
5327       test -n "$release" && \
5328         func_warning "\`-release' is ignored for objects"
5330       case $output in
5331       *.lo)
5332         test -n "$objs$old_deplibs" && \
5333           func_fatal_error "cannot build library object \`$output' from non-libtool objects"
5335         libobj="$output"
5336         obj=`$ECHO "X$output" | $Xsed -e "$lo2o"`
5337         ;;
5338       *)
5339         libobj=
5340         obj="$output"
5341         ;;
5342       esac
5344       # Delete the old objects.
5345       $opt_dry_run || $RM $obj $libobj
5347       # Objects from convenience libraries.  This assumes
5348       # single-version convenience libraries.  Whenever we create
5349       # different ones for PIC/non-PIC, this we'll have to duplicate
5350       # the extraction.
5351       reload_conv_objs=
5352       gentop=
5353       # reload_cmds runs $LD directly, so let us get rid of
5354       # -Wl from whole_archive_flag_spec
5355       wl=
5357       if test -n "$convenience"; then
5358         if test -n "$whole_archive_flag_spec"; then
5359           eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
5360         else
5361           gentop="$output_objdir/${obj}x"
5362           generated="$generated $gentop"
5364           func_extract_archives $gentop $convenience
5365           reload_conv_objs="$reload_objs $func_extract_archives_result"
5366         fi
5367       fi
5369       # Create the old-style object.
5370       reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
5372       output="$obj"
5373       func_execute_cmds "$reload_cmds" 'exit $?'
5375       # Exit if we aren't doing a library object file.
5376       if test -z "$libobj"; then
5377         if test -n "$gentop"; then
5378           func_show_eval '${RM}r "$gentop"'
5379         fi
5381         exit $EXIT_SUCCESS
5382       fi
5384       if test "$build_libtool_libs" != yes; then
5385         if test -n "$gentop"; then
5386           func_show_eval '${RM}r "$gentop"'
5387         fi
5389         # Create an invalid libtool object if no PIC, so that we don't
5390         # accidentally link it into a program.
5391         # $show "echo timestamp > $libobj"
5392         # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
5393         exit $EXIT_SUCCESS
5394       fi
5396       if test -n "$pic_flag" || test "$pic_mode" != default; then
5397         # Only do commands if we really have different PIC objects.
5398         reload_objs="$libobjs $reload_conv_objs"
5399         output="$libobj"
5400         func_execute_cmds "$reload_cmds" 'exit $?'
5401       fi
5403       if test -n "$gentop"; then
5404         func_show_eval '${RM}r "$gentop"'
5405       fi
5407       exit $EXIT_SUCCESS
5408       ;;
5410     prog)
5411       case $host in
5412         *cygwin*) func_stripname '' '.exe' "$output"
5413                   output=$func_stripname_result.exe;;
5414       esac
5415       test -n "$vinfo" && \
5416         func_warning "\`-version-info' is ignored for programs"
5418       test -n "$release" && \
5419         func_warning "\`-release' is ignored for programs"
5421       test "$preload" = yes \
5422         && test "$dlopen_support" = unknown \
5423         && test "$dlopen_self" = unknown \
5424         && test "$dlopen_self_static" = unknown && \
5425           func_warning "\`LT_INIT([[dlopen]])' not used. Assuming no dlopen support."
5427       case $host in
5428       *-*-rhapsody* | *-*-darwin1.[[012]])
5429         # On Rhapsody replace the C library is the System framework
5430         compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
5431         finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
5432         ;;
5433       esac
5435       case $host in
5436       *-*-darwin*)
5437         # Don't allow lazy linking, it breaks C++ global constructors
5438         # But is supposedly fixed on 10.4 or later (yay!).
5439         if test "$tagname" = CXX ; then
5440           case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
5441             10.[[0123]])
5442               compile_command="$compile_command ${wl}-bind_at_load"
5443               finalize_command="$finalize_command ${wl}-bind_at_load"
5444             ;;
5445           esac
5446         fi
5447         # Time to change all our "foo.ltframework" stuff back to "-framework foo"
5448         compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([[^ $]]*\).ltframework% -framework \1%g'`
5449         finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([[^ $]]*\).ltframework% -framework \1%g'`
5450         ;;
5451       esac
5453       compile_command="$compile_command $compile_deplibs"
5454       finalize_command="$finalize_command $finalize_deplibs"
5456       if test -n "$rpath$xrpath"; then
5457         # If the user specified any rpath flags, then add them.
5458         for libdir in $rpath $xrpath; do
5459           # This is the magic to use -rpath.
5460           case "$finalize_rpath " in
5461           *" $libdir "*) ;;
5462           *) finalize_rpath="$finalize_rpath $libdir" ;;
5463           esac
5464         done
5465       fi
5467       # Now hardcode the library paths
5468       rpath=
5469       hardcode_libdirs=
5470       for libdir in $compile_rpath $finalize_rpath; do
5471         if test -n "$hardcode_libdir_flag_spec"; then
5472           if test -n "$hardcode_libdir_separator"; then
5473             if test -z "$hardcode_libdirs"; then
5474               hardcode_libdirs="$libdir"
5475             else
5476               # Just accumulate the unique libdirs.
5477               case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
5478               *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
5479                 ;;
5480               *)
5481                 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
5482                 ;;
5483               esac
5484             fi
5485           else
5486             eval flag=\"$hardcode_libdir_flag_spec\"
5487             rpath="$rpath $flag"
5488           fi
5489         elif test -n "$runpath_var"; then
5490           case "$perm_rpath " in
5491           *" $libdir "*) ;;
5492           *) perm_rpath="$perm_rpath $libdir" ;;
5493           esac
5494         fi
5495         case $host in
5496         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
5497           testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
5498           case :$dllsearchpath: in
5499           *":$libdir:"*) ;;
5500           *) dllsearchpath="$dllsearchpath:$libdir";;
5501           esac
5502           case :$dllsearchpath: in
5503           *":$testbindir:"*) ;;
5504           *) dllsearchpath="$dllsearchpath:$testbindir";;
5505           esac
5506           ;;
5507         esac
5508       done
5509       # Substitute the hardcoded libdirs into the rpath.
5510       if test -n "$hardcode_libdir_separator" &&
5511          test -n "$hardcode_libdirs"; then
5512         libdir="$hardcode_libdirs"
5513         eval rpath=\" $hardcode_libdir_flag_spec\"
5514       fi
5515       compile_rpath="$rpath"
5517       rpath=
5518       hardcode_libdirs=
5519       for libdir in $finalize_rpath; do
5520         if test -n "$hardcode_libdir_flag_spec"; then
5521           if test -n "$hardcode_libdir_separator"; then
5522             if test -z "$hardcode_libdirs"; then
5523               hardcode_libdirs="$libdir"
5524             else
5525               # Just accumulate the unique libdirs.
5526               case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
5527               *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
5528                 ;;
5529               *)
5530                 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
5531                 ;;
5532               esac
5533             fi
5534           else
5535             eval flag=\"$hardcode_libdir_flag_spec\"
5536             rpath="$rpath $flag"
5537           fi
5538         elif test -n "$runpath_var"; then
5539           case "$finalize_perm_rpath " in
5540           *" $libdir "*) ;;
5541           *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
5542           esac
5543         fi
5544       done
5545       # Substitute the hardcoded libdirs into the rpath.
5546       if test -n "$hardcode_libdir_separator" &&
5547          test -n "$hardcode_libdirs"; then
5548         libdir="$hardcode_libdirs"
5549         eval rpath=\" $hardcode_libdir_flag_spec\"
5550       fi
5551       finalize_rpath="$rpath"
5553       if test -n "$libobjs" && test "$build_old_libs" = yes; then
5554         # Transform all the library objects into standard objects.
5555         compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
5556         finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
5557       fi
5559       func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
5561       # template prelinking step
5562       if test -n "$prelink_cmds"; then
5563         func_execute_cmds "$prelink_cmds" 'exit $?'
5564       fi
5566       wrappers_required=yes
5567       case $host in
5568       *cygwin* | *mingw* )
5569         if test "$build_libtool_libs" != yes; then
5570           wrappers_required=no
5571         fi
5572         ;;
5573       *)
5574         if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
5575           wrappers_required=no
5576         fi
5577         ;;
5578       esac
5579       if test "$wrappers_required" = no; then
5580         # Replace the output file specification.
5581         compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
5582         link_command="$compile_command$compile_rpath"
5584         # We have no uninstalled library dependencies, so finalize right now.
5585         func_show_eval "$link_command"
5586         status=$?
5588         # Delete the generated files.
5589         if test -f "$output_objdir/${outputname}S.${objext}"; then
5590           func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
5591         fi
5593         exit $status
5594       fi
5596       if test -n "$compile_shlibpath$finalize_shlibpath"; then
5597         compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
5598       fi
5599       if test -n "$finalize_shlibpath"; then
5600         finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
5601       fi
5603       compile_var=
5604       finalize_var=
5605       if test -n "$runpath_var"; then
5606         if test -n "$perm_rpath"; then
5607           # We should set the runpath_var.
5608           rpath=
5609           for dir in $perm_rpath; do
5610             rpath="$rpath$dir:"
5611           done
5612           compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
5613         fi
5614         if test -n "$finalize_perm_rpath"; then
5615           # We should set the runpath_var.
5616           rpath=
5617           for dir in $finalize_perm_rpath; do
5618             rpath="$rpath$dir:"
5619           done
5620           finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
5621         fi
5622       fi
5624       if test "$no_install" = yes; then
5625         # We don't need to create a wrapper script.
5626         link_command="$compile_var$compile_command$compile_rpath"
5627         # Replace the output file specification.
5628         link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
5629         # Delete the old output file.
5630         $opt_dry_run || $RM $output
5631         # Link the executable and exit
5632         func_show_eval "$link_command" 'exit $?'
5633         exit $EXIT_SUCCESS
5634       fi
5636       if test "$hardcode_action" = relink; then
5637         # Fast installation is not supported
5638         link_command="$compile_var$compile_command$compile_rpath"
5639         relink_command="$finalize_var$finalize_command$finalize_rpath"
5641         func_warning "this platform does not like uninstalled shared libraries"
5642         func_warning "\`$output' will be relinked during installation"
5643       else
5644         if test "$fast_install" != no; then
5645           link_command="$finalize_var$compile_command$finalize_rpath"
5646           if test "$fast_install" = yes; then
5647             relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
5648           else
5649             # fast_install is set to needless
5650             relink_command=
5651           fi
5652         else
5653           link_command="$compile_var$compile_command$compile_rpath"
5654           relink_command="$finalize_var$finalize_command$finalize_rpath"
5655         fi
5656       fi
5658       # Replace the output file specification.
5659       link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
5661       # Delete the old output files.
5662       $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
5664       func_show_eval "$link_command" 'exit $?'
5666       # Now create the wrapper script.
5667       func_echo "creating $output"
5669       # Quote the relink command for shipping.
5670       if test -n "$relink_command"; then
5671         # Preserve any variables that may affect compiler behavior
5672         for var in $variables_saved_for_relink; do
5673           if eval test -z \"\${$var+set}\"; then
5674             relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
5675           elif eval var_value=\$$var; test -z "$var_value"; then
5676             relink_command="$var=; export $var; $relink_command"
5677           else
5678             func_quote_for_eval "$var_value"
5679             relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
5680           fi
5681         done
5682         relink_command="(cd `pwd`; $relink_command)"
5683         relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
5684       fi
5686       # Quote $ECHO for shipping.
5687       if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
5688         case $progpath in
5689         [[\\/]]* | [[A-Za-z]]:[[\\/]]*) qecho="$SHELL $progpath --fallback-echo";;
5690         *) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
5691         esac
5692         qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
5693       else
5694         qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
5695       fi
5697       # Only actually do things if not in dry run mode.
5698       $opt_dry_run || {
5699         # win32 will think the script is a binary if it has
5700         # a .exe suffix, so we strip it off here.
5701         case $output in
5702           *.exe) func_stripname '' '.exe' "$output"
5703                  output=$func_stripname_result ;;
5704         esac
5705         # test for cygwin because mv fails w/o .exe extensions
5706         case $host in
5707           *cygwin*)
5708             exeext=.exe
5709             func_stripname '' '.exe' "$outputname"
5710             outputname=$func_stripname_result ;;
5711           *) exeext= ;;
5712         esac
5713         case $host in
5714           *cygwin* | *mingw* )
5715             output_name=`basename $output`
5716             output_path=`dirname $output`
5717             cwrappersource="$output_path/$objdir/lt-$output_name.c"
5718             cwrapper="$output_path/$output_name.exe"
5719             $RM $cwrappersource $cwrapper
5720             trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
5722             cat > $cwrappersource <<EOF
5724 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
5725    Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
5727    The $output program cannot be directly executed until all the libtool
5728    libraries that it depends on are installed.
5730    This wrapper executable should never be moved out of the build directory.
5731    If it is, it will not operate correctly.
5733    Currently, it simply execs the wrapper *script* "/bin/sh $output",
5734    but could eventually absorb all of the scripts functionality and
5735    exec $objdir/$outputname directly.
5738             cat >> $cwrappersource<<"EOF"
5739 #include <stdio.h>
5740 #include <stdlib.h>
5741 #include <unistd.h>
5742 #include <malloc.h>
5743 #include <stdarg.h>
5744 #include <assert.h>
5745 #include <string.h>
5746 #include <ctype.h>
5747 #include <sys/stat.h>
5749 #if defined(PATH_MAX)
5750 # define LT_PATHMAX PATH_MAX
5751 #elif defined(MAXPATHLEN)
5752 # define LT_PATHMAX MAXPATHLEN
5753 #else
5754 # define LT_PATHMAX 1024
5755 #endif
5757 #ifndef DIR_SEPARATOR
5758 # define DIR_SEPARATOR '/'
5759 # define PATH_SEPARATOR ':'
5760 #endif
5762 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
5763   defined (__OS2__)
5764 # define HAVE_DOS_BASED_FILE_SYSTEM
5765 # ifndef DIR_SEPARATOR_2
5766 #  define DIR_SEPARATOR_2 '\\'
5767 # endif
5768 # ifndef PATH_SEPARATOR_2
5769 #  define PATH_SEPARATOR_2 ';'
5770 # endif
5771 #endif
5773 #ifndef DIR_SEPARATOR_2
5774 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5775 #else /* DIR_SEPARATOR_2 */
5776 # define IS_DIR_SEPARATOR(ch) \
5777         (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5778 #endif /* DIR_SEPARATOR_2 */
5780 #ifndef PATH_SEPARATOR_2
5781 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5782 #else /* PATH_SEPARATOR_2 */
5783 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5784 #endif /* PATH_SEPARATOR_2 */
5786 #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
5787 #define XFREE(stale) do { \
5788   if (stale) { free ((void *) stale); stale = 0; } \
5789 } while (0)
5791 /* -DDEBUG is fairly common in CFLAGS.  */
5792 #undef DEBUG
5793 #if defined DEBUGWRAPPER
5794 # define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
5795 #else
5796 # define DEBUG(format, ...)
5797 #endif
5799 const char *program_name = NULL;
5801 void * xmalloc (size_t num);
5802 char * xstrdup (const char *string);
5803 const char * base_name (const char *name);
5804 char * find_executable(const char *wrapper);
5805 int    check_executable(const char *path);
5806 char * strendzap(char *str, const char *pat);
5807 void lt_fatal (const char *message, ...);
5810 main (int argc, char *argv[[]])
5812   char **newargz;
5813   int i;
5815   program_name = (char *) xstrdup (base_name (argv[[0]]));
5816   DEBUG("(main) argv[[0]]      : %s\n",argv[[0]]);
5817   DEBUG("(main) program_name : %s\n",program_name);
5818   newargz = XMALLOC(char *, argc+2);
5821             cat >> $cwrappersource <<EOF
5822   newargz[[0]] = (char *) xstrdup("$SHELL");
5825             cat >> $cwrappersource <<"EOF"
5826   newargz[[1]] = find_executable(argv[[0]]);
5827   if (newargz[[1]] == NULL)
5828     lt_fatal("Couldn't find %s", argv[[0]]);
5829   DEBUG("(main) found exe at : %s\n",newargz[[1]]);
5830   /* we know the script has the same name, without the .exe */
5831   /* so make sure newargz[[1]] doesn't end in .exe */
5832   strendzap(newargz[[1]],".exe");
5833   for (i = 1; i < argc; i++)
5834     newargz[[i+1]] = xstrdup(argv[[i]]);
5835   newargz[[argc+1]] = NULL;
5837   for (i=0; i<argc+1; i++)
5838   {
5839     DEBUG("(main) newargz[[%d]]   : %s\n",i,newargz[[i]]);
5840     ;
5841   }
5845             case $host_os in
5846               mingw*)
5847                 cat >> $cwrappersource <<EOF
5848   execv("$SHELL",(char const **)newargz);
5850               ;;
5851               *)
5852                 cat >> $cwrappersource <<EOF
5853   execv("$SHELL",newargz);
5855               ;;
5856             esac
5858             cat >> $cwrappersource <<"EOF"
5859   return 127;
5862 void *
5863 xmalloc (size_t num)
5865   void * p = (void *) malloc (num);
5866   if (!p)
5867     lt_fatal ("Memory exhausted");
5869   return p;
5872 char *
5873 xstrdup (const char *string)
5875   return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
5879 const char *
5880 base_name (const char *name)
5882   const char *base;
5884 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5885   /* Skip over the disk name in MSDOS pathnames. */
5886   if (isalpha ((unsigned char)name[[0]]) && name[[1]] == ':')
5887     name += 2;
5888 #endif
5890   for (base = name; *name; name++)
5891     if (IS_DIR_SEPARATOR (*name))
5892       base = name + 1;
5893   return base;
5897 check_executable(const char * path)
5899   struct stat st;
5901   DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
5902   if ((!path) || (!*path))
5903     return 0;
5905   if ((stat (path, &st) >= 0) &&
5906       (
5907         /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
5908 #if defined (S_IXOTH)
5909        ((st.st_mode & S_IXOTH) == S_IXOTH) ||
5910 #endif
5911 #if defined (S_IXGRP)
5912        ((st.st_mode & S_IXGRP) == S_IXGRP) ||
5913 #endif
5914        ((st.st_mode & S_IXUSR) == S_IXUSR))
5915       )
5916     return 1;
5917   else
5918     return 0;
5921 /* Searches for the full path of the wrapper.  Returns
5922    newly allocated full path name if found, NULL otherwise */
5923 char *
5924 find_executable (const char* wrapper)
5926   int has_slash = 0;
5927   const char* p;
5928   const char* p_next;
5929   /* static buffer for getcwd */
5930   char tmp[[LT_PATHMAX + 1]];
5931   int tmp_len;
5932   char* concat_name;
5934   DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
5936   if ((wrapper == NULL) || (*wrapper == '\0'))
5937     return NULL;
5939   /* Absolute path? */
5940 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5941   if (isalpha ((unsigned char)wrapper[[0]]) && wrapper[[1]] == ':')
5942   {
5943     concat_name = xstrdup (wrapper);
5944     if (check_executable(concat_name))
5945       return concat_name;
5946     XFREE(concat_name);
5947   }
5948   else
5949   {
5950 #endif
5951     if (IS_DIR_SEPARATOR (wrapper[[0]]))
5952     {
5953       concat_name = xstrdup (wrapper);
5954       if (check_executable(concat_name))
5955         return concat_name;
5956       XFREE(concat_name);
5957     }
5958 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5959   }
5960 #endif
5962   for (p = wrapper; *p; p++)
5963     if (*p == '/')
5964     {
5965       has_slash = 1;
5966       break;
5967     }
5968   if (!has_slash)
5969   {
5970     /* no slashes; search PATH */
5971     const char* path = getenv ("PATH");
5972     if (path != NULL)
5973     {
5974       for (p = path; *p; p = p_next)
5975       {
5976         const char* q;
5977         size_t p_len;
5978         for (q = p; *q; q++)
5979           if (IS_PATH_SEPARATOR(*q))
5980             break;
5981         p_len = q - p;
5982         p_next = (*q == '\0' ? q : q + 1);
5983         if (p_len == 0)
5984         {
5985           /* empty path: current directory */
5986           if (getcwd (tmp, LT_PATHMAX) == NULL)
5987             lt_fatal ("getcwd failed");
5988           tmp_len = strlen(tmp);
5989           concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5990           memcpy (concat_name, tmp, tmp_len);
5991           concat_name[[tmp_len]] = '/';
5992           strcpy (concat_name + tmp_len + 1, wrapper);
5993         }
5994         else
5995         {
5996           concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
5997           memcpy (concat_name, p, p_len);
5998           concat_name[[p_len]] = '/';
5999           strcpy (concat_name + p_len + 1, wrapper);
6000         }
6001         if (check_executable(concat_name))
6002           return concat_name;
6003         XFREE(concat_name);
6004       }
6005     }
6006     /* not found in PATH; assume curdir */
6007   }
6008   /* Relative path | not found in path: prepend cwd */
6009   if (getcwd (tmp, LT_PATHMAX) == NULL)
6010     lt_fatal ("getcwd failed");
6011   tmp_len = strlen(tmp);
6012   concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
6013   memcpy (concat_name, tmp, tmp_len);
6014   concat_name[[tmp_len]] = '/';
6015   strcpy (concat_name + tmp_len + 1, wrapper);
6017   if (check_executable(concat_name))
6018     return concat_name;
6019   XFREE(concat_name);
6020   return NULL;
6023 char *
6024 strendzap(char *str, const char *pat)
6026   size_t len, patlen;
6028   assert(str != NULL);
6029   assert(pat != NULL);
6031   len = strlen(str);
6032   patlen = strlen(pat);
6034   if (patlen <= len)
6035   {
6036     str += len - patlen;
6037     if (strcmp(str, pat) == 0)
6038       *str = '\0';
6039   }
6040   return str;
6043 static void
6044 lt_error_core (int exit_status, const char * mode,
6045           const char * message, va_list ap)
6047   fprintf (stderr, "%s: %s: ", program_name, mode);
6048   vfprintf (stderr, message, ap);
6049   fprintf (stderr, ".\n");
6051   if (exit_status >= 0)
6052     exit (exit_status);
6055 void
6056 lt_fatal (const char *message, ...)
6058   va_list ap;
6059   va_start (ap, message);
6060   lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
6061   va_end (ap);
6064           # we should really use a build-platform specific compiler
6065           # here, but OTOH, the wrappers (shell script and this C one)
6066           # are only useful if you want to execute the "real" binary.
6067           # Since the "real" binary is built for $host, then this
6068           # wrapper might as well be built for $host, too.
6069           $opt_dry_run || $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
6070           ;;
6071         esac
6072         $RM $output
6073         trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
6075         $ECHO > $output "\
6076 #! $SHELL
6078 # $output - temporary wrapper script for $objdir/$outputname
6079 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
6081 # The $output program cannot be directly executed until all the libtool
6082 # libraries that it depends on are installed.
6084 # This wrapper script should never be moved out of the build directory.
6085 # If it is, it will not operate correctly.
6087 # Sed substitution that helps us do robust quoting.  It backslashifies
6088 # metacharacters that are still active within double-quoted strings.
6089 Xsed='${SED} -e 1s/^X//'
6090 sed_quote_subst='$sed_quote_subst'
6092 # The HP-UX ksh and POSIX shell print the target directory to stdout
6093 # if CDPATH is set.
6094 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
6096 relink_command=\"$relink_command\"
6098 # This environment variable determines our operation mode.
6099 if test \"\$libtool_install_magic\" = \"$magic\"; then
6100   # install mode needs the following variables:
6101   generated_by_libtool_version='$macro_version'
6102   notinst_deplibs='$notinst_deplibs'
6103 else
6104   # When we are sourced in execute mode, \$file and \$ECHO are already set.
6105   if test \"\$libtool_execute_magic\" != \"$magic\"; then
6106     ECHO=\"$qecho\"
6107     file=\"\$0\"
6108     # Make sure echo works.
6109     if test \"X\$1\" = X--no-reexec; then
6110       # Discard the --no-reexec flag, and continue.
6111       shift
6112     elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
6113       # Yippee, \$ECHO works!
6114       :
6115     else
6116       # Restart under the correct shell, and then maybe \$ECHO will work.
6117       exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
6118     fi
6119   fi\
6121         $ECHO >> $output "\
6123   # Find the directory that this script lives in.
6124   thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[[^/]]*$%%'\`
6125   test \"x\$thisdir\" = \"x\$file\" && thisdir=.
6127   # Follow symbolic links until we get to the real thisdir.
6128   file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
6129   while test -n \"\$file\"; do
6130     destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[[^/]]*\$%%'\`
6132     # If there was a directory component, then change thisdir.
6133     if test \"x\$destdir\" != \"x\$file\"; then
6134       case \"\$destdir\" in
6135       [[\\\\/]]* | [[A-Za-z]]:[[\\\\/]]*) thisdir=\"\$destdir\" ;;
6136       *) thisdir=\"\$thisdir/\$destdir\" ;;
6137       esac
6138     fi
6140     file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
6141     file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
6142   done
6144   # Try to get the absolute directory name.
6145   absdir=\`cd \"\$thisdir\" && pwd\`
6146   test -n \"\$absdir\" && thisdir=\"\$absdir\"
6149         if test "$fast_install" = yes; then
6150           $ECHO >> $output "\
6151   program=lt-'$outputname'$exeext
6152   progdir=\"\$thisdir/$objdir\"
6154   if test ! -f \"\$progdir/\$program\" ||
6155      { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
6156        test \"X\$file\" != \"X\$progdir/\$program\"; }; then
6158     file=\"\$\$-\$program\"
6160     if test ! -d \"\$progdir\"; then
6161       $MKDIR \"\$progdir\"
6162     else
6163       $RM \"\$progdir/\$file\"
6164     fi"
6166           $ECHO >> $output "\
6168     # relink executable if necessary
6169     if test -n \"\$relink_command\"; then
6170       if relink_command_output=\`eval \$relink_command 2>&1\`; then :
6171       else
6172         $ECHO \"\$relink_command_output\" >&2
6173         $RM \"\$progdir/\$file\"
6174         exit 1
6175       fi
6176     fi
6178     $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
6179     { $RM \"\$progdir/\$program\";
6180       $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
6181     $RM \"\$progdir/\$file\"
6182   fi"
6183         else
6184           $ECHO >> $output "\
6185   program='$outputname'
6186   progdir=\"\$thisdir/$objdir\"
6188         fi
6190         $ECHO >> $output "\
6192   if test -f \"\$progdir/\$program\"; then"
6194         # Export our shlibpath_var if we have one.
6195         if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
6196           $ECHO >> $output "\
6197     # Add our own library path to $shlibpath_var
6198     $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
6200     # Some systems cannot cope with colon-terminated $shlibpath_var
6201     # The second colon is a workaround for a bug in BeOS R4 sed
6202     $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
6204     export $shlibpath_var
6206         fi
6208         # fixup the dll searchpath if we need to.
6209         if test -n "$dllsearchpath"; then
6210           $ECHO >> $output "\
6211     # Add the dll search path components to the executable PATH
6212     PATH=$dllsearchpath:\$PATH
6214         fi
6216         $ECHO >> $output "\
6217     if test \"\$libtool_execute_magic\" != \"$magic\"; then
6218       # Run the actual program with our arguments.
6220         case $host in
6221         # Backslashes separate directories on plain windows
6222         *-*-mingw | *-*-os2*)
6223           $ECHO >> $output "\
6224       exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
6226           ;;
6228         *)
6229           $ECHO >> $output "\
6230       exec \"\$progdir/\$program\" \${1+\"\$@\"}
6232           ;;
6233         esac
6234         $ECHO >> $output "\
6235       \$ECHO \"\$0: cannot exec \$program \${1+\"\$@\"}\"
6236       exit 1
6237     fi
6238   else
6239     # The program doesn't exist.
6240     \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
6241     \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
6242     $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
6243     exit 1
6244   fi
6247         chmod +x $output
6248       }
6249       exit $EXIT_SUCCESS
6250       ;;
6251     esac
6253     # See if we need to build an old-fashioned archive.
6254     for oldlib in $oldlibs; do
6256       if test "$build_libtool_libs" = convenience; then
6257         oldobjs="$libobjs_save $symfileobj"
6258         addlibs="$convenience"
6259         build_libtool_libs=no
6260       else
6261         if test "$build_libtool_libs" = module; then
6262           oldobjs="$libobjs_save"
6263           build_libtool_libs=no
6264         else
6265           oldobjs="$old_deplibs $non_pic_objects"
6266           if test "$preload" = yes && test -f "$symfileobj"; then
6267             oldobjs="$oldobjs $symfileobj"
6268           fi
6269         fi
6270         addlibs="$old_convenience"
6271       fi
6273       if test -n "$addlibs"; then
6274         gentop="$output_objdir/${outputname}x"
6275         generated="$generated $gentop"
6277         func_extract_archives $gentop $addlibs
6278         oldobjs="$oldobjs $func_extract_archives_result"
6279       fi
6281       # Do each command in the archive commands.
6282       if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
6283         cmds=$old_archive_from_new_cmds
6284       else
6286         # Add any objects from preloaded convenience libraries
6287         if test -n "$dlprefiles"; then
6288           gentop="$output_objdir/${outputname}x"
6289           generated="$generated $gentop"
6291           func_extract_archives $gentop $dlprefiles
6292           oldobjs="$oldobjs $func_extract_archives_result"
6293         fi
6295         # POSIX demands no paths to be encoded in archives.  We have
6296         # to avoid creating archives with duplicate basenames if we
6297         # might have to extract them afterwards, e.g., when creating a
6298         # static archive out of a convenience library, or when linking
6299         # the entirety of a libtool archive into another (currently
6300         # not supported by libtool).
6301         if (for obj in $oldobjs
6302             do
6303               func_basename "$obj"
6304               $ECHO "$func_basename_result"
6305             done | sort | sort -uc >/dev/null 2>&1); then
6306           :
6307         else
6308           $ECHO "copying selected object files to avoid basename conflicts..."
6309           gentop="$output_objdir/${outputname}x"
6310           generated="$generated $gentop"
6311           func_mkdir_p "$gentop"
6312           save_oldobjs=$oldobjs
6313           oldobjs=
6314           counter=1
6315           for obj in $save_oldobjs
6316           do
6317             func_basename "$obj"
6318             objbase="$func_basename_result"
6319             case " $oldobjs " in
6320             " ") oldobjs=$obj ;;
6321             *[[\ /]]"$objbase "*)
6322               while :; do
6323                 # Make sure we don't pick an alternate name that also
6324                 # overlaps.
6325                 newobj=lt$counter-$objbase
6326                 counter=`expr $counter + 1`
6327                 case " $oldobjs " in
6328                 *[[\ /]]"$newobj "*) ;;
6329                 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
6330                 esac
6331               done
6332               func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
6333               oldobjs="$oldobjs $gentop/$newobj"
6334               ;;
6335             *) oldobjs="$oldobjs $obj" ;;
6336             esac
6337           done
6338         fi
6339         eval cmds=\"$old_archive_cmds\"
6341         if len=`expr "X$cmds" : ".*" 2>/dev/null` &&
6342            test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
6343           cmds=$old_archive_cmds
6344         else
6345           # the command line is too long to link in one step, link in parts
6346           func_echo "using piecewise archive linking..."
6347           save_RANLIB=$RANLIB
6348           RANLIB=:
6349           objlist=
6350           concat_cmds=
6351           save_oldobjs=$oldobjs
6352           # Is there a better way of finding the last object in the list?
6353           for obj in $save_oldobjs
6354           do
6355             last_oldobj=$obj
6356           done
6357           for obj in $save_oldobjs
6358           do
6359             oldobjs="$objlist $obj"
6360             objlist="$objlist $obj"
6361             eval test_cmds=\"$old_archive_cmds\"
6362             if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
6363                test "$len" -le "$max_cmd_len"; then
6364               :
6365             else
6366               # the above command should be used before it gets too long
6367               oldobjs=$objlist
6368               if test "$obj" = "$last_oldobj" ; then
6369                 RANLIB=$save_RANLIB
6370               fi
6371               test -z "$concat_cmds" || concat_cmds=$concat_cmds~
6372               eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
6373               objlist=
6374             fi
6375           done
6376           RANLIB=$save_RANLIB
6377           oldobjs=$objlist
6378           if test "X$oldobjs" = "X" ; then
6379             eval cmds=\"\$concat_cmds\"
6380           else
6381             eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
6382           fi
6383         fi
6384       fi
6385       func_execute_cmds "$cmds" 'exit $?'
6386     done
6388     test -n "$generated" && \
6389       func_show_eval "${RM}r$generated"
6391     # Now create the libtool archive.
6392     case $output in
6393     *.la)
6394       old_library=
6395       test "$build_old_libs" = yes && old_library="$libname.$libext"
6396       func_echo "creating $output"
6398       # Preserve any variables that may affect compiler behavior
6399       for var in $variables_saved_for_relink; do
6400         if eval test -z \"\${$var+set}\"; then
6401           relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
6402         elif eval var_value=\$$var; test -z "$var_value"; then
6403           relink_command="$var=; export $var; $relink_command"
6404         else
6405           func_quote_for_eval "$var_value"
6406           relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
6407         fi
6408       done
6409       # Quote the link command for shipping.
6410       relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
6411       relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
6412       if test "$hardcode_automatic" = yes ; then
6413         relink_command=
6414       fi
6416       # Only create the output if not a dry run.
6417       $opt_dry_run || {
6418         for installed in no yes; do
6419           if test "$installed" = yes; then
6420             if test -z "$install_libdir"; then
6421               break
6422             fi
6423             output="$output_objdir/$outputname"i
6424             # Replace all uninstalled libtool libraries with the installed ones
6425             newdependency_libs=
6426             for deplib in $dependency_libs; do
6427               case $deplib in
6428               *.la)
6429                 func_basename "$deplib"
6430                 name="$func_basename_result"
6431                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
6432                 test -z "$libdir" && \
6433                   func_fatal_error "\`$deplib' is not a valid libtool archive"
6434                 newdependency_libs="$newdependency_libs $libdir/$name"
6435                 ;;
6436               *) newdependency_libs="$newdependency_libs $deplib" ;;
6437               esac
6438             done
6439             dependency_libs="$newdependency_libs"
6440             newdlfiles=
6442             for lib in $dlfiles; do
6443               case $lib in
6444               *.la)
6445                 func_basename "$lib"
6446                 name="$func_basename_result"
6447                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
6448                 test -z "$libdir" && \
6449                   func_fatal_error "\`$lib' is not a valid libtool archive"
6450                 newdlfiles="$newdlfiles $libdir/$name"
6451                 ;;
6452               *) newdlfiles="$newdlfiles $lib" ;;
6453               esac
6454             done
6455             dlfiles="$newdlfiles"
6456             newdlprefiles=
6457             for lib in $dlprefiles; do
6458               case $lib in
6459               *.la)
6460                 # Only pass preopened files to the pseudo-archive (for
6461                 # eventual linking with the app. that links it) if we
6462                 # didn't already link the preopened objects directly into
6463                 # the library:
6464                 func_basename "$lib"
6465                 name="$func_basename_result"
6466                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
6467                 test -z "$libdir" && \
6468                   func_fatal_error "\`$lib' is not a valid libtool archive"
6469                 newdlprefiles="$newdlprefiles $libdir/$name"
6470                 ;;
6471               esac
6472             done
6473             dlprefiles="$newdlprefiles"
6474           else
6475             newdlfiles=
6476             for lib in $dlfiles; do
6477               case $lib in
6478                 [[\\/]]* | [[A-Za-z]]:[[\\/]]*) abs="$lib" ;;
6479                 *) abs=`pwd`"/$lib" ;;
6480               esac
6481               newdlfiles="$newdlfiles $abs"
6482             done
6483             dlfiles="$newdlfiles"
6484             newdlprefiles=
6485             for lib in $dlprefiles; do
6486               case $lib in
6487                 [[\\/]]* | [[A-Za-z]]:[[\\/]]*) abs="$lib" ;;
6488                 *) abs=`pwd`"/$lib" ;;
6489               esac
6490               newdlprefiles="$newdlprefiles $abs"
6491             done
6492             dlprefiles="$newdlprefiles"
6493           fi
6494           $RM $output
6495           # place dlname in correct position for cygwin
6496           tdlname=$dlname
6497           case $host,$output,$installed,$module,$dlname in
6498             *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
6499           esac
6500           $ECHO > $output "\
6501 # $outputname - a libtool library file
6502 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
6504 # Please DO NOT delete this file!
6505 # It is necessary for linking the library.
6507 # The name that we can dlopen(3).
6508 dlname='$tdlname'
6510 # Names of this library.
6511 library_names='$library_names'
6513 # The name of the static archive.
6514 old_library='$old_library'
6516 # Linker flags that can not go in dependency_libs.
6517 inherited_linker_flags='$new_inherited_linker_flags'
6519 # Libraries that this one depends upon.
6520 dependency_libs='$dependency_libs'
6522 # Names of additional weak libraries provided by this library
6523 weak_library_names='$weak_libs'
6525 # Version information for $libname.
6526 current=$current
6527 age=$age
6528 revision=$revision
6530 # Is this an already installed library?
6531 installed=$installed
6533 # Should we warn about portability when linking against -modules?
6534 shouldnotlink=$module
6536 # Files to dlopen/dlpreopen
6537 dlopen='$dlfiles'
6538 dlpreopen='$dlprefiles'
6540 # Directory that this library needs to be installed in:
6541 libdir='$install_libdir'"
6542           if test "$installed" = no && test "$need_relink" = yes; then
6543             $ECHO >> $output "\
6544 relink_command=\"$relink_command\""
6545           fi
6546         done
6547       }
6549       # Do a symbolic link so that the libtool archive can be found in
6550       # LD_LIBRARY_PATH before the program is installed.
6551       func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
6552       ;;
6553     esac
6554     exit $EXIT_SUCCESS
6558 # func_mode_uninstall arg...
6559 func_mode_uninstall ()
6561     $opt_debug
6562     RM="$nonopt"
6563     files=
6564     rmforce=
6565     exit_status=0
6567     # This variable tells wrapper scripts just to set variables rather
6568     # than running their programs.
6569     libtool_install_magic="$magic"
6571     for arg
6572     do
6573       case $arg in
6574       -f) RM="$RM $arg"; rmforce=yes ;;
6575       -*) RM="$RM $arg" ;;
6576       *) files="$files $arg" ;;
6577       esac
6578     done
6580     test -z "$RM" && \
6581       func_fatal_help "you must specify an RM program"
6583     rmdirs=
6585     origobjdir="$objdir"
6586     for file in $files; do
6587       func_dirname "$file" "" "."
6588       dir="$func_dirname_result"
6589       if test "X$dir" = X.; then
6590         objdir="$origobjdir"
6591       else
6592         objdir="$dir/$origobjdir"
6593       fi
6594       func_basename "$file"
6595       name="$func_basename_result"
6596       test "$mode" = uninstall && objdir="$dir"
6598       # Remember objdir for removal later, being careful to avoid duplicates
6599       if test "$mode" = clean; then
6600         case " $rmdirs " in
6601           *" $objdir "*) ;;
6602           *) rmdirs="$rmdirs $objdir" ;;
6603         esac
6604       fi
6606       # Don't error if the file doesn't exist and rm -f was used.
6607       if { test -L "$file"; } >/dev/null 2>&1 ||
6608          { test -h "$file"; } >/dev/null 2>&1 ||
6609          test -f "$file"; then
6610         :
6611       elif test -d "$file"; then
6612         exit_status=1
6613         continue
6614       elif test "$rmforce" = yes; then
6615         continue
6616       fi
6618       rmfiles="$file"
6620       case $name in
6621       *.la)
6622         # Possibly a libtool archive, so verify it.
6623         if func_lalib_p "$file"; then
6624           . $dir/$name
6626           # Delete the libtool libraries and symlinks.
6627           for n in $library_names; do
6628             rmfiles="$rmfiles $objdir/$n"
6629           done
6630           test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
6632           case "$mode" in
6633           clean)
6634             case "  $library_names " in
6635             # "  " in the beginning catches empty $dlname
6636             *" $dlname "*) ;;
6637             *) rmfiles="$rmfiles $objdir/$dlname" ;;
6638             esac
6639             test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
6640             ;;
6641           uninstall)
6642             if test -n "$library_names"; then
6643               # Do each command in the postuninstall commands.
6644               func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
6645             fi
6647             if test -n "$old_library"; then
6648               # Do each command in the old_postuninstall commands.
6649               func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
6650             fi
6651             # FIXME: should reinstall the best remaining shared library.
6652             ;;
6653           esac
6654         fi
6655         ;;
6657       *.lo)
6658         # Possibly a libtool object, so verify it.
6659         if func_lalib_p "$file"; then
6661           # Read the .lo file
6662           . $dir/$name
6664           # Add PIC object to the list of files to remove.
6665           if test -n "$pic_object" &&
6666              test "$pic_object" != none; then
6667             rmfiles="$rmfiles $dir/$pic_object"
6668           fi
6670           # Add non-PIC object to the list of files to remove.
6671           if test -n "$non_pic_object" &&
6672              test "$non_pic_object" != none; then
6673             rmfiles="$rmfiles $dir/$non_pic_object"
6674           fi
6675         fi
6676         ;;
6678       *)
6679         if test "$mode" = clean ; then
6680           noexename=$name
6681           case $file in
6682           *.exe)
6683             func_stripname '' '.exe' "$file"
6684             file=$func_stripname_result
6685             func_stripname '' '.exe' "$name"
6686             noexename=$func_stripname_result
6687             # $file with .exe has already been added to rmfiles,
6688             # add $file without .exe
6689             rmfiles="$rmfiles $file"
6690             ;;
6691           esac
6692           # Do a test to see if this is a libtool program.
6693           if func_ltwrapper_p "$file"; then
6694             relink_command=
6695             . $dir/$noexename
6697             # note $name still contains .exe if it was in $file originally
6698             # as does the version of $file that was added into $rmfiles
6699             rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
6700             if test "$fast_install" = yes && test -n "$relink_command"; then
6701               rmfiles="$rmfiles $objdir/lt-$name"
6702             fi
6703             if test "X$noexename" != "X$name" ; then
6704               rmfiles="$rmfiles $objdir/lt-${noexename}.c"
6705             fi
6706           fi
6707         fi
6708         ;;
6709       esac
6710       func_show_eval "$RM $rmfiles" 'exit_status=1'
6711     done
6712     objdir="$origobjdir"
6714     # Try to remove the ${objdir}s in the directories where we deleted files
6715     for dir in $rmdirs; do
6716       if test -d "$dir"; then
6717         func_show_eval "rmdir $dir >/dev/null 2>&1"
6718       fi
6719     done
6721     exit $exit_status
6725 # TEST SUITE MARKER ## NON-FUNCTION
6726 ## ----------- ##
6727 ##    Main.    ##
6728 ## ----------- ##
6731   # Sanity checks first:
6732   func_check_version_match
6734   if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
6735     func_fatal_configuration "not configured to build any kind of library"
6736   fi
6738   test -z "$mode" && func_fatal_error "error: you must specify a MODE."
6741   # Darwin sucks
6742   eval std_shrext=\"$shrext_cmds\"
6745   # Only execute mode is allowed to have -dlopen flags.
6746   if test -n "$execute_dlfiles" && test "$mode" != execute; then
6747     func_error "unrecognized option \`-dlopen'"
6748     $ECHO "$help" 1>&2
6749     exit $EXIT_FAILURE
6750   fi
6752   # Change the help message to a mode-specific one.
6753   generic_help="$help"
6754   help="Try \`$progname --help --mode=$mode' for more information."
6756   case $mode in
6757     compile)            func_mode_compile ${1+"$@"}             ;;
6758     execute)            func_mode_execute ${1+"$@"}             ;;
6759     finish)             func_mode_finish ${1+"$@"}              ;;
6760     install)            func_mode_install ${1+"$@"}             ;;
6761     link|relink)        func_mode_link ${1+"$@"}                ;;
6762     uninstall|clean)    func_mode_uninstall ${1+"$@"}           ;;
6764     "")                 help="$generic_help"
6765                         func_fatal_help "you must specify a MODE"
6766                         ;;
6767   esac
6769   test -z "$exec_cmd" && \
6770     func_fatal_help "invalid operation mode \`$mode'"
6772   if test -n "$exec_cmd"; then
6773     eval exec "$exec_cmd"
6774     exit $EXIT_FAILURE
6775   fi
6778 exit $exit_status
6781 # The TAGs below are defined such that we never get into a situation
6782 # in which we disable both kinds of libraries.  Given conflicting
6783 # choices, we go for a static library, that is the most portable,
6784 # since we can't tell whether shared libraries were disabled because
6785 # the user asked for that or because the platform doesn't support
6786 # them.  This is particularly important on AIX, because we don't
6787 # support having both static and shared libraries enabled at the same
6788 # time on that platform, so we default to a shared-only configuration.
6789 # If a disable-shared tag is given, we'll fallback to a static-only
6790 # configuration.  But we'll never go from static-only to shared-only.
6792 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
6793 build_libtool_libs=no
6794 build_old_libs=yes
6795 # ### END LIBTOOL TAG CONFIG: disable-shared
6797 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
6798 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
6799 # ### END LIBTOOL TAG CONFIG: disable-static
6801 # Local Variables:
6802 # mode:shell-script
6803 # sh-indentation:2
6804 # End: