/[svn]/ircd-hybrid-7.2/ltmain.sh
ViewVC logotype

Diff of /ircd-hybrid-7.2/ltmain.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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