Skip to content
Snippets Groups Projects
ltmain.sh 179 KiB
Newer Older
  • Learn to ignore specific revisions
  •   # libtool link mode
      link | relink)
        modename="$modename: link"
        case $host in
        *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-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 invocation.
          # 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
          ;;
        *)
          allow_undefined=yes
          ;;
        esac
        libtool_args="$nonopt"
        base_compile="$nonopt $@"
        compile_command="$nonopt"
        finalize_command="$nonopt"
    
        compile_rpath=
        finalize_rpath=
        compile_shlibpath=
        finalize_shlibpath=
        convenience=
        old_convenience=
        deplibs=
        old_deplibs=
        compiler_flags=
        linker_flags=
        dllsearchpath=
        lib_search_path=`pwd`
        inst_prefix_dir=
    
        avoid_version=no
        dlfiles=
        dlprefiles=
        dlself=no
        export_dynamic=no
        export_symbols=
        export_symbols_regex=
        generated=
        libobjs=
        ltlibs=
        module=no
        no_install=no
        objs=
        non_pic_objects=
        precious_files_regex=
        prefer_static_libs=no
        preload=no
        prev=
        prevarg=
        release=
        rpath=
        xrpath=
        perm_rpath=
        temp_rpath=
        thread_safe=no
        vinfo=
        vinfo_number=no
    
        func_infer_tag $base_compile
    
        # We need to know -static, to get the right output filenames.
        for arg
        do
          case $arg in
    
          -all-static | -static)
    	if test "X$arg" = "X-all-static"; then
    
    	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
    	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
    	  fi
    	  if test -n "$link_static_flag"; then
    	    dlopen_self=$dlopen_self_static
    	  fi
    
    	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
    	    dlopen_self=$dlopen_self_static
    	  fi
    
    	build_libtool_libs=no
    	build_old_libs=yes
    
    	prefer_static_libs=yes
    
        # 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.
        while test "$#" -gt 0; do
          arg="$1"
          shift
          case $arg in
          *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
    	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
    	;;
          *) qarg=$arg ;;
          esac
          libtool_args="$libtool_args $qarg"
    
          # If the previous option needs an argument, assign it.
          if test -n "$prev"; then
    	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.
    	  force)
    	    if test "$dlself" = no; then
    	      dlself=needless
    	      export_dynamic=yes
    	    fi
    	    prev=
    	    continue
    	    ;;
    	  self)
    	    if test "$prev" = dlprefiles; then
    	      dlself=yes
    	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
    	      dlself=yes
    	    else
    	      dlself=needless
    	      export_dynamic=yes
    	    fi
    	    prev=
    	    continue
    	    ;;
    	  *)
    	    if test "$prev" = dlfiles; then
    	      dlfiles="$dlfiles $arg"
    	    else
    	      dlprefiles="$dlprefiles $arg"
    	    fi
    	    prev=
    	    continue
    	    ;;
    	  esac
    	  ;;
    	expsyms)
    	  export_symbols="$arg"
    	  if test ! -f "$arg"; then
    	    $echo "$modename: symbol file \`$arg' does not exist"
    	    exit $EXIT_FAILURE
    	  fi
    	  prev=
    	  continue
    	  ;;
    	expsyms_regex)
    	  export_symbols_regex="$arg"
    	  prev=
    	  continue
    	  ;;
    	inst_prefix)
    	  inst_prefix_dir="$arg"
    	  prev=
    	  continue
    	  ;;
    	precious_regex)
    	  precious_files_regex="$arg"
    	  prev=
    	  continue
    	  ;;
    	release)
    	  release="-$arg"
    	  prev=
    	  continue
    	  ;;
    	objectlist)
    	  if test -f "$arg"; then
    	    save_arg=$arg
    	    moreargs=
    	    for fil in `cat $save_arg`
    	    do
    #	      moreargs="$moreargs $fil"
    	      arg=$fil
    	      # A libtool-controlled object.
    
    	      # Check to see that this really is a libtool object.
    	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
    		pic_object=
    		non_pic_object=
    
    		# Read the .lo file
    		# If there is no directory component, then add one.
    		case $arg in
    		*/* | *\\*) . $arg ;;
    		*) . ./$arg ;;
    		esac
    
    		if test -z "$pic_object" || \
    		   test -z "$non_pic_object" ||
    		   test "$pic_object" = none && \
    		   test "$non_pic_object" = none; then
    		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
    		  exit $EXIT_FAILURE
    		fi
    
    		# Extract subdirectory from the argument.
    		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
    		if test "X$xdir" = "X$arg"; then
    		  xdir=
    		else
    		  xdir="$xdir/"
    		fi
    
    		if test "$pic_object" != none; then
    		  # Prepend the subdirectory the object is found in.
    		  pic_object="$xdir$pic_object"
    
    		  if test "$prev" = dlfiles; then
    		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
    		      dlfiles="$dlfiles $pic_object"
    		      prev=
    		      continue
    		    else
    		      # If libtool objects are unsupported, then we need to preload.
    		      prev=dlprefiles
    		    fi
    		  fi
    
    		  # CHECK ME:  I think I busted this.  -Ossama
    		  if test "$prev" = dlprefiles; then
    		    # Preload the old-style object.
    		    dlprefiles="$dlprefiles $pic_object"
    		    prev=
    		  fi
    
    		  # A PIC object.
    		  libobjs="$libobjs $pic_object"
    		  arg="$pic_object"
    		fi
    
    		# Non-PIC object.
    		if test "$non_pic_object" != none; then
    		  # Prepend the subdirectory the object is found in.
    		  non_pic_object="$xdir$non_pic_object"
    
    		  # A standard non-PIC object
    		  non_pic_objects="$non_pic_objects $non_pic_object"
    		  if test -z "$pic_object" || test "$pic_object" = none ; then
    		    arg="$non_pic_object"
    		  fi
    		fi
    	      else
    		# Only an error if not doing a dry-run.
    		if test -z "$run"; then
    		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
    		  exit $EXIT_FAILURE
    		else
    		  # Dry-run case.
    
    		  # Extract subdirectory from the argument.
    		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
    		  if test "X$xdir" = "X$arg"; then
    		    xdir=
    		  else
    		    xdir="$xdir/"
    		  fi
    
    		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
    		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
    		  libobjs="$libobjs $pic_object"
    		  non_pic_objects="$non_pic_objects $non_pic_object"
    		fi
    	      fi
    	    done
    	  else
    	    $echo "$modename: link input file \`$save_arg' does not exist"
    	    exit $EXIT_FAILURE
    	  fi
    	  arg=$save_arg
    	  prev=
    	  continue
    	  ;;
    	rpath | xrpath)
    	  # We need an absolute path.
    	  case $arg in
    	  [\\/]* | [A-Za-z]:[\\/]*) ;;
    	  *)
    	    $echo "$modename: only absolute run-paths are allowed" 1>&2
    	    exit $EXIT_FAILURE
    	    ;;
    	  esac
    	  if test "$prev" = rpath; then
    	    case "$rpath " in
    	    *" $arg "*) ;;
    	    *) rpath="$rpath $arg" ;;
    	    esac
    	  else
    	    case "$xrpath " in
    	    *" $arg "*) ;;
    	    *) xrpath="$xrpath $arg" ;;
    	    esac
    	  fi
    	  prev=
    	  continue
    	  ;;
    	xcompiler)
    	  compiler_flags="$compiler_flags $qarg"
    	  prev=
    	  compile_command="$compile_command $qarg"
    	  finalize_command="$finalize_command $qarg"
    	  continue
    	  ;;
    	xlinker)
    	  linker_flags="$linker_flags $qarg"
    	  compiler_flags="$compiler_flags $wl$qarg"
    	  prev=
    	  compile_command="$compile_command $wl$qarg"
    	  finalize_command="$finalize_command $wl$qarg"
    	  continue
    	  ;;
    	xcclinker)
    	  linker_flags="$linker_flags $qarg"
    	  compiler_flags="$compiler_flags $qarg"
    	  prev=
    	  compile_command="$compile_command $qarg"
    	  finalize_command="$finalize_command $qarg"
    	  continue
    	  ;;
    	shrext)
      	  shrext_cmds="$arg"
    	  prev=
    	  continue
    	  ;;
    	*)
    	  eval "$prev=\"\$arg\""
    	  prev=
    	  continue
    	  ;;
    	esac
          fi # test -n "$prev"
    
          case $arg in
          -all-static)
    	if test -n "$link_static_flag"; then
    	  compile_command="$compile_command $link_static_flag"
    	  finalize_command="$finalize_command $link_static_flag"
    	fi
    	continue
    	;;
    
          -allow-undefined)
    	# FIXME: remove this flag sometime in the future.
    	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
    	continue
    	;;
    
          -avoid-version)
    	avoid_version=yes
    	continue
    	;;
    
          -dlpreopen)
    	prev=dlprefiles
    	continue
    	;;
    
          -export-dynamic)
    	export_dynamic=yes
    	continue
    	;;
    
          -export-symbols | -export-symbols-regex)
    	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
    	  $echo "$modename: more than one -exported-symbols argument is not allowed"
    	  exit $EXIT_FAILURE
    	fi
    	if test "X$arg" = "X-export-symbols"; then
    	  prev=expsyms
    	else
    	  prev=expsyms_regex
    	fi
    	continue
    	;;
    
          -inst-prefix-dir)
    	prev=inst_prefix
    	continue
    	;;
    
          # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
          # so, if we see these flags be careful not to treat them like -L
          -L[A-Z][A-Z]*:*)
    	case $with_gcc/$host in
    	no/*-*-irix* | /*-*-irix*)
    	  compile_command="$compile_command $arg"
    	  finalize_command="$finalize_command $arg"
    	  ;;
    	esac
    	continue
    	;;
    
          -L*)
    	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
    	# We need an absolute path.
    	case $dir in
    	[\\/]* | [A-Za-z]:[\\/]*) ;;
    	*)
    	  absdir=`cd "$dir" && pwd`
    	  if test -z "$absdir"; then
    	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
    
    	    exit $EXIT_FAILURE
    
    	  fi
    	  dir="$absdir"
    	  ;;
    	esac
    	case "$deplibs " in
    	*" -L$dir "*) ;;
    	*)
    	  deplibs="$deplibs -L$dir"
    	  lib_search_path="$lib_search_path $dir"
    	  ;;
    	esac
    	case $host in
    	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
    	  case :$dllsearchpath: in
    	  *":$dir:"*) ;;
    	  *) dllsearchpath="$dllsearchpath:$dir";;
    	  esac
    	  ;;
    	esac
    	continue
    	;;
    
          -l*)
    	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
    	  case $host in
    
    	  *-*-cygwin* | *-*-pw32* | *-*-beos*)
    
    	    # These systems don't actually have a C or math library (as such)
    	    continue
    	    ;;
    
    	  *-*-mingw* | *-*-os2*)
    
    	    # These systems don't actually have a C library (as such)
    	    test "X$arg" = "X-lc" && continue
    	    ;;
    
    	  *-*-openbsd* | *-*-freebsd*)
    
    	    # Do not include libc due to us having libc/libc_r.
    	    test "X$arg" = "X-lc" && continue
    	    ;;
    	  *-*-rhapsody* | *-*-darwin1.[012])
    	    # Rhapsody C and math libraries are in the System framework
    	    deplibs="$deplibs -framework System"
    	    continue
    	  esac
    	elif test "X$arg" = "X-lc_r"; then
    	 case $host in
    
    	 *-*-openbsd* | *-*-freebsd*)
    
    	   # Do not include libc_r directly, use -pthread flag.
    	   continue
    	   ;;
    	 esac
    	fi
    	deplibs="$deplibs $arg"
    	continue
    	;;
    
         -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
    
            case "$archive_cmds" in
                *"\$LD"*) ;;
                *) deplibs="$deplibs $arg";;
            esac
    
          # gcc -m* arguments should be passed to the linker via $compiler_flags
          # in order to pass architecture information to the linker
          # (e.g. 32 vs 64-bit).  This may also be accomplished via -Wl,-mfoo
          # but this is not reliable with gcc because gcc may use -mfoo to
          # select a different linker, different libraries, etc, while
          # -Wl,-mfoo simply passes -mfoo to the linker.
          -m*)
    
    	# 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
            compile_command="$compile_command $arg"
            finalize_command="$finalize_command $arg"
    
            if test "$with_gcc" = "yes" ; then
              compiler_flags="$compiler_flags $arg"
            fi
    
          -no-fast-install)
    	fast_install=no
    	continue
    	;;
    
          -no-install)
    	case $host in
    	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
    	  # The PATH hackery in wrapper scripts is required on Windows
    	  # in order for the loader to find any dlls it needs.
    	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
    	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
    	  fast_install=no
    	  ;;
    	*) no_install=yes ;;
    	esac
    	continue
    	;;
    
          -no-undefined)
    	allow_undefined=no
    	continue
    	;;
    
          -objectlist)
    	prev=objectlist
    	continue
    	;;
    
          -precious-files-regex)
    	prev=precious_regex
    	continue
    	;;
    
          -R*)
    	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
    	# We need an absolute path.
    	case $dir in
    	[\\/]* | [A-Za-z]:[\\/]*) ;;
    	*)
    	  $echo "$modename: only absolute run-paths are allowed" 1>&2
    	  exit $EXIT_FAILURE
    	  ;;
    	esac
    	case "$xrpath " in
    	*" $dir "*) ;;
    	*) xrpath="$xrpath $dir" ;;
    	esac
    	continue
    
    	# The effects of -static are defined in a previous loop.
    	# We used to do the same as -all-static on platforms that
    	# didn't have a PIC flag, but the assumption that the effects
    	# would be equivalent was wrong.  It would break on at least
    	# Digital Unix and AIX.
    	continue
    
          -thread-safe)
    	thread_safe=yes
    
          -version-info)
    	prev=vinfo
    	continue
    	;;
          -version-number)
    	prev=vinfo
    	vinfo_number=yes
    	continue
    	;;
    
          -Wc,*)
    	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
    	arg=
    	save_ifs="$IFS"; IFS=','
    	for flag in $args; do
    	  IFS="$save_ifs"
    	  case $flag in
    	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
    	    flag="\"$flag\""
    	    ;;
    	  esac
    	  arg="$arg $wl$flag"
    	  compiler_flags="$compiler_flags $flag"
    	done
    	IFS="$save_ifs"
    	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
    	;;
    
          -Wl,*)
    	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
    	arg=
    	save_ifs="$IFS"; IFS=','
    	for flag in $args; do
    	  IFS="$save_ifs"
    	  case $flag in
    	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
    	    flag="\"$flag\""
    	    ;;
    	  esac
    	  arg="$arg $wl$flag"
    	  compiler_flags="$compiler_flags $wl$flag"
    	  linker_flags="$linker_flags $flag"
    	done
    	IFS="$save_ifs"
    	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
    	;;
    
          -Xcompiler)
    	prev=xcompiler
    	continue
    
          -XCClinker)
    	prev=xcclinker
    	continue
    	;;
    
          # 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
    	;;
    
          *.$objext)
    	# A standard object.
    	objs="$objs $arg"
    	;;
    
          *.lo)
    	# A libtool-controlled object.
    
    	# Check to see that this really is a libtool object.
    	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
    	  pic_object=
    	  non_pic_object=
    
    	  # Read the .lo file
    	  # If there is no directory component, then add one.
    	  case $arg in
    	  */* | *\\*) . $arg ;;
    	  *) . ./$arg ;;
    	  esac
    
    	  if test -z "$pic_object" || \
    	     test -z "$non_pic_object" ||
    	     test "$pic_object" = none && \
    	     test "$non_pic_object" = none; then
    	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
    	    exit $EXIT_FAILURE
    	  fi
    
    	  # Extract subdirectory from the argument.
    	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
    	  if test "X$xdir" = "X$arg"; then
    	    xdir=
     	  else
    	    xdir="$xdir/"
    	  fi
    
    	  if test "$pic_object" != none; then
    	    # Prepend the subdirectory the object is found in.
    	    pic_object="$xdir$pic_object"
    
    	    if test "$prev" = dlfiles; then
    	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
    		dlfiles="$dlfiles $pic_object"
    		prev=
    		continue
    	      else
    		# If libtool objects are unsupported, then we need to preload.
    		prev=dlprefiles
    	      fi
    	    fi
    
    	    # CHECK ME:  I think I busted this.  -Ossama
    	    if test "$prev" = dlprefiles; then
    	      # Preload the old-style object.
    	      dlprefiles="$dlprefiles $pic_object"
    	      prev=
    	    fi
    
    	    # A PIC object.
    	    libobjs="$libobjs $pic_object"
    	    arg="$pic_object"
    	  fi
    
    	  # Non-PIC object.
    	  if test "$non_pic_object" != none; then
    	    # Prepend the subdirectory the object is found in.
    	    non_pic_object="$xdir$non_pic_object"
    
    	    # A standard non-PIC object
    	    non_pic_objects="$non_pic_objects $non_pic_object"
    	    if test -z "$pic_object" || test "$pic_object" = none ; then
    	      arg="$non_pic_object"
    	    fi
    	  fi
    	else
    	  # Only an error if not doing a dry-run.
    	  if test -z "$run"; then
    	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
    	    exit $EXIT_FAILURE
    	  else
    	    # Dry-run case.
    
    	    # Extract subdirectory from the argument.
    	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
    	    if test "X$xdir" = "X$arg"; then
    	      xdir=
    	    else
    	      xdir="$xdir/"
    	    fi
    
    	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
    	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
    	    libobjs="$libobjs $pic_object"
    	    non_pic_objects="$non_pic_objects $non_pic_object"
    	  fi
    	fi
    
    
          *.$libext)
    	# An archive.
    	deplibs="$deplibs $arg"
    	old_deplibs="$old_deplibs $arg"
    
    
          *.la)
    	# A libtool-controlled library.
    
    	if test "$prev" = dlfiles; then
    	  # This library was specified with -dlopen.
    	  dlfiles="$dlfiles $arg"
    	  prev=
    	elif test "$prev" = dlprefiles; then
    	  # The library was specified with -dlpreopen.
    	  dlprefiles="$dlprefiles $arg"
    
    	  deplibs="$deplibs $arg"
    
          # Some other compiler argument.
          *)
    	# 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
    	;;
          esac # arg
    
          # Now actually substitute the argument into the commands.
          if test -n "$arg"; then
    	compile_command="$compile_command $arg"
    	finalize_command="$finalize_command $arg"
          fi
        done # argument parsing loop
    
        if test -n "$prev"; then
          $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
          $echo "$help" 1>&2
          exit $EXIT_FAILURE
        fi
    
        if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
          eval arg=\"$export_dynamic_flag_spec\"
          compile_command="$compile_command $arg"
          finalize_command="$finalize_command $arg"
    
        oldlibs=
        # calculate the name of the file, without its directory
        outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
        libobjs_save="$libobjs"
    
        if test -n "$shlibpath_var"; then
          # get the directories listed in $shlibpath_var
          eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
    
          shlib_search_path=
        fi
        eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
        eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
    
        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"
    
        # Create the object directory.
        if test ! -d "$output_objdir"; then
          $show "$mkdir $output_objdir"
          $run $mkdir $output_objdir
    
          status=$?
          if test "$status" -ne 0 && test ! -d "$output_objdir"; then
    	exit $status
    
          fi
        fi
    
        # Determine the type of output
        case $output in
        "")
          $echo "$modename: you must specify an output file" 1>&2
          $echo "$help" 1>&2
          exit $EXIT_FAILURE
    
        *.$libext) linkmode=oldlib ;;
        *.lo | *.$objext) linkmode=obj ;;
        *.la) linkmode=lib ;;
        *) linkmode=prog ;; # Anything else should be a program.
    
        case $host in
        *cygwin* | *mingw* | *pw32*)
          # don't eliminate duplications in $postdeps and $predeps
          duplicate_compiler_generated_deps=yes
          ;;
        *)
          duplicate_compiler_generated_deps=$duplicate_deps
          ;;
        esac
        specialdeplibs=
    
        libs=
        # Find all interdependent deplibs by searching for libraries
        # that are linked more than once (e.g. -la -lb -la)
        for deplib in $deplibs; do
          if test "X$duplicate_deps" = "Xyes" ; then
    	case "$libs " in
    	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
    	esac
          fi
          libs="$libs $deplib"
        done
    
        if test "$linkmode" = lib; then
          libs="$predeps $libs $compiler_lib_search_path $postdeps"
    
          # Compute libraries that are listed more than once in $predeps
          # $postdeps and mark them as special (i.e., whose duplicates are
          # not to be eliminated).
          pre_post_deps=
          if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
    	for pre_post_dep in $predeps $postdeps; do
    	  case "$pre_post_deps " in
    	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
    
    	  pre_post_deps="$pre_post_deps $pre_post_dep"
    	done
          fi
          pre_post_deps=
        fi
    
        deplibs=
        newdependency_libs=
        newlib_search_path=
        need_relink=no # whether we're linking any uninstalled libtool libraries
        notinst_deplibs= # not-installed libtool libraries
    
        notinst_path= # paths that contain not-installed libtool libraries
    
        case $linkmode in
        lib)
    	passes="conv link"
    	for file in $dlfiles $dlprefiles; do
    	  case $file in
    	  *.la) ;;
    	  *)
    	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
    	    exit $EXIT_FAILURE
    
        prog)
    	compile_deplibs=
    	finalize_deplibs=
    	alldeplibs=no
    	newdlfiles=
    	newdlprefiles=
    	passes="conv scan dlopen dlpreopen link"
    
        *)  passes="conv"
    	;;
        esac
        for pass in $passes; do
          if test "$linkmode,$pass" = "lib,link" ||
    	 test "$linkmode,$pass" = "prog,scan"; then
    	libs="$deplibs"
    	deplibs=
          fi
          if test "$linkmode" = prog; then
    	case $pass in
    	dlopen) libs="$dlfiles" ;;
    	dlpreopen) libs="$dlprefiles" ;;
    	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
    
          fi
          if test "$pass" = dlopen; then
    	# Collect dlpreopened libraries
    	save_deplibs="$deplibs"
    	deplibs=
          fi
          for deplib in $libs; do
    	lib=
    	found=no
    	case $deplib in
    	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
    	  if test "$linkmode,$pass" = "prog,link"; then
    	    compile_deplibs="$deplib $compile_deplibs"
    	    finalize_deplibs="$deplib $finalize_deplibs"
    	  else
    
                  case "$archive_cmds" in
                    *"\$LD"*) ;;
                    *) deplibs="$deplib $deplibs";;
                  esac
    
    	  fi
    	  continue
    	  ;;
    	-l*)
    	  if test "$linkmode" != lib && test "$linkmode" != prog; then
    	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
    	    continue
    	  fi
    
    	  if test "$pass" = conv; then
    	    deplibs="$deplib $deplibs"
    	    continue
    	  fi
    
    	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
    	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
    	    for search_ext in .la $std_shrext .so .a; do