ltmain.sh 102 KB
Newer Older
Jason Merrill committed
1
# ltmain.sh - Provide generalized library-building support services.
#  
Jeff Law committed
2 3
# NOTE: Changing this file will not affect anything until you rerun ltconfig.
#
4
# Copyright (C) 1996-1999 Free Software Foundation, Inc.
Jason Merrill committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
# Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.

26 27 28 29
# Check that we have a working $echo.
if test "X$1" = X--no-reexec; then
  # Discard the --no-reexec flag, and continue.
  shift
30 31 32 33 34 35 36
elif test "X$1" = X--fallback-echo; then
  # used as fallback echo
  shift
  cat <<EOF
$*
EOF
  exit 0
37 38 39 40 41 42 43 44
elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
  # Yippee, $echo works!
  :
else
  # Restart under the correct shell, and then maybe $echo will work.
  exec $SHELL "$0" --no-reexec ${1+"$@"}
fi

Jason Merrill committed
45
# The name of this program.
#  
Jeff Law committed
46 47
progname=`$echo "$0" | sed 's%^.*/%%'`
modename="$progname"
Jason Merrill committed
48 49 50 51

# Constants.
PROGRAM=ltmain.sh
PACKAGE=libtool
52 53
VERSION=1.2f
TIMESTAMP=" (1.385 1999/03/15 17:24:54)"
Jason Merrill committed
54 55 56 57 58 59 60 61

default_mode=
help="Try \`$progname --help' for more information."
magic="%%%MAGIC variable%%%"
mkdir="mkdir"
mv="mv -f"
rm="rm -f"

#  
Jeff Law committed
62 63
# Sed substitution that helps us do robust quoting.  It backslashifies
# metacharacters that are still active within double-quoted strings.
64
Xsed='sed -e 1s/^X//'
#  
Jeff Law committed
65
sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
66 67
SP2NL='tr \040 \012'
NL2SP='tr \012 \040'
#  
Jeff Law committed
68 69 70 71 72

# NLS nuisances.
# Only set LANG and LC_ALL to C if already set.
# These must not be set unconditionally because not all systems understand
# e.g. LANG=C (notably SCO).
73 74 75 76 77 78 79
# We save the old values to restore during execute mode.
if test "${LC_ALL+set}" = set; then
  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
fi
if test "${LANG+set}" = set; then
  save_LANG="$LANG"; LANG=C; export LANG
fi
#  
Jeff Law committed
80

Jason Merrill committed
81
if test "$LTCONFIG_VERSION" != "$VERSION"; then
#  
Jeff Law committed
82
  echo "$modename: ltconfig version \`$LTCONFIG_VERSION' does not match $PROGRAM version \`$VERSION'" 1>&2
Jason Merrill committed
83 84 85 86 87
  echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
  exit 1
fi

if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
#  
Jeff Law committed
88
  echo "$modename: not configured to build any kind of library" 1>&2
Jason Merrill committed
89 90 91 92 93 94 95 96 97 98
  echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
  exit 1
fi

# Global variables.
mode=$default_mode
nonopt=
prev=
prevopt=
run=
#  
Jeff Law committed
99
show="$echo"
Jason Merrill committed
100
show_help=
#  
Jeff Law committed
101
execute_dlfiles=
102
lo2o="s/\\.lo\$/.${objext}/"
Jason Merrill committed
103 104 105 106 107 108 109 110

# Parse our command line options once, thoroughly.
while test $# -gt 0
do
  arg="$1"
  shift

  case "$arg" in
#  
Jeff Law committed
111
  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
Jason Merrill committed
112 113 114 115 116
  *) optarg= ;;
  esac

  # If the previous option needs an argument, assign it.
  if test -n "$prev"; then
#  
Jeff Law committed
117 118 119 120 121 122 123 124 125
    case "$prev" in
    execute_dlfiles)
      eval "$prev=\"\$$prev \$arg\""
      ;;
    *)
      eval "$prev=\$arg"
      ;;
    esac

Jason Merrill committed
126 127 128 129 130 131 132 133 134 135 136 137
    prev=
    prevopt=
    continue
  fi

  # Have we seen a non-optional argument yet?
  case "$arg" in
  --help)
    show_help=yes
    ;;

  --version)
138
    echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
Jason Merrill committed
139 140 141
    exit 0
    ;;

#  
Jeff Law committed
142 143 144 145 146 147 148 149 150 151
  --config)
    sed -e '1,/^### BEGIN LIBTOOL CONFIG/d' -e '/^### END LIBTOOL CONFIG/,$d' $0
    exit 0
    ;;

  --debug)
    echo "$progname: enabling shell trace mode"
    set -x
    ;;

Jason Merrill committed
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
  --dry-run | -n)
    run=:
    ;;

  --features)
    echo "host: $host"
    if test "$build_libtool_libs" = yes; then
      echo "enable shared libraries"
    else
      echo "disable shared libraries"
    fi
    if test "$build_old_libs" = yes; then
      echo "enable static libraries"
    else
      echo "disable static libraries"
    fi
    exit 0
    ;;

  --finish) mode="finish" ;;

  --mode) prevopt="--mode" prev=mode ;;
  --mode=*) mode="$optarg" ;;

#  
Jeff Law committed
176 177 178 179 180 181 182 183 184
  --quiet | --silent)
    show=:
    ;;

  -dlopen)
    prevopt="-dlopen"
    prev=execute_dlfiles
    ;;

Jason Merrill committed
185
  -*)
#  
Jeff Law committed
186 187
    $echo "$modename: unrecognized option \`$arg'" 1>&2
    $echo "$help" 1>&2
Jason Merrill committed
188 189 190 191 192 193 194 195 196 197 198
    exit 1
    ;;

  *)
    nonopt="$arg"
    break
    ;;
  esac
done

if test -n "$prevopt"; then
#  
Jeff Law committed
199 200
  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
  $echo "$help" 1>&2
Jason Merrill committed
201 202 203 204 205 206 207 208
  exit 1
fi

if test -z "$show_help"; then

  # Infer the operation mode.
  if test -z "$mode"; then
    case "$nonopt" in
#  
Jeff Law committed
209
    *cc | *++ | gcc* | *-gcc*)
Jason Merrill committed
210 211 212
      mode=link
      for arg
      do
213 214 215 216 217 218
	case "$arg" in
	-c)
	   mode=compile
	   break
	   ;;
	esac
Jason Merrill committed
219 220
      done
      ;;
221
    *db | *dbx | *strace | *truss)
#  
Jeff Law committed
222 223 224
      mode=execute
      ;;
    *install*|cp|mv)
Jason Merrill committed
225 226 227 228 229 230
      mode=install
      ;;
    *rm)
      mode=uninstall
      ;;
    *)
#  
Jeff Law committed
231 232 233
      # If we have no mode, but dlfiles were specified, then do execute mode.
      test -n "$execute_dlfiles" && mode=execute

Jason Merrill committed
234 235
      # Just use the default operation mode.
      if test -z "$mode"; then
236 237 238 239 240
	if test -n "$nonopt"; then
	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
	else
	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
	fi
Jason Merrill committed
241 242 243 244 245
      fi
      ;;
    esac
  fi

#  
Jeff Law committed
246 247 248 249 250 251 252
  # Only execute mode is allowed to have -dlopen flags.
  if test -n "$execute_dlfiles" && test "$mode" != execute; then
    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
    $echo "$help" 1>&2
    exit 1
  fi

Jason Merrill committed
253 254
  # Change the help message to a mode-specific one.
  generic_help="$help"
#  
Jeff Law committed
255
  help="Try \`$modename --help --mode=$mode' for more information."
Jason Merrill committed
256 257 258 259 260

  # These modes are in order of execution frequency so that they run quickly.
  case "$mode" in
  # libtool compile mode
  compile)
#  
Jeff Law committed
261
    modename="$modename: compile"
Jason Merrill committed
262
    # Get the compilation command and the source file.
#  
Jeff Law committed
263
    base_compile=
Jason Merrill committed
264
    lastarg=
#  
Jeff Law committed
265 266
    srcfile="$nonopt"
    suppress_output=
Jason Merrill committed
267

268
    user_target=no
Jason Merrill committed
269 270
    for arg
    do
#  
Jeff Law committed
271
      # Accept any command-line options.
Jason Merrill committed
272
      case "$arg" in
#  
Jeff Law committed
273
      -o)
274 275 276 277 278
	if test "$user_target" != "no"; then
	  $echo "$modename: you cannot specify \`-o' more than once" 1>&2
	  exit 1
	fi
	user_target=next
#  
Jeff Law committed
279 280 281 282 283 284
	;;

      -static)
	build_old_libs=yes
	continue
	;;
Jason Merrill committed
285 286
      esac

287 288 289 290 291 292 293 294 295 296 297 298 299 300
      case "$user_target" in
      next)
	# The next one is the -o target name
	user_target=yes
	continue
	;;
      yes)
	# We got the output file
	user_target=set
	libobj="$arg"
	continue
	;;
      esac

#  
Jeff Law committed
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
      # Accept the current argument as the source file.
      lastarg="$srcfile"
      srcfile="$arg"

      # Aesthetically quote the previous argument.

      # Backslashify any backslashes, double quotes, and dollar signs.
      # These are the only characters that are still specially
      # interpreted inside of double-quoted scrings.
      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`

      # Double-quote args containing other shell metacharacters.
      # Many Bourne shells cannot handle close brackets correctly in scan
      # sets, so we specify it separately.
      case "$lastarg" in
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
	lastarg="\"$lastarg\""
	;;
      esac

      # Add the previous argument to base_compile.
      if test -z "$base_compile"; then
	base_compile="$lastarg"
      else
	base_compile="$base_compile $lastarg"
      fi
Jason Merrill committed
327 328
    done

329 330 331 332 333 334 335 336 337 338 339 340
    case "$user_target" in
    set)
      ;;
    no)
      # Get the name of the library object.
      libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
      ;;
    *)
      $echo "$modename: you must specify a target with \`-o'" 1>&2
      exit 1
      ;;
    esac
Jason Merrill committed
341 342

    # Recognize several different file suffixes.
343 344
    # If the user specifies -o file.o, it is replaced with file.lo
    xform='[cCFSfmso]'
Jason Merrill committed
345
    case "$libobj" in
#  
Jeff Law committed
346 347 348 349 350
    *.ada) xform=ada ;;
    *.adb) xform=adb ;;
    *.ads) xform=ads ;;
    *.asm) xform=asm ;;
    *.c++) xform=c++ ;;
Jason Merrill committed
351 352 353 354
    *.cc) xform=cc ;;
    *.cpp) xform=cpp ;;
    *.cxx) xform=cxx ;;
    *.f90) xform=f90 ;;
#  
Jeff Law committed
355
    *.for) xform=for ;;
Jason Merrill committed
356 357
    esac

#  
Jeff Law committed
358
    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
Jason Merrill committed
359 360

    case "$libobj" in
361
    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
Jason Merrill committed
362
    *)
363
      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
Jason Merrill committed
364 365 366 367 368
      exit 1
      ;;
    esac

    if test -z "$base_compile"; then
#  
Jeff Law committed
369 370
      $echo "$modename: you must specify a compilation command" 1>&2
      $echo "$help" 1>&2
Jason Merrill committed
371 372 373 374 375
      exit 1
    fi

    # Delete any leftover library objects.
    if test "$build_old_libs" = yes; then
376
      removelist="$obj $libobj"
Jason Merrill committed
377
    else
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419
      removelist="$libobj"
    fi

    $run $rm $removelist
    trap "$run $rm $removelist; exit 1" 1 2 15

    # Calculate the filename of the output object if compiler does
    # not support -o with -c
    if test "$compiler_c_o" = no; then
      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\..*$%%'`.${objext}
      lockfile="$output_obj.lock"
      removelist="$removelist $output_obj $lockfile"
      trap "$run $rm $removelist; exit 1" 1 2 15
    else
      need_locks=no
      lockfile=
    fi

    # Lock this critical section if it is needed
    # We use this script file to make the link, it avoids creating a new file
    if test "$need_locks" = yes; then
      until ln "$0" "$lockfile" 2>/dev/null; do
	$show "Waiting for $lockfile to be removed"
	sleep 2
      done
    elif test "$need_locks" = warn; then
      if test -f "$lockfile"; then
	echo "\
*** ERROR, $lockfile exists and contains:
`cat $lockfile 2>/dev/null`

This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together.  If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."

	$run $rm $removelist
	exit 1
      fi
      echo $srcfile > "$lockfile"
Jason Merrill committed
420 421
    fi

422 423 424 425
    if test -n "$fix_srcfile_path"; then
      eval srcfile=\"$fix_srcfile_path\"
    fi

Jason Merrill committed
426 427
    # Only build a PIC object if we are building libtool libraries.
    if test "$build_libtool_libs" = yes; then
#  
Jeff Law committed
428 429 430
      # Without this assignment, base_compile gets emptied.
      fbsd_hideous_sh_bug=$base_compile

