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

gauche/0.8.12/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
    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: # Check that we have a working $echo.
   28: if test "X$1" = X--no-reexec; then
   29:   # Discard the --no-reexec flag, and continue.
   30:   shift
   31: elif test "X$1" = X--fallback-echo; then
   32:   # Avoid inline document here, it may be left over
   33:   :
   34: elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
   35:   # Yippee, $echo works!
   36:   :
   37: else
   38:   # Restart under the correct shell, and then maybe $echo will work.
   39:   exec $SHELL "$0" --no-reexec ${1+"$@"}
   40: fi
   41: 
   42: if test "X$1" = X--fallback-echo; then
   43:   # used as fallback echo
   44:   shift
   45:   cat <<EOF
   46: $*
   47: EOF
   48:   exit 0
   49: fi
   50: 
   51: # define SED for historic ltconfig's generated by Libtool 1.3
   52: test -z "$SED" && SED=sed
   53: 
   54: # The name of this program.
   55: progname=`$echo "$0" | ${SED} 's%^.*/%%'`
   56: modename="$progname"
   57: 
   58: # Constants.
   59: PROGRAM=ltmain.sh
   60: PACKAGE=libtool
   61: VERSION=1.4.3
   62: TIMESTAMP=" (1.922.2.111 2002/10/23 02:54:36)"
   63: 
   64: default_mode=
   65: help="Try \`$progname --help' for more information."
   66: magic="%%%MAGIC variable%%%"
   67: mkdir="mkdir"
   68: mv="mv -f"
   69: rm="rm -f"
   70: 
   71: # Sed substitution that helps us do robust quoting.  It backslashifies
   72: # metacharacters that are still active within double-quoted strings.
   73: Xsed="${SED}"' -e 1s/^X//'
   74: sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
   75: # test EBCDIC or ASCII                                                         
   76: case `echo A|od -x` in                                                         
   77:  *[Cc]1*) # EBCDIC based system                                                
   78:   SP2NL="tr '\100' '\n'"                                                       
   79:   NL2SP="tr '\r\n' '\100\100'"                                                 
   80:   ;;                                                                           
   81:  *) # Assume ASCII based system                                                
   82:   SP2NL="tr '\040' '\012'"                                                     
   83:   NL2SP="tr '\015\012' '\040\040'"                                             
   84:   ;;                                                                           
   85: esac                                                                           
   86: 
   87: # NLS nuisances.
   88: # Only set LANG and LC_ALL to C if already set.
   89: # These must not be set unconditionally because not all systems understand
   90: # e.g. LANG=C (notably SCO).
   91: # We save the old values to restore during execute mode.
   92: if test "${LC_ALL+set}" = set; then
   93:   save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
   94: fi
   95: if test "${LANG+set}" = set; then
   96:   save_LANG="$LANG"; LANG=C; export LANG
   97: fi
   98: 
   99: # Make sure IFS has a sensible default
  100: : ${IFS="       "}
  101: 
  102: if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
  103:   echo "$modename: not configured to build any kind of library" 1>&2
  104:   echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
  105:   exit 1
  106: fi
  107: 
  108: # Global variables.
  109: mode=$default_mode
  110: nonopt=
  111: prev=
  112: prevopt=
  113: run=
  114: show="$echo"
  115: show_help=
  116: execute_dlfiles=
  117: lo2o="s/\\.lo\$/.${objext}/"
  118: o2lo="s/\\.${objext}\$/.lo/"
  119: 
  120: # Parse our command line options once, thoroughly.
  121: while test $# -gt 0
  122: do
  123:   arg="$1"
  124:   shift
  125: 
  126:   case $arg in
  127:   -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
  128:   *) optarg= ;;
  129:   esac
  130: 
  131:   # If the previous option needs an argument, assign it.
  132:   if test -n "$prev"; then
  133:     case $prev in
  134:     execute_dlfiles)
  135:       execute_dlfiles="$execute_dlfiles $arg"
  136:       ;;
  137:     *)
  138:       eval "$prev=\$arg"
  139:       ;;
  140:     esac
  141: 
  142:     prev=
  143:     prevopt=
  144:     continue
  145:   fi
  146: 
  147:   # Have we seen a non-optional argument yet?
  148:   case $arg in
  149:   --help)
  150:     show_help=yes
  151:     ;;
  152: 
  153:   --version)
  154:     echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
  155:     exit 0
  156:     ;;
  157: 
  158:   --config)
  159:     ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0
  160:     exit 0
  161:     ;;
  162: 
  163:   --debug)
  164:     echo "$progname: enabling shell trace mode"
  165:     set -x
  166:     ;;
  167: 
  168:   --dry-run | -n)
  169:     run=:
  170:     ;;
  171: 
  172:   --features)
  173:     echo "host: $host"
  174:     if test "$build_libtool_libs" = yes; then
  175:       echo "enable shared libraries"
  176:     else
  177:       echo "disable shared libraries"
  178:     fi
  179:     if test "$build_old_libs" = yes; then
  180:       echo "enable static libraries"
  181:     else
  182:       echo "disable static libraries"
  183:     fi
  184:     exit 0
  185:     ;;
  186: 
  187:   --finish) mode="finish" ;;
  188: 
  189:   --mode) prevopt="--mode" prev=mode ;;
  190:   --mode=*) mode="$optarg" ;;
  191: 
  192:   --preserve-dup-deps) duplicate_deps="yes" ;;
  193: 
  194:   --quiet | --silent)
  195:     show=:
  196:     ;;
  197: 
  198:   -dlopen)
  199:     prevopt="-dlopen"
  200:     prev=execute_dlfiles
  201:     ;;
  202: 
  203:   -*)
  204:     $echo "$modename: unrecognized option \`$arg'" 1>&2
  205:     $echo "$help" 1>&2
  206:     exit 1
  207:     ;;
  208: 
  209:   *)
  210:     nonopt="$arg"
  211:     break
  212:     ;;
  213:   esac
  214: done
  215: 
  216: if test -n "$prevopt"; then
  217:   $echo "$modename: option \`$prevopt' requires an argument" 1>&2
  218:   $echo "$help" 1>&2
  219:   exit 1
  220: fi
  221: 
  222: # If this variable is set in any of the actions, the command in it
  223: # will be execed at the end.  This prevents here-documents from being
  224: # left over by shells.
  225: exec_cmd=
  226: 
  227: if test -z "$show_help"; then
  228: 
  229:   # Infer the operation mode.
  230:   if test -z "$mode"; then
  231:     case $nonopt in
  232:     *cc | *++ | gcc* | *-gcc* | xlc*)
  233:       mode=link
  234:       for arg
  235:       do
  236:         case $arg in
  237:         -c)
  238:            mode=compile
  239:            break
  240:            ;;
  241:         esac
  242:       done
  243:       ;;
  244:     *db | *dbx | *strace | *truss)
  245:       mode=execute
  246:       ;;
  247:     *install*|cp|mv)
  248:       mode=install
  249:       ;;
  250:     *rm)
  251:       mode=uninstall
  252:       ;;
  253:     *)
  254:       # If we have no mode, but dlfiles were specified, then do execute mode.
  255:       test -n "$execute_dlfiles" && mode=execute
  256: 
  257:       # Just use the default operation mode.
  258:       if test -z "$mode"; then
  259:         if test -n "$nonopt"; then
  260:           $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
  261:         else
  262:           $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
  263:         fi
  264:       fi
  265:       ;;
  266:     esac
  267:   fi
  268: 
  269:   # Only execute mode is allowed to have -dlopen flags.
  270:   if test -n "$execute_dlfiles" && test "$mode" != execute; then
  271:     $echo "$modename: unrecognized option \`-dlopen'" 1>&2
  272:     $echo "$help" 1>&2
  273:     exit 1
  274:   fi
  275: 
  276:   # Change the help message to a mode-specific one.
  277:   generic_help="$help"
  278:   help="Try \`$modename --help --mode=$mode' for more information."
  279: 
  280:   # These modes are in order of execution frequency so that they run quickly.
  281:   case $mode in
  282:   # libtool compile mode
  283:   compile)
  284:     modename="$modename: compile"
  285:     # Get the compilation command and the source file.
  286:     base_compile=
  287:     prev=
  288:     lastarg=
  289:     srcfile="$nonopt"
  290:     suppress_output=
  291: 
  292:     user_target=no
  293:     for arg
  294:     do
  295:       case $prev in
  296:       "") ;;
  297:       xcompiler)
  298:         # Aesthetically quote the previous argument.
  299:         prev=
  300:         lastarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
  301: 
  302:         case $arg in
  303:         # Double-quote args containing other shell metacharacters.
  304:         # Many Bourne shells cannot handle close brackets correctly
  305:         # in scan sets, so we specify it separately.
  306:         *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \  ]*|*]*|"")
  307:           arg="\"$arg\""
  308:           ;;
  309:         esac
  310: 
  311:         # Add the previous argument to base_compile.
  312:         if test -z "$base_compile"; then
  313:           base_compile="$lastarg"
  314:         else
  315:           base_compile="$base_compile $lastarg"
  316:         fi
  317:         continue
  318:         ;;
  319:       esac
  320: 
  321:       # Accept any command-line options.
  322:       case $arg in
  323:       -o)
  324:         if test "$user_target" != "no"; then
  325:           $echo "$modename: you cannot specify \`-o' more than once" 1>&2
  326:           exit 1
  327:         fi
  328:         user_target=next
  329:         ;;
  330: 
  331:       -static)
  332:         build_old_libs=yes
  333:         continue
  334:         ;;
  335: 
  336:       -prefer-pic)
  337:         pic_mode=yes
  338:         continue
  339:         ;;
  340: 
  341:       -prefer-non-pic)
  342:         pic_mode=no
  343:         continue
  344:         ;;
  345: 
  346:       -Xcompiler)
  347:         prev=xcompiler
  348:         continue
  349:         ;;
  350: 
  351:       -Wc,*)
  352:         args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
  353:         lastarg=
  354:         save_ifs="$IFS"; IFS=','
  355:         for arg in $args; do
  356:           IFS="$save_ifs"
  357: 
  358:           # Double-quote args containing other shell metacharacters.
  359:           # Many Bourne shells cannot handle close brackets correctly
  360:           # in scan sets, so we specify it separately.
  361:           case $arg in
  362:             *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \      ]*|*]*|"")
  363:             arg="\"$arg\""
  364:             ;;
  365:           esac
  366:           lastarg="$lastarg $arg"
  367:         done
  368:         IFS="$save_ifs"
  369:         lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
  370: 
  371:         # Add the arguments to base_compile.
  372:         if test -z "$base_compile"; then
  373:           base_compile="$lastarg"
  374:         else
  375:           base_compile="$base_compile $lastarg"
  376:         fi
  377:         continue
  378:         ;;
  379:       esac
  380: 
  381:       case $user_target in
  382:       next)
  383:         # The next one is the -o target name
  384:         user_target=yes
  385:         continue
  386:         ;;
  387:       yes)
  388:         # We got the output file
  389:         user_target=set
  390:         libobj="$arg"
  391:         continue
  392:         ;;
  393:       esac
  394: 
  395:       # Accept the current argument as the source file.
  396:       lastarg="$srcfile"
  397:       srcfile="$arg"
  398: 
  399:       # Aesthetically quote the previous argument.
  400: 
  401:       # Backslashify any backslashes, double quotes, and dollar signs.
  402:       # These are the only characters that are still specially
  403:       # interpreted inside of double-quoted scrings.
  404:       lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
  405: 
  406:       # Double-quote args containing other shell metacharacters.
  407:       # Many Bourne shells cannot handle close brackets correctly
  408:       # in scan sets, so we specify it separately.
  409:       case $lastarg in
  410:       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
  411:         lastarg="\"$lastarg\""
  412:         ;;
  413:       esac
  414: 
  415:       # Add the previous argument to base_compile.
  416:       if test -z "$base_compile"; then
  417:         base_compile="$lastarg"
  418:       else
  419:         base_compile="$base_compile $lastarg"
  420:       fi
  421:     done
  422: 
  423:     case $user_target in
  424:     set)
  425:       ;;
  426:     no)
  427:       # Get the name of the library object.
  428:       libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
  429:       ;;
  430:     *)
  431:       $echo "$modename: you must specify a target with \`-o'" 1>&2
  432:       exit 1
  433:       ;;
  434:     esac
  435: 
  436:     # Recognize several different file suffixes.
  437:     # If the user specifies -o file.o, it is replaced with file.lo
  438:     xform='[cCFSfmso]'
  439:     case $libobj in
  440:     *.ada) xform=ada ;;
  441:     *.adb) xform=adb ;;
  442:     *.ads) xform=ads ;;
  443:     *.asm) xform=asm ;;
  444:     *.c++) xform=c++ ;;
  445:     *.cc) xform=cc ;;
  446:     *.cpp) xform=cpp ;;
  447:     *.cxx) xform=cxx ;;
  448:     *.f90) xform=f90 ;;
  449:     *.for) xform=for ;;
  450:     esac
  451: 
  452:     libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
  453: 
  454:     case $libobj in
  455:     *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
  456:     *)
  457:       $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
  458:       exit 1
  459:       ;;
  460:     esac
  461: 
  462:     if test -z "$base_compile"; then
  463:       $echo "$modename: you must specify a compilation command" 1>&2
  464:       $echo "$help" 1>&2
  465:       exit 1
  466:     fi
  467: 
  468:     # Delete any leftover library objects.
  469:     if test "$build_old_libs" = yes; then
  470:       removelist="$obj $libobj"
  471:     else
  472:       removelist="$libobj"
  473:     fi
  474: 
  475:     $run $rm $removelist
  476:     trap "$run $rm $removelist; exit 1" 1 2 15
  477: 
  478:     # On Cygwin there's no "real" PIC flag so we must build both object types
  479:     case $host_os in
  480:     cygwin* | mingw* | pw32* | os2*)
  481:       pic_mode=default
  482:       ;;
  483:     esac
  484:     if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
  485:       # non-PIC code in shared libraries is not supported
  486:       pic_mode=default
  487:     fi
  488: 
  489:     # Calculate the filename of the output object if compiler does
  490:     # not support -o with -c
  491:     if test "$compiler_c_o" = no; then
  492:       output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
  493:       lockfile="$output_obj.lock"
  494:       removelist="$removelist $output_obj $lockfile"
  495:       trap "$run $rm $removelist; exit 1" 1 2 15
  496:     else
  497:       need_locks=no
  498:       lockfile=
  499:     fi
  500: 
  501:     # Lock this critical section if it is needed
  502:     # We use this script file to make the link, it avoids creating a new file
  503:     if test "$need_locks" = yes; then
  504:       until $run ln "$0" "$lockfile" 2>/dev/null; do
  505:         $show "Waiting for $lockfile to be removed"
  506:         sleep 2
  507:       done
  508:     elif test "$need_locks" = warn; then
  509:       if test -f "$lockfile"; then
  510:         echo "\
  511: *** ERROR, $lockfile exists and contains:
  512: `cat $lockfile 2>/dev/null`
  513: 
  514: This indicates that another process is trying to use the same
  515: temporary object file, and libtool could not work around it because
  516: your compiler does not support \`-c' and \`-o' together.  If you
  517: repeat this compilation, it may succeed, by chance, but you had better
  518: avoid parallel builds (make -j) in this platform, or get a better
  519: compiler."
  520: 
  521:         $run $rm $removelist
  522:         exit 1
  523:       fi
  524:       echo $srcfile > "$lockfile"
  525:     fi
  526: 
  527:     if test -n "$fix_srcfile_path"; then
  528:       eval srcfile=\"$fix_srcfile_path\"
  529:     fi
  530: 
  531:     # Only build a PIC object if we are building libtool libraries.
  532:     if test "$build_libtool_libs" = yes; then
  533:       # Without this assignment, base_compile gets emptied.
  534:       fbsd_hideous_sh_bug=$base_compile
  535: 
  536:       if test "$pic_mode" != no; then
  537:         # All platforms use -DPIC, to notify preprocessed assembler code.
  538:         command="$base_compile $srcfile $pic_flag -DPIC"
  539:       else
  540:         # Don't build PIC code
  541:         command="$base_compile $srcfile"
  542:       fi
  543:       if test "$build_old_libs" = yes; then
  544:         lo_libobj="$libobj"
  545:         dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
  546:         if test "X$dir" = "X$libobj"; then
  547:           dir="$objdir"
  548:         else
  549:           dir="$dir/$objdir"
  550:         fi
  551:         libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
  552: 
  553:         if test -d "$dir"; then
  554:           $show "$rm $libobj"
  555:           $run $rm $libobj
  556:         else
  557:           $show "$mkdir $dir"
  558:           $run $mkdir $dir
  559:           status=$?
  560:           if test $status -ne 0 && test ! -d $dir; then
  561:             exit $status
  562:           fi
  563:         fi
  564:       fi
  565:       if test "$compiler_o_lo" = yes; then
  566:         output_obj="$libobj"
  567:         command="$command -o $output_obj"
  568:       elif test "$compiler_c_o" = yes; then
  569:         output_obj="$obj"
  570:         command="$command -o $output_obj"
  571:       fi
  572: 
  573:       $run $rm "$output_obj"
  574:       $show "$command"
  575:       if $run eval "$command"; then :
  576:       else
  577:         test -n "$output_obj" && $run $rm $removelist
  578:         exit 1
  579:       fi
  580: 
  581:       if test "$need_locks" = warn &&
  582:          test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
  583:         echo "\
  584: *** ERROR, $lockfile contains:
  585: `cat $lockfile 2>/dev/null`
  586: 
  587: but it should contain:
  588: $srcfile
  589: 
  590: This indicates that another process is trying to use the same
  591: temporary object file, and libtool could not work around it because
  592: your compiler does not support \`-c' and \`-o' together.  If you
  593: repeat this compilation, it may succeed, by chance, but you had better
  594: avoid parallel builds (make -j) in this platform, or get a better
  595: compiler."
  596: 
  597:         $run $rm $removelist
  598:         exit 1
  599:       fi
  600: 
  601:       # Just move the object if needed, then go on to compile the next one
  602:       if test x"$output_obj" != x"$libobj"; then
  603:         $show "$mv $output_obj $libobj"
  604:         if $run $mv $output_obj $libobj; then :
  605:         else
  606:           error=$?
  607:           $run $rm $removelist
  608:           exit $error
  609:         fi
  610:       fi
  611: 
  612:       # If we have no pic_flag, then copy the object into place and finish.
  613:       if (test -z "$pic_flag" || test "$pic_mode" != default) &&
  614:          test "$build_old_libs" = yes; then
  615:         # Rename the .lo from within objdir to obj
  616:         if