Skip to content
Snippets Groups Projects
ltmain.sh 179 KiB
Newer Older
  • Learn to ignore specific revisions
  • 	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
    	  fi
    	done
    
    	# If -module or -export-dynamic was specified, set the dlname.
    	if test "$module" = yes || test "$export_dynamic" = yes; then
    	  # On all known operating systems, these are identical.
    	  dlname="$soname"
    	fi
          fi
          ;;
    
        obj)
          if test -n "$deplibs"; then
    	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
          fi
    
          if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
    	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
          fi
    
          if test -n "$rpath"; then
    	$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
          fi
    
          if test -n "$vinfo"; then
    	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
          fi
    
          if test -n "$release"; then
    	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
          fi
    
          case $output in
          *.lo)
    	if test -n "$objs$old_deplibs"; then
    	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
    	  exit $EXIT_FAILURE
    	fi
    	libobj="$output"
    	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
    	;;
          *)
    	libobj=
    	obj="$output"
    	;;
          esac
    
          # Delete the old objects.
          $run $rm $obj $libobj
    
          # Objects from convenience libraries.  This assumes
          # single-version convenience libraries.  Whenever we create
          # different ones for PIC/non-PIC, this we'll have to duplicate
          # the extraction.
          reload_conv_objs=
          gentop=
          # reload_cmds runs $LD directly, so let us get rid of
    
          # -Wl from whole_archive_flag_spec
    
          if test -n "$convenience"; then
    	if test -n "$whole_archive_flag_spec"; then
    
    	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
    
    	else
    	  gentop="$output_objdir/${obj}x"
    	  generated="$generated $gentop"
    
    	  func_extract_archives $gentop $convenience
    	  reload_conv_objs="$reload_objs $func_extract_archives_result"
    	fi
          fi
    
          # Create the old-style object.
          reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
    
          output="$obj"
          cmds=$reload_cmds
          save_ifs="$IFS"; IFS='~'
          for cmd in $cmds; do
    	IFS="$save_ifs"
    	eval cmd=\"$cmd\"
    	$show "$cmd"
    	$run eval "$cmd" || exit $?
          done
          IFS="$save_ifs"
    
          # Exit if we aren't doing a library object file.
          if test -z "$libobj"; then
    	if test -n "$gentop"; then
    	  $show "${rm}r $gentop"
    	  $run ${rm}r $gentop
    	fi
    
          if test "$build_libtool_libs" != yes; then
    	if test -n "$gentop"; then
    	  $show "${rm}r $gentop"
    	  $run ${rm}r $gentop
    	fi
    
    	# 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 $EXIT_SUCCESS
          fi
    
          if test -n "$pic_flag" || test "$pic_mode" != default; then
    	# Only do commands if we really have different PIC objects.
    	reload_objs="$libobjs $reload_conv_objs"
    	output="$libobj"
    	cmds=$reload_cmds
    	save_ifs="$IFS"; IFS='~'
    	for cmd in $cmds; do
    	  IFS="$save_ifs"
    	  eval cmd=\"$cmd\"
    	  $show "$cmd"
    	  $run eval "$cmd" || exit $?
    	done
    	IFS="$save_ifs"
          fi
    
          if test -n "$gentop"; then
    	$show "${rm}r $gentop"
    	$run ${rm}r $gentop
          fi
    
        prog)
          case $host in
    	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
          esac
          if test -n "$vinfo"; then
    	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
          fi
    
          if test -n "$release"; then
    	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
          fi
    
          if test "$preload" = yes; then
    	if test "$dlopen_support" = 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
    
          case $host in
          *-*-rhapsody* | *-*-darwin1.[012])
    	# On Rhapsody replace the C library is the System framework
    	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
    	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
    	;;
          esac
    
          case $host in
          *darwin*)
            # Don't allow lazy linking, it breaks C++ global constructors
            if test "$tagname" = CXX ; then
            compile_command="$compile_command ${wl}-bind_at_load"
            finalize_command="$finalize_command ${wl}-bind_at_load"
            fi
            ;;
          esac
    
          compile_command="$compile_command $compile_deplibs"
          finalize_command="$finalize_command $finalize_deplibs"
    
          if test -n "$rpath$xrpath"; then
    	# If the user specified any rpath flags, then add them.
    	for libdir in $rpath $xrpath; do
    	  # This is the magic to use -rpath.
    	  case "$finalize_rpath " in
    	  *" $libdir "*) ;;
    	  *) finalize_rpath="$finalize_rpath $libdir" ;;
    	  esac
    	done
          fi
    
          # 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
    	case $host in
    	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
    	  case :$dllsearchpath: in
    	  *":$libdir:"*) ;;
    	  *) dllsearchpath="$dllsearchpath:$libdir";;
    	  esac
    	  ;;
    	esac
          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\"
          fi
          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\"
    	    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\"
          fi
          finalize_rpath="$rpath"
    
          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
    
          dlsyms=
          if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
    	if test -n "$NM" && test -n "$global_symbol_pipe"; then
    	  dlsyms="${outputname}S.c"
    	else
    	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
    	fi
          fi
    
          if test -n "$dlsyms"; then
    	case $dlsyms in
    	"") ;;
    	*.c)
    	  # Discover the nlist of each of the dlfiles.
    	  nlist="$output_objdir/${outputname}.nm"
    
    	  $show "$rm $nlist ${nlist}S ${nlist}T"
    	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
    
    	  # Parse the name list into a source file.
    	  $show "creating $output_objdir/$dlsyms"
    
    	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
    /* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
    /* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
    
    #ifdef __cplusplus
    extern \"C\" {
    #endif
    
    /* Prevent the only kind of declaration conflicts we can make. */
    #define lt_preloaded_symbols some_other_symbol
    
    /* External symbol declarations for the compiler. */\
    "
    
    	  if test "$dlself" = yes; then
    	    $show "generating symbol list for \`$output'"
    
    	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
    
    	    # Add our own program objects to the symbol list.
    	    progfiles=`$echo "X$objs$old_deplibs" | $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="$output_objdir/$output.exp"
    
    	      $run $rm $export_symbols
    
    	      $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
    
    	      $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
    	      $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
    
    	      $run eval 'mv "$nlist"T "$nlist"'
    	    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"
    
    
    	    # Try sorting and uniquifying the output.
    	    if grep -v "^: " < "$nlist" |
    		if sort -k 3 </dev/null >/dev/null 2>&1; then
    		  sort -k 3
    		else
    		  sort +2
    		fi |
    		uniq > "$nlist"S; then
    	      :
    
    	      grep -v "^: " < "$nlist" > "$nlist"S
    
    
    	    if test -f "$nlist"S; then
    	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
    
    	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
    
    	    $echo >> "$output_objdir/$dlsyms" "\
    
    #undef lt_preloaded_symbols
    
    #if defined (__STDC__) && __STDC__
    # define lt_ptr void *
    #else
    # define lt_ptr char *
    # define const
    #endif
    
    /* The mapping between symbol names and symbols. */
    const struct {
      const char *name;
      lt_ptr address;
    }
    lt_preloaded_symbols[] =
    {\
    "
    
    	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
    
    	    $echo >> "$output_objdir/$dlsyms" "\
      {0, (lt_ptr) 0}
    };
    
    /* This works around a problem in FreeBSD linker */
    #ifdef FREEBSD_WORKAROUND
    static const void *lt_preloaded_setup() {
      return lt_preloaded_symbols;
    }
    #endif
    
    #ifdef __cplusplus
    }
    #endif\
    "
    
    
    	  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*|*-*-freebsdelf3.0*)
    	    case "$compile_command " in
    	    *" -static "*) ;;
    	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
    	    esac;;
    	  *-*-hpux*)
    	    case "$compile_command " in
    	    *" -static "*) ;;
    	    *) pic_flag_for_symtable=" $pic_flag";;
    
    	  esac
    
    	  # Now compile the dynamic symbol file.
    
    	  $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
    	  $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
    
    
    	  # Clean up the generated files.
    	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
    	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
    
    	  # Transform the symbol file into the correct name.
    
    	  compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
    	  finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
    
    	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
    	  exit $EXIT_FAILURE
    
          else
    	# 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.
    
    	# Nullify the symbol file.
    
    	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
    	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
    
          if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
    	# 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"
    
    	# Delete the generated files.
    	if test -n "$dlsyms"; then
    	  $show "$rm $output_objdir/${outputname}S.${objext}"
    	  $run $rm "$output_objdir/${outputname}S.${objext}"
    	fi
    
          if test -n "$shlibpath_var"; then
    	# 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"
          fi
    
          if test -n "$compile_shlibpath$finalize_shlibpath"; then
    	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
          fi
          if test -n "$finalize_shlibpath"; then
    	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
          fi
    
          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\" "
    
    	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\" "
    
          if test "$no_install" = yes; then
    	# We don't need to create a wrapper script.
    	link_command="$compile_var$compile_command$compile_rpath"
    	# Replace the output file specification.
    	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
    	# Delete the old output file.
    	$run $rm $output
    	# Link the executable and exit
    	$show "$link_command"
    	$run eval "$link_command" || exit $?
    	exit $EXIT_SUCCESS
          fi
    
          if test "$hardcode_action" = relink; then
    	# Fast installation is not supported
    	link_command="$compile_var$compile_command$compile_rpath"
    	relink_command="$finalize_var$finalize_command$finalize_rpath"
    
    	$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'`
    
    	    # fast_install is set to needless
    	    relink_command=
    
    	else
    	  link_command="$compile_var$compile_command$compile_rpath"
    	  relink_command="$finalize_var$finalize_command$finalize_rpath"
    
          # Replace the output file specification.
          link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
    
          # Delete the old output files.
          $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
    
          $show "$link_command"
          $run eval "$link_command" || exit $?
    
          # Now create the wrapper script.
          $show "creating $output"
    
          # Quote the relink command for shipping.
          if test -n "$relink_command"; then
    	# Preserve any variables that may affect compiler behavior
    	for var in $variables_saved_for_relink; do
    	  if eval test -z \"\${$var+set}\"; then
    	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
    	  elif eval var_value=\$$var; test -z "$var_value"; then
    	    relink_command="$var=; export $var; $relink_command"
    	  else
    	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
    	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
    	  fi
    	done
    	relink_command="(cd `pwd`; $relink_command)"
    
    	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
    
          # Quote $echo for shipping.
          if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
    	case $progpath in
    	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
    	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
    	esac
    	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
          else
    	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
          fi
    
          # Only actually do things if our run command is non-null.
          if test -z "$run"; then
    	# 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
    	# test for cygwin because mv fails w/o .exe extensions
    
    	case $host in
    
    	  *cygwin*)
    	    exeext=.exe
    	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
    	  *) exeext= ;;
    
    	case $host in
    	  *cygwin* | *mingw* )
    
    	    cwrappersource=`$echo ${objdir}/lt-${output}.c`
    	    cwrapper=`$echo ${output}.exe`
    	    $rm $cwrappersource $cwrapper
    	    trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
    
    	    cat > $cwrappersource <<EOF
    
    /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
       Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
    
       The $output program cannot be directly executed until all the libtool
       libraries that it depends on are installed.
    
       This wrapper executable should never be moved out of the build directory.
       If it is, it will not operate correctly.
    
       Currently, it simply execs the wrapper *script* "/bin/sh $output",
       but could eventually absorb all of the scripts functionality and
       exec $objdir/$outputname directly.
    */
    EOF
    	    cat >> $cwrappersource<<"EOF"
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <malloc.h>
    #include <stdarg.h>
    #include <assert.h>
    
    #if defined(PATH_MAX)
    # define LT_PATHMAX PATH_MAX
    #elif defined(MAXPATHLEN)
    # define LT_PATHMAX MAXPATHLEN
    #else
    # define LT_PATHMAX 1024
    #endif
    
    #ifndef DIR_SEPARATOR
    
    #define DIR_SEPARATOR '/'
    
    #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
      defined (__OS2__)
    
    #define HAVE_DOS_BASED_FILE_SYSTEM
    #ifndef DIR_SEPARATOR_2
    #define DIR_SEPARATOR_2 '\\'
    #endif
    
    #ifndef DIR_SEPARATOR_2
    # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
    #else /* DIR_SEPARATOR_2 */
    # define IS_DIR_SEPARATOR(ch) \
            (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
    #endif /* DIR_SEPARATOR_2 */
    
    #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
    #define XFREE(stale) do { \
      if (stale) { free ((void *) stale); stale = 0; } \
    } while (0)
    
    const char *program_name = NULL;
    
    void * xmalloc (size_t num);
    char * xstrdup (const char *string);
    
    char * basename (const char *name);
    char * fnqualify(const char *path);
    
    char * strendzap(char *str, const char *pat);
    void lt_fatal (const char *message, ...);
    
    int
    main (int argc, char *argv[])
    {
      char **newargz;
      int i;
    
      program_name = (char *) xstrdup ((char *) basename (argv[0]));
    
      newargz = XMALLOC(char *, argc+2);
    EOF
    
    	    cat >> $cwrappersource <<EOF
      newargz[0] = "$SHELL";
    
    	    cat >> $cwrappersource <<"EOF"
      newargz[1] = fnqualify(argv[0]);
    
      /* we know the script has the same name, without the .exe */
      /* so make sure newargz[1] doesn't end in .exe */
      strendzap(newargz[1],".exe");
      for (i = 1; i < argc; i++)
        newargz[i+1] = xstrdup(argv[i]);
      newargz[argc+1] = NULL;
    EOF
    
    	    cat >> $cwrappersource <<EOF
    
      execv("$SHELL",newargz);
    EOF
    
    	    cat >> $cwrappersource <<"EOF"
    
    void *
    xmalloc (size_t num)
    {
      void * p = (void *) malloc (num);
      if (!p)
        lt_fatal ("Memory exhausted");
    
    char *
    xstrdup (const char *string)
    {
      return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
    ;
    }
    
    char *
    basename (const char *name)
    
    #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
      /* Skip over the disk name in MSDOS pathnames. */
    
      if (isalpha (name[0]) && name[1] == ':')
    
      for (base = name; *name; name++)
        if (IS_DIR_SEPARATOR (*name))
          base = name + 1;
    
      return (char *) base;
    
    fnqualify(const char *path)
    
      char tmp[LT_PATHMAX + 1];
    
      assert(path != NULL);
    
      /* Is it qualified already? */
    
    #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
    
      if (isalpha (path[0]) && path[1] == ':')
        return xstrdup (path);
    
      if (IS_DIR_SEPARATOR (path[0]))
        return xstrdup (path);
    
      /* prepend the current directory */
      /* doesn't handle '~' */
    
      if (getcwd (tmp, LT_PATHMAX) == NULL)
        lt_fatal ("getcwd failed");
    
      size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
      p = XMALLOC(char, size);
      sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path);
      return p;
    
    }
    
    char *
    strendzap(char *str, const char *pat)
    {
      size_t len, patlen;
    
      assert(str != NULL);
      assert(pat != NULL);
    
      len = strlen(str);
      patlen = strlen(pat);
    
      if (patlen <= len)
      {
        str += len - patlen;
        if (strcmp(str, pat) == 0)
          *str = '\0';
      }
      return str;
    }
    
    static void
    lt_error_core (int exit_status, const char * mode,
              const char * message, va_list ap)
    {
      fprintf (stderr, "%s: %s: ", program_name, mode);
      vfprintf (stderr, message, ap);
      fprintf (stderr, ".\n");
    
      if (exit_status >= 0)
        exit (exit_status);
    }
    
    void
    lt_fatal (const char *message, ...)
    {
      va_list ap;
      va_start (ap, message);
      lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
      va_end (ap);
    }
    EOF
    
    	  # we should really use a build-platform specific compiler
    	  # here, but OTOH, the wrappers (shell script and this C one)
    	  # are only useful if you want to execute the "real" binary.
    	  # Since the "real" binary is built for $host, then this
    	  # wrapper might as well be built for $host, too.
    	  $run $LTCC -s -o $cwrapper $cwrappersource
    	  ;;
    	esac
    	$rm $output
    	trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
    
    	$echo > $output "\
    #! $SHELL
    
    # $output - temporary wrapper script for $objdir/$outputname
    # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
    #
    # The $output program cannot be directly executed until all the libtool
    # libraries that it depends on are installed.
    #
    # This wrapper script should never be moved out of the build directory.
    # If it is, it will not operate correctly.
    
    # Sed substitution that helps us do robust quoting.  It backslashifies
    # metacharacters that are still active within double-quoted strings.
    Xsed='${SED} -e 1s/^X//'
    sed_quote_subst='$sed_quote_subst'
    
    # The HP-UX ksh and POSIX shell print the target directory to stdout
    # if CDPATH is set.
    (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
    
    relink_command=\"$relink_command\"
    
    # This environment variable determines our operation mode.
    if test \"\$libtool_install_magic\" = \"$magic\"; then
      # install mode needs the following variable:
      notinst_deplibs='$notinst_deplibs'
    else
      # When we are sourced in execute mode, \$file and \$echo are already set.
      if test \"\$libtool_execute_magic\" != \"$magic\"; then
        echo=\"$qecho\"
        file=\"\$0\"
        # 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
      fi\
    "
    	$echo >> $output "\
    
      # 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
          [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
          *) thisdir=\"\$thisdir/\$destdir\" ;;
          esac
        fi
    
        file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
        file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
      done
    
      # Try to get the absolute directory name.
      absdir=\`cd \"\$thisdir\" && pwd\`
      test -n \"\$absdir\" && thisdir=\"\$absdir\"
    "
    
    	if test "$fast_install" = yes; then
    	  $echo >> $output "\
      program=lt-'$outputname'$exeext
      progdir=\"\$thisdir/$objdir\"
    
      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"
    
        # relink executable if necessary
        if test -n \"\$relink_command\"; then
          if relink_command_output=\`eval \$relink_command 2>&1\`; then :
          else
    	$echo \"\$relink_command_output\" >&2
    	$rm \"\$progdir/\$file\"
    	exit $EXIT_FAILURE
          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
    
      if test -f \"\$progdir/\$program\"; then"
    
    	# 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 "\
        # Add our own library path to $shlibpath_var
        $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
    
        # Some systems cannot cope with colon-terminated $shlibpath_var
        # The second colon is a workaround for a bug in BeOS R4 sed
        $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
    
    	# 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
    "
    
    	$echo >> $output "\
        if test \"\$libtool_execute_magic\" != \"$magic\"; then
          # Run the actual program with our arguments.
    "
    	case $host in
    	# Backslashes separate directories on plain windows
    	*-*-mingw | *-*-os2*)
    	  $echo >> $output "\
    
          exec \$progdir\\\\\$program \${1+\"\$@\"}
    
          exec \$progdir/\$program \${1+\"\$@\"}
    
          \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
    
          exit $EXIT_FAILURE
        fi
      else
        # The program doesn't exist.
    
        \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2