Jason Merrill committed
431
      # All platforms use -DPIC, to notify preprocessed assembler code.
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464
      command="$base_compile $pic_flag -DPIC $srcfile"
      if test "$build_old_libs" = yes; then
	lo_libobj="$libobj"
	dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
	if test "X$dir" = "X$libobj"; then
	  dir="$objdir"
	else
	  dir="$dir/$objdir"
	fi
	libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`

	if test -d "$dir"; then
	  $show "$rm $libobj"
	  $run $rm $libobj
	else
	  $show "$mkdir $dir"
	  $run $mkdir $dir
	  status=$?
	  if test $status -ne 0 && test ! -d $dir; then
	    exit $status
	  fi
	fi
      fi
      if test "$compiler_o_lo" = yes; then
	output_obj="$libobj"
	command="$command -o $output_obj"
      elif test "$compiler_c_o" = yes; then
	output_obj="$obj"
	command="$command -o $output_obj"
      fi

      $show "$command"
      if $run eval "$command"; then :
Jason Merrill committed
465
      else
466 467
	test -n "$output_obj" && $run $rm $removelist
	exit 1
Jason Merrill committed
468 469
      fi

470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498
      if test "$need_locks" = warn &&
	 test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
	echo "\
*** ERROR, $lockfile contains:
`cat $lockfile 2>/dev/null`

but it should contain:
$srcfile

This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together.  If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."

	$run $rm $removelist
	exit 1
      fi

      # Just move the object if needed, then go on to compile the next one
      if test x"$output_obj" != x"$libobj"; then
	$show "$mv $output_obj $libobj"
	if $run $mv $output_obj $libobj; then :
	else
	  error=$?
	  $run $rm $removelist
	  exit $error
	fi
Jason Merrill committed
499 500
      fi

501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526
      # If we have no pic_flag, then copy the object into place and finish.
      if test -z "$pic_flag" && test "$build_old_libs" = yes; then
	# Rename the .lo from within objdir to obj
	if test -f $obj; then
	  $show $rm $obj
	  $run $rm $obj
	fi

	$show "$mv $libobj $obj"
	if $run $mv $libobj $obj; then :
	else
	  error=$?
	  $run $rm $removelist
	  exit $error
	fi

	# Now arrange that obj and lo_libobj become the same file
	$show "$LN_S $obj $lo_libobj"
	if $run $LN_S $obj $lo_libobj; then
	  exit 0
	else
	  error=$?
	  $run $rm $removelist
	  exit $error
	fi
      fi
#  
Jeff Law committed
527 528 529

      # Allow error messages only from the first compilation.
      suppress_output=' >/dev/null 2>&1'
Jason Merrill committed
530 531 532 533
    fi

    # Only build a position-dependent object if we build old libraries.
    if test "$build_old_libs" = yes; then
534 535 536 537 538 539
      command="$base_compile $srcfile"
      if test "$compiler_c_o" = yes; then
	command="$command -o $obj"
	output_obj="$obj"
      fi

#  
Jeff Law committed
540
      # Suppress compiler output if we already did a PIC compilation.
541 542 543
      command="$command$suppress_output"
      $show "$command"
      if $run eval "$command"; then :
Jason Merrill committed
544
      else
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
	$run $rm $removelist
	exit 1
      fi

      if test "$need_locks" = warn &&
	 test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
	echo "\
*** ERROR, $lockfile contains:
`cat $lockfile 2>/dev/null`

but it should contain:
$srcfile

This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together.  If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."

	$run $rm $removelist
	exit 1
      fi

      # Just move the object if needed
      if test x"$output_obj" != x"$obj"; then
	$show "$mv $output_obj $obj"
	if $run $mv $output_obj $obj; then :
	else
	  error=$?
	  $run $rm $removelist
	  exit $error
	fi
      fi

      # Create an invalid libtool object if no PIC, so that we do not
      # accidentally link it into a program.
      if test "$build_libtool_libs" != yes; then
	$show "echo timestamp > $libobj"
	$run eval "echo timestamp > \$libobj" || exit $?
      else
	# Move the .lo from within objdir
	$show "$mv $libobj $lo_libobj"
	if $run $mv $libobj $lo_libobj; then :
	else
	  error=$?
	  $run $rm $removelist
	  exit $error
	fi
Jason Merrill committed
594 595 596
      fi
    fi

597 598 599
    # Unlock the critical section if it was locked
    if test "$need_locks" != no; then
      $rm "$lockfile"
Jason Merrill committed
600 601 602 603 604 605 606
    fi

    exit 0
    ;;

  # libtool link mode
  link)
#  
Jeff Law committed
607
    modename="$modename: link"
608
    C_compiler="$CC" # save it, to compile generated C sources
#  
Jeff Law committed
609
    CC="$nonopt"
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782
    case "$host" in
    *-*-cygwin* | *-*-mingw* | *-*-os2*)
      # It is impossible to link a dll without this setting, and
      # we shouldn't force the makefile maintainer to figure out
      # which system we are compiling for in order to pass an extra
      # flag for every libtool invokation.
      # allow_undefined=no

      # FIXME: Unfortunately, there are problems with the above when trying
      # to make a dll which has undefined symbols, in which case not
      # even a static library is built.  For now, we need to specify
      # -no-undefined on the libtool link line when we can be certain
      # that all symbols are satisfied, otherwise we get a static library.
      allow_undefined=yes

      # This is a source program that is used to create dlls on Windows
      # Don't remove nor modify the starting and closing comments
# /* ltdll.c starts here */
# #define WIN32_LEAN_AND_MEAN
# #include <windows.h>
# #undef WIN32_LEAN_AND_MEAN
# #include <stdio.h>
#
# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
#
# #include <cygwin/cygwin_dll.h>
# DECLARE_CYGWIN_DLL( DllMain );
# HINSTANCE __hDllInstance_base;
#
# BOOL APIENTRY
# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
# {
#   __hDllInstance_base = hInst;
#   return TRUE;
# }
# /* ltdll.c ends here */
      # This is a source program that is used to create import libraries
      # on Windows for dlls which lack them. Don't remove nor modify the
      # starting and closing comments
# /* impgen.c starts here */
# /*   Copyright (C) 1999 Free Software Foundation, Inc.
# 
#  This file is part of GNU libtool.
# 
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
# 
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
# 
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#  */
# 
#  #include <stdio.h>		/* for printf() */
#  #include <unistd.h>		/* for open(), lseek(), read() */
#  #include <fcntl.h>		/* for O_RDONLY, O_BINARY */
#  #include <string.h>		/* for strdup() */
# 
#  static unsigned int
#  pe_get16 (fd, offset)
#       int fd;
#       int offset;
#  {
#    unsigned char b[2];
#    lseek (fd, offset, SEEK_SET);
#    read (fd, b, 2);
#    return b[0] + (b[1]<<8);
#  }
# 
#  static unsigned int
#  pe_get32 (fd, offset)
#      int fd;
#      int offset;
#  {
#    unsigned char b[4];
#    lseek (fd, offset, SEEK_SET);
#    read (fd, b, 4);
#    return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
#  }
# 
#  static unsigned int
#  pe_as32 (ptr)
#       void *ptr;
#  {
#    unsigned char *b = ptr;
#    return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
#  }
# 
#  int
#  main (argc, argv)
#      int argc;
#      char *argv[];
#  {
#      int dll;
#      unsigned long pe_header_offset, opthdr_ofs, num_entries, i;
#      unsigned long export_rva, export_size, nsections, secptr, expptr;
#      unsigned long name_rvas, nexp;
#      unsigned char *expdata, *erva;
#      char *filename, *dll_name;
# 
#      filename = argv[1];
# 
#      dll = open(filename, O_RDONLY|O_BINARY);
#      if (!dll)
#  	return 1;
# 
#      dll_name = filename;
#    
#      for (i=0; filename[i]; i++)
#  	if (filename[i] == '/' || filename[i] == '\\'  || filename[i] == ':')
#  	    dll_name = filename + i +1;
# 
#      pe_header_offset = pe_get32 (dll, 0x3c);
#      opthdr_ofs = pe_header_offset + 4 + 20;
#      num_entries = pe_get32 (dll, opthdr_ofs + 92);
# 
#      if (num_entries < 1) /* no exports */
#  	return 1;
# 
#      export_rva = pe_get32 (dll, opthdr_ofs + 96);
#      export_size = pe_get32 (dll, opthdr_ofs + 100);
#      nsections = pe_get16 (dll, pe_header_offset + 4 +2);
#      secptr = (pe_header_offset + 4 + 20 +
#  	      pe_get16 (dll, pe_header_offset + 4 + 16));
# 
#      expptr = 0;
#      for (i = 0; i < nsections; i++)
#      {
#  	char sname[8];
#  	unsigned long secptr1 = secptr + 40 * i;
#  	unsigned long vaddr = pe_get32 (dll, secptr1 + 12);
#  	unsigned long vsize = pe_get32 (dll, secptr1 + 16);
#  	unsigned long fptr = pe_get32 (dll, secptr1 + 20);
#  	lseek(dll, secptr1, SEEK_SET);
#  	read(dll, sname, 8);
#  	if (vaddr <= export_rva && vaddr+vsize > export_rva)
#  	{
#  	    expptr = fptr + (export_rva - vaddr);
#  	    if (export_rva + export_size > vaddr + vsize)
#  		export_size = vsize - (export_rva - vaddr);
#  	    break;
#  	}
#      }
# 
#      expdata = (unsigned char*)malloc(export_size);
#      lseek (dll, expptr, SEEK_SET);
#      read (dll, expdata, export_size);
#      erva = expdata - export_rva;
# 
#      nexp = pe_as32 (expdata+24);
#      name_rvas = pe_as32 (expdata+32);
# 
#      printf ("EXPORTS\n");
#      for (i = 0; i<nexp; i++)
#      {
#  	unsigned long name_rva = pe_as32 (erva+name_rvas+i*4);
#  	printf ("\t%s @ %ld ;\n", erva+name_rva, 1+ i);
#      }
# 
#      return 0;
#  }
# /* impgen.c ends here */
      ;;
    *)
      allow_undefined=yes
      ;;
    esac
#  
Jeff Law committed
783 784 785
    compile_command="$CC"
    finalize_command="$CC"

786 787
    compile_rpath=
    finalize_rpath=
Jason Merrill committed
788 789
    compile_shlibpath=
    finalize_shlibpath=
790 791
    convenience=
    old_convenience=
Jason Merrill committed
792
    deplibs=
793 794 795 796 797 798 799 800 801 802 803 804 805
    linkopts=

    if test -n "$shlibpath_var"; then
      # get the directories listed in $shlibpath_var
      eval lib_search_path=\`\$echo \"X \${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
    else
      lib_search_path=
    fi
    # now prepend the system-specific ones
    eval lib_search_path=\"$sys_lib_search_path_spec\$lib_search_path\"
    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
    
    avoid_version=no
#  
Jeff Law committed
806 807
    dlfiles=
    dlprefiles=
808
    dlself=no
Jason Merrill committed
809
    export_dynamic=no
810 811
    export_symbols=
    export_symbols_regex=
812
    generated=
Jason Merrill committed
813 814 815
    libobjs=
    link_against_libtool_libs=
    ltlibs=
816
    module=no
Jason Merrill committed
817
    objs=
818
    preload=no
Jason Merrill committed
819 820
    prev=
    prevarg=
#  
Jeff Law committed
821 822
    release=
    rpath=
823
    xrpath=
Jason Merrill committed
824 825
    perm_rpath=
    temp_rpath=
826
    thread_safe=no
Jason Merrill committed
827 828 829 830 831 832
    vinfo=

    # We need to know -static, to get the right output filenames.
    for arg
    do
      case "$arg" in
#  
Jeff Law committed
833
      -all-static | -static)
834
	if test "X$arg" = "X-all-static" && test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
#  
Jeff Law committed
835
	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
836 837
	fi
	build_libtool_libs=no
#  
Jeff Law committed
838
	build_old_libs=yes
839 840
	break
	;;
Jason Merrill committed
841 842 843
      esac
    done

#  
Jeff Law committed
844 845 846 847
    # See if our shared archives depend on static archives.
    test -n "$old_archive_from_new_cmds" && build_old_libs=yes

    # Go through the arguments, transforming them on the way.
848 849 850 851
    while test $# -gt 0; do
      arg="$1"
      shift

Jason Merrill committed
852 853
      # If the previous option needs an argument, assign it.
      if test -n "$prev"; then
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900
	case "$prev" in
	output)
	  compile_command="$compile_command @OUTPUT@"
	  finalize_command="$finalize_command @OUTPUT@"
	  ;;
	esac

	case "$prev" in
	dlfiles|dlprefiles)
	  if test "$preload" = no; then
	    # Add the symbol object into the linking commands.
	    compile_command="$compile_command @SYMFILE@"
	    finalize_command="$finalize_command @SYMFILE@"
	    preload=yes
	  fi
	  case "$arg" in
	  *.la | *.lo) ;;  # We handle these cases below.
	  self)
	    if test "$prev" = dlprefiles; then
	      dlself=yes
	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
	      dlself=yes
	    fi
	    prev=
	    continue
	    ;;
	  *)
	    dlprefiles="$dlprefiles $arg"
	    test "$prev" = dlfiles && dlfiles="$dlfiles $arg"
	    prev=
	    ;;
	  esac
	  ;;
	expsyms)
	  export_symbols="$arg"
	  if test ! -f "$arg"; then
	    $echo "$modename: symbol file \`$arg' does not exist"
	    exit 1
	  fi
	  prev=
	  continue
	  ;;
	expsyms_regex)
	  export_symbols_regex="$arg"
	  prev=
	  continue
	  ;;
#  
Jeff Law committed
901 902 903 904 905
	release)
	  release="-$arg"
	  prev=
	  continue
	  ;;
906 907
	rpath)
	  rpath="$rpath $arg"
#  
Jeff Law committed
908 909 910
	  prev=
	  continue
	  ;;
911 912 913 914 915 916 917 918 919 920 921
	xrpath)
	  xrpath="$xrpath $arg"
	  prev=
	  continue
	  ;;
	*)
	  eval "$prev=\"\$arg\""
	  prev=
	  continue
	  ;;
	esac
Jason Merrill committed
922 923 924 925 926
      fi

      prevarg="$arg"

      case "$arg" in
#  
Jeff Law committed
927 928
      -all-static)
	if test -n "$link_static_flag"; then
929
	  compile_command="$compile_command $link_static_flag"
#  
Jeff Law committed
930
	  finalize_command="$finalize_command $link_static_flag"
931 932 933
	  dlopen_self=$dlopen_self_static
	fi
	continue
#  
Jeff Law committed
934
	;;
Jason Merrill committed
935

#  
Jeff Law committed
936 937 938
      -allow-undefined)
	# FIXME: remove this flag sometime in the future.
	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
Jason Merrill committed
939 940 941
	continue
	;;

942 943 944 945 946
      -avoid-version)
	avoid_version=yes
	continue
	;;

#  
Jeff Law committed
947
      -dlopen)
948 949 950
	prev=dlfiles
	continue
	;;
Jason Merrill committed
951

#  
Jeff Law committed
952
      -dlpreopen)
953 954 955
	prev=dlprefiles
	continue
	;;
Jason Merrill committed
956

#  
Jeff Law committed
957
      -export-dynamic)
958 959
	if test "$export_dynamic" != yes; then
	  export_dynamic=yes
#  
Jeff Law committed
960 961 962 963 964
	  if test -n "$export_dynamic_flag_spec"; then
	    eval arg=\"$export_dynamic_flag_spec\"
	  else
	    arg=
	  fi
965 966
	fi
	;;
Jason Merrill committed
967

968 969 970 971 972 973 974 975 976 977 978 979
      -export-symbols | -export-symbols-regex)
	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
	  $echo "$modename: cannot have more than one -exported-symbols"
	  exit 1
	fi
	if test "$arg" = "-export-symbols"; then
	  prev=expsyms
	else
	  prev=expsyms_regex
	fi
	continue
	;;
Jason Merrill committed
980

#  
Jeff Law committed
981
      -L*)
982 983 984
	dir=`$echo "X$arg" | $Xsed -e 's%^-L\(.*\)$%\1%'`
	case "$dir" in
	/* | [A-Za-z]:[/\\]*)
#  
Jeff Law committed
985
	  # Add the corresponding hardcode_libdir_flag, if it is not identical.
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
	  ;;
	*)
	  $echo "$modename: \`-L$dir' cannot specify a relative directory" 1>&2
	  exit 1
	  ;;
	esac
	case " $deplibs " in
	*" $arg "*) ;;
	*) deplibs="$deplibs $arg";;
	esac
	case " $lib_search_path " in
	*" $dir "*) ;;
	*) lib_search_path="$lib_search_path $dir";;
	esac
	case "$host" in
	*-*-cygwin* | *-*-mingw* | *-*-os2*)
	  dllsearchdir=`cd "$dir" && pwd || echo "$dir"`
	  case ":$dllsearchpath:" in
	  ::) dllsearchpath="$dllsearchdir";;
	  *":$dllsearchdir:"*) ;;
	  *) dllsearchpath="$dllsearchpath:$dllsearchdir";;
	  esac
	  ;;
	esac
	;;
Jason Merrill committed
1011

1012 1013 1014
      -l*)
	deplibs="$deplibs $arg"
	;;
Jason Merrill committed
1015

1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026
      -module)
	if test "$module" != yes; then
	  module=yes
	  if test -n "$export_dynamic_flag_spec"; then
	    eval arg=\"$export_dynamic_flag_spec\"
	  else
	    arg=
	  fi
	fi
	;;
	
#  
Jeff Law committed
1027 1028
      -no-undefined)
	allow_undefined=no
Jason Merrill committed
1029 1030 1031
	continue
	;;

#  
Jeff Law committed
1032
      -o) prev=output ;;
Jason Merrill committed
1033

#  
Jeff Law committed
1034 1035 1036
      -release)
	prev=release
	continue
Jason Merrill committed
1037 1038
	;;

#  
Jeff Law committed
1039
      -rpath)
1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052
	prev=rpath
	continue
	;;

      -R)
	prev=xrpath
	continue
	;;

      -R*)
	xrpath="$xrpath "`$echo "X$arg" | $Xsed -e 's/^-R//'`
	continue
	;;
Jason Merrill committed
1053

#  
Jeff Law committed
1054 1055 1056
      -static)
	# If we have no pic_flag, then this is the same as -all-static.
	if test -z "$pic_flag" && test -n "$link_static_flag"; then
1057
	  compile_command="$compile_command $link_static_flag"
#  
Jeff Law committed
1058
	  finalize_command="$finalize_command $link_static_flag"
1059 1060 1061 1062 1063 1064 1065
	  dlopen_self=$dlopen_self_static
	fi
	continue
	;;

      -thread-safe)
	thread_safe=yes
#  
Jeff Law committed
1066
	continue
Jason Merrill committed
1067 1068
	;;

#  
Jeff Law committed
1069
      -version-info)
1070 1071 1072
	prev=vinfo
	continue
	;;
Jason Merrill committed
1073

#  
Jeff Law committed
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083
      # Some other compiler flag.
      -* | +*)
	# Unknown arguments in both finalize_command and compile_command need
	# to be aesthetically quoted because they are evaled later.
	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
	case "$arg" in
	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
	  arg="\"$arg\""
	  ;;
	esac
1084
	;;
Jason Merrill committed
1085

1086
      *.o | *.obj | *.a | *.lib)
1087 1088 1089
	# A standard object.
	objs="$objs $arg"
	;;
Jason Merrill committed
1090

#  
Jeff Law committed
1091
      *.lo)
1092
	# A library object.
#  
Jeff Law committed
1093 1094
	if test "$prev" = dlfiles; then
	  dlfiles="$dlfiles $arg"
1095
	  if test "$build_libtool_libs" = yes && test "$dlopen" = yes; then
#  
Jeff Law committed
1096 1097 1098 1099 1100 1101
	    prev=
	    continue
	  else
	    # If libtool objects are unsupported, then we need to preload.
	    prev=dlprefiles
	  fi
Jason Merrill committed
1102 1103
	fi

#  
Jeff Law committed
1104 1105
	if test "$prev" = dlprefiles; then
	  # Preload the old-style object.
1106
	  dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"`
