~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
TINA5/tina-libs/ltmain.sh

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 # ltmain.sh - Provide generalized library-building support services.
  2 # NOTE: Changing this file will not affect anything until you rerun configure.
  3 #
  4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
  5 # Free Software Foundation, Inc.
  6 # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
  7 #
  8 # This program is free software; you can redistribute it and/or modify
  9 # it under the terms of the GNU General Public License as published by
 10 # the Free Software Foundation; either version 2 of the License, or
 11 # (at your option) any later version.
 12 #
 13 # This program is distributed in the hope that it will be useful, but
 14 # WITHOUT ANY WARRANTY; without even the implied warranty of
 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 16 # General Public License for more details.
 17 #
 18 # You should have received a copy of the GNU General Public License
 19 # along with this program; if not, write to the Free Software
 20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 21 #
 22 # As a special exception to the GNU General Public License, if you
 23 # distribute this file as part of a program that contains a
 24 # configuration script generated by Autoconf, you may include it under
 25 # the same distribution terms that you use for the rest of that program.
 26 
 27 basename="s,^.*/,,g"
 28 
 29 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
 30 # is ksh but when the shell is invoked as "sh" and the current value of
 31 # the _XPG environment variable is not equal to 1 (one), the special
 32 # positional parameter $0, within a function call, is the name of the
 33 # function.
 34 progpath="$0"
 35 
 36 # The name of this program:
 37 progname=`echo "$progpath" | $SED $basename`
 38 modename="$progname"
 39 
 40 # Global variables:
 41 EXIT_SUCCESS=0
 42 EXIT_FAILURE=1
 43 
 44 PROGRAM=ltmain.sh
 45 PACKAGE=libtool
 46 VERSION=1.5.14
 47 TIMESTAMP=" (1.1220.2.195 2005/02/12 12:12:33)"
 48 
 49 # See if we are running on zsh, and set the options which allow our
 50 # commands through without removal of \ escapes.
 51 if test -n "${ZSH_VERSION+set}" ; then
 52   setopt NO_GLOB_SUBST
 53 fi
 54 
 55 # Check that we have a working $echo.
 56 if test "X$1" = X--no-reexec; then
 57   # Discard the --no-reexec flag, and continue.
 58   shift
 59 elif test "X$1" = X--fallback-echo; then
 60   # Avoid inline document here, it may be left over
 61   :
 62 elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
 63   # Yippee, $echo works!
 64   :
 65 else
 66   # Restart under the correct shell, and then maybe $echo will work.
 67   exec $SHELL "$progpath" --no-reexec ${1+"$@"}
 68 fi
 69 
 70 if test "X$1" = X--fallback-echo; then
 71   # used as fallback echo
 72   shift
 73   cat <<EOF
 74 $*
 75 EOF
 76   exit $EXIT_SUCCESS
 77 fi
 78 
 79 default_mode=
 80 help="Try \`$progname --help' for more information."
 81 magic="%%%MAGIC variable%%%"
 82 mkdir="mkdir"
 83 mv="mv -f"
 84 rm="rm -f"
 85 
 86 # Sed substitution that helps us do robust quoting.  It backslashifies
 87 # metacharacters that are still active within double-quoted strings.
 88 Xsed="${SED}"' -e 1s/^X//'
 89 sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
 90 # test EBCDIC or ASCII
 91 case `echo A|tr A '\301'` in
 92  A) # EBCDIC based system
 93   SP2NL="tr '\100' '\n'"
 94   NL2SP="tr '\r\n' '\100\100'"
 95   ;;
 96  *) # Assume ASCII based system
 97   SP2NL="tr '\040' '\012'"
 98   NL2SP="tr '\015\012' '\040\040'"
 99   ;;
100 esac
101 
102 # NLS nuisances.
103 # Only set LANG and LC_ALL to C if already set.
104 # These must not be set unconditionally because not all systems understand
105 # e.g. LANG=C (notably SCO).
106 # We save the old values to restore during execute mode.
107 if test "${LC_ALL+set}" = set; then
108   save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
109 fi
110 if test "${LANG+set}" = set; then
111   save_LANG="$LANG"; LANG=C; export LANG
112 fi
113 
114 # Make sure IFS has a sensible default
115 : ${IFS="       
116 "}
117 
118 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
119   $echo "$modename: not configured to build any kind of library" 1>&2
120   $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
121   exit $EXIT_FAILURE
122 fi
123 
124 # Global variables.
125 mode=$default_mode
126 nonopt=
127 prev=
128 prevopt=
129 run=
130 show="$echo"
131 show_help=
132 execute_dlfiles=
133 lo2o="s/\\.lo\$/.${objext}/"
134 o2lo="s/\\.${objext}\$/.lo/"
135 quote_scanset='[[~#^*{};<>?'"'"'        ]'
136 
137 #####################################
138 # Shell function definitions:
139 # This seems to be the best place for them
140 
141 # func_win32_libid arg
142 # return the library type of file 'arg'
143 #
144 # Need a lot of goo to handle *both* DLLs and import libs
145 # Has to be a shell function in order to 'eat' the argument
146 # that is supplied when $file_magic_command is called.
147 func_win32_libid ()
148 {
149   win32_libid_type="unknown"
150   win32_fileres=`file -L $1 2>/dev/null`
151   case $win32_fileres in
152   *ar\ archive\ import\ library*) # definitely import
153     win32_libid_type="x86 archive import"
154     ;;
155   *ar\ archive*) # could be an import, or static
156     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
157       $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
158       win32_nmres=`eval $NM -f posix -A $1 | \
159         sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
160       if test "X$win32_nmres" = "Ximport" ; then
161         win32_libid_type="x86 archive import"
162       else
163         win32_libid_type="x86 archive static"
164       fi
165     fi
166     ;;
167   *DLL*)
168     win32_libid_type="x86 DLL"
169     ;;
170   *executable*) # but shell scripts are "executable" too...
171     case $win32_fileres in
172     *MS\ Windows\ PE\ Intel*)
173       win32_libid_type="x86 DLL"
174       ;;
175     esac
176     ;;
177   esac
178   $echo $win32_libid_type
179 }
180 
181 
182 # func_infer_tag arg
183 # Infer tagged configuration to use if any are available and
184 # if one wasn't chosen via the "--tag" command line option.
185 # Only attempt this if the compiler in the base compile
186 # command doesn't match the default compiler.
187 # arg is usually of the form 'gcc ...'
188 func_infer_tag ()
189 {
190     if test -n "$available_tags" && test -z "$tagname"; then
191       CC_quoted=
192       for arg in $CC; do
193         case $arg in
194           *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
195           arg="\"$arg\""
196           ;;
197         esac
198         CC_quoted="$CC_quoted $arg"
199       done
200       case $@ in
201       # Blanks in the command may have been stripped by the calling shell,
202       # but not from the CC environment variable when configure was run.
203       " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
204       # Blanks at the start of $base_compile will cause this to fail
205       # if we don't check for them as well.
206       *)
207         for z in $available_tags; do
208           if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
209             # Evaluate the configuration.
210             eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
211             CC_quoted=
212             for arg in $CC; do
213             # Double-quote args containing other shell metacharacters.
214             case $arg in
215               *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
216               arg="\"$arg\""
217               ;;
218             esac
219             CC_quoted="$CC_quoted $arg"
220           done
221             case "$@ " in
222               " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
223               # The compiler in the base compile command matches
224               # the one in the tagged configuration.
225               # Assume this is the tagged configuration we want.
226               tagname=$z
227               break
228               ;;
229             esac
230           fi
231         done
232         # If $tagname still isn't set, then no tagged configuration
233         # was found and let the user know that the "--tag" command
234         # line option must be used.
235         if test -z "$tagname"; then
236           $echo "$modename: unable to infer tagged configuration"
237           $echo "$modename: specify a tag with \`--tag'" 1>&2
238           exit $EXIT_FAILURE
239 #        else
240 #          $echo "$modename: using $tagname tagged configuration"
241         fi
242         ;;
243       esac
244     fi
245 }
246 
247 
248 # func_extract_an_archive dir oldlib
249 func_extract_an_archive ()
250 {
251     f_ex_an_ar_dir="$1"; shift
252     f_ex_an_ar_oldlib="$1"
253     f_ex_an_ar_lib=`$echo "X$f_ex_an_ar_oldlib" | $Xsed -e 's%^.*/%%'`
254 
255     $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
256     $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
257     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
258      :
259     else
260       $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
261       $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
262       $show "cp $f_ex_an_ar_oldlib $f_ex_an_ar_dir/$f_ex_an_ar_lib"
263       $run eval "cp \$f_ex_an_ar_oldlib \$f_ex_an_ar_dir/\$f_ex_an_ar_lib"
264       $AR t "$f_ex_an_ar_oldlib" | sort | uniq -c \
265         | $EGREP -v '^[         ]*1[    ]' | while read count name
266       do
267         i=1
268         while test "$i" -le "$count"
269           do
270           # Put our $i before any first dot (extension)
271           # Never overwrite any file
272           name_to="$name"
273           while test "X$name_to" = "X$name" || test -f "$f_ex_an_ar_dir/$name_to"
274             do
275             name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
276           done
277           $show "(cd $f_ex_an_ar_dir && $AR x  $f_ex_an_ar_lib '$name' && $mv '$name' '$name_to')"
278           $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_lib '$name' && $mv '$name' '$name_to' && $AR -d \$f_ex_an_ar_lib '$name')" || exit $?
279           i=`expr $i + 1`
280         done
281       done
282       $show "$rm $f_ex_an_ar_dir/$f_ex_an_ar_lib"
283       $run eval "$rm \$f_ex_an_ar_dir/\$f_ex_an_ar_lib"
284     fi
285 }
286 
287 # func_extract_archives gentop oldlib ...
288 func_extract_archives ()
289 {
290     my_gentop="$1"; shift
291     my_oldlibs=${1+"$@"}
292     my_oldobjs=""
293     my_xlib=""
294     my_xabs=""
295     my_xdir=""
296     my_status=""
297 
298     $show "${rm}r $my_gentop"
299     $run ${rm}r "$my_gentop"
300     $show "$mkdir $my_gentop"
301     $run $mkdir "$my_gentop"
302     my_status=$?
303     if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
304       exit $my_status
305     fi
306 
307     for my_xlib in $my_oldlibs; do
308       # Extract the objects.
309       case $my_xlib in
310         [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
311         *) my_xabs=`pwd`"/$my_xlib" ;;
312       esac
313       my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
314       my_xdir="$my_gentop/$my_xlib"
315 
316       $show "${rm}r $my_xdir"
317       $run ${rm}r "$my_xdir"
318       $show "$mkdir $my_xdir"
319       $run $mkdir "$my_xdir"
320       status=$?
321       if test "$status" -ne 0 && test ! -d "$my_xdir"; then
322         exit $status
323       fi
324       case $host in
325       *-darwin*)
326         $show "Extracting $my_xabs"
327         # Do not bother doing anything if just a dry run
328         if test -z "$run"; then
329           darwin_orig_dir=`pwd`
330           cd $my_xdir || exit $?
331           darwin_archive=$my_xabs
332           darwin_curdir=`pwd`
333           darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
334           darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
335           if test -n "$darwin_arches"; then 
336             darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
337             darwin_arch=
338             $show "$darwin_base_archive has multiple architectures $darwin_arches"
339             for darwin_arch in  $darwin_arches ; do
340               mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
341               lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
342               cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
343               func_extract_an_archive "`pwd`" "${darwin_base_archive}"
344               cd "$darwin_curdir"
345               $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
346             done # $darwin_arches
347       ## Okay now we have a bunch of thin objects, gotta fatten them up :)
348             darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
349             darwin_file=
350             darwin_files=
351             for darwin_file in $darwin_filelist; do
352               darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
353               lipo -create -output "$darwin_file" $darwin_files
354             done # $darwin_filelist
355             ${rm}r unfat-$$
356             cd "$darwin_orig_dir"
357           else
358             cd "$darwin_orig_dir"
359             func_extract_an_archive "$my_xdir" "$my_xabs"
360           fi # $darwin_arches
361         fi # $run
362       ;;
363       *)
364         func_extract_an_archive "$my_xdir" "$my_xabs"
365         ;;
366       esac
367       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
368     done
369     func_extract_archives_result="$my_oldobjs"
370 }
371 # End of Shell function definitions
372 #####################################
373 
374 # Darwin sucks
375 eval std_shrext=\"$shrext_cmds\"
376 
377 # Parse our command line options once, thoroughly.
378 while test "$#" -gt 0
379 do
380   arg="$1"
381   shift
382 
383   case $arg in
384   -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
385   *) optarg= ;;
386   esac
387 
388   # If the previous option needs an argument, assign it.
389   if test -n "$prev"; then
390     case $prev in
391     execute_dlfiles)
392       execute_dlfiles="$execute_dlfiles $arg"
393       ;;
394     tag)
395       tagname="$arg"
396       preserve_args="${preserve_args}=$arg"
397 
398       # Check whether tagname contains only valid characters
399       case $tagname in
400       *[!-_A-Za-z0-9,/]*)
401         $echo "$progname: invalid tag name: $tagname" 1>&2
402         exit $EXIT_FAILURE
403         ;;
404       esac
405 
406       case $tagname in
407       CC)
408         # Don't test for the "default" C tag, as we know, it's there, but
409         # not specially marked.
410         ;;
411       *)
412         if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
413           taglist="$taglist $tagname"
414           # Evaluate the configuration.
415           eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
416         else
417           $echo "$progname: ignoring unknown tag $tagname" 1>&2
418         fi
419         ;;
420       esac
421       ;;
422     *)
423       eval "$prev=\$arg"
424       ;;
425     esac
426 
427     prev=
428     prevopt=
429     continue
430   fi
431 
432   # Have we seen a non-optional argument yet?
433   case $arg in
434   --help)
435     show_help=yes
436     ;;
437 
438   --version)
439     $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
440     $echo
441     $echo "Copyright (C) 2005  Free Software Foundation, Inc."
442     $echo "This is free software; see the source for copying conditions.  There is NO"
443     $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
444     exit $?
445     ;;
446 
447   --config)
448     ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
449     # Now print the configurations for the tags.
450     for tagname in $taglist; do
451       ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
452     done
453     exit $?
454     ;;
455 
456   --debug)
457     $echo "$progname: enabling shell trace mode"
458     set -x
459     preserve_args="$preserve_args $arg"
460     ;;
461 
462   --dry-run | -n)
463     run=:
464     ;;
465 
466   --features)
467     $echo "host: $host"
468     if test "$build_libtool_libs" = yes; then
469       $echo "enable shared libraries"
470     else
471       $echo "disable shared libraries"
472     fi
473     if test "$build_old_libs" = yes; then
474       $echo "enable static libraries"
475     else
476       $echo "disable static libraries"
477     fi
478     exit $?
479     ;;
480 
481   --finish) mode="finish" ;;
482 
483   --mode) prevopt="--mode" prev=mode ;;
484   --mode=*) mode="$optarg" ;;
485 
486   --preserve-dup-deps) duplicate_deps="yes" ;;
487 
488   --quiet | --silent)
489     show=:
490     preserve_args="$preserve_args $arg"
491     ;;
492 
493   --tag) prevopt="--tag" prev=tag ;;
494   --tag=*)
495     set tag "$optarg" ${1+"$@"}
496     shift
497     prev=tag
498     preserve_args="$preserve_args --tag"
499     ;;
500 
501   -dlopen)
502     prevopt="-dlopen"
503     prev=execute_dlfiles
504     ;;
505 
506   -*)
507     $echo "$modename: unrecognized option \`$arg'" 1>&2
508     $echo "$help" 1>&2
509     exit $EXIT_FAILURE
510     ;;
511 
512   *)
513     nonopt="$arg"
514     break
515     ;;
516   esac
517 done
518 
519 if test -n "$prevopt"; then
520   $echo "$modename: option \`$prevopt' requires an argument" 1>&2
521   $echo "$help" 1>&2
522   exit $EXIT_FAILURE
523 fi
524 
525 # If this variable is set in any of the actions, the command in it
526 # will be execed at the end.  This prevents here-documents from being
527 # left over by shells.
528 exec_cmd=
529 
530 if test -z "$show_help"; then
531 
532   # Infer the operation mode.
533   if test -z "$mode"; then
534     $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
535     $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
536     case $nonopt in
537     *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
538       mode=link
539       for arg
540       do
541         case $arg in
542         -c)
543            mode=compile
544            break
545            ;;
546         esac
547       done
548       ;;
549     *db | *dbx | *strace | *truss)
550       mode=execute
551       ;;
552     *install*|cp|mv)
553       mode=install
554       ;;
555     *rm)
556       mode=uninstall
557       ;;
558     *)
559       # If we have no mode, but dlfiles were specified, then do execute mode.
560       test -n "$execute_dlfiles" && mode=execute
561 
562       # Just use the default operation mode.
563       if test -z "$mode"; then
564         if test -n "$nonopt"; then
565           $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
566         else
567           $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
568         fi
569       fi
570       ;;
571     esac
572   fi
573 
574   # Only execute mode is allowed to have -dlopen flags.
575   if test -n "$execute_dlfiles" && test "$mode" != execute; then
576     $echo "$modename: unrecognized option \`-dlopen'" 1>&2
577     $echo "$help" 1>&2
578     exit $EXIT_FAILURE
579   fi
580 
581   # Change the help message to a mode-specific one.
582   generic_help="$help"
583   help="Try \`$modename --help --mode=$mode' for more information."
584 
585   # These modes are in order of execution frequency so that they run quickly.
586   case $mode in
587   # libtool compile mode
588   compile)
589     modename="$modename: compile"
590     # Get the compilation command and the source file.
591     base_compile=
592     srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
593     suppress_opt=yes
594     suppress_output=
595     arg_mode=normal
596     libobj=
597     later=
598 
599     for arg
600     do
601       case "$arg_mode" in
602       arg  )
603         # do not "continue".  Instead, add this to base_compile
604         lastarg="$arg"
605         arg_mode=normal
606         ;;
607 
608       target )
609         libobj="$arg"
610         arg_mode=normal
611         continue
612         ;;
613 
614       normal )
615         # Accept any command-line options.
616         case $arg in
617         -o)
618           if test -n "$libobj" ; then
619             $echo "$modename: you cannot specify \`-o' more than once" 1>&2
620             exit $EXIT_FAILURE
621           fi
622           arg_mode=target
623           continue
624           ;;
625 
626         -static | -prefer-pic | -prefer-non-pic)
627           later="$later $arg"
628           continue
629           ;;
630 
631         -no-suppress)
632           suppress_opt=no
633           continue
634           ;;
635 
636         -Xcompiler)
637           arg_mode=arg  #  the next one goes into the "base_compile" arg list
638           continue      #  The current "srcfile" will either be retained or
639           ;;            #  replaced later.  I would guess that would be a bug.
640 
641         -Wc,*)
642           args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
643           lastarg=
644           save_ifs="$IFS"; IFS=','
645           for arg in $args; do
646             IFS="$save_ifs"
647 
648             # Double-quote args containing other shell metacharacters.
649             # Many Bourne shells cannot handle close brackets correctly
650             # in scan sets, so we specify it separately.
651             case $arg in
652               *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
653               arg="\"$arg\""
654               ;;
655             esac
656             lastarg="$lastarg $arg"
657           done
658           IFS="$save_ifs"
659           lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
660 
661           # Add the arguments to base_compile.
662           base_compile="$base_compile $lastarg"
663           continue
664           ;;
665 
666         * )
667           # Accept the current argument as the source file.
668           # The previous "srcfile" becomes the current argument.
669           #
670           lastarg="$srcfile"
671           srcfile="$arg"
672           ;;
673         esac  #  case $arg
674         ;;
675       esac    #  case $arg_mode
676 
677       # Aesthetically quote the previous argument.
678       lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
679 
680       case $lastarg in
681       # Double-quote args containing other shell metacharacters.
682       # Many Bourne shells cannot handle close brackets correctly
683       # in scan sets, and some SunOS ksh mistreat backslash-escaping
684       # in scan sets (worked around with variable expansion),
685       # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
686       # at all, so we specify them separately.
687       *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
688         lastarg="\"$lastarg\""
689         ;;
690       esac
691 
692       base_compile="$base_compile $lastarg"
693     done # for arg
694 
695     case $arg_mode in
696     arg)
697       $echo "$modename: you must specify an argument for -Xcompile"
698       exit $EXIT_FAILURE
699       ;;
700     target)
701       $echo "$modename: you must specify a target with \`-o'" 1>&2
702       exit $EXIT_FAILURE
703       ;;
704     *)
705       # Get the name of the library object.
706       [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
707       ;;
708     esac
709 
710     # Recognize several different file suffixes.
711     # If the user specifies -o file.o, it is replaced with file.lo
712     xform='[cCFSifmso]'
713     case $libobj in
714     *.ada) xform=ada ;;
715     *.adb) xform=adb ;;
716     *.ads) xform=ads ;;
717     *.asm) xform=asm ;;
718     *.c++) xform=c++ ;;
719     *.cc) xform=cc ;;
720     *.ii) xform=ii ;;
721     *.class) xform=class ;;
722     *.cpp) xform=cpp ;;
723     *.cxx) xform=cxx ;;
724     *.f90) xform=f90 ;;
725     *.for) xform=for ;;
726     *.java) xform=java ;;
727     esac
728 
729     libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
730 
731     case $libobj in
732     *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
733     *)
734       $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
735       exit $EXIT_FAILURE
736       ;;
737     esac
738 
739     func_infer_tag $base_compile
740 
741     for arg in $later; do
742       case $arg in
743       -static)
744         build_old_libs=yes
745         continue
746         ;;
747 
748       -prefer-pic)
749         pic_mode=yes
750         continue
751         ;;
752 
753       -prefer-non-pic)
754         pic_mode=no
755         continue
756         ;;
757       esac
758     done
759 
760     objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
761     xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
762     if test "X$xdir" = "X$obj"; then
763       xdir=
764     else
765       xdir=$xdir/
766     fi
767     lobj=${xdir}$objdir/$objname
768 
769     if test -z "$base_compile"; then
770       $echo "$modename: you must specify a compilation command" 1>&2
771       $echo "$help" 1>&2
772       exit $EXIT_FAILURE
773     fi
774 
775     # Delete any leftover library objects.
776     if test "$build_old_libs" = yes; then
777       removelist="$obj $lobj $libobj ${libobj}T"
778     else
779       removelist="$lobj $libobj ${libobj}T"
780     fi
781 
782     $run $rm $removelist
783     trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
784 
785     # On Cygwin there's no "real" PIC flag so we must build both object types
786     case $host_os in
787     cygwin* | mingw* | pw32* | os2*)
788       pic_mode=default
789       ;;
790     esac
791     if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
792       # non-PIC code in shared libraries is not supported
793       pic_mode=default
794     fi
795 
796     # Calculate the filename of the output object if compiler does
797     # not support -o with -c
798     if test "$compiler_c_o" = no; then
799       output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
800       lockfile="$output_obj.lock"
801       removelist="$removelist $output_obj $lockfile"
802       trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
803     else
804       output_obj=
805       need_locks=no
806       lockfile=
807     fi
808 
809     # Lock this critical section if it is needed
810     # We use this script file to make the link, it avoids creating a new file
811     if test "$need_locks" = yes; then
812       until $run ln "$progpath" "$lockfile" 2>/dev/null; do
813         $show "Waiting for $lockfile to be removed"
814         sleep 2
815       done
816     elif test "$need_locks" = warn; then
817       if test -f "$lockfile"; then
818         $echo "\
819 *** ERROR, $lockfile exists and contains:
820 `cat $lockfile 2>/dev/null`
821 
822 This indicates that another process is trying to use the same
823 temporary object file, and libtool could not work around it because
824 your compiler does not support \`-c' and \`-o' together.  If you
825 repeat this compilation, it may succeed, by chance, but you had better
826 avoid parallel builds (make -j) in this platform, or get a better
827 compiler."
828 
829         $run $rm $removelist
830         exit $EXIT_FAILURE
831       fi
832       $echo $srcfile > "$lockfile"
833     fi
834 
835     if test -n "$fix_srcfile_path"; then
836       eval srcfile=\"$fix_srcfile_path\"
837     fi
838 
839     $run $rm "$libobj" "${libobj}T"
840 
841     # Create a libtool object file (analogous to a ".la" file),
842     # but don't create it if we're doing a dry run.
843     test -z "$run" && cat > ${libobj}T <<EOF
844 # $libobj - a libtool object file
845 # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
846 #
847 # Please DO NOT delete this file!
848 # It is necessary for linking the library.
849 
850 # Name of the PIC object.
851 EOF
852 
853     # Only build a PIC object if we are building libtool libraries.
854     if test "$build_libtool_libs" = yes; then
855       # Without this assignment, base_compile gets emptied.
856       fbsd_hideous_sh_bug=$base_compile
857 
858       if test "$pic_mode" != no; then
859         command="$base_compile $srcfile $pic_flag"
860       else
861         # Don't build PIC code
862         command="$base_compile $srcfile"
863       fi
864 
865       if test ! -d "${xdir}$objdir"; then
866         $show "$mkdir ${xdir}$objdir"
867         $run $mkdir ${xdir}$objdir
868         status=$?
869         if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then
870           exit $status
871         fi
872       fi
873 
874       if test -z "$output_obj"; then
875         # Place PIC objects in $objdir
876         command="$command -o $lobj"
877       fi
878 
879       $run $rm "$lobj" "$output_obj"
880 
881       $show "$command"
882       if $run eval "$command"; then :
883       else
884         test -n "$output_obj" && $run $rm $removelist
885         exit $EXIT_FAILURE
886       fi
887 
888       if test "$need_locks" = warn &&
889          test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
890         $echo "\
891 *** ERROR, $lockfile contains:
892 `cat $lockfile 2>/dev/null`
893 
894 but it should contain:
895 $srcfile
896 
897 This indicates that another process is trying to use the same
898 temporary object file, and libtool could not work around it because
899 your compiler does not support \`-c' and \`-o' together.  If you
900 repeat this compilation, it may succeed, by chance, but you had better
901 avoid parallel builds (make -j) in this platform, or get a better
902 compiler."
903 
904         $run $rm $removelist
905         exit $EXIT_FAILURE
906       fi
907 
908       # Just move the object if needed, then go on to compile the next one
909       if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
910         $show "$mv $output_obj $lobj"
911         if $run $mv $output_obj $lobj; then :
912         else
913           error=$?
914           $run $rm $removelist
915           exit $error
916         fi
917       fi
918 
919       # Append the name of the PIC object to the libtool object file.
920       test -z "$run" && cat >> ${libobj}T <<EOF
921 pic_object='$objdir/$objname'
922 
923 EOF
924 
925       # Allow error messages only from the first compilation.
926       if test "$suppress_opt" = yes; then
927         suppress_output=' >/dev/null 2>&1'
928       fi
929     else
930       # No PIC object so indicate it doesn't exist in the libtool
931       # object file.
932       test -z "$run" && cat >> ${libobj}T <<EOF
933 pic_object=none
934 
935 EOF
936     fi
937 
938     # Only build a position-dependent object if we build old libraries.
939     if test "$build_old_libs" = yes; then
940       if test "$pic_mode" != yes; then
941         # Don't build PIC code
942         command="$base_compile $srcfile"
943       else
944         command="$base_compile $srcfile $pic_flag"
945       fi
946       if test "$compiler_c_o" = yes; then
947         command="$command -o $obj"
948       fi
949 
950       # Suppress compiler output if we already did a PIC compilation.
951       command="$command$suppress_output"
952       $run $rm "$obj" "$output_obj"
953       $show "$command"
954       if $run eval "$command"; then :
955       else
956         $run $rm $removelist
957         exit $EXIT_FAILURE
958       fi
959 
960       if test "$need_locks" = warn &&
961          test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
962         $echo "\
963 *** ERROR, $lockfile contains:
964 `cat $lockfile 2>/dev/null`
965 
966 but it should contain:
967 $srcfile
968 
969 This indicates that another process is trying to use the same
970 temporary object file, and libtool could not work around it because
971 your compiler does not support \`-c' and \`-o' together.  If you
972 repeat this compilation, it may succeed, by chance, but you had better
973 avoid parallel builds (make -j) in this platform, or get a better
974 compiler."
975 
976         $run $rm $removelist
977         exit $EXIT_FAILURE
978       fi
979 
980       # Just move the object if needed
981       if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
982         $show "$mv $output_obj $obj"
983         if $run $mv $output_obj $obj; then :
984         else
985           error=$?
986           $run $rm $removelist
987           exit $error
988         fi
989       fi
990 
991       # Append the name of the non-PIC object the libtool object file.
992       # Only append if the libtool object file exists.
993       test -z "$run" && cat >> ${libobj}T <<EOF
994 # Name of the non-PIC object.
995 non_pic_object='$objname'
996 
997 EOF
998     else
999       # Append the name of the non-PIC object the libtool object file.
1000       # Only append if the libtool object file exists.
1001       test -z "$run" && cat >> ${libobj}T <<EOF
1002 # Name of the non-PIC object.
1003 non_pic_object=none
1004 
1005 EOF
1006     fi
1007 
1008     $run $mv "${libobj}T" "${libobj}"
1009 
1010     # Unlock the critical section if it was locked
1011     if test "$need_locks" != no; then
1012       $run $rm "$lockfile"
1013     fi
1014 
1015     exit $EXIT_SUCCESS
1016     ;;
1017 
1018   # libtool link mode
1019   link | relink)
1020     modename="$modename: link"
1021     case $host in
1022     *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1023       # It is impossible to link a dll without this setting, and
1024       # we shouldn't force the makefile maintainer to figure out
1025       # which system we are compiling for in order to pass an extra
1026       # flag for every libtool invocation.
1027       # allow_undefined=no
1028 
1029       # FIXME: Unfortunately, there are problems with the above when trying
1030       # to make a dll which has undefined symbols, in which case not
1031       # even a static library is built.  For now, we need to specify
1032       # -no-undefined on the libtool link line when we can be certain
1033       # that all symbols are satisfied, otherwise we get a static library.
1034       allow_undefined=yes
1035       ;;
1036     *)
1037       allow_undefined=yes
1038       ;;
1039     esac
1040     libtool_args="$nonopt"
1041     base_compile="$nonopt $@"
1042     compile_command="$nonopt"
1043     finalize_command="$nonopt"
1044 
1045     compile_rpath=
1046     finalize_rpath=
1047     compile_shlibpath=
1048     finalize_shlibpath=
1049     convenience=
1050     old_convenience=
1051     deplibs=
1052     old_deplibs=
1053     compiler_flags=
1054     linker_flags=
1055     dllsearchpath=
1056     lib_search_path=`pwd`
1057     inst_prefix_dir=
1058 
1059     avoid_version=no
1060     dlfiles=
1061     dlprefiles=
1062     dlself=no
1063     export_dynamic=no
1064     export_symbols=
1065     export_symbols_regex=
1066     generated=
1067     libobjs=
1068     ltlibs=
1069     module=no
1070     no_install=no
1071     objs=
1072     non_pic_objects=
1073     precious_files_regex=
1074     prefer_static_libs=no
1075     preload=no
1076     prev=
1077     prevarg=
1078     release=
1079     rpath=
1080     xrpath=
1081     perm_rpath=
1082     temp_rpath=
1083     thread_safe=no
1084     vinfo=
1085     vinfo_number=no
1086 
1087     func_infer_tag $base_compile
1088 
1089     # We need to know -static, to get the right output filenames.
1090     for arg
1091     do
1092       case $arg in
1093       -all-static | -static)
1094         if test "X$arg" = "X-all-static"; then
1095           if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
1096             $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
1097           fi
1098           if test -n "$link_static_flag"; then
1099             dlopen_self=$dlopen_self_static
1100           fi
1101         else
1102           if test -z "$pic_flag" && test -n "$link_static_flag"; then
1103             dlopen_self=$dlopen_self_static
1104           fi
1105         fi
1106         build_libtool_libs=no
1107         build_old_libs=yes
1108         prefer_static_libs=yes
1109         break
1110         ;;
1111       esac
1112     done
1113 
1114     # See if our shared archives depend on static archives.
1115     test -n "$old_archive_from_new_cmds" && build_old_libs=yes
1116 
1117     # Go through the arguments, transforming them on the way.
1118     while test "$#" -gt 0; do
1119       arg="$1"
1120       shift
1121       case $arg in
1122       *$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
1123         qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
1124         ;;
1125       *) qarg=$arg ;;
1126       esac
1127       libtool_args="$libtool_args $qarg"
1128 
1129       # If the previous option needs an argument, assign it.
1130       if test -n "$prev"; then
1131         case $prev in
1132         output)
1133           compile_command="$compile_command @OUTPUT@"
1134           finalize_command="$finalize_command @OUTPUT@"
1135           ;;
1136         esac
1137 
1138         case $prev in
1139         dlfiles|dlprefiles)
1140           if test "$preload" = no; then
1141             # Add the symbol object into the linking commands.
1142             compile_command="$compile_command @SYMFILE@"
1143             finalize_command="$finalize_command @SYMFILE@"
1144             preload=yes
1145           fi
1146           case $arg in
1147           *.la | *.lo) ;;  # We handle these cases below.
1148           force)
1149             if test "$dlself" = no; then
1150               dlself=needless
1151               export_dynamic=yes
1152             fi
1153             prev=
1154             continue
1155             ;;
1156           self)
1157             if test "$prev" = dlprefiles; then
1158               dlself=yes
1159             elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
1160               dlself=yes
1161             else
1162               dlself=needless
1163               export_dynamic=yes
1164             fi
1165             prev=
1166             continue
1167             ;;
1168           *)
1169             if test "$prev" = dlfiles; then
1170               dlfiles="$dlfiles $arg"
1171             else
1172               dlprefiles="$dlprefiles $arg"
1173             fi
1174             prev=
1175             continue
1176             ;;
1177           esac
1178           ;;
1179         expsyms)
1180           export_symbols="$arg"
1181           if test ! -f "$arg"; then
1182             $echo "$modename: symbol file \`$arg' does not exist"
1183             exit $EXIT_FAILURE
1184           fi
1185           prev=
1186           continue
1187           ;;
1188         expsyms_regex)
1189           export_symbols_regex="$arg"
1190           prev=
1191           continue
1192           ;;
1193         inst_prefix)
1194           inst_prefix_dir="$arg"
1195           prev=
1196           continue
1197           ;;
1198         precious_regex)
1199           precious_files_regex="$arg"
1200           prev=
1201           continue
1202           ;;
1203         release)
1204           release="-$arg"
1205           prev=
1206           continue
1207           ;;
1208         objectlist)
1209           if test -f "$arg"; then
1210             save_arg=$arg
1211             moreargs=
1212             for fil in `cat $save_arg`
1213             do
1214 #             moreargs="$moreargs $fil"
1215               arg=$fil
1216               # A libtool-controlled object.
1217 
1218               # Check to see that this really is a libtool object.
1219               if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1220                 pic_object=
1221                 non_pic_object=
1222 
1223                 # Read the .lo file
1224                 # If there is no directory component, then add one.
1225                 case $arg in
1226                 */* | *\\*) . $arg ;;
1227                 *) . ./$arg ;;
1228                 esac
1229 
1230                 if test -z "$pic_object" || \
1231                    test -z "$non_pic_object" ||
1232                    test "$pic_object" = none && \
1233                    test "$non_pic_object" = none; then
1234                   $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1235                   exit $EXIT_FAILURE
1236                 fi
1237 
1238                 # Extract subdirectory from the argument.
1239                 xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1240                 if test "X$xdir" = "X$arg"; then
1241                   xdir=
1242                 else
1243                   xdir="$xdir/"
1244                 fi
1245 
1246                 if test "$pic_object" != none; then
1247                   # Prepend the subdirectory the object is found in.
1248                   pic_object="$xdir$pic_object"
1249 
1250                   if test "$prev" = dlfiles; then
1251                     if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1252                       dlfiles="$dlfiles $pic_object"
1253                       prev=
1254                       continue
1255                     else
1256                       # If libtool objects are unsupported, then we need to preload.
1257                       prev=dlprefiles
1258                     fi
1259                   fi
1260 
1261                   # CHECK ME:  I think I busted this.  -Ossama
1262                   if test "$prev" = dlprefiles; then
1263                     # Preload the old-style object.
1264                     dlprefiles="$dlprefiles $pic_object"
1265                     prev=
1266                   fi
1267 
1268                   # A PIC object.
1269                   libobjs="$libobjs $pic_object"
1270                   arg="$pic_object"
1271                 fi
1272 
1273                 # Non-PIC object.
1274                 if test "$non_pic_object" != none; then
1275                   # Prepend the subdirectory the object is found in.
1276                   non_pic_object="$xdir$non_pic_object"
1277 
1278                   # A standard non-PIC object
1279                   non_pic_objects="$non_pic_objects $non_pic_object"
1280                   if test -z "$pic_object" || test "$pic_object" = none ; then
1281                     arg="$non_pic_object"
1282                   fi
1283                 fi
1284               else
1285                 # Only an error if not doing a dry-run.
1286                 if test -z "$run"; then
1287                   $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1288                   exit $EXIT_FAILURE
1289                 else
1290                   # Dry-run case.
1291 
1292                   # Extract subdirectory from the argument.
1293                   xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1294                   if test "X$xdir" = "X$arg"; then
1295                     xdir=
1296                   else
1297                     xdir="$xdir/"
1298                   fi
1299 
1300                   pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1301                   non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1302                   libobjs="$libobjs $pic_object"
1303                   non_pic_objects="$non_pic_objects $non_pic_object"
1304                 fi
1305               fi
1306             done
1307           else
1308             $echo "$modename: link input file \`$save_arg' does not exist"
1309             exit $EXIT_FAILURE
1310           fi
1311           arg=$save_arg
1312           prev=
1313           continue
1314           ;;
1315         rpath | xrpath)
1316           # We need an absolute path.
1317           case $arg in
1318           [\\/]* | [A-Za-z]:[\\/]*) ;;
1319           *)
1320             $echo "$modename: only absolute run-paths are allowed" 1>&2
1321             exit $EXIT_FAILURE
1322             ;;
1323           esac
1324           if test "$prev" = rpath; then
1325             case "$rpath " in
1326             *" $arg "*) ;;
1327             *) rpath="$rpath $arg" ;;
1328             esac
1329           else
1330             case "$xrpath " in
1331             *" $arg "*) ;;
1332             *) xrpath="$xrpath $arg" ;;
1333             esac
1334           fi
1335           prev=
1336           continue
1337           ;;
1338         xcompiler)
1339           compiler_flags="$compiler_flags $qarg"
1340           prev=
1341           compile_command="$compile_command $qarg"
1342           finalize_command="$finalize_command $qarg"
1343           continue
1344           ;;
1345         xlinker)
1346           linker_flags="$linker_flags $qarg"
1347           compiler_flags="$compiler_flags $wl$qarg"
1348           prev=
1349           compile_command="$compile_command $wl$qarg"
1350           finalize_command="$finalize_command $wl$qarg"
1351           continue
1352           ;;
1353         xcclinker)
1354           linker_flags="$linker_flags $qarg"
1355           compiler_flags="$compiler_flags $qarg"
1356           prev=
1357           compile_command="$compile_command $qarg"
1358           finalize_command="$finalize_command $qarg"
1359           continue
1360           ;;
1361         shrext)
1362           shrext_cmds="$arg"
1363           prev=
1364           continue
1365           ;;
1366         darwin_framework)
1367           compiler_flags="$compiler_flags $arg"
1368           prev=
1369           continue
1370           ;;
1371         *)
1372           eval "$prev=\"\$arg\""
1373           prev=
1374           continue
1375           ;;
1376         esac
1377       fi # test -n "$prev"
1378 
1379       prevarg="$arg"
1380 
1381       case $arg in
1382       -all-static)
1383         if test -n "$link_static_flag"; then
1384           compile_command="$compile_command $link_static_flag"
1385           finalize_command="$finalize_command $link_static_flag"
1386         fi
1387         continue
1388         ;;
1389 
1390       -allow-undefined)
1391         # FIXME: remove this flag sometime in the future.
1392         $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
1393         continue
1394         ;;
1395 
1396       -avoid-version)
1397         avoid_version=yes
1398         continue
1399         ;;
1400 
1401       -dlopen)
1402         prev=dlfiles
1403         continue
1404         ;;
1405 
1406       -dlpreopen)
1407         prev=dlprefiles
1408         continue
1409         ;;
1410 
1411       -export-dynamic)
1412         export_dynamic=yes
1413         continue
1414         ;;
1415 
1416       -export-symbols | -export-symbols-regex)
1417         if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
1418           $echo "$modename: more than one -exported-symbols argument is not allowed"
1419           exit $EXIT_FAILURE
1420         fi
1421         if test "X$arg" = "X-export-symbols"; then
1422           prev=expsyms
1423         else