root/ImageMagick/trunk/config/ltmain.sh

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