#  
Jeff Law committed
1107
	  prev=
Jason Merrill committed
1108
	fi
#  
Jeff Law committed
1109
	libobjs="$libobjs $arg"
1110
	;;
Jason Merrill committed
1111

#  
Jeff Law committed
1112
      *.la)
1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182
	# A libtool-controlled library.

	dlname=
	libdir=
	library_names=
	old_library=

	# Check to see that this really is a libtool archive.
	if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
	else
	  $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2
	  exit 1
	fi

	# If the library was installed with an old release of libtool,
	# it will not redefine variable installed.
	installed=yes

	# If there is no directory component, then add one.
	case "$arg" in
	*/* | *\\*) . $arg ;;
	*) . ./$arg ;;
	esac

	# Get the name of the library we link against.
	linklib=
	for l in $old_library $library_names; do
	  linklib="$l"
	done

	if test -z "$linklib"; then
	  $echo "$modename: cannot find name of link library for \`$arg'" 1>&2
	  exit 1
	fi

	# Find the relevant object directory and library name.
	name=`$echo "X$arg" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'`

	if test "X$installed" = Xyes; then
	  dir="$libdir"
	else
	  dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
	  if test "X$dir" = "X$arg"; then
	    dir="$objdir"
	  else
	    dir="$dir/$objdir"
	  fi
	fi

	if test -n "$dependency_libs"; then
	  # Extract -R from dependency_libs
	  temp_deplibs=
	  for deplib in $dependency_libs; do
	    case "$deplib" in
	    -R*) temp_xrpath=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
		 case " $rpath $xrpath " in
		 *" $temp_xrpath "*) ;;
		 *) xrpath="$xrpath $temp_xrpath";;
		 esac;;
	    -L*) case "$compile_command $temp_deplibs " in
		 *" $deplib "*) ;;
		 *) temp_deplibs="$temp_deplibs $deplib";;
		 esac;;
	    *) temp_deplibs="$temp_deplibs $deplib";;
	    esac
	  done
	  dependency_libs="$temp_deplibs"
	fi

	if test -z "$libdir"; then
1183
	  # It is a libtool convenience library, so add in its objects.
1184
	  convenience="$convenience $dir/$old_library"
1185
	  old_convenience="$old_convenience $dir/$old_library"
1186 1187 1188
	  deplibs="$deplibs$dependency_libs"
	  compile_command="$compile_command $dir/$old_library$dependency_libs"
	  finalize_command="$finalize_command $dir/$old_library$dependency_libs"
1189 1190 1191
	  continue
	fi

1192 1193 1194 1195 1196 1197 1198 1199 1200
	# This library was specified with -dlopen.
	if test "$prev" = dlfiles; then
	  dlfiles="$dlfiles $arg"
	  if test -z "$dlname" || test "$dlopen" != yes || test "$build_libtool_libs" = no; then
	    # If there is no dlname, no dlopen support or we're linking statically,
	    # we need to preload.
	    prev=dlprefiles
	  else
	    # We should not create a dependency on this library, but we
#  
Jeff Law committed
1201 1202 1203
	    # may need any libraries it requires.
	    compile_command="$compile_command$dependency_libs"
	    finalize_command="$finalize_command$dependency_libs"
1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229
	    prev=
	    continue
	  fi
	fi

	# The library was specified with -dlpreopen.
	if test "$prev" = dlprefiles; then
	  # Prefer using a static library (so that no silly _DYNAMIC symbols
	  # are required to link).
	  if test -n "$old_library"; then
	    dlprefiles="$dlprefiles $dir/$old_library"
	  else
	    dlprefiles="$dlprefiles $dir/$linklib"
	  fi
	  prev=
	fi

	if test "$build_libtool_libs" = yes && test -n "$library_names"; then
	  link_against_libtool_libs="$link_against_libtool_libs $arg"
	  if test -n "$shlibpath_var"; then
	    # Make sure the rpath contains only unique directories.
	    case "$temp_rpath " in
	    *" $dir "*) ;;
	    *) temp_rpath="$temp_rpath $dir" ;;
	    esac
	  fi
#  
Jeff Law committed
1230

1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242
	  # We need an absolute path.
	  case "$dir" in
	  /* | [A-Za-z]:[/\\]*) absdir="$dir" ;;
	  *)
	    absdir=`cd "$dir" && pwd`
	    if test -z "$absdir"; then
	      $echo "$modename: cannot determine absolute directory name of \`$libdir'" 1>&2
	      exit 1
	    fi
	    ;;
	  esac
	  
#  
Jeff Law committed
1243
	  # This is the magic to use -rpath.
1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254
	  # Skip directories that are in the system default run-time
	  # search path, unless they have been requested with -R.
	  case " $sys_lib_dlsearch_path " in
 	  *" $absdir "*) ;;
	  *)
	    case "$compile_rpath " in
	    *" $absdir "*) ;;
	    *) compile_rpath="$compile_rpath $absdir" 
	    esac
	    ;;
 	  esac
#  
Jeff Law committed
1255

1256 1257 1258 1259 1260 1261 1262 1263 1264
	  case " $sys_lib_dlsearch_path " in
 	  *" $libdir "*) ;;
	  *)
	    case "$finalize_rpath " in
	    *" $libdir "*) ;;
	    *) finalize_rpath="$finalize_rpath $libdir"
	    esac
	    ;;
 	  esac
#  
Jeff Law committed
1265

1266
	  lib_linked=yes
1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282
	  case "$hardcode_action" in
	  immediate | unsupported)
	    if test "$hardcode_direct" = no; then
	      compile_command="$compile_command $dir/$linklib"
	      deplibs="$deplibs $dir/$linklib"
	      case "$host" in
	      *-*-cygwin* | *-*-mingw* | *-*-os2*)
		dllsearchdir=`cd "$dir" && pwd || echo "$dir"`
		if test -n "$dllsearchpath"; then
		  dllsearchpath="$dllsearchpath:$dllsearchdir"
		else
		  dllsearchpath="$dllsearchdir"
		fi
		;;
	      esac
	    elif test "$hardcode_minus_L" = no; then
1283 1284
	      case "$host" in
	      *-*-sunos*)
1285
		compile_shlibpath="$compile_shlibpath$dir:"
1286 1287
		;;
	      esac
1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300
	      case "$compile_command " in
	      *" -L$dir "*) ;;
	      *) compile_command="$compile_command -L$dir";;
	      esac
	      compile_command="$compile_command -l$name"
	      deplibs="$deplibs -L$dir -l$name"
	    elif test "$hardcode_shlibpath_var" = no; then
	      case ":$compile_shlibpath:" in
	      *":$dir:"*) ;;
	      *) compile_shlibpath="$compile_shlibpath$dir:";;
	      esac
	      compile_command="$compile_command -l$name"
	      deplibs="$deplibs -l$name"
1301 1302
	    else
	      lib_linked=no
1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323
	    fi
	    ;;

	  relink)
	    if test "$hardcode_direct" = yes; then
	      compile_command="$compile_command $absdir/$linklib"
	      deplibs="$deplibs $absdir/$linklib"
	    elif test "$hardcode_minus_L" = yes; then
	      case "$compile_command " in
	      *" -L$absdir "*) ;;
	      *) compile_command="$compile_command -L$absdir";;
	      esac
	      compile_command="$compile_command -l$name"
	      deplibs="$deplibs -L$absdir -l$name"
	    elif test "$hardcode_shlibpath_var" = yes; then
	      case ":$compile_shlibpath:" in
	      *":$absdir:"*) ;;
	      *) compile_shlibpath="$compile_shlibpath$absdir:";;
	      esac
	      compile_command="$compile_command -l$name"
	      deplibs="$deplibs -l$name"
1324 1325
	    else
	      lib_linked=no
1326 1327
	    fi
	    ;;
1328 1329 1330 1331

	  *)
	    lib_linked=no
	    ;;
1332
	  esac
#  
Jeff Law committed
1333

1334 1335 1336 1337 1338
	  if test "$lib_linked" != yes; then
	    $echo "$modename: configuration error: unsupported hardcode properties"
	    exit 1
	  fi

1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367
	  # Finalize command for both is simple: just hardcode it.
	  if test "$hardcode_direct" = yes; then
	    finalize_command="$finalize_command $libdir/$linklib"
	  elif test "$hardcode_minus_L" = yes; then
	    case "$finalize_command " in
	    *" -L$libdir "*) ;;
	    *) finalize_command="$finalize_command -L$libdir";;
	    esac
	    finalize_command="$finalize_command -l$name"
	  elif test "$hardcode_shlibpath_var" = yes; then
	    case ":$finalize_shlibpath:" in
	    *":$libdir:"*) ;;
	    *) finalize_shlibpath="$finalize_shlibpath$libdir:";;
	    esac
	    finalize_command="$finalize_command -l$name"
	  else
	    # We cannot seem to hardcode it, guess we'll fake it.
	    case "$finalize_command " in
	    *" -L$dir "*) ;;
	    *) finalize_command="$finalize_command -L$libdir";;
	    esac
	    finalize_command="$finalize_command -l$name"
	  fi
	else
	  # Transform directly to old archives if we don't build new libraries.
	  if test -n "$pic_flag" && test -z "$old_library"; then
	    $echo "$modename: cannot find static library for \`$arg'" 1>&2
	    exit 1
	  fi
#  
Jeff Law committed
1368 1369 1370 1371 1372 1373 1374 1375 1376

	  # Here we assume that one of hardcode_direct or hardcode_minus_L
	  # is not unsupported.  This is valid on all known static and
	  # shared platforms.
	  if test "$hardcode_direct" != unsupported; then
	    test -n "$old_library" && linklib="$old_library"
	    compile_command="$compile_command $dir/$linklib"
	    finalize_command="$finalize_command $dir/$linklib"
	  else
1377 1378 1379 1380 1381 1382 1383 1384 1385 1386
	    case "$compile_command " in
	    *" -L$dir "*) ;;
	    *) compile_command="$compile_command -L$dir";;
	    esac
	    compile_command="$compile_command -l$name"
	    case "$finalize_command " in
	    *" -L$dir "*) ;;
	    *) finalize_command="$finalize_command -L$dir";;
	    esac
	    finalize_command="$finalize_command -l$name"
Jason Merrill committed
1387
	  fi
1388
	fi
#  
Jeff Law committed
1389 1390 1391 1392

	# Add in any libraries that this one depends upon.
	compile_command="$compile_command$dependency_libs"
	finalize_command="$finalize_command$dependency_libs"
Jason Merrill committed
1393
	continue
1394
	;;
Jason Merrill committed
1395

#  
Jeff Law committed
1396
      # Some other compiler argument.
Jason Merrill committed
1397
      *)
#  
Jeff Law committed
1398 1399 1400 1401 1402 1403 1404 1405
	# Unknown arguments in both finalize_command and compile_command need
	# to be aesthetically quoted because they are evaled later.
	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
	case "$arg" in
	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
	  arg="\"$arg\""
	  ;;
	esac
1406
	;;
Jason Merrill committed
1407 1408
      esac

#  
Jeff Law committed
1409 1410 1411 1412 1413
      # Now actually substitute the argument into the commands.
      if test -n "$arg"; then
	compile_command="$compile_command $arg"
	finalize_command="$finalize_command $arg"
      fi
Jason Merrill committed
1414 1415 1416
    done

    if test -n "$prev"; then
#  
Jeff Law committed
1417 1418
      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
      $echo "$help" 1>&2
Jason Merrill committed
1419 1420 1421
      exit 1
    fi

1422
    oldlibs=
1423 1424 1425 1426
    # calculate the name of the file, without its directory
    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
    libobjs_save="$libobjs"

Jason Merrill committed
1427 1428
    case "$output" in
    "")
#  
Jeff Law committed
1429 1430
      $echo "$modename: you must specify an output file" 1>&2
      $echo "$help" 1>&2
Jason Merrill committed
1431 1432 1433
      exit 1
      ;;

1434 1435
    *.a | *.lib)
      if test -n "$link_against_libtool_libs"; then
1436 1437
	$echo "$modename: error: cannot link libtool libraries into archives" 1>&2
	exit 1
1438 1439 1440
      fi

      if test -n "$deplibs"; then
1441
	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
1442 1443 1444
      fi

      if test -n "$dlfiles$dlprefiles"; then
1445
	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
1446 1447 1448
      fi

      if test -n "$rpath"; then
1449 1450 1451 1452 1453
	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
      fi

      if test -n "$xrpath"; then
	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
1454 1455 1456
      fi

      if test -n "$vinfo"; then
1457
	$echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2
1458 1459 1460
      fi

      if test -n "$release"; then
1461 1462 1463 1464 1465
	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
      fi

      if test -n "$export_symbols"; then
	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
1466 1467
      fi

#  
Jeff Law committed
1468 1469
      # Now set the variables for building old libraries.
      build_libtool_libs=no
1470
      oldlibs="$output"
#  
Jeff Law committed
1471 1472
      ;;

Jason Merrill committed
1473
    *.la)
#  
Jeff Law committed
1474
      # Make sure we only generate libraries of the form `libNAME.la'.
1475 1476 1477 1478 1479
      case "$outputname" in
      lib*)
	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
	eval libname=\"$libname_spec\"
	;;
#  
Jeff Law committed
1480
      *)
1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492
	if test "$module" = no; then
	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
	  $echo "$help" 1>&2
	  exit 1
	fi
	if test "$need_lib_prefix" != no; then
	  # Add the "lib" prefix for modules if required
	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
	  eval libname=\"$libname_spec\"
	else
	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
	fi
#  
Jeff Law committed
1493 1494 1495
	;;
      esac

1496 1497 1498 1499 1500 1501
      output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
      if test "X$output_objdir" = "X$output"; then
	output_objdir="$objdir"
      else
	output_objdir="$output_objdir/$objdir"
      fi
Jason Merrill committed
1502 1503 1504 1505 1506 1507 1508

      # All the library-specific variables (install_libdir is set above).
      library_names=
      old_library=
      dlname=

      if test -n "$objs"; then
1509 1510
	$echo "$modename: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1
	exit 1
Jason Merrill committed
1511 1512 1513 1514
      fi

      # How the heck are we supposed to write a wrapper for a shared library?
      if test -n "$link_against_libtool_libs"; then
1515 1516
	 $echo "$modename: error: cannot link shared libraries into libtool libraries" 1>&2
	 exit 1
Jason Merrill committed
1517 1518
      fi

#  
Jeff Law committed
1519
      if test -n "$dlfiles$dlprefiles"; then
1520
	$echo "$modename: warning: \`-dlopen' is ignored for libtool libraries" 1>&2
#  
Jeff Law committed
1521
      fi
Jason Merrill committed
1522

#  
Jeff Law committed
1523 1524 1525
      set dummy $rpath
      if test $# -gt 2; then
	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
Jason Merrill committed
1526
      fi
#  
Jeff Law committed
1527
      install_libdir="$2"
Jason Merrill committed
1528

1529
      oldlibs=
1530
      if test -z "$rpath"; then
1531 1532 1533 1534 1535 1536 1537 1538
	if test "$build_libtool_libs" = yes; then
	  # Building a libtool convenience library.
	  libext=al
	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
	  build_libtool_libs=convenience
	  build_old_libs=yes
	fi
	dependency_libs="$deplibs"
1539 1540 1541 1542 1543 1544 1545 1546 1547

	if test -n "$vinfo"; then
	  $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2
	fi

	if test -n "$release"; then
	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
	fi
      else
Jason Merrill committed
1548

#  
Jeff Law committed
1549 1550
	# Parse the version information argument.
	IFS="${IFS= 	}"; save_ifs="$IFS"; IFS=':'
1551
	set dummy $vinfo 0 0 0
#  
Jeff Law committed
1552
	IFS="$save_ifs"
Jason Merrill committed
1553

1554
	if test -n "$8"; then
#  
Jeff Law committed
1555 1556 1557 1558
	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
	  $echo "$help" 1>&2
	  exit 1
	fi
Jason Merrill committed
1559

1560 1561 1562
	current="$2"
	revision="$3"
	age="$4"
Jason Merrill committed
1563

#  
Jeff Law committed
1564 1565 1566 1567 1568 1569 1570 1571 1572
	# Check that each of the things are valid numbers.
	case "$current" in
	0 | [1-9] | [1-9][0-9]*) ;;
	*)
	  $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
	  exit 1
	  ;;
	esac
Jason Merrill committed
1573

#  
Jeff Law committed
1574 1575 1576 1577 1578 1579 1580 1581
	case "$revision" in
	0 | [1-9] | [1-9][0-9]*) ;;
	*)
	  $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
	  exit 1
	  ;;
	esac
Jason Merrill committed
1582

#  
Jeff Law committed
1583 1584 1585 1586 1587 1588 1589 1590
	case "$age" in
	0 | [1-9] | [1-9][0-9]*) ;;
	*)
	  $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
	  exit 1
	  ;;
	esac
Jason Merrill committed
1591

#  
Jeff Law committed
1592 1593 1594 1595 1596
	if test $age -gt $current; then
	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
	  exit 1
	fi
Jason Merrill committed
1597

#  
Jeff Law committed
1598
	# Calculate the version variables.
1599 1600 1601
	major=
	versuffix=
	verstring=
#  
Jeff Law committed
1602 1603
	case "$version_type" in
	none) ;;
Jason Merrill committed
1604

1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618
	irix)
	  major=`expr $current - $age + 1`
	  versuffix="$major.$revision"
	  verstring="sgi$major.$revision"

	  # Add in all the interfaces that we are compatible with.
	  loop=$revision
	  while test $loop != 0; do
	    iface=`expr $revision - $loop`
	    loop=`expr $loop - 1`
	    verstring="sgi$major.$iface:$verstring"
	  done
	  ;;

#  
Jeff Law committed
1619 1620
	linux)
	  major=.`expr $current - $age`
1621
	  versuffix="$major.$age.$revision"
#  
Jeff Law committed
1622
	  ;;
Jason Merrill committed
1623

#  
Jeff Law committed
1624
	osf)
1625 1626
	  major=`expr $current - $age`
	  versuffix=".$current.$age.$revision"
#  
Jeff Law committed
1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641
	  verstring="$current.$age.$revision"

	  # Add in all the interfaces that we are compatible with.
	  loop=$age
	  while test $loop != 0; do
	    iface=`expr $current - $loop`
	    loop=`expr $loop - 1`
	    verstring="$verstring:${iface}.0"
	  done

	  # Make executables depend on our current version.
	  verstring="$verstring:${current}.0"
	  ;;

	sunos)
1642 1643
	  major=".$current"
	  versuffix=".$current.$revision"
#  
Jeff Law committed
1644 1645
	  ;;

1646 1647 1648 1649 1650 1651 1652 1653 1654 1655
	freebsd-aout)
	  major=".$current"
	  versuffix=".$current.$revision";
	  ;;

	freebsd-elf)
	  major=".$current"
	  versuffix=".$current";
	  ;;

#  
Jeff Law committed
1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669
	windows)
	  # Like Linux, but with '-' rather than '.', since we only
	  # want one extension on Windows 95.
	  major=`expr $current - $age`
	  versuffix="-$major-$age-$revision"
	  ;;

	*)
	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
	  echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
	  exit 1
	  ;;
	esac

1670 1671
	# Clear the version info if we defaulted, and they specified a release.
	if test -z "$vinfo" && test -n "$release"; then
#  
Jeff Law committed
1672
	  major=
1673
	  verstring="0.0"
1674 1675 1676
	  if test "$need_version" = no; then
	    versuffix=
	  else
1677
	    versuffix=".0.0"
1678
	  fi
1679
	fi
#  
Jeff Law committed
1680

1681 1682 1683 1684 1685 1686 1687
	# Remove version info from name if versioning should be avoided
	if test "$avoid_version" = yes && test "$need_version" = no; then
	  major=
	  versuffix=
	  verstring=""
	fi
	
1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698
	# Check to see if the archive will have undefined symbols.
	if test "$allow_undefined" = yes; then
	  if test "$allow_undefined_flag" = unsupported; then
	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
	    build_libtool_libs=no
	    build_old_libs=yes
	  fi
	else
	  # Don't allow undefined symbols.
	  allow_undefined_flag="$no_undefined_flag"
	fi
#  
Jeff Law committed
1699

1700
	dependency_libs="$deplibs"
1701 1702 1703 1704 1705 1706 1707 1708 1709
	case "$host" in
	*-*-cygwin* | *-*-mingw* | *-*-os2*)
	  # these systems don't actually have a c library (as such)!
	  ;;
	*)
	  # Add libc to deplibs on all other systems.
	  deplibs="$deplibs -lc"
	  ;;
	esac
#  
Jeff Law committed
1710
      fi
Jason Merrill committed
1711 1712

      # Create the output directory, or remove our outputs if we need to.
1713 1714 1715
      if test -d $output_objdir; then
	$show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*"
	$run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*
Jason Merrill committed
1716
      else
1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730
	$show "$mkdir $output_objdir"
	$run $mkdir $output_objdir
	status=$?
	if test $status -ne 0 && test ! -d $output_objdir; then
	  exit $status
	fi
      fi

      # Now set the variables for building old libraries.
      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
	oldlibs="$oldlibs $output_objdir/$libname.$libext"

	# Transform .lo files to .o files.
	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
Jason Merrill committed
1731 1732 1733
      fi

      if test "$build_libtool_libs" = yes; then
1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940
	# Transform deplibs into only deplibs that can be linked in shared.
	name_save=$name
	libname_save=$libname
	release_save=$release
	versuffix_save=$versuffix
	major_save=$major
	# I'm not sure if I'm treating the release correctly.  I think
	# release should show up in the -l (ie -lgmp5) so we don't want to
	# add it in twice.  Is that correct?
	release=""
	versuffix=""
	major=""
	newdeplibs=
	droppeddeps=no
	case "$deplibs_check_method" in
	pass_all)
	  newdeplibs=$deplibs
		    ;; # Don't check for shared/static.  Everything works.
		       # This might be a little naive.  We might want to check
		       # whether the library exists or not.  But this is on
		       # osf3 & osf4 and I'm not really sure... Just
		       # implementing what was already the behaviour.
	test_compile)
	  # This code stresses the "libraries are programs" paradigm to its
	  # limits. Maybe even breaks it.  We compile a program, linking it
	  # against the deplibs as a proxy for the library.  Then we can check
	  # whether they linked in statically or dynamically with ldd.
	  $rm conftest.c
	  cat > conftest.c <<EOF
	  int main() { return 0; }
EOF
	  $rm conftest
	  $C_compiler -o conftest conftest.c $deplibs
	  if test $? -eq 0 ; then
	    ldd_output=`ldd conftest`
	    for i in $deplibs; do
	      name="`expr $i : '-l\(.*\)'`"
	      # If $name is empty we are operating on a -L argument.
	      if test "$name" != "" ; then
		libname=`eval \\$echo \"$libname_spec\"`
		deplib_matches=`eval \\$echo \"$library_names_spec\"`
		set dummy $deplib_matches
		deplib_match=$2
		if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
		  newdeplibs="$newdeplibs $i"
		else
		  droppeddeps=yes
		  echo
		  echo "*** Warning: This library needs some functionality provided by $i."
		  echo "*** I have the capability to make that library automatically link in when"
		  echo "*** you link to this library.  But I can only do this if you have a"
		  echo "*** shared version of the library, which you do not appear to have."
		fi
	      else
		newdeplibs="$newdeplibs $i"
	      fi
	    done
	  else
	    # Error occured in the first compile.  Let's try to salvage the situation:
	    # Compile a seperate program for each library.
	    for i in $deplibs; do
	      name="`expr $i : '-l\(.*\)'`"
	     # If $name is empty we are operating on a -L argument.
	      if test "$name" != "" ; then
		$rm conftest
		$C_compiler -o conftest conftest.c $i
		# Did it work?
		if test $? -eq 0 ; then
		  ldd_output=`ldd conftest`
		    libname=`eval \\$echo \"$libname_spec\"`
		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
		    set dummy $deplib_matches
		    deplib_match=$2
		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
		      newdeplibs="$newdeplibs $i"
		    else
		      droppeddeps=yes
		      echo
		      echo "*** Warning: This library needs some functionality provided by $i."
		      echo "*** I have the capability to make that library automatically link in when"
		      echo "*** you link to this library.  But I can only do this if you have a"
		      echo "*** shared version of the library, which you do not appear to have."
		    fi
		else
		  droppeddeps=yes
		  echo
		  echo "*** Warning!  Library $i is needed by this library but I was not able to"
		  echo "***  make it link in!  You will probably need to install it or some"
		  echo "*** library that it depends on before this library will be fully"
		  echo "*** functional.  Installing it before continuing would be even better."
		fi
	      else
		newdeplibs="$newdeplibs $i"
	      fi
	    done
	  fi
	  deplibs=$newdeplibs
	  ;;
	file_magic*)
	  set dummy $deplibs_check_method
	  file_magic_regex="`expr \"$deplibs_check_method\" : \"$2 \(.*\)\"`"
	  for a_deplib in $deplibs; do
	    name="`expr $a_deplib : '-l\(.*\)'`"
	    # If $name is empty we are operating on a -L argument.
	    if test "$name" != "" ; then
	      libname=`eval \\$echo \"$libname_spec\"`
	      for i in $lib_search_path; do
		    potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
		    for potent_lib in $potential_libs; do
		      # Follow soft links.
		      if ls -lLd "$potlib" 2>/dev/null \
			 | grep " -> " >/dev/null; then
			continue 
		      fi
		      # The statement above tries to avoid entering an
		      # endless loop below, in case of cyclic links.
		      # We might still enter an endless loop, since a link
		      # loop can be closed while we follow links,
		      # but so what?
		      potlib="$potent_lib"
		      while test -h "$potlib" 2>/dev/null; do
			potliblink=`ls -ld $potlib | sed 's/.* -> //'`
			case "$potliblink" in
			/*) potlib="$potliblink";;
			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
			esac
		      done
		      if eval $file_magic_cmd \"\$potlib\" \
			 | sed 10q \
			 | egrep "$file_magic_regex" > /dev/null; then
			newdeplibs="$newdeplibs $a_deplib"
			a_deplib=""
			break 2
		      fi
		    done
	      done
	      if test -n "$a_deplib" ; then
		droppeddeps=yes
		echo
		echo "*** Warning: This library needs some functionality provided by $a_deplib."
		echo "*** I have the capability to make that library automatically link in when"
		echo "*** you link to this library.  But I can only do this if you have a"
		echo "*** shared version of the library, which you do not appear to have."
	      fi
	    else
	      # Add a -L argument.
	      newdeplibs="$newdeplibs $a_deplib"
	    fi
	  done # Gone through all deplibs.
	  ;;
	none | unknown | *) newdeplibs=""
	  if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
	       -e 's/ -[LR][^ ]*//g' -e 's/[ 	]//g' |
	     grep . >/dev/null; then
	    echo
	    if test "X$deplibs_check_method" = "Xnone"; then
	      echo "*** Warning: inter-library dependencies are not supported in this platform."
	    else
	      echo "*** Warning: inter-library dependencies are not known to be supported."
	    fi
	    echo "*** All declared inter-library dependencies are being dropped."
	    droppeddeps=yes
	  fi
	  ;;
	esac
	versuffix=$versuffix_save
	major=$major_save
	release=$release_save
	libname=$libname_save
	name=$name_save

	if test "$droppeddeps" = yes; then
	  if test "$module" = yes; then
	    echo
	    echo "*** Warning: libtool could not satisfy all declared inter-library"
	    echo "*** dependencies of module $libname.  Therefore, libtool will create"
	    echo "*** a static module, that should work as long as the dlopening"
	    echo "*** application is linked with the -dlopen flag."
	    if test -z "$global_symbol_pipe"; then
	      echo
	      echo "*** However, this would only work if libtool was able to extract symbol"
	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
	      echo "*** not find such a program.  So, this module is probably useless."
	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
	    fi
	    if test "$build_old_libs" = no; then
	      oldlibs="$output_objdir/$libname.$libext"
	      build_libtool_libs=module
	      build_old_libs=yes
	    else
	      build_libtool_libs=no
	    fi
	    dlname=
	    library_names=
	  else
	    echo "*** The inter-library dependencies that have been dropped here will be"
	    echo "*** automatically added whenever a program is linked with this library"
	    echo "*** or is declared to -dlopen it."
	  fi
	fi
      fi

      # test again, we may have decided not to build it any more
      if test "$build_libtool_libs" = yes; then
	deplibs=$newdeplibs
	# Done checking deplibs!
 
1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951
	# Get the real and link names of the library.
	eval library_names=\"$library_names_spec\"
	set dummy $library_names
	realname="$2"
	shift; shift

	if test -n "$soname_spec"; then
	  eval soname=\"$soname_spec\"
	else
	  soname="$realname"
	fi
Jason Merrill committed
1952

1953
	lib="$output_objdir/$realname"
Jason Merrill committed
1954 1955 1956 1957 1958
	for link
	do
	  linknames="$linknames $link"
	done

1959 1960 1961 1962 1963 1964
	# Ensure that we have .o objects for linkers which dislike .lo
	# (e.g. aix) incase we are running --disable-static
	for obj in $libobjs; do
	  oldobj=`$echo "X$obj" | $Xsed -e "$lo2o"`
	  test -f $oldobj || ${LN_S} $obj $oldobj
	done
Jason Merrill committed
1965

1966 1967
	# Use standard objects if they are pic
	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
Jason Merrill committed
1968

1969 1970 1971 1972 1973 1974 1975 1976 1977
	if test -n "$whole_archive_flag_spec"; then
	  if test -n "$convenience"; then
	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
	  fi
	else
	  for xlib in $convenience; do
	    # Extract the objects.
	    xdir="$xlib"x
	    generated="$generated $xdir"
1978
	    xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990

	    $show "${rm}r $xdir"
	    $run ${rm}r "$xdir"
	    $show "mkdir $xdir"
	    $run mkdir "$xdir"
	    status=$?
	    if test $status -ne 0 && test ! -d "$xdir"; then
	      exit $status
	    fi
	    $show "(cd $xdir && $AR x ../$xlib)"
	    $run eval "(cd \$xdir && $AR x ../\$xlib)" || exit $?

1991
	    libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
1992 1993 1994
	  done
	fi

1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027
	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
	  eval flag=\"$thread_safe_flag_spec\"

	  linkopts="$linkopts $flag"
	fi

	# Prepare the list of exported symbols
	if test -z "$export_symbols"; then
	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
	    $show "generating symbol list for \`$libname.la'"
	    export_symbols="$objdir/$libname.exp"
	    $run $rm $export_symbols
	    eval cmds=\"$export_symbols_cmds\"
	    IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
	    for cmd in $cmds; do
	      IFS="$save_ifs"
	      $show "$cmd"
	      $run eval "$cmd" || exit $?
	    done
	    IFS="$save_ifs"
	    if test -n "$export_symbols_regex"; then
	      $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
	      $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
	    fi
	  fi
	fi

	if test -n "$export_symbols" && test -n "$include_expsyms"; then
	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
	fi

2028
	# Do each of the archive commands.
2029 2030 2031 2032 2033 2034
	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
	  eval cmds=\"$archive_expsym_cmds\"
	else
	  eval cmds=\"$archive_cmds\"
	fi
	IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
2035 2036 2037 2038 2039 2040 2041 2042 2043
	for cmd in $cmds; do
	  IFS="$save_ifs"
	  $show "$cmd"
	  $run eval "$cmd" || exit $?
	done
	IFS="$save_ifs"

	# Create links to the real library.
	for linkname in $linknames; do
#  
Jeff Law committed
2044
	  if test "$realname" != "$linkname"; then
2045 2046
	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
2047 2048
	  fi
	done
Jason Merrill committed
2049

2050 2051
	# If -module or -export-dynamic was specified, set the dlname.
	if test "$module" = yes || test "$export_dynamic" = yes; then
2052 2053 2054
	  # On all known operating systems, these are identical.
	  dlname="$soname"
	fi
Jason Merrill committed
2055 2056 2057
      fi
      ;;

2058
    *.lo | *.o | *.obj)
Jason Merrill committed
2059
      if test -n "$link_against_libtool_libs"; then
2060 2061
	$echo "$modename: error: cannot link libtool libraries into objects" 1>&2
	exit 1
Jason Merrill committed
2062 2063 2064
      fi

      if test -n "$deplibs"; then
2065
	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
#  
Jeff Law committed
2066 2067 2068
      fi

      if test -n "$dlfiles$dlprefiles"; then
2069
	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
Jason Merrill committed
2070 2071
      fi

#  
Jeff Law committed
2072
      if test -n "$rpath"; then
2073 2074 2075 2076 2077
	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
      fi

      if test -n "$xrpath"; then
	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
Jason Merrill committed
2078 2079 2080
      fi

      if test -n "$vinfo"; then
2081
	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
#  
Jeff Law committed
2082 2083 2084
      fi

      if test -n "$release"; then
2085
	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
Jason Merrill committed
2086 2087 2088 2089
      fi

      case "$output" in
      *.lo)
2090 2091 2092 2093 2094 2095 2096
	if test -n "$objs"; then
	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
	  exit 1
	fi
	libobj="$output"
	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
	;;
Jason Merrill committed
2097
      *)
2098 2099 2100
	libobj=
	obj="$output"
	;;
Jason Merrill committed
2101 2102 2103 2104 2105 2106
      esac

      # Delete the old objects.
      $run $rm $obj $libobj

      # Create the old-style object.
2107
      reload_objs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`
Jason Merrill committed
2108 2109

      output="$obj"
#  
Jeff Law committed
2110
      eval cmds=\"$reload_cmds\"
2111
      IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
Jason Merrill committed
2112
      for cmd in $cmds; do
2113 2114 2115
	IFS="$save_ifs"
	$show "$cmd"
	$run eval "$cmd" || exit $?
Jason Merrill committed
2116 2117 2118 2119 2120 2121 2122
      done
      IFS="$save_ifs"

      # Exit if we aren't doing a library object file.
      test -z "$libobj" && exit 0

      if test "$build_libtool_libs" != yes; then
2123 2124 2125 2126 2127
	# Create an invalid libtool object if no PIC, so that we don't
	# accidentally link it into a program.
	$show "echo timestamp > $libobj"
	$run eval "echo timestamp > $libobj" || exit $?
	exit 0
Jason Merrill committed
2128 2129 2130
      fi

      if test -n "$pic_flag"; then
2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141
	# Only do commands if we really have different PIC objects.
	reload_objs="$libobjs"
	output="$libobj"
	eval cmds=\"$reload_cmds\"
	IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
	for cmd in $cmds; do
	  IFS="$save_ifs"
	  $show "$cmd"
	  $run eval "$cmd" || exit $?
	done
	IFS="$save_ifs"
Jason Merrill committed
2142
      else
2143 2144 2145 2146 2147
	# Just create a symlink.
	$show $rm $libobj
	$run $rm $libobj
	$show "$LN_S $obj $libobj"
	$run $LN_S $obj $libobj || exit $?
Jason Merrill committed
2148 2149 2150 2151 2152
      fi

      exit 0
      ;;

2153
    # Anything else should be a program.
Jason Merrill committed
2154
    *)
#  
Jeff Law committed
2155
      if test -n "$vinfo"; then
2156
	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
Jason Merrill committed
2157 2158
      fi

#  
Jeff Law committed
2159
      if test -n "$release"; then
2160
	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
Jason Merrill committed
2161 2162
      fi

2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175
      if test "$preload" = yes; then
	if test "$dlopen" = unknown && test "$dlopen_self" = unknown &&
	   test "$dlopen_self_static" = unknown; then
	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
	fi 
      fi
    
      if test "$dlself" = yes && test "$export_dynamic" = no; then
	$echo "$modename: error: \`-dlopen self' requires \`-export-dynamic'" 1>&2
	exit 1
      fi

      if test -n "$rpath$xrpath"; then
#  
Jeff Law committed
2176
	# If the user specified any rpath flags, then add them.
2177 2178 2179 2180 2181 2182 2183 2184 2185 2186
	for libdir in $rpath $xrpath; do
	  # This is the magic to use -rpath.
	  case "$compile_rpath " in
	  *" $libdir "*) ;;
	  *) compile_rpath="$compile_rpath $libdir" ;;
	  esac
	  case "$finalize_rpath " in
	  *" $libdir "*) ;;
	  *) finalize_rpath="$finalize_rpath $libdir" ;;
	  esac
#  
Jeff Law committed
2187
	done
Jason Merrill committed
2188 2189
      fi

2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224
      # Now hardcode the library paths
      rpath=
      hardcode_libdirs=
      for libdir in $compile_rpath $finalize_rpath; do
	if test -n "$hardcode_libdir_flag_spec"; then
	  if test -n "$hardcode_libdir_separator"; then
	    if test -z "$hardcode_libdirs"; then
	      hardcode_libdirs="$libdir"
	    else
	      # Just accumulate the unique libdirs.
	      case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
		;;
	      *)
		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
		;;
	      esac
	    fi
	  else
	    eval flag=\"$hardcode_libdir_flag_spec\"

	    rpath="$rpath $flag"
	  fi
	elif test -n "$runpath_var"; then
	  case "$perm_rpath " in
	  *" $libdir "*) ;;
	  *) perm_rpath="$perm_rpath $libdir" ;;
	  esac
	fi
      done
      # Substitute the hardcoded libdirs into the rpath.
      if test -n "$hardcode_libdir_separator" &&
	 test -n "$hardcode_libdirs"; then
	libdir="$hardcode_libdirs"
	eval rpath=\" $hardcode_libdir_flag_spec\"
#  
Jeff Law committed
2225
      fi
2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246
      compile_rpath="$rpath"

      rpath=
      hardcode_libdirs=
      for libdir in $finalize_rpath; do
	if test -n "$hardcode_libdir_flag_spec"; then
	  if test -n "$hardcode_libdir_separator"; then
	    if test -z "$hardcode_libdirs"; then
	      hardcode_libdirs="$libdir"
	    else
	      # Just accumulate the unique libdirs.
	      case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
		;;
	      *)
		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
		;;
	      esac
	    fi
	  else
	    eval flag=\"$hardcode_libdir_flag_spec\"
Jason Merrill committed
2247

2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261
	    rpath="$rpath $flag"
	  fi
	elif test -n "$runpath_var"; then
	  case "$finalize_perm_rpath " in
	  *" $libdir "*) ;;
	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
	  esac
	fi
      done
      # Substitute the hardcoded libdirs into the rpath.
      if test -n "$hardcode_libdir_separator" &&
	 test -n "$hardcode_libdirs"; then
	libdir="$hardcode_libdirs"
	eval rpath=\" $hardcode_libdir_flag_spec\"
#  
Jeff Law committed
2262
      fi
2263
      finalize_rpath="$rpath"
#  
Jeff Law committed
2264

2265 2266 2267
      output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
      if test "X$output_objdir" = "X$output"; then
	output_objdir="$objdir"
#  
Jeff Law committed
2268
      else
2269
	output_objdir="$output_objdir/$objdir"
#  
Jeff Law committed
2270 2271
      fi

2272 2273 2274 2275 2276
      if test -n "$libobjs" && test "$build_old_libs" = yes; then
	# Transform all the library objects into standard objects.
	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
      fi
#  
Jeff Law committed
2277

2278 2279 2280 2281
      dlsyms=
      if test -n "$dlfiles$dlprefiles" || test "$dlself" = yes; then
	if test -n "$NM" && test -n "$global_symbol_pipe"; then
	  dlsyms="${outputname}S.c"
#  
Jeff Law committed
2282
	else
2283
	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
Jason Merrill committed
2284
	fi
2285
      fi
#  
Jeff Law committed
2286

2287 2288 2289 2290 2291 2292 2293 2294 2295 2296
      if test -n "$dlsyms"; then
	case "$dlsyms" in
	"") ;;
	*.c)
	  # Discover the nlist of each of the dlfiles.
	  nlist="$objdir/${output}.nm"

	  if test -d $objdir; then
	    $show "$rm $nlist ${nlist}S ${nlist}T"
	    $run $rm "$nlist" "${nlist}S" "${nlist}T"
#  
Jeff Law committed
2297
	  else
2298 2299 2300 2301 2302 2303
	    $show "$mkdir $objdir"
	    $run $mkdir $objdir
	    status=$?
	    if test $status -ne 0 && test ! -d $objdir; then
	      exit $status
	    fi
#  
Jeff Law committed
2304 2305
	  fi

2306 2307 2308 2309 2310 2311
	  # Parse the name list into a source file.
	  $show "creating $objdir/$dlsyms"

	  $echo > "$objdir/$dlsyms" "\
/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
#  
Jeff Law committed
2312 2313 2314 2315 2316 2317

#ifdef __cplusplus
extern \"C\" {
#endif

/* Prevent the only kind of declaration conflicts we can make. */
2318
#define lt_preloaded_symbols some_other_symbol
#  
Jeff Law committed
2319 2320 2321 2322

/* External symbol declarations for the compiler. */\
"

2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382
	  if test "$dlself" = yes; then
	    $show "generating symbol list for \`$output'"

	    echo ': @PROGRAM@ ' > "$nlist"

	    # Add our own program objects to the symbol list.
	    progfiles=`$echo "X$objs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
	    for arg in $progfiles; do
	      $show "extracting global C symbols from \`$arg'"
	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
	    done

	    if test -n "$exclude_expsyms"; then
	      $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
	      $run eval '$mv "$nlist"T "$nlist"'
	    fi
	    
	    if test -n "$export_symbols_regex"; then
	      $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T'
	      $run eval '$mv "$nlist"T "$nlist"'
	    fi

	    # Prepare the list of exported symbols
	    if test -z "$export_symbols"; then
	      export_symbols="$objdir/$output.exp"
	      $run $rm $export_symbols
	      $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
	    else
	      $run $rm $export_symbols
	      $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$objdir/$output.exp"'
	      $run eval 'grep -f "$objdir/$output.exp" < "$nlist" > "$nlist"T'
	      $run eval 'mv "$nlist"T "$nlist"'
	    fi
	  fi

	  for arg in $dlprefiles; do
	    $show "extracting global C symbols from \`$arg'"
	    name=`echo "$arg" | sed -e 's%^.*/%%'`
	    $run eval 'echo ": $name " >> "$nlist"'
	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
	  done

	  if test -z "$run"; then
	    # Make sure we have at least an empty file.
	    test -f "$nlist" || : > "$nlist"

	    if test -n "$exclude_expsyms"; then
	      egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
	      $mv "$nlist"T "$nlist"
	    fi

	    # Try sorting and uniquifying the output.
	    if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then
	      :
	    else
	      grep -v "^: " < "$nlist" > "$nlist"S
	    fi

	    if test -f "$nlist"S; then
	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
#  
Jeff Law committed
2383
	    else
2384
	      echo '/* NONE */' >> "$output_objdir/$dlsyms"
#  
Jeff Law committed
2385 2386
	    fi

2387
	    $echo >> "$output_objdir/$dlsyms" "\
#  
Jeff Law committed
2388

2389
#undef lt_preloaded_symbols
#  
Jeff Law committed
2390 2391

#if defined (__STDC__) && __STDC__
2392
# define lt_ptr_t void *
#  
Jeff Law committed
2393
#else
2394 2395
# define lt_ptr_t char *
# define const
#  
Jeff Law committed
2396 2397 2398
#endif

/* The mapping between symbol names and symbols. */
2399 2400 2401
const struct {
  const char *name;
  lt_ptr_t address;
#  
Jeff Law committed
2402
}
2403
lt_preloaded_symbols[] =
#  
Jeff Law committed
2404 2405 2406
{\
"

2407 2408 2409
	    sed -n -e 's/^: \([^ ]*\) $/  {\"\1\", (lt_ptr_t) 0},/p' \
		-e 's/^. \([^ ]*\) \([^ ]*\)$/  {"\2", (lt_ptr_t) \&\2},/p' \
		  < "$nlist" >> "$output_objdir/$dlsyms"
#  
Jeff Law committed
2410

2411 2412
	    $echo >> "$output_objdir/$dlsyms" "\
  {0, (lt_ptr_t) 0}
#  
Jeff Law committed
2413 2414
};

2415 2416 2417 2418 2419 2420 2421
/* This works around a problem in FreeBSD linker */
#ifdef FREEBSD_WORKAROUND
static const void *lt_preloaded_setup() {
  return lt_preloaded_symbols;
}
#endif

#  
Jeff Law committed
2422 2423 2424 2425
#ifdef __cplusplus
}
#endif\
"
2426
	  fi
#  
Jeff Law committed
2427

2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439
	  pic_flag_for_symtable=
          case "$host" in
	  # compiling the symbol table file with pic_flag works around
	  # a FreeBSD bug that causes programs to crash when -lm is
	  # linked before any other PIC object.  But we must not use
	  # pic_flag when linking with -static.  The problem exists in
	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
	  *-*-freebsd2*|*-*-freebsd3.0*)
	    case "$compile_command " in
	    *" -static "*) ;;
	    *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";;
	    esac
#  
Jeff Law committed
2440 2441
	  esac

2442 2443 2444
	  # Now compile the dynamic symbol file.
	  $show "(cd $objdir && $C_compiler -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
	  $run eval '(cd $objdir && $C_compiler -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
#  
Jeff Law committed
2445

2446 2447 2448 2449 2450 2451 2452 2453 2454
	  # Transform the symbol file into the correct name.
	  compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$objdir/${output}S.${objext}%"`
	  finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$objdir/${output}S.${objext}%"`
	  ;;
	*)
	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
	  exit 1
	  ;;
	esac
#  
Jeff Law committed
2455
      else
2456 2457 2458
	# We keep going just in case the user didn't refer to
	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
	# really was required.
#  
Jeff Law committed
2459

2460 2461 2462
	# Nullify the symbol file.
	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
#  
Jeff Law committed
2463 2464 2465
      fi

      if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then
2466 2467 2468 2469 2470 2471 2472 2473
	# Replace the output file specification.
	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
	link_command="$compile_command$compile_rpath"

	# We have no uninstalled library dependencies, so finalize right now.
	$show "$link_command"
	$run eval "$link_command"
	exit $?
Jason Merrill committed
2474 2475 2476
      fi

      if test -n "$shlibpath_var"; then
2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491
	# We should set the shlibpath_var
	rpath=
	for dir in $temp_rpath; do
	  case "$dir" in
	  /* | [A-Za-z]:[/\\]*)
	    # Absolute path.
	    rpath="$rpath$dir:"
	    ;;
	  *)
	    # Relative path: add a thisdir entry.
	    rpath="$rpath\$thisdir/$dir:"
	    ;;
	  esac
	done
	temp_rpath="$rpath"
Jason Merrill committed
2492 2493
      fi

2494 2495
      if test -n "$compile_shlibpath$finalize_shlibpath"; then
	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
Jason Merrill committed
2496 2497
      fi
      if test -n "$finalize_shlibpath"; then
2498
	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
Jason Merrill committed
2499 2500
      fi

2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519
      compile_var=
      finalize_var=
      if test -n "$runpath_var"; then
	if test -n "$perm_rpath"; then
	  # We should set the runpath_var.
	  rpath=
	  for dir in $perm_rpath; do
	    rpath="$rpath$dir:"
	  done
	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
	fi
	if test -n "$finalize_perm_rpath"; then
	  # We should set the runpath_var.
	  rpath=
	  for dir in $finalize_perm_rpath; do
	    rpath="$rpath$dir:"
	  done
	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
	fi
Jason Merrill committed
2520 2521
      fi

#  
Jeff Law committed
2522
      if test "$hardcode_action" = relink; then
2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555
	# Fast installation is not supported
	link_command="$compile_var$compile_command$compile_rpath"
	relink_command="$finalize_var$finalize_command$finalize_rpath"
	
	# AGH! Flame the AIX and HP-UX people for me, will ya?
	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
	$echo "$modename: \`$output' will be relinked during installation" 1>&2
      else
	if test "$fast_install" != no; then
	  link_command="$finalize_var$compile_command$finalize_rpath"
	  if test "$fast_install" = yes; then
	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
	  else
	    # fast_install is set to needless
	    relink_command=
	  fi
	else
	  link_command="$compile_var$compile_command$compile_rpath"
	  relink_command="$finalize_var$finalize_command$finalize_rpath"
	fi
      fi

      # Replace the output file specification.
      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
      
      # Create the binary in the object directory, then wrap it.
      if test ! -d $output_objdir; then
	$show "$mkdir $output_objdir"
	$run $mkdir $output_objdir
	status=$?
	if test $status -ne 0 && test ! -d $objdir; then
	  exit $status
	fi
#  
Jeff Law committed
2556
      fi
Jason Merrill committed
2557

2558 2559 2560 2561 2562
      # Delete the old output file.
      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname

      $show "$link_command"
      $run eval "$link_command" || exit $?
Jason Merrill committed
2563 2564

      # Now create the wrapper script.
#  
Jeff Law committed
2565 2566
      $show "creating $output"

2567 2568 2569 2570
      # Quote the relink command for shipping.
      if test -n "$relink_command"; then
	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
      fi
#  
Jeff Law committed
2571 2572

      # Quote $echo for shipping.
2573 2574 2575 2576 2577 2578 2579 2580 2581
      if test "X$echo" = "X$SHELL $0 --fallback-echo"; then
	case "$0" in
	/* | [A-Za-z]:[/\\]*) qecho="$SHELL $0 --fallback-echo";;
	*) qecho="$SHELL `pwd`/$0 --fallback-echo";;
	esac
	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
      else
	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
      fi
Jason Merrill committed
2582 2583 2584

      # Only actually do things if our run command is non-null.
      if test -z "$run"; then
2585 2586 2587 2588 2589 2590 2591
	# win32 will think the script is a binary if it has
	# a .exe suffix, so we strip it off here.
	case $output in
	  *.exe) output=`echo $output|sed 's,.exe$,,'` ;;
	esac
	$rm $output
	trap "$rm $output; exit 1" 1 2 15
Jason Merrill committed
2592

2593
	$echo > $output "\
#  
Jeff Law committed
2594
#! $SHELL
Jason Merrill committed
2595

2596 2597
# $output - temporary wrapper script for $objdir/$outputname
# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
Jason Merrill committed
2598 2599 2600 2601
#
# The $output program cannot be directly executed until all the libtool
# libraries that it depends on are installed.
#
2602
# This wrapper script should never be moved out of the build directory.
Jason Merrill committed
2603 2604
# If it is, it will not operate correctly.

#  
Jeff Law committed
2605 2606
# Sed substitution that helps us do robust quoting.  It backslashifies
# metacharacters that are still active within double-quoted strings.
2607
Xsed='sed -e 1s/^X//'
#  
Jeff Law committed
2608 2609 2610 2611 2612 2613
sed_quote_subst='$sed_quote_subst'

# The HP-UX ksh and POSIX shell print the target directory to stdout
# if CDPATH is set.
if test \"\${CDPATH+set}\" = set; then CDPATH=; export CDPATH; fi

2614 2615
relink_command=\"$relink_command\"

Jason Merrill committed
2616
# This environment variable determines our operation mode.
#  
Jeff Law committed
2617
if test \"\$libtool_install_magic\" = \"$magic\"; then
2618
  # install mode needs the following variable:
Jason Merrill committed
2619 2620
  link_against_libtool_libs='$link_against_libtool_libs'
else
#  
Jeff Law committed
2621
  # When we are sourced in execute mode, \$file and \$echo are already set.
2622
  if test \"\$libtool_execute_magic\" != \"$magic\"; then
#  
Jeff Law committed
2623 2624
    echo=\"$qecho\"
    file=\"\$0\"
2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635
    # Make sure echo works.
    if test \"X\$1\" = X--no-reexec; then
      # Discard the --no-reexec flag, and continue.
      shift
    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
      # Yippee, \$echo works!
      :
    else
      # Restart under the correct shell, and then maybe \$echo will work.
      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
    fi
#  
Jeff Law committed
2636 2637
  fi\
"
2638
	$echo >> $output "\
Jason Merrill committed
2639

#  
Jeff Law committed
2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651
  # Find the directory that this script lives in.
  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
  test \"x\$thisdir\" = \"x\$file\" && thisdir=.

  # Follow symbolic links until we get to the real thisdir.
  file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\`
  while test -n \"\$file\"; do
    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`

    # If there was a directory component, then change thisdir.
    if test \"x\$destdir\" != \"x\$file\"; then
      case \"\$destdir\" in
2652
      /* | [A-Za-z]:[/\\]*) thisdir=\"\$destdir\" ;;
#  
Jeff Law committed
2653 2654 2655
      *) thisdir=\"\$thisdir/\$destdir\" ;;
      esac
    fi
Jason Merrill committed
2656

#  
Jeff Law committed
2657 2658 2659
    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
    file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\`
  done
Jason Merrill committed
2660

#  
Jeff Law committed
2661 2662 2663
  # Try to get the absolute directory name.
  absdir=\`cd \"\$thisdir\" && pwd\`
  test -n \"\$absdir\" && thisdir=\"\$absdir\"
2664
"
Jason Merrill committed
2665

2666 2667 2668
	if test "$fast_install" = yes; then
	  echo >> $output "\
  program=lt-'$outputname'
#  
Jeff Law committed
2669
  progdir=\"\$thisdir/$objdir\"
2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706
  
  if test ! -f \"\$progdir/\$program\" || \\
     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\
       test \"X\$file\" != \"X\$progdir/\$program\"; }; then

    file=\"\$\$-\$program\"

    if test ! -d \"\$progdir\"; then
      $mkdir \"\$progdir\"
    else
      $rm \"\$progdir/\$file\"
    fi"

	  echo >> $output "\

    # relink executable if necessary
    if test -n \"\$relink_command\"; then
      if (cd \"\$thisdir\" && eval \$relink_command); then :
      else
	$rm \"\$progdir/\$file\"
	exit 1
      fi
    fi

    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
    { $rm \"\$progdir/\$program\";
      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
    $rm \"\$progdir/\$file\"
  fi"
	else
	  echo >> $output "\
  program='$outputname'
  progdir=\"\$thisdir/$objdir\"
"
	fi

	echo >> $output "\
Jason Merrill committed
2707

#  
Jeff Law committed
2708
  if test -f \"\$progdir/\$program\"; then"
Jason Merrill committed
2709

2710 2711 2712
	# Export our shlibpath_var if we have one.
	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
	  $echo >> $output "\
Jason Merrill committed
2713
    # Add our own library path to $shlibpath_var
#  
Jeff Law committed
2714
    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
Jason Merrill committed
2715 2716

    # Some systems cannot cope with colon-terminated $shlibpath_var
2717 2718
    # The second colon is a workaround for a bug in BeOS R4 sed
    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
Jason Merrill committed
2719 2720

    export $shlibpath_var
#  
Jeff Law committed
2721
"
2722 2723 2724 2725 2726 2727 2728 2729 2730
	fi

	# fixup the dll searchpath if we need to.
	if test -n "$dllsearchpath"; then
	  $echo >> $output "\
    # Add the dll search path components to the executable PATH
    PATH=$dllsearchpath:\$PATH
"
	fi
Jason Merrill committed
2731

2732
	$echo >> $output "\
#  
Jeff Law committed
2733 2734
    if test \"\$libtool_execute_magic\" != \"$magic\"; then
      # Run the actual program with our arguments.
2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745
"
	case $host in
	*-*-cygwin* | *-*-mingw | *-*-os2*)
	  # win32 systems need to use the prog path for dll
	  # lookup to work
	  $echo >> $output "\
      exec \$progdir\\\\\$program \${1+\"\$@\"}
"
	  ;;
	*)
	  $echo >> $output "\
#  
Jeff Law committed
2746 2747 2748
      # Export the path to the program.
      PATH=\"\$progdir:\$PATH\"
      export PATH
Jason Merrill committed
2749

#  
Jeff Law committed
2750
      exec \$program \${1+\"\$@\"}
2751 2752 2753 2754
"
	  ;;
	esac
	$echo >> $output "\
#  
Jeff Law committed
2755 2756 2757
      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
      exit 1
    fi
Jason Merrill committed
2758 2759
  else
    # The program doesn't exist.
#  
Jeff Law committed
2760 2761 2762
    \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
    \$echo \"This script is just a wrapper for \$program.\" 1>&2
    echo \"See the $PACKAGE documentation for more information.\" 1>&2
Jason Merrill committed
2763 2764
    exit 1
  fi
#  
Jeff Law committed
2765 2766
fi\
"
2767
	chmod +x $output
Jason Merrill committed
2768 2769 2770 2771 2772 2773
      fi
      exit 0
      ;;
    esac

    # See if we need to build an old-fashioned archive.
2774 2775 2776
    for oldlib in $oldlibs; do

      if test "$build_libtool_libs" = convenience; then
2777
	oldobjs="$libobjs_save"
2778 2779 2780
	addlibs="$convenience"
	build_libtool_libs=no
      else
2781 2782 2783 2784 2785 2786
	if test "$build_libtool_libs" = module; then
	  oldobjs="$libobjs_save"
	  build_libtool_libs=no
	else
	  oldobjs="$objs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`
	fi
2787 2788 2789 2790 2791 2792 2793 2794
	addlibs="$old_convenience"
      fi

      # Add in members from convenience archives.
      for xlib in $addlibs; do
	# Extract the objects.
	xdir="$xlib"x
	generated="$generated $xdir"
2795
	xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807

	$show "${rm}r $xdir"
	$run ${rm}r "$xdir"
	$show "mkdir $xdir"
	$run mkdir "$xdir"
	status=$?
	if test $status -ne 0 && test ! -d "$xdir"; then
	  exit $status
	fi
	$show "(cd $xdir && $AR x ../$xlib)"
	$run eval "(cd \$xdir && $AR x ../\$xlib)" || exit $?

2808
	oldobjs="$oldobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
2809
      done
Jason Merrill committed
2810

#  
Jeff Law committed
2811 2812 2813
      # Do each command in the archive commands.
      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
	eval cmds=\"$old_archive_from_new_cmds\"
Jason Merrill committed
2814
      else
#  
Jeff Law committed
2815
	eval cmds=\"$old_archive_cmds\"
Jason Merrill committed
2816
      fi
2817
      IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
Jason Merrill committed
2818
      for cmd in $cmds; do
2819 2820 2821
	IFS="$save_ifs"
	$show "$cmd"
	$run eval "$cmd" || exit $?
Jason Merrill committed
2822 2823
      done
      IFS="$save_ifs"
2824 2825 2826 2827 2828
    done

    if test -n "$generated"; then
      $show "${rm}r$generated"
      $run ${rm}r$generated
Jason Merrill committed
2829 2830 2831 2832 2833 2834
    fi

    # Now create the libtool archive.
    case "$output" in
    *.la)
      old_library=
2835
      test "$build_old_libs" = yes && old_library="$libname.$libext"
#  
Jeff Law committed
2836
      $show "creating $output"
Jason Merrill committed
2837

2838 2839 2840 2841 2842 2843 2844 2845
      if test -n "$xrpath"; then
	temp_xrpath=
	for libdir in $xrpath; do
	  temp_xrpath="$temp_xrpath -R$libdir"
	done
	dependency_libs="$temp_xrpath $dependency_libs"
      fi

Jason Merrill committed
2846 2847
      # Only create the output if not a dry run.
      if test -z "$run"; then
2848
	$echo > $output "\
Jason Merrill committed
2849
# $output - a libtool library file
2850
# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
Jason Merrill committed
2851 2852 2853 2854 2855 2856 2857 2858 2859 2860

# The name that we can dlopen(3).
dlname='$dlname'

# Names of this library.
library_names='$library_names'

# The name of the static archive.
old_library='$old_library'

#  
Jeff Law committed
2861 2862 2863
# Libraries that this one depends upon.
dependency_libs='$dependency_libs'

Jason Merrill committed
2864 2865 2866 2867 2868
# Version information for $libname.
current=$current
age=$age
revision=$revision

2869 2870 2871
# Is this an already installed library?
installed=no

Jason Merrill committed
2872
# Directory that this library needs to be installed in:
#  
Jeff Law committed
2873 2874
libdir='$install_libdir'\
"
2875 2876 2877 2878

	$rm "$output_objdir/$outputname"i
	sed 's/^installed=no$/installed=yes/' \
	  < "$output" > "$output_objdir/$outputname"i || exit 1
Jason Merrill committed
2879 2880 2881 2882
      fi

      # Do a symbolic link so that the libtool archive can be found in
      # LD_LIBRARY_PATH before the program is installed.
2883 2884
      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
      $run eval "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" || exit $?
Jason Merrill committed
2885 2886 2887 2888 2889 2890 2891
      ;;
    esac
    exit 0
    ;;

  # libtool install mode
  install)
#  
Jeff Law committed
2892
    modename="$modename: install"
Jason Merrill committed
2893

#  
Jeff Law committed
2894 2895
    # There may be an optional sh(1) argument at the beginning of
    # install_prog (especially on Windows NT).
2896
    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh; then
#  
Jeff Law committed
2897 2898 2899 2900 2901 2902 2903 2904 2905
      # Aesthetically quote it.
      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
      case "$arg" in
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
	arg="\"$arg\""
	;;
      esac
      install_prog="$arg "
      arg="$1"
Jason Merrill committed
2906
      shift
#  
Jeff Law committed
2907 2908 2909
    else
      install_prog=
      arg="$nonopt"
Jason Merrill committed
2910 2911
    fi

#  
Jeff Law committed
2912 2913 2914 2915 2916 2917 2918 2919 2920 2921
    # The real first argument should be the name of the installation program.
    # Aesthetically quote it.
    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
    case "$arg" in
    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
      arg="\"$arg\""
      ;;
    esac
    install_prog="$install_prog$arg"

Jason Merrill committed
2922 2923 2924 2925 2926 2927
    # We need to accept at least all the BSD install flags.
    dest=
    files=
    opts=
    prev=
    install_type=
#  
Jeff Law committed
2928
    isdir=no
Jason Merrill committed
2929 2930 2931 2932
    stripme=
    for arg
    do
      if test -n "$dest"; then
2933 2934 2935
	files="$files $dest"
	dest="$arg"
	continue
Jason Merrill committed
2936 2937 2938 2939 2940 2941 2942 2943 2944
      fi

      case "$arg" in
      -d) isdir=yes ;;
      -f) prev="-f" ;;
      -g) prev="-g" ;;
      -m) prev="-m" ;;
      -o) prev="-o" ;;
      -s)
2945 2946 2947
	stripme=" -s"
	continue
	;;
Jason Merrill committed
2948 2949 2950
      -*) ;;

      *)
2951 2952 2953 2954 2955 2956 2957 2958
	# If the previous option needed an argument, then skip it.
	if test -n "$prev"; then
	  prev=
	else
	  dest="$arg"
	  continue
	fi
	;;
Jason Merrill committed
2959
      esac
#  
Jeff Law committed
2960 2961 2962 2963 2964 2965 2966 2967

      # Aesthetically quote the argument.
      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
      case "$arg" in
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
	arg="\"$arg\""
	;;
      esac
Jason Merrill committed
2968 2969 2970 2971
      install_prog="$install_prog $arg"
    done

    if test -z "$install_prog"; then
#  
Jeff Law committed
2972 2973
      $echo "$modename: you must specify an install program" 1>&2
      $echo "$help" 1>&2
Jason Merrill committed
2974 2975 2976 2977
      exit 1
    fi

    if test -n "$prev"; then
#  
Jeff Law committed
2978 2979
      $echo "$modename: the \`$prev' option requires an argument" 1>&2
      $echo "$help" 1>&2
Jason Merrill committed
2980 2981 2982 2983 2984
      exit 1
    fi

    if test -z "$files"; then
      if test -z "$dest"; then
2985
	$echo "$modename: no file or destination specified" 1>&2
Jason Merrill committed
2986
      else
2987
	$echo "$modename: you must specify a destination" 1>&2
Jason Merrill committed
2988
      fi
#  
Jeff Law committed
2989
      $echo "$help" 1>&2
Jason Merrill committed
2990 2991 2992 2993
      exit 1
    fi

    # Strip any trailing slash from the destination.
#  
Jeff Law committed
2994
    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
Jason Merrill committed
2995 2996 2997

    # Check to see that the destination is a directory.
    test -d "$dest" && isdir=yes
#  
Jeff Law committed
2998
    if test "$isdir" = yes; then
Jason Merrill committed
2999 3000 3001
      destdir="$dest"
      destname=
    else
#  
Jeff Law committed
3002 3003 3004
      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
      test "X$destdir" = "X$dest" && destdir=.
      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
Jason Merrill committed
3005 3006 3007 3008

      # Not a directory, so check to see that there is only one file specified.
      set dummy $files
      if test $# -gt 2; then
3009 3010 3011
	$echo "$modename: \`$dest' is not a directory" 1>&2
	$echo "$help" 1>&2
	exit 1
Jason Merrill committed
3012 3013 3014
      fi
    fi
    case "$destdir" in
3015
    /* | [A-Za-z]:[/\\]*) ;;
Jason Merrill committed
3016 3017
    *)
      for file in $files; do
3018 3019 3020 3021 3022 3023 3024 3025
	case "$file" in
	*.lo) ;;
	*)
	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
	  $echo "$help" 1>&2
	  exit 1
	  ;;
	esac
Jason Merrill committed
3026 3027 3028 3029
      done
      ;;
    esac

#  
Jeff Law committed
3030 3031 3032 3033
    # This variable tells wrapper scripts just to set variables rather
    # than running their programs.
    libtool_install_magic="$magic"

Jason Merrill committed
3034 3035 3036 3037 3038 3039 3040
    staticlibs=
    future_libdirs=
    current_libdirs=
    for file in $files; do

      # Do each installation.
      case "$file" in
3041
      *.a | *.lib)
3042 3043 3044
	# Do the static libraries later.
	staticlibs="$staticlibs $file"
	;;
Jason Merrill committed
3045 3046

      *.la)
3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100
	# Check to see that this really is a libtool archive.
	if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
	else
	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
	  $echo "$help" 1>&2
	  exit 1
	fi

	library_names=
	old_library=
	# If there is no directory component, then add one.
	case "$file" in
	*/* | *\\*) . $file ;;
	*) . ./$file ;;
	esac

	# Add the libdir to current_libdirs if it is the destination.
	if test "X$destdir" = "X$libdir"; then
	  case "$current_libdirs " in
	  *" $libdir "*) ;;
	  *) current_libdirs="$current_libdirs $libdir" ;;
	  esac
	else
	  # Note the libdir as a future libdir.
	  case "$future_libdirs " in
	  *" $libdir "*) ;;
	  *) future_libdirs="$future_libdirs $libdir" ;;
	  esac
	fi

	dir="`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/"
	test "X$dir" = "X$file/" && dir=
	dir="$dir$objdir"

	# See the names of the shared library.
	set dummy $library_names
	if test -n "$2"; then
	  realname="$2"
	  shift
	  shift

	  # Install the shared library and build the symlinks.
	  $show "$install_prog $dir/$realname $destdir/$realname"
	  $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $?
	  test "X$dlname" = "X$realname" && dlname=

	  if test $# -gt 0; then
	    # Delete the old symlinks, and create new ones.
	    for linkname
	    do
	      test "X$dlname" = "X$linkname" && dlname=
	      if test "$linkname" != "$realname"; then
		$show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
		$run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
3101
	      fi
3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137
	    done
	  fi

	  if test -n "$dlname"; then
	    # Install the dynamically-loadable library.
	    $show "$install_prog $dir/$dlname $destdir/$dlname"
	    $run eval "$install_prog $dir/$dlname $destdir/$dlname" || exit $?
	  fi

	  # Do each command in the postinstall commands.
	  lib="$destdir/$realname"
	  eval cmds=\"$postinstall_cmds\"
	  IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
	  for cmd in $cmds; do
	    IFS="$save_ifs"
	    $show "$cmd"
	    $run eval "$cmd" || exit $?
	  done
	  IFS="$save_ifs"
	fi

	# Install the pseudo-library for information purposes.
	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
	instname="$dir/$name"i
	if test ! -f "$instname"; then
	  # Just in case it was removed...
	  $show "Creating $instname"
	  $rm "$instname"
	  sed 's/^installed=no$/installed=yes/' "$file" > "$instname"
	fi
	$show "$install_prog $instname $destdir/$name"
	$run eval "$install_prog $instname $destdir/$name" || exit $?

	# Maybe install the static library, too.
	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
	;;
Jason Merrill committed
3138 3139

      *.lo)
3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181
	# Install (i.e. copy) a libtool object.

	# Figure out destination file name, if it wasn't already specified.
	if test -n "$destname"; then
	  destfile="$destdir/$destname"
	else
	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
	  destfile="$destdir/$destfile"
	fi

	# Deduce the name of the destination old-style object file.
	case "$destfile" in
	*.lo)
	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
	  ;;
	*.o | *.obj)
	  staticdest="$destfile"
	  destfile=
	  ;;
	*)
	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
	  $echo "$help" 1>&2
	  exit 1
	  ;;
	esac

	# Install the libtool object if requested.
	if test -n "$destfile"; then
	  $show "$install_prog $file $destfile"
	  $run eval "$install_prog $file $destfile" || exit $?
	fi

	# Install the old object if enabled.
	if test "$build_old_libs" = yes; then
	  # Deduce the name of the old-style object file.
	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`

	  $show "$install_prog $staticobj $staticdest"
	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
	fi
	exit 0
	;;
Jason Merrill committed
3182 3183

      *)
3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246
	# Figure out destination file name, if it wasn't already specified.
	if test -n "$destname"; then
	  destfile="$destdir/$destname"
	else
	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
	  destfile="$destdir/$destfile"
	fi

	# Do a test to see if this is really a libtool program.
	if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
	  link_against_libtool_libs=
	  relink_command=

	  # If there is no directory component, then add one.
	  case "$file" in
	  */* | *\\*) . $file ;;
	  *) . ./$file ;;
	  esac

	  # Check the variables that should have been set.
	  if test -z "$link_against_libtool_libs"; then
	    $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2
	    exit 1
	  fi

	  finalize=yes
	  for lib in $link_against_libtool_libs; do
	    # Check to see that each library is installed.
	    libdir=
	    if test -f "$lib"; then
	      # If there is no directory component, then add one.
	      case "$lib" in
	      */* | *\\*) . $lib ;;
	      *) . ./$lib ;;
	      esac
	    fi
	    libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`"
	    if test -n "$libdir" && test ! -f "$libfile"; then
	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
	      finalize=no
	    fi
	  done

	  outputname=
	  if test "$fast_install" = no && test -n "$relink_command"; then
	    if test "$finalize" = yes; then
	      outputname="/tmp/$$-$file"
	      # Replace the output file specification.
	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`

	      $echo "$modename: warning: relinking \`$file' on behalf of your buggy system linker" 1>&2
	      $show "$relink_command"
	      if $run eval "$relink_command"; then :
	      else
		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
		continue
	      fi
	      file="$outputname"
	    else
	      $echo "$modename: warning: cannot relink \`$file' on behalf of your buggy system linker" 1>&2
	    fi
	  else
	    # Install the binary that we compiled earlier.
#  
Jeff Law committed
3247
	    file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
3248 3249
	  fi
	fi
Jason Merrill committed
3250

3251 3252 3253 3254
	$show "$install_prog$stripme $file $destfile"
	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
	test -n "$outputname" && $rm $outputname
	;;
Jason Merrill committed
3255 3256 3257 3258
      esac
    done

    for file in $staticlibs; do
#  
Jeff Law committed
3259
      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
Jason Merrill committed
3260 3261 3262 3263 3264

      # Set up the ranlib parameters.
      oldlib="$destdir/$name"

      $show "$install_prog $file $oldlib"
#  
Jeff Law committed
3265
      $run eval "$install_prog \$file \$oldlib" || exit $?
Jason Merrill committed
3266 3267

      # Do each command in the postinstall commands.
#  
Jeff Law committed
3268
      eval cmds=\"$old_postinstall_cmds\"
3269
      IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
Jason Merrill committed
3270
      for cmd in $cmds; do
3271 3272 3273
	IFS="$save_ifs"
	$show "$cmd"
	$run eval "$cmd" || exit $?
Jason Merrill committed
3274 3275 3276 3277 3278
      done
      IFS="$save_ifs"
    done

    if test -n "$future_libdirs"; then
#  
Jeff Law committed
3279
      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
Jason Merrill committed
3280 3281 3282 3283 3284
    fi

    if test -n "$current_libdirs"; then
      # Maybe just do a dry run.
      test -n "$run" && current_libdirs=" -n$current_libdirs"
#  
Jeff Law committed
3285
      exec $SHELL $0 --finish$current_libdirs
Jason Merrill committed
3286 3287 3288 3289 3290 3291
      exit 1
    fi

    exit 0
    ;;

#  
Jeff Law committed
3292 3293 3294 3295 3296 3297 3298 3299 3300
  # libtool finish mode
  finish)
    modename="$modename: finish"
    libdirs="$nonopt"
    admincmds=

    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
      for dir
      do
3301
	libdirs="$libdirs $dir"
#  
Jeff Law committed
3302 3303 3304 3305 3306 3307
      done

      for libdir in $libdirs; do
	if test -n "$finish_cmds"; then
	  # Do each command in the finish commands.
	  eval cmds=\"$finish_cmds\"
3308 3309 3310 3311 3312
	  IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
	  for cmd in $cmds; do
	    IFS="$save_ifs"
	    $show "$cmd"
	    $run eval "$cmd" || admincmds="$admincmds
#  
Jeff Law committed
3313
       $cmd"
3314 3315
	  done
	  IFS="$save_ifs"
#  
Jeff Law committed
3316 3317 3318 3319 3320 3321 3322 3323 3324 3325
	fi
	if test -n "$finish_eval"; then
	  # Do the single finish_eval.
	  eval cmds=\"$finish_eval\"
	  $run eval "$cmds" || admincmds="$admincmds
       $cmds"
	fi
      done
    fi

3326 3327 3328
    # Exit here if they wanted silent mode.
    test "$show" = : && exit 0

#  
Jeff Law committed
3329 3330 3331 3332
    echo "----------------------------------------------------------------------"
    echo "Libraries have been installed in:"
    for libdir in $libdirs; do
      echo "   $libdir"
Jason Merrill committed
3333
    done
#  
Jeff Law committed
3334
    echo
3335 3336 3337 3338
    echo "If you ever happen to want to link against installed libraries"
    echo "in a given directory, LIBDIR, you must either use libtool, and"
    echo "specify the full pathname of the library, or use \`-LLIBDIR'"
    echo "flag during linking and do at least one of the following:"
#  
Jeff Law committed
3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349
    if test -n "$shlibpath_var"; then
      echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
      echo "     during execution"
    fi
    if test -n "$runpath_var"; then
      echo "   - add LIBDIR to the \`$runpath_var' environment variable"
      echo "     during linking"
    fi
    if test -n "$hardcode_libdir_flag_spec"; then
      libdir=LIBDIR
      eval flag=\"$hardcode_libdir_flag_spec\"
Jason Merrill committed
3350

#  
Jeff Law committed
3351
      echo "   - use the \`$flag' linker flag"
Jason Merrill committed
3352
    fi
#  
Jeff Law committed
3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364
    if test -n "$admincmds"; then
      echo "   - have your system administrator run these commands:$admincmds"
    fi
    if test -f /etc/ld.so.conf; then
      echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
    fi
    echo
    echo "See any operating system documentation about shared libraries for"
    echo "more information, such as the ld(1) and ld.so(8) manual pages."
    echo "----------------------------------------------------------------------"
    exit 0
    ;;
Jason Merrill committed
3365

#  
Jeff Law committed
3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376
  # libtool execute mode
  execute)
    modename="$modename: execute"

    # The first argument is the command name.
    cmd="$nonopt"
    if test -z "$cmd"; then
      $echo "$modename: you must specify a COMMAND" 1>&2
      $echo "$help"
      exit 1
    fi
Jason Merrill committed
3377

#  
Jeff Law committed
3378 3379
    # Handle -dlopen flags immediately.
    for file in $execute_dlfiles; do
3380
      if test ! -f "$file"; then
#  
Jeff Law committed
3381 3382 3383
	$echo "$modename: \`$file' is not a file" 1>&2
	$echo "$help" 1>&2
	exit 1
Jason Merrill committed
3384 3385
      fi

#  
Jeff Law committed
3386 3387 3388
      dir=
      case "$file" in
      *.la)
3389 3390 3391 3392 3393 3394 3395
	# Check to see that this really is a libtool archive.
	if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
	else
	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
	  $echo "$help" 1>&2
	  exit 1
	fi
#  
Jeff Law committed
3396 3397 3398 3399 3400

	# Read the libtool library.
	dlname=
	library_names=

3401
	# If there is no directory component, then add one.
#  
Jeff Law committed
3402 3403
	case "$file" in
	*/* | *\\*) . $file ;;
3404
	*) . ./$file ;;
#  
Jeff Law committed
3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432
	esac

	# Skip this library if it cannot be dlopened.
	if test -z "$dlname"; then
	  # Warn if it was a shared library.
	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
	  continue
	fi

	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
	test "X$dir" = "X$file" && dir=.

	if test -f "$dir/$objdir/$dlname"; then
	  dir="$dir/$objdir"
	else
	  $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
	  exit 1
	fi
	;;

      *.lo)
	# Just add the directory containing the .lo file.
	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
	test "X$dir" = "X$file" && dir=.
	;;

      *)
	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
3433
	continue
#  
Jeff Law committed
3434
	;;
Jason Merrill committed
3435 3436
      esac

#  
Jeff Law committed
3437 3438 3439 3440 3441 3442 3443
      # Get the absolute pathname.
      absdir=`cd "$dir" && pwd`
      test -n "$absdir" && dir="$absdir"

      # Now add the directory to shlibpath_var.
      if eval "test -z \"\$$shlibpath_var\""; then
	eval "$shlibpath_var=\"\$dir\""
Jason Merrill committed
3444
      else
#  
Jeff Law committed
3445
	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
Jason Merrill committed
3446 3447 3448
      fi
    done

#  
Jeff Law committed
3449 3450 3451
    # This variable tells wrapper scripts just to set shlibpath_var
    # rather than running their programs.
    libtool_execute_magic="$magic"
Jason Merrill committed
3452

#  
Jeff Law committed
3453 3454 3455 3456 3457 3458 3459
    # Check if any of the arguments is a wrapper script.
    args=
    for file
    do
      case "$file" in
      -*) ;;
      *)
3460 3461
	# Do a test to see if this is really a libtool program.
	if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
#  
Jeff Law committed
3462 3463 3464 3465 3466
	  # If there is no directory component, then add one.
	  case "$file" in
	  */* | *\\*) . $file ;;
	  *) . ./$file ;;
	  esac
Jason Merrill committed
3467

#  
Jeff Law committed
3468 3469 3470
	  # Transform arg to wrapped name.
	  file="$progdir/$program"
	fi
3471
	;;
#  
Jeff Law committed
3472 3473 3474 3475 3476
      esac
      # Quote arguments (to preserve shell metacharacters).
      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
      args="$args \"$file\""
    done
Jason Merrill committed
3477

#  
Jeff Law committed
3478 3479 3480 3481
    if test -z "$run"; then
      # Export the shlibpath_var.
      eval "export $shlibpath_var"

3482 3483
      # Restore saved enviroment variables
      if test "${save_LC_ALL+set}" = set; then
3484
	LC_ALL="$save_LC_ALL"; export LC_ALL
3485 3486
      fi
      if test "${save_LANG+set}" = set; then
3487
	LANG="$save_LANG"; export LANG
3488 3489
      fi

#  
Jeff Law committed
3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500
      # Now actually exec the command.
      eval "exec \$cmd$args"

      $echo "$modename: cannot exec \$cmd$args"
      exit 1
    else
      # Display what would be done.
      eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
      $echo "export $shlibpath_var"
      $echo "$cmd$args"
      exit 0
Jason Merrill committed
3501 3502 3503 3504 3505
    fi
    ;;

  # libtool uninstall mode
  uninstall)
#  
Jeff Law committed
3506
    modename="$modename: uninstall"
Jason Merrill committed
3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518
    rm="$nonopt"
    files=

    for arg
    do
      case "$arg" in
      -*) rm="$rm $arg" ;;
      *) files="$files $arg" ;;
      esac
    done

    if test -z "$rm"; then
#  
Jeff Law committed
3519 3520
      $echo "$modename: you must specify an RM program" 1>&2
      $echo "$help" 1>&2
Jason Merrill committed
3521 3522 3523 3524
      exit 1
    fi

    for file in $files; do
#  
Jeff Law committed
3525 3526 3527
      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
      test "X$dir" = "X$file" && dir=.
      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
Jason Merrill committed
3528 3529 3530 3531 3532

      rmfiles="$file"

      case "$name" in
      *.la)
3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543
	# Possibly a libtool archive, so verify it.
	if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
	  . $dir/$name

	  # Delete the libtool libraries and symlinks.
	  for n in $library_names; do
	    rmfiles="$rmfiles $dir/$n"
	    test "X$n" = "X$dlname" && dlname=
	  done
	  test -n "$dlname" && rmfiles="$rmfiles $dir/$dlname"
	  test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library"
#  
Jeff Law committed
3544 3545 3546 3547 3548 3549 3550

	  $show "$rm $rmfiles"
	  $run $rm $rmfiles

	  if test -n "$library_names"; then
	    # Do each command in the postuninstall commands.
	    eval cmds=\"$postuninstall_cmds\"
3551
	    IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
#  
Jeff Law committed
3552 3553 3554 3555 3556 3557 3558
	    for cmd in $cmds; do
	      IFS="$save_ifs"
	      $show "$cmd"
	      $run eval "$cmd"
	    done
	    IFS="$save_ifs"
	  fi
Jason Merrill committed
3559

3560
	  if test -n "$old_library"; then
#  
Jeff Law committed
3561 3562
	    # Do each command in the old_postuninstall commands.
	    eval cmds=\"$old_postuninstall_cmds\"
3563
	    IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
#  
Jeff Law committed
3564 3565 3566 3567 3568 3569 3570 3571
	    for cmd in $cmds; do
	      IFS="$save_ifs"
	      $show "$cmd"
	      $run eval "$cmd"
	    done
	    IFS="$save_ifs"
	  fi

3572 3573 3574
	  # FIXME: should reinstall the best remaining shared library.
	fi
	;;
Jason Merrill committed
3575 3576

      *.lo)
3577 3578 3579 3580
	if test "$build_old_libs" = yes; then
	  oldobj=`$echo "X$name" | $Xsed -e "$lo2o"`
	  rmfiles="$rmfiles $dir/$oldobj"
	fi
#  
Jeff Law committed
3581 3582
	$show "$rm $rmfiles"
	$run $rm $rmfiles
3583
	;;
Jason Merrill committed
3584

#  
Jeff Law committed
3585
      *)
3586
	$show "$rm $rmfiles"
#  
Jeff Law committed
3587 3588 3589
	$run $rm $rmfiles
	;;
      esac
Jason Merrill committed
3590 3591 3592 3593
    done
    exit 0
    ;;

#  
Jeff Law committed
3594 3595 3596
  "")
    $echo "$modename: you must specify a MODE" 1>&2
    $echo "$generic_help" 1>&2
Jason Merrill committed
3597 3598 3599 3600
    exit 1
    ;;
  esac

#  
Jeff Law committed
3601 3602
  $echo "$modename: invalid operation mode \`$mode'" 1>&2
  $echo "$generic_help" 1>&2
Jason Merrill committed
3603 3604 3605 3606 3607
  exit 1
fi # test -z "$show_help"

# We need to display help for each of the modes.
case "$mode" in
#  
Jeff Law committed
3608 3609
"") $echo \
"Usage: $modename [OPTION]... [MODE-ARG]...
Jason Merrill committed
3610 3611 3612

Provide generalized library-building support services.

#  
Jeff Law committed
3613 3614
    --config          show all configuration variables
    --debug           enable verbose shell tracing
Jason Merrill committed
3615
-n, --dry-run         display commands without modifying any files
#  
Jeff Law committed
3616
    --features        display basic configuration information and exit
Jason Merrill committed
3617 3618 3619
    --finish          same as \`--mode=finish'
    --help            display this help message and exit
    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
#  
Jeff Law committed
3620 3621
    --quiet           same as \`--silent'
    --silent          don't print informational messages
Jason Merrill committed
3622 3623 3624 3625 3626
    --version         print version information

MODE must be one of the following:

      compile         compile a source file into a libtool object
#  
Jeff Law committed
3627
      execute         automatically set library path, then run a program
Jason Merrill committed
3628 3629 3630 3631 3632
      finish          complete the installation of libtool libraries
      install         install libraries or executables
      link            create a library or an executable
      uninstall       remove libraries from an installed directory

#  
Jeff Law committed
3633 3634 3635
MODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
a more detailed description of MODE."
  exit 0
Jason Merrill committed
3636 3637 3638
  ;;

compile)
#  
Jeff Law committed
3639 3640
  $echo \
"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
Jason Merrill committed
3641 3642 3643

Compile a source file into a libtool library object.

3644 3645
This mode accepts the following additional options:

3646
  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
3647 3648
  -static           always build a \`.o' file suitable for static linking

Jason Merrill committed
3649 3650 3651 3652 3653
COMPILE-COMMAND is a command to be used in creating a \`standard' object file
from the given SOURCEFILE.

The output file name is determined by removing the directory component from
SOURCEFILE, then substituting the C source code suffix \`.c' with the
#  
Jeff Law committed
3654
library object suffix, \`.lo'."
Jason Merrill committed
3655 3656
  ;;

#  
Jeff Law committed
3657 3658 3659 3660 3661 3662 3663
execute)
  $echo \
"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...

Automatically set library path, then run a program.

This mode accepts the following additional options:
Jason Merrill committed
3664

#  
Jeff Law committed
3665
  -dlopen FILE      add the directory containing FILE to the library path
Jason Merrill committed
3666

#  
Jeff Law committed
3667 3668
This mode sets the library path environment variable according to \`-dlopen'
flags.
Jason Merrill committed
3669

#  
Jeff Law committed
3670 3671 3672 3673 3674
If any of the ARGS are libtool executable wrappers, then they are translated
into their corresponding uninstalled binary, and any of their required library
directories are added to the library path.

Then, COMMAND is executed, with ARGS as arguments."
Jason Merrill committed
3675 3676 3677
  ;;

finish)
#  
Jeff Law committed
3678 3679
  $echo \
"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
Jason Merrill committed
3680 3681 3682 3683 3684 3685

Complete the installation of libtool libraries.

Each LIBDIR is a directory that contains libtool libraries.

The commands that this mode executes may require superuser privileges.  Use
#  
Jeff Law committed
3686
the \`--dry-run' option if you just want to see what would be executed."
Jason Merrill committed
3687 3688 3689
  ;;

install)
#  
Jeff Law committed
3690 3691
  $echo \
"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
Jason Merrill committed
3692 3693 3694 3695 3696 3697 3698

Install executables or libraries.

INSTALL-COMMAND is the installation command.  The first component should be
either the \`install' or \`cp' program.

The rest of the components are interpreted as arguments to that command (only
#  
Jeff Law committed
3699
BSD-compatible install options are recognized)."
Jason Merrill committed
3700 3701 3702
  ;;

link)
#  
Jeff Law committed
3703 3704
  $echo \
"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
Jason Merrill committed
3705 3706 3707 3708 3709 3710 3711 3712 3713

Link object files or libraries together to form another library, or to
create an executable program.

LINK-COMMAND is a command using the C compiler that you would use to create
a program from several object files.

The following components of LINK-COMMAND are treated specially:

#  
Jeff Law committed
3714
  -all-static       do not do any dynamic linking at all
3715
  -avoid-version    do not add a version suffix if possible
#  
Jeff Law committed
3716
  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
3717
  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
Jason Merrill committed
3718
  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
3719 3720
  -export-symbols SYMFILE
		    try to export only the symbols listed in SYMFILE
Jason Merrill committed
3721 3722
  -LLIBDIR          search LIBDIR for required installed libraries
  -lNAME            OUTPUT-FILE requires the installed library libNAME
3723
  -module           build a library that can dlopened
#  
Jeff Law committed
3724
  -no-undefined     declare that a library does not refer to external symbols
Jason Merrill committed
3725
  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
#  
Jeff Law committed
3726
  -release RELEASE  specify package release information
Jason Merrill committed
3727
  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
3728
  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
#  
Jeff Law committed
3729
  -static           do not do any dynamic linking of libtool libraries
Jason Merrill committed
3730
  -version-info CURRENT[:REVISION[:AGE]]
3731
		    specify library version info [each variable defaults to 0]
Jason Merrill committed
3732 3733 3734 3735 3736 3737 3738

All other options (arguments beginning with \`-') are ignored.

Every other argument is treated as a filename.  Files ending in \`.la' are
treated as uninstalled libtool libraries, other files are standard or library
object files.

3739 3740 3741
If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
only library objects (\`.lo' files) may be specified, and \`-rpath' is
required, except when creating a convenience library.
Jason Merrill committed
3742

3743
If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
3744
using \`ar' and \`ranlib', or on Windows using \`lib'.
Jason Merrill committed
3745

3746 3747
If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
is created, otherwise an executable program is created."
Jason Merrill committed
3748 3749 3750
  ;;

uninstall)
#  
Jeff Law committed
3751 3752
  $echo
"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
Jason Merrill committed
3753 3754 3755 3756 3757 3758 3759 3760

Remove libraries from an installation directory.

RM is the name of the program to use to delete files associated with each FILE
(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
to RM.

If FILE is a libtool library, all the files associated with it are deleted.
#  
Jeff Law committed
3761
Otherwise, only FILE itself is deleted using RM."
Jason Merrill committed
3762 3763 3764
  ;;

*)
#  
Jeff Law committed
3765 3766
  $echo "$modename: invalid operation mode \`$mode'" 1>&2
  $echo "$help" 1>&2
Jason Merrill committed
3767 3768 3769 3770
  exit 1
  ;;
esac

#  
Jeff Law committed
3771 3772
echo
$echo "Try \`$modename --help' for more information about other modes."
Jason Merrill committed
3773 3774 3775 3776 3777 3778 3779

exit 0

# Local Variables:
# mode:shell-script
# sh-indentation:2
# End: