root/gnuradio/tags/releases/3.0.3rc1/gr-howto-write-a-block/ltmain.sh

Revision 3727 (checked in by jcorgan, 2 years ago)

Apply changeset r3722 on trunk to release branch.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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.22 Debian 1.5.22-4"
47 TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
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 X|tr X '\101'` in
92  A) # ASCII based system
93     # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
94   SP2NL='tr \040 \012'
95   NL2SP='tr \015\012 \040\040'
96   ;;
97  *) # EBCDIC based system
98   SP2NL='tr \100 \n'
99   NL2SP='tr \r\n \100\100'
100   ;;
101 esac
102
103 # NLS nuisances.
104 # Only set LANG and LC_ALL to C if already set.
105 # These must not be set unconditionally because not all systems understand
106 # e.g. LANG=C (notably SCO).
107 # We save the old values to restore during execute mode.
108 if test "${LC_ALL+set}" = set; then
109   save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
110 fi
111 if test "${LANG+set}" = set; then
112   save_LANG="$LANG"; LANG=C; export LANG
113 fi
114
115 # Make sure IFS has a sensible default
116 lt_nl='
117 '
118 IFS="   $lt_nl"
119
120 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
121   $echo "$modename: not configured to build any kind of library" 1>&2
122   $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
123   exit $EXIT_FAILURE
124 fi
125
126 # Global variables.
127 mode=$default_mode
128 nonopt=
129 prev=
130 prevopt=
131 run=
132 show="$echo"
133 show_help=
134 execute_dlfiles=
135 duplicate_deps=no
136 preserve_args=
137 lo2o="s/\\.lo\$/.${objext}/"
138 o2lo="s/\\.${objext}\$/.lo/"
139
140 #####################################
141 # Shell function definitions:
142 # This seems to be the best place for them
143
144 # func_mktempdir [string]
145 # Make a temporary directory that won't clash with other running
146 # libtool processes, and avoids race conditions if possible.  If
147 # given, STRING is the basename for that directory.
148 func_mktempdir ()
149 {
150     my_template="${TMPDIR-/tmp}/${1-$progname}"
151
152     if test "$run" = ":"; then
153       # Return a directory name, but don't create it in dry-run mode
154       my_tmpdir="${my_template}-$$"
155     else
156
157       # If mktemp works, use that first and foremost
158       my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
159
160       if test ! -d "$my_tmpdir"; then
161         # Failing that, at least try and use $RANDOM to avoid a race
162         my_tmpdir="${my_template}-${RANDOM-0}$$"
163
164         save_mktempdir_umask=`umask`
165         umask 0077
166         $mkdir "$my_tmpdir"
167         umask $save_mktempdir_umask
168       fi
169
170       # If we're not in dry-run mode, bomb out on failure
171       test -d "$my_tmpdir" || {
172         $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
173         exit $EXIT_FAILURE
174       }
175     fi
176
177     $echo "X$my_tmpdir" | $Xsed
178 }
179
180
181 # func_win32_libid arg
182 # return the library type of file 'arg'
183 #
184 # Need a lot of goo to handle *both* DLLs and import libs
185 # Has to be a shell function in order to 'eat' the argument
186 # that is supplied when $file_magic_command is called.
187 func_win32_libid ()
188 {
189   win32_libid_type="unknown"
190   win32_fileres=`file -L $1 2>/dev/null`
191   case $win32_fileres in
192   *ar\ archive\ import\ library*) # definitely import
193     win32_libid_type="x86 archive import"
194     ;;
195   *ar\ archive*) # could be an import, or static
196     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
197       $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
198       win32_nmres=`eval $NM -f posix -A $1 | \
199         $SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
200       case $win32_nmres in
201       import*)  win32_libid_type="x86 archive import";;
202       *)        win32_libid_type="x86 archive static";;
203       esac
204     fi
205     ;;
206   *DLL*)
207     win32_libid_type="x86 DLL"
208     ;;
209   *executable*) # but shell scripts are "executable" too...
210     case $win32_fileres in
211     *MS\ Windows\ PE\ Intel*)
212       win32_libid_type="x86 DLL"
213       ;;
214     esac
215     ;;
216   esac
217   $echo $win32_libid_type
218 }
219
220
221 # func_infer_tag arg
222 # Infer tagged configuration to use if any are available and
223 # if one wasn't chosen via the "--tag" command line option.
224 # Only attempt this if the compiler in the base compile
225 # command doesn't match the default compiler.
226 # arg is usually of the form 'gcc ...'
227 func_infer_tag ()
228 {
229     if test -n "$available_tags" && test -z "$tagname"; then
230       CC_quoted=
231       for arg in $CC; do
232         case $arg in
233           *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
234           arg="\"$arg\""
235           ;;
236         esac
237         CC_quoted="$CC_quoted $arg"
238       done
239       case $@ in
240       # Blanks in the command may have been stripped by the calling shell,
241       # but not from the CC environment variable when configure was run.
242       " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
243       # Blanks at the start of $base_compile will cause this to fail
244       # if we don't check for them as well.
245       *)
246         for z in $available_tags; do
247           if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
248             # Evaluate the configuration.
249             eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
250             CC_quoted=
251             for arg in $CC; do
252             # Double-quote args containing other shell metacharacters.
253             case $arg in
254               *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
255               arg="\"$arg\""
256               ;;
257             esac
258             CC_quoted="$CC_quoted $arg"
259           done
260             case "$@ " in
261               " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
262               # The compiler in the base compile command matches
263               # the one in the tagged configuration.
264               # Assume this is the tagged configuration we want.
265               tagname=$z
266               break
267               ;;
268             esac
269           fi
270         done
271         # If $tagname still isn't set, then no tagged configuration
272         # was found and let the user know that the "--tag" command
273         # line option must be used.
274         if test -z "$tagname"; then
275           $echo "$modename: unable to infer tagged configuration"
276           $echo "$modename: specify a tag with \`--tag'" 1>&2
277           exit $EXIT_FAILURE
278 #        else
279 #          $echo "$modename: using $tagname tagged configuration"
280         fi
281         ;;
282       esac
283     fi
284 }
285
286
287 # func_extract_an_archive dir oldlib
288 func_extract_an_archive ()
289 {
290     f_ex_an_ar_dir="$1"; shift
291     f_ex_an_ar_oldlib="$1"
292
293     $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
294     $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
295     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
296      :
297     else
298       $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
299       exit $EXIT_FAILURE
300     fi
301 }
302
303 # func_extract_archives gentop oldlib ...
304 func_extract_archives ()
305 {
306     my_gentop="$1"; shift
307     my_oldlibs=${1+"$@"}
308     my_oldobjs=""
309     my_xlib=""
310     my_xabs=""
311     my_xdir=""
312     my_status=""
313
314     $show "${rm}r $my_gentop"
315     $run ${rm}r "$my_gentop"
316     $show "$mkdir $my_gentop"
317     $run $mkdir "$my_gentop"
318     my_status=$?
319     if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
320       exit $my_status
321     fi
322
323     for my_xlib in $my_oldlibs; do
324       # Extract the objects.
325       case $my_xlib in
326         [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
327         *) my_xabs=`pwd`"/$my_xlib" ;;
328       esac
329       my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
330       my_xdir="$my_gentop/$my_xlib"
331
332       $show "${rm}r $my_xdir"
333       $run ${rm}r "$my_xdir"
334       $show "$mkdir $my_xdir"
335       $run $mkdir "$my_xdir"
336       exit_status=$?
337       if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
338         exit $exit_status
339       fi
340       case $host in
341       *-darwin*)
342         $show "Extracting $my_xabs"
343         # Do not bother doing anything if just a dry run
344         if test -z "$run"; then
345           darwin_orig_dir=`pwd`
346           cd $my_xdir || exit $?
347           darwin_archive=$my_xabs
348           darwin_curdir=`pwd`
349           darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
350           darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
351           if test -n "$darwin_arches"; then
352             darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
353             darwin_arch=
354             $show "$darwin_base_archive has multiple architectures $darwin_arches"
355             for darwin_arch in  $darwin_arches ; do
356               mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
357               lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
358               cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
359               func_extract_an_archive "`pwd`" "${darwin_base_archive}"
360               cd "$darwin_curdir"
361               $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
362             done # $darwin_arches
363       ## Okay now we have a bunch of thin objects, gotta fatten them up :)
364             darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
365             darwin_file=
366             darwin_files=
367             for darwin_file in $darwin_filelist; do
368               darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
369               lipo -create -output "$darwin_file" $darwin_files
370             done # $darwin_filelist
371             ${rm}r unfat-$$
372             cd "$darwin_orig_dir"
373           else
374             cd "$darwin_orig_dir"
375             func_extract_an_archive "$my_xdir" "$my_xabs"
376           fi # $darwin_arches
377         fi # $run
378         ;;
379       *)
380         func_extract_an_archive "$my_xdir" "$my_xabs"
381         ;;
382       esac
383       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
384     done
385     func_extract_archives_result="$my_oldobjs"
386 }
387 # End of Shell function definitions
388 #####################################
389
390 # Darwin sucks
391 eval std_shrext=\"$shrext_cmds\"
392
393 disable_libs=no
394
395 # Parse our command line options once, thoroughly.
396 while test "$#" -gt 0
397 do
398   arg="$1"
399   shift
400
401   case $arg in
402   -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
403   *) optarg= ;;
404   esac
405
406   # If the previous option needs an argument, assign it.
407   if test -n "$prev"; then
408     case $prev in
409     execute_dlfiles)
410       execute_dlfiles="$execute_dlfiles $arg"
411       ;;
412     tag)
413       tagname="$arg"
414       preserve_args="${preserve_args}=$arg"
415
416       # Check whether tagname contains only valid characters
417       case $tagname in
418       *[!-_A-Za-z0-9,/]*)
419         $echo "$progname: invalid tag name: $tagname" 1>&2
420         exit $EXIT_FAILURE
421         ;;
422       esac
423
424       case $tagname in
425       CC)
426         # Don't test for the "default" C tag, as we know, it's there, but
427         # not specially marked.
428         ;;
429       *)
430         if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
431           taglist="$taglist $tagname"
432           # Evaluate the configuration.
433           eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
434         else
435           $echo "$progname: ignoring unknown tag $tagname" 1>&2
436         fi
437         ;;
438       esac
439       ;;
440     *)
441       eval "$prev=\$arg"
442       ;;
443     esac
444
445     prev=
446     prevopt=
447     continue
448   fi
449
450   # Have we seen a non-optional argument yet?
451   case $arg in
452   --help)
453     show_help=yes
454     ;;
455
456   --version)
457     $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
458     $echo
459     $echo "Copyright (C) 2005  Free Software Foundation, Inc."
460     $echo "This is free software; see the source for copying conditions.  There is NO"
461     $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
462     exit $?
463     ;;
464
465   --config)
466     ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
467     # Now print the configurations for the tags.
468     for tagname in $taglist; do
469       ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
470     done
471     exit $?
472     ;;
473
474   --debug)
475     $echo "$progname: enabling shell trace mode"
476     set -x
477     preserve_args="$preserve_args $arg"
478     ;;
479
480   --dry-run | -n)
481     run=:
482     ;;
483
484   --features)
485     $echo "host: $host"
486     if test "$build_libtool_libs" = yes; then
487       $echo "enable shared libraries"
488     else
489       $echo "disable shared libraries"
490     fi
491     if test "$build_old_libs" = yes; then
492       $echo "enable static libraries"
493     else
494       $echo "disable static libraries"
495     fi
496     exit $?
497     ;;
498
499   --finish) mode="finish" ;;
500
501   --mode) prevopt="--mode" prev=mode ;;
502   --mode=*) mode="$optarg" ;;
503
504   --preserve-dup-deps) duplicate_deps="yes" ;;
505
506   --quiet | --silent)
507     show=:
508     preserve_args="$preserve_args $arg"
509     ;;
510
511   --tag)
512     prevopt="--tag"
513     prev=tag
514     preserve_args="$preserve_args --tag"
515     ;;
516   --tag=*)
517     set tag "$optarg" ${1+"$@"}
518     shift
519     prev=tag
520     preserve_args="$preserve_args --tag"
521     ;;
522
523   -dlopen)
524     prevopt="-dlopen"
525     prev=execute_dlfiles
526     ;;
527
528   -*)
529     $echo "$modename: unrecognized option \`$arg'" 1>&2
530     $echo "$help" 1>&2
531     exit $EXIT_FAILURE
532     ;;
533
534   *)
535     nonopt="$arg"
536     break
537     ;;
538   esac
539 done
540
541 if test -n "$prevopt"; then
542   $echo "$modename: option \`$prevopt' requires an argument" 1>&2
543   $echo "$help" 1>&2
544   exit $EXIT_FAILURE
545 fi
546
547 case $disable_libs in
548 no)
549   ;;
550 shared)
551   build_libtool_libs=no
552   build_old_libs=yes
553   ;;
554 static)
555   build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
556   ;;
557 esac
558
559 # If this variable is set in any of the actions, the command in it
560 # will be execed at the end.  This prevents here-documents from being
561 # left over by shells.
562 exec_cmd=
563
564 if test -z "$show_help"; then
565
566   # Infer the operation mode.
567   if test -z "$mode"; then
568     $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
569     $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
570     case $nonopt in
571     *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
572       mode=link
573       for arg
574       do
575         case $arg in
576         -c)
577            mode=compile
578            break
579            ;;
580         esac
581       done
582       ;;
583     *db | *dbx | *strace | *truss)
584       mode=execute
585       ;;
586     *install*|cp|mv)
587       mode=install
588       ;;
589     *rm)
590       mode=uninstall
591       ;;
592     *)
593       # If we have no mode, but dlfiles were specified, then do execute mode.
594       test -n "$execute_dlfiles" && mode=execute
595
596       # Just use the default operation mode.
597       if test -z "$mode"; then
598         if test -n "$nonopt"; then
599           $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
600         else
601           $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
602         fi
603       fi
604       ;;
605     esac
606   fi
607
608   # Only execute mode is allowed to have -dlopen flags.
609   if test -n "$execute_dlfiles" && test "$mode" != execute; then
610     $echo "$modename: unrecognized option \`-dlopen'" 1>&2
611     $echo "$help" 1>&2
612     exit $EXIT_FAILURE
613   fi
614
615   # Change the help message to a mode-specific one.
616   generic_help="$help"
617   help="Try \`$modename --help --mode=$mode' for more information."
618
619   # These modes are in order of execution frequency so that they run quickly.
620   case $mode in
621   # libtool compile mode
622   compile)
623     modename="$modename: compile"
624     # Get the compilation command and the source file.
625     base_compile=
626     srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
627     suppress_opt=yes
628     suppress_output=
629     arg_mode=normal
630     libobj=
631     later=
632
633     for arg
634     do
635       case $arg_mode in
636       arg  )
637         # do not "continue".  Instead, add this to base_compile
638         lastarg="$arg"
639         arg_mode=normal
640         ;;
641
642       target )
643         libobj="$arg"
644         arg_mode=normal
645         continue
646         ;;
647
648       normal )
649         # Accept any command-line options.
650         case $arg in
651         -o)
652           if test -n "$libobj" ; then
653             $echo "$modename: you cannot specify \`-o' more than once" 1>&2
654             exit $EXIT_FAILURE
655           fi
656           arg_mode=target
657           continue
658           ;;
659
660         -static | -prefer-pic | -prefer-non-pic)
661           later="$later $arg"
662           continue
663           ;;
664
665         -no-suppress)
666           suppress_opt=no
667           continue
668           ;;
669
670         -Xcompiler)
671           arg_mode=arg  #  the next one goes into the "base_compile" arg list
672           continue      #  The current "srcfile" will either be retained or
673           ;;            #  replaced later.  I would guess that would be a bug.
674
675         -Wc,*)
676           args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
677           lastarg=
678           save_ifs="$IFS"; IFS=','
679           for arg in $args; do
680             IFS="$save_ifs"
681
682             # Double-quote args containing other shell metacharacters.
683             # Many Bourne shells cannot handle close brackets correctly
684             # in scan sets, so we specify it separately.
685             case $arg in
686               *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
687               arg="\"$arg\""
688               ;;
689             esac
690             lastarg="$lastarg $arg"
691           done
692           IFS="$save_ifs"
693           lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
694
695           # Add the arguments to base_compile.
696           base_compile="$base_compile $lastarg"
697           continue
698           ;;
699
700         * )
701           # Accept the current argument as the source file.
702           # The previous "srcfile" becomes the current argument.
703           #
704           lastarg="$srcfile"
705           srcfile="$arg"
706           ;;
707         esac  #  case $arg
708         ;;
709       esac    #  case $arg_mode
710
711       # Aesthetically quote the previous argument.
712       lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
713
714       case $lastarg in
715       # Double-quote args containing other shell metacharacters.
716       # Many Bourne shells cannot handle close brackets correctly
717       # in scan sets, and some SunOS ksh mistreat backslash-escaping
718       # in scan sets (worked around with variable expansion),
719       # and furthermore cannot handle '|' '&' '(' ')' in scan sets
720       # at all, so we specify them separately.
721       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
722         lastarg="\"$lastarg\""
723         ;;
724       esac
725
726       base_compile="$base_compile $lastarg"
727     done # for arg
728
729     case $arg_mode in
730     arg)
731       $echo "$modename: you must specify an argument for -Xcompile"
732       exit $EXIT_FAILURE
733       ;;
734     target)
735       $echo "$modename: you must specify a target with \`-o'" 1>&2
736       exit $EXIT_FAILURE
737       ;;
738     *)
739       # Get the name of the library object.
740       [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
741       ;;
742     esac
743
744     # Recognize several different file suffixes.
745     # If the user specifies -o file.o, it is replaced with file.lo
746     xform='[cCFSifmso]'
747     case $libobj in
748     *.ada) xform=ada ;;
749     *.adb) xform=adb ;;
750     *.ads) xform=ads ;;
751     *.asm) xform=asm ;;
752     *.c++) xform=c++ ;;
753     *.cc) xform=cc ;;
754     *.ii) xform=ii ;;
755     *.class) xform=class ;;
756     *.cpp) xform=cpp ;;
757     *.cxx) xform=cxx ;;
758     *.f90) xform=f90 ;;
759     *.for) xform=for ;;
760     *.java) xform=java ;;
761     esac
762
763     libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
764
765     case $libobj in
766     *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
767     *)
768       $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
769       exit $EXIT_FAILURE
770       ;;
771     esac
772
773     func_infer_tag $base_compile
774
775     for arg in $later; do
776       case $arg in
777       -static)
778         build_old_libs=yes
779         continue
780         ;;
781
782       -prefer-pic)
783         pic_mode=yes
784         continue
785         ;;
786
787       -prefer-non-pic)
788         pic_mode=no
789         continue
790         ;;
791       esac
792     done
793
794     qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
795     case $qlibobj in
796       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
797         qlibobj="\"$qlibobj\"" ;;
798     esac
799     test "X$libobj" != "X$qlibobj" \
800         && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"'  &()|`$[]' \
801         && $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
802     objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
803     xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
804     if test "X$xdir" = "X$obj"; then
805       xdir=
806     else
807       xdir=$xdir/
808     fi
809     lobj=${xdir}$objdir/$objname
810
811     if test -z "$base_compile"; then
812       $echo "$modename: you must specify a compilation command" 1>&2
813       $echo "$help" 1>&2
814       exit $EXIT_FAILURE
815     fi
816
817     # Delete any leftover library objects.
818     if test "$build_old_libs" = yes; then
819       removelist="$obj $lobj $libobj ${libobj}T"
820     else
821       removelist="$lobj $libobj ${libobj}T"
822     fi
823
824     $run $rm $removelist
825     trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
826
827     # On Cygwin there's no "real" PIC flag so we must build both object types
828     case $host_os in
829     cygwin* | mingw* | pw32* | os2*)
830       pic_mode=default
831       ;;
832     esac
833     if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
834       # non-PIC code in shared libraries is not supported
835       pic_mode=default
836     fi
837
838     # Calculate the filename of the output object if compiler does
839     # not support -o with -c
840     if test "$compiler_c_o" = no; then
841       output_obj=`$echo