(linenum→info "unix/slp.c:2238")

anthy/9100e/ltmain.sh

    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
    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.6
   47: TIMESTAMP=" (1.1220.2.95 2004/04/11 05:50:42) Debian$Rev: 224 $"
   48: 
   49: 
   50: # Check that we have a working $echo.
   51: if test "X$1" = X--no-reexec; then
   52:   # Discard the --no-reexec flag, and continue.
   53:   shift
   54: elif test "X$1" = X--fallback-echo; then
   55:   # Avoid inline document here, it may be left over
   56:   :
   57: elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
   58:   # Yippee, $echo works!
   59:   :
   60: else
   61:   # Restart under the correct shell, and then maybe $echo will work.
   62:   exec $SHELL "$progpath" --no-reexec ${1+"$@"}
   63: fi
   64: 
   65: if test "X$1" = X--fallback-echo; then
   66:   # used as fallback echo
   67:   shift
   68:   cat <<EOF
   69: $*
   70: EOF
   71:   exit $EXIT_SUCCESS
   72: fi
   73: 
   74: default_mode=
   75: help="Try \`$progname --help' for more information."
   76: magic="%%%MAGIC variable%%%"
   77: mkdir="mkdir"
   78: mv="mv -f"
   79: rm="rm -f"
   80: 
   81: # Sed substitution that helps us do robust quoting.  It backslashifies
   82: # metacharacters that are still active within double-quoted strings.
   83: Xsed="${SED}"' -e 1s/^X//'
   84: sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
   85: # test EBCDIC or ASCII
   86: case `echo A|tr A '\301'` in
   87:  A) # EBCDIC based system
   88:   SP2NL="tr '\100' '\n'"
   89:   NL2SP="tr '\r\n' '\100\100'"
   90:   ;;
   91:  *) # Assume ASCII based system
   92:   SP2NL="tr '\040' '\012'"
   93:   NL2SP="tr '\015\012' '\040\040'"
   94:   ;;
   95: esac
   96: 
   97: # NLS nuisances.
   98: # Only set LANG and LC_ALL to C if already set.
   99: # These must not be set unconditionally because not all systems understand
  100: # e.g. LANG=C (notably SCO).
  101: # We save the old values to restore during execute mode.
  102: if test "${LC_ALL+set}" = set; then
  103:   save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
  104: fi
  105: if test "${LANG+set}" = set; then
  106:   save_LANG="$LANG"; LANG=C; export LANG
  107: fi
  108: 
  109: # Make sure IFS has a sensible default
  110: : ${IFS="       
  111: "}
  112: 
  113: if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
  114:   $echo "$modename: not configured to build any kind of library" 1>&2
  115:   $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
  116:   exit $EXIT_FAILURE
  117: fi
  118: 
  119: # Global variables.
  120: mode=$default_mode
  121: nonopt=
  122: prev=
  123: prevopt=
  124: run=
  125: show="$echo"
  126: show_help=
  127: execute_dlfiles=
  128: lo2o="s/\\.lo\$/.${objext}/"
  129: o2lo="s/\\.${objext}\$/.lo/"
  130: 
  131: #####################################
  132: # Shell function definitions:
  133: # This seems to be the best place for them
  134: 
  135: # func_win32_libid arg
  136: # return the library type of file 'arg'
  137: #
  138: # Need a lot of goo to handle *both* DLLs and import libs
  139: # Has to be a shell function in order to 'eat' the argument
  140: # that is supplied when $file_magic_command is called.
  141: func_win32_libid () {
  142:   win32_libid_type="unknown"
  143:   win32_fileres=`file -L $1 2>/dev/null`
  144:   case $win32_fileres in
  145:   *ar\ archive\ import\ library*) # definitely import
  146:     win32_libid_type="x86 archive import"
  147:     ;;
  148:   *ar\ archive*) # could be an import, or static
  149:     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
  150:       $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
  151:       win32_nmres=`eval $NM -f posix -A $1 | \
  152:         sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
  153:       if test "X$win32_nmres" = "Ximport" ; then
  154:         win32_libid_type="x86 archive import"
  155:       else
  156:         win32_libid_type="x86 archive static"
  157:       fi
  158:     fi
  159:     ;;
  160:   *DLL*)
  161:     win32_libid_type="x86 DLL"
  162:     ;;
  163:   *executable*) # but shell scripts are "executable" too...
  164:     case $win32_fileres in
  165:     *MS\ Windows\ PE\ Intel*)
  166:       win32_libid_type="x86 DLL"
  167:       ;;
  168:     esac
  169:     ;;
  170:   esac
  171:   $echo $win32_libid_type
  172: }
  173: 
  174: 
  175: # func_infer_tag arg
  176: # Infer tagged configuration to use if any are available and
  177: # if one wasn't chosen via the "--tag" command line option.
  178: # Only attempt this if the compiler in the base compile
  179: # command doesn't match the default compiler.
  180: # arg is usually of the form 'gcc ...'
  181: func_infer_tag () {
  182:     if test -n "$available_tags" && test -z "$tagname"; then
  183:       CC_quoted=
  184:       for arg in $CC; do
  185:         case $arg in
  186:           *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \        ]*|*]*|"")
  187:           arg="\"$arg\""
  188:           ;;
  189:         esac
  190:         CC_quoted="$CC_quoted $arg"
  191:       done
  192:       case $@ in
  193:       # Blanks in the command may have been stripped by the calling shell,
  194:       # but not from the CC environment variable when configure was run.
  195:       " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
  196:       # Blanks at the start of $base_compile will cause this to fail
  197:       # if we don't check for them as well.
  198:       *)
  199:         for z in $available_tags; do
  200:           if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
  201:             # Evaluate the configuration.
  202:             eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
  203:             CC_quoted=
  204:             for arg in $CC; do
  205:             # Double-quote args containing other shell metacharacters.
  206:             case $arg in
  207:               *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
  208:               arg="\"$arg\""
  209:               ;;
  210:             esac
  211:             CC_quoted="$CC_quoted $arg"
  212:           done
  213:             case "$@ " in
  214:               " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
  215:               # The compiler in the base compile command matches
  216:               # the one in the tagged configuration.
  217:               # Assume this is the tagged configuration we want.
  218:               tagname=$z
  219:               break
  220:               ;;
  221:             esac
  222:           fi
  223:         done
  224:         # If $tagname still isn't set, then no tagged configuration
  225:         # was found and let the user know that the "--tag" command
  226:         # line option must be used.
  227:         if test -z "$tagname"; then
  228:           $echo "$modename: unable to infer tagged configuration"
  229:           $echo "$modename: specify a tag with \`--tag'" 1>&2
  230:           exit $EXIT_FAILURE
  231: #        else
  232: #          $echo "$modename: using $tagname tagged configuration"
  233:         fi
  234:         ;;
  235:       esac
  236:     fi
  237: }
  238: # End of Shell function definitions
  239: #####################################
  240: 
  241: # Darwin sucks
  242: eval std_shrext=\"$shrext_cmds\"
  243: 
  244: # Parse our command line options once, thoroughly.
  245: while test "$#" -gt 0
  246: do
  247:   arg="$1"
  248:   shift
  249: 
  250:   case $arg in
  251:   -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
  252:   *) optarg= ;;
  253:   esac
  254: 
  255:   # If the previous option needs an argument, assign it.
  256:   if test -n "$prev"; then
  257:     case $prev in
  258:     execute_dlfiles)
  259:       execute_dlfiles="$execute_dlfiles $arg"
  260:       ;;
  261:     tag)
  262:       tagname="$arg"
  263:       preserve_args="${preserve_args}=$arg"
  264: 
  265:       # Check whether tagname contains only valid characters
  266:       case $tagname in
  267:       *[!-_A-Za-z0-9,/]*)
  268:         $echo "$progname: invalid tag name: $tagname" 1>&2
  269:         exit $EXIT_FAILURE
  270:         ;;
  271:       esac
  272: 
  273:       case $tagname in
  274:       CC)
  275:         # Don't test for the "default" C tag, as we know, it's there, but
  276:         # not specially marked.
  277:         ;;
  278:       *)
  279:         if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
  280:           taglist="$taglist $tagname"
  281:           # Evaluate the configuration.
  282:           eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
  283:         else
  284:           $echo "$progname: ignoring unknown tag $tagname" 1>&2
  285:         fi
  286:         ;;
  287:       esac
  288:       ;;
  289:     *)
  290:       eval "$prev=\$arg"
  291:       ;;
  292:     esac
  293: 
  294:     prev=
  295:     prevopt=
  296:     continue
  297:   fi
  298: 
  299:   # Have we seen a non-optional argument yet?
  300:   case $arg in
  301:   --help)
  302:     show_help=yes
  303:     ;;
  304: 
  305:   --version)
  306:     $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
  307:     $echo
  308:     $echo "Copyright (C) 2003  Free Software Foundation, Inc."
  309:     $echo "This is free software; see the source for copying conditions.  There is NO"
  310:     $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
  311:     exit $EXIT_SUCCESS
  312:     ;;
  313: 
  314:   --config)
  315:     ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
  316:     # Now print the configurations for the tags.
  317:     for tagname in $taglist; do
  318:       ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
  319:     done
  320:     exit $EXIT_SUCCESS
  321:     ;;
  322: 
  323:   --debug)
  324:     $echo "$progname: enabling shell trace mode"
  325:     set -x
  326:     preserve_args="$preserve_args $arg"
  327:     ;;
  328: 
  329:   --dry-run | -n)
  330:     run=:
  331:     ;;
  332: 
  333:   --features)
  334:     $echo "host: $host"
  335:     if test "$build_libtool_libs" = yes; then
  336:       $echo "enable shared libraries"
  337:     else
  338:       $echo "disable shared libraries"
  339:     fi
  340:     if test "$build_old_libs" = yes; then
  341:       $echo "enable static libraries"
  342:     else
  343:       $echo "disable static libraries"
  344:     fi
  345:     exit $EXIT_SUCCESS
  346:     ;;
  347: 
  348:   --finish) mode="finish" ;;
  349: 
  350:   --mode) prevopt="--mode" prev=mode ;;
  351:   --mode=*) mode="$optarg" ;;
  352: 
  353:   --preserve-dup-deps) duplicate_deps="yes" ;;
  354: 
  355:   --quiet | --silent)
  356:     show=:
  357:     preserve_args="$preserve_args $arg"
  358:     ;;
  359: 
  360:   --tag) prevopt="--tag" prev=tag ;;
  361:   --tag=*)
  362:     set tag "$optarg" ${1+"$@"}
  363:     shift
  364:     prev=tag
  365:     preserve_args="$preserve_args --tag"
  366:     ;;
  367: 
  368:   -dlopen)
  369:     prevopt="-dlopen"
  370:     prev=execute_dlfiles
  371:     ;;
  372: 
  373:   -*)
  374:     $echo "$modename: unrecognized option \`$arg'" 1>&2
  375:     $echo "$help" 1>&2
  376:     exit $EXIT_FAILURE
  377:     ;;
  378: 
  379:   *)
  380:     nonopt="$arg"
  381:     break
  382:     ;;
  383:   esac
  384: done
  385: 
  386: if test -n "$prevopt"; then
  387:   $echo "$modename: option \`$prevopt' requires an argument" 1>&2
  388:   $echo "$help" 1>&2
  389:   exit $EXIT_FAILURE
  390: fi
  391: 
  392: # If this variable is set in any of the actions, the command in it
  393: # will be execed at the end.  This prevents here-documents from being
  394: # left over by shells.
  395: exec_cmd=
  396: 
  397: if test -z "$show_help"; then
  398: 
  399:   # Infer the operation mode.
  400:   if test -z "$mode"; then
  401:     $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
  402:     $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2
  403:     case $nonopt in
  404:     *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
  405:       mode=link
  406:       for arg
  407:       do
  408:         case $arg in
  409:         -c)
  410:            mode=compile
  411:            break
  412:            ;;
  413:         esac
  414:       done
  415:       ;;
  416:     *db | *dbx | *strace | *truss)
  417:       mode=execute
  418:       ;;
  419:     *install*|cp|mv)
  420:       mode=install
  421:       ;;
  422:     *rm)
  423:       mode=uninstall
  424:       ;;
  425:     *)
  426:       # If we have no mode, but dlfiles were specified, then do execute mode.
  427:       test -n "$execute_dlfiles" && mode=execute
  428: 
  429:       # Just use the default operation mode.
  430:       if test -z "$mode"; then
  431:         if test -n "$nonopt"; then
  432:           $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
  433:         else
  434:           $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
  435:         fi
  436:       fi
  437:       ;;
  438:     esac
  439:   fi
  440: 
  441:   # Only execute mode is allowed to have -dlopen flags.
  442:   if test -n "$execute_dlfiles" && test "$mode" != execute; then
  443:     $echo "$modename: unrecognized option \`-dlopen'" 1>&2
  444:     $echo "$help" 1>&2
  445:     exit $EXIT_FAILURE
  446:   fi
  447: 
  448:   # Change the help message to a mode-specific one.
  449:   generic_help="$help"
  450:   help="Try \`$modename --help --mode=$mode' for more information."
  451: 
  452:   # These modes are in order of execution frequency so that they run quickly.
  453:   case $mode in
  454:   # libtool compile mode
  455:   compile)
  456:     modename="$modename: compile"
  457:     # Get the compilation command and the source file.
  458:     base_compile=
  459:     srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
  460:     suppress_opt=yes
  461:     suppress_output=
  462:     arg_mode=normal
  463:     libobj=
  464:     later=
  465: 
  466:     for arg
  467:     do
  468:       case "$arg_mode" in
  469:       arg  )
  470:         # do not "continue".  Instead, add this to base_compile
  471:         lastarg="$arg"
  472:         arg_mode=normal
  473:         ;;
  474: 
  475:       target )
  476:         libobj="$arg"
  477:         arg_mode=normal
  478:         continue
  479:         ;;
  480: 
  481:       normal )
  482:         # Accept any command-line options.
  483:         case $arg in
  484:         -o)
  485:           if test -n "$libobj" ; then
  486:             $echo "$modename: you cannot specify \`-o' more than once" 1>&2
  487:             exit $EXIT_FAILURE
  488:           fi
  489:           arg_mode=target
  490:           continue
  491:           ;;
  492: 
  493:         -static | -prefer-pic | -prefer-non-pic)
  494:           later="$later $arg"
  495:           continue
  496:           ;;
  497: 
  498:         -no-suppress)
  499:           suppress_opt=no
  500:           continue
  501:           ;;
  502: 
  503:         -Xcompiler)
  504:           arg_mode=arg  #  the next one goes into the "base_compile" arg list
  505:           continue      #  The current "srcfile" will either be retained or
  506:           ;;            #  replaced later.  I would guess that would be a bug.
  507: 
  508:         -Wc,*)
  509:           args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
  510:           lastarg=
  511:           save_ifs="$IFS"; IFS=','
  512:           for arg in $args; do
  513:             IFS="$save_ifs"
  514: 
  515:             # Double-quote args containing other shell metacharacters.
  516:             # Many Bourne shells cannot handle close brackets correctly
  517:             # in scan sets, so we specify it separately.
  518:             case $arg in
  519:               *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
  520:               arg="\"$arg\""
  521:               ;;
  522:             esac
  523:             lastarg="$lastarg $arg"
  524:           done
  525:           IFS="$save_ifs"
  526:           lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
  527: 
  528:           # Add the arguments to base_compile.
  529:           base_compile="$base_compile $lastarg"
  530:           continue
  531:           ;;
  532: 
  533:         * )
  534:           # Accept the current argument as the source file.
  535:           # The previous "srcfile" becomes the current argument.
  536:           #
  537:           lastarg="$srcfile"
  538:           srcfile="$arg"
  539:           ;;
  540:         esac  #  case $arg
  541:         ;;
  542:       esac    #  case $arg_mode
  543: 
  544:       # Aesthetically quote the previous argument.
  545:       lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
  546: 
  547:       case $lastarg in
  548:       # Double-quote args containing other shell metacharacters.
  549:       # Many Bourne shells cannot handle close brackets correctly
  550:       # in scan sets, so we specify it separately.
  551:       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
  552:         lastarg="\"$lastarg\""
  553:         ;;
  554:       esac
  555: 
  556:       base_compile="$base_compile $lastarg"
  557:     done # for arg
  558: 
  559:     case $arg_mode in
  560:     arg)
  561:       $echo "$modename: you must specify an argument for -Xcompile"
  562:       exit $EXIT_FAILURE
  563:       ;;
  564:     target)
  565:       $echo "$modename: you must specify a target with \`-o'" 1>&2
  566:       exit $EXIT_FAILURE
  567:       ;;
  568:     *)
  569:       # Get the name of the library object.
  570:       [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
  571:       ;;
  572:     esac
  573: 
  574:     # Recognize several different file suffixes.
  575:     # If the user specifies -o file.o, it is replaced with file.lo
  576:     xform='[cCFSifmso]'
  577:     case $libobj in
  578:     *.ada) xform=ada ;;
  579:     *.adb) xform=adb ;;
  580:     *.ads) xform=ads ;;
  581:     *.asm) xform=asm ;;
  582:     *.c++) xform=c++ ;;
  583:     *.cc) xform=cc ;;
  584:     *.ii) xform=ii ;;
  585:     *.class) xform=class ;;
  586:     *.cpp) xform=cpp ;;
  587:     *.cxx) xform=cxx ;;
  588:     *.f90) xform=f90 ;;
  589:     *.for) xform=for ;;
  590:     *.java) xform=java ;;
  591:     esac
  592: 
  593:     libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
  594: 
  595:     case $libobj in
  596:     *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
  597:     *)
  598:       $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
  599:       exit $EXIT_FAILURE
  600:       ;;
  601:     esac
  602: 
  603:     func_infer_tag $base_compile
  604: 
  605:     for arg in $later; do
  606:       case $arg in
  607:       -static)
  608:         build_old_libs=yes
  609:         continue
  610:         ;;
  611: 
  612:       -prefer-pic)
  613:         pic_mode=yes
  614:         continue
  615:         ;;
  616: 
  617:       -prefer-non-pic)
  618:         pic_mode=no
  619:         continue
  620:         ;;
  621:       esac
  622:     done
  623: 
  624:     objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
  625:     xdir=`$echo "