Added some support for cross-compilation using mingw32.

diff --git a/Make.rules.in b/Make.rules.in
index 54a7907..6dbd8c5 100644
--- a/Make.rules.in
+++ b/Make.rules.in
@@ -37,18 +37,23 @@
 YACC      = @YACC@
 LEX       = @LEX@
 LEXLIB    = @LEXLIB@
+EXEEXT    = @EXEEXT@
+OBJEXT    = @OBJEXT@
 LIBEXT    = @LIBEXT@
 DLLEXT    = @DLLEXT@
 LDSHARED  = @LDSHARED@
 DLLWRAP   = @DLLWRAP@
 DLLWRAPFLAGS = --add-stdcall-alias
+AR        = @AR@ rc
 RANLIB    = @RANLIB@
+STRIP     = @STRIP@
+WINDRES   = @WINDRES@
 LN_S      = @LN_S@
+TOOLSDIR  = @TOOLSDIR@
 DIVINCL   = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
 LDCOMBINE = @LDCOMBINE@
 LDFLAGS   = @LDFLAGS@
-AR        = ar rc
 RM        = rm -f
 MV        = mv
 C2MAN     = @C2MAN@
@@ -62,10 +67,10 @@
 ALLLINTFLAGS = $(LINTFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL)
 MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs
 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
-WINEBUILD = $(TOPOBJDIR)/tools/winebuild/winebuild
-MAKEDEP   = $(TOPOBJDIR)/tools/makedep
-WRC       = $(TOPOBJDIR)/tools/wrc/wrc
-WMC       = $(TOPOBJDIR)/tools/wmc/wmc
+WINEBUILD    = $(TOOLSDIR)/tools/winebuild/winebuild
+MAKEDEP      = $(TOOLSDIR)/tools/makedep
+WRC          = $(TOOLSDIR)/tools/wrc/wrc
+WMC          = $(TOOLSDIR)/tools/wmc/wmc
 LDPATH    = @LDPATH@
 DLLDIR    = $(TOPOBJDIR)/dlls
 LIBWINE   = -L$(TOPOBJDIR)/library -lwine
@@ -100,7 +105,7 @@
 prog_manext     = 1
 conf_manext     = 5
 includedir      = @includedir@/wine
-CLEAN_FILES     = *.o *.a *.so *.ln \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
+CLEAN_FILES     = *.o *.a *.so *.ln *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
                   *.flc *.spec.c *.spec.def *.glue.c y.tab.c y.tab.h @LEX_OUTPUT_ROOT@.c core
 
 OBJS = $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) \
@@ -110,7 +115,7 @@
 
 # Implicit rules
 
-.SUFFIXES: .mc .rc .mc.rc .res .spec .spec.c .spec.def .glue.c .pl .ok
+.SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .glue.c .pl .ok
 
 .c.o:
 	$(CC) -c $(ALLCFLAGS) -o $@ $<
@@ -127,11 +132,14 @@
 .rc.res:
 	$(LDPATH) $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
 
+.res.res.o:
+	$(WINDRES) -i $< -o $@
+
 .spec.spec.c:
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) -o $@ -spec $<
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -o $@ -spec $<
 
 .spec.spec.def:
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) -o $@ -def $<
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -o $@ -def $<
 
 .c.glue.c:
 	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -o $@ -glue $<
@@ -158,27 +166,27 @@
 
 $(MODULE).tmp.o: $(SPEC_SRCS:.spec=.spec.o) $(OBJS) Makefile.in
 	$(LDCOMBINE) $(SPEC_SRCS:.spec=.spec.o) $(OBJS) -o $@
-	-strip --strip-unneeded $@
+	-$(STRIP) --strip-unneeded $@
 
 # Rule to rebuild the resource compiler
 
 $(WRC):
-	cd $(TOPOBJDIR)/tools/wrc && $(MAKE) wrc
+	cd $(TOOLSDIR)/tools/wrc && $(MAKE) wrc
 
 # Rule to rebuild the message compiler
 
 $(WMC):
-	cd $(TOPOBJDIR)/tools/wmc && $(MAKE) wmc
+	cd $(TOOLSDIR)/tools/wmc && $(MAKE) wmc
 
 # Rule to rebuild the 'makedep' program
 
 $(MAKEDEP):
-	cd $(TOPOBJDIR)/tools && $(MAKE) makedep
+	cd $(TOOLSDIR)/tools && $(MAKE) makedep
 
 # Rule to rebuild the 'winebuild' program
 
 $(WINEBUILD):
-	cd $(TOPOBJDIR)/tools/winebuild && $(MAKE) winebuild
+	cd $(TOOLSDIR)/tools/winebuild && $(MAKE) winebuild
 
 # Rules for makefile
 
@@ -241,7 +249,7 @@
 	$(RM) $(TESTRESULTS)
 
 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
-	$(RM) $(CLEAN_FILES) $(GEN_C_SRCS) $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res) $(MC_SRCS:.mc=.mc.rc) $(TESTRESULTS) $(TESTLIST) $(PROGRAMS)
+	$(RM) $(CLEAN_FILES) $(GEN_C_SRCS) $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res) $(MC_SRCS:.mc=.mc.rc) $(TESTRESULTS) $(TESTLIST) $(TESTPROGRAM)$(EXEEXT) $(PROGRAMS)
 
 # Rules for installing
 
@@ -259,7 +267,7 @@
 	@cd `dirname $@` && $(MAKE) test
 
 $(PLTESTS:.c=.ok): $(WINETEST)
-$(CTESTS:.c=.ok): $(TESTPROGRAM).so
+$(CTESTS:.c=.ok): $(TESTPROGRAM)$(EXEEXT)
 
 $(WINETEST):
 	cd $(TOPOBJDIR)/programs/winetest && $(MAKE) winetest
@@ -270,16 +278,22 @@
 $(TESTLIST): Makefile.in
 	$(TOPSRCDIR)/programs/winetest/make_ctests $(CTESTS) >$(TESTLIST) || $(RM) $(TESTLIST)
 
+$(TESTPROGRAM): $(TESTPROGRAM).so
+	$(RM) $(TESTPROGRAM) && cd tests && $(LN_S) $(TOPOBJDIR)/../wine `basename $(TESTPROGRAM)`
+
 $(TESTPROGRAM).so: $(TESTPROGRAM).spec.o $(TESTOBJS)
 	$(LDSHARED) $(LDDLLFLAGS) $(TESTPROGRAM).spec.o $(TESTOBJS) -o $@ $(LIBWINE) $(LIBS)
 
 $(TESTPROGRAM).tmp.o: $(TESTOBJS)
 	$(LDCOMBINE) $(TESTOBJS) -o $@
-	-strip --strip-unneeded $@
+	-$(STRIP) --strip-unneeded $@
 
 $(TESTPROGRAM).spec.c: $(TESTPROGRAM).tmp.o $(WINEBUILD)
 	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym $(TESTPROGRAM).tmp.o -o $@ -exe $(TESTPROGRAM) -mcui -L$(DLLDIR) $(TESTIMPORTS:%=-l%)
 
+$(TESTPROGRAM).exe: $(TESTOBJS)
+	$(CC) $(TESTOBJS) -o $@ $(TESTIMPORTS:%=-l%) $(LIBWINE) $(LIBS)
+
 # Misc. rules
 
 $(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD)
diff --git a/configure b/configure
index 5aad81d..60fc401 100755
--- a/configure
+++ b/configure
@@ -820,7 +820,6 @@
 System types:
   --build=BUILD     configure for building on BUILD [guessed]
   --host=HOST       cross-compile to build programs to run on HOST [BUILD]
-  --target=TARGET   configure for building compilers for TARGET [HOST]
 _ACEOF
 fi
 
@@ -842,6 +841,7 @@
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --without-curses        do not use curses
+  --with-wine-tools=<dir> use Wine tools from directory <dir>
   --with-x                use the X Window System
 
 Some influential environment variables:
@@ -1265,6 +1265,12 @@
 
 fi;
 
+# Check whether --with-wine-tools or --without-wine-tools was given.
+if test "${with_wine_tools+set}" = set; then
+  withval="$with_wine_tools"
+
+fi;
+
 
 if test "x$enable_debug" = "xno"
 then
@@ -1338,34 +1344,6 @@
 host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 
 
-echo "$as_me:$LINENO: checking target system type" >&5
-echo $ECHO_N "checking target system type... $ECHO_C" >&6
-if test "${ac_cv_target+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_cv_target_alias=$target_alias
-test "x$ac_cv_target_alias" = "x" &&
-  ac_cv_target_alias=$ac_cv_host_alias
-ac_cv_target=`$ac_config_sub $ac_cv_target_alias` ||
-  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_target_alias failed" >&5
-echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;}
-   { (exit 1); exit 1; }; }
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_target" >&5
-echo "${ECHO_T}$ac_cv_target" >&6
-target=$ac_cv_target
-target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-
-
-# The aliases save the names the user supplied, while $host etc.
-# will get canonicalized.
-test -n "$target_alias" &&
-  test "$program_prefix$program_suffix$program_transform_name" = \
-    NONENONEs,x,x, &&
-  program_prefix=${target_alias}-
 echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \${MAKE}" >&5
 echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'`
@@ -2354,6 +2332,36 @@
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
+echo "$as_me:$LINENO: checking for the directory containing the Wine tools" >&5
+echo $ECHO_N "checking for the directory containing the Wine tools... $ECHO_C" >&6
+if test "${wine_cv_toolsdir+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -z "$with_wine_tools"; then
+     if test "$cross_compiling" = "yes"; then
+       { { echo "$as_me:$LINENO: error: you must use the --with-wine-tools option when cross-compiling." >&5
+echo "$as_me: error: you must use the --with-wine-tools option when cross-compiling." >&2;}
+   { (exit 1); exit 1; }; }
+     else
+       wine_cv_toolsdir="\$(TOPOBJDIR)"
+     fi
+   elif test -d "$with_wine_tools/tools/winebuild"; then
+     case $with_wine_tools in
+       /*) wine_cv_toolsdir="$with_wine_tools" ;;
+       *)  wine_cv_toolsdir="\$(TOPOBJDIR)/$with_wine_tools" ;;
+     esac
+   else
+     { { echo "$as_me:$LINENO: error: could not find Wine tools in $with_wine_tools." >&5
+echo "$as_me: error: could not find Wine tools in $with_wine_tools." >&2;}
+   { (exit 1); exit 1; }; }
+   fi
+fi
+echo "$as_me:$LINENO: result: $wine_cv_toolsdir" >&5
+echo "${ECHO_T}$wine_cv_toolsdir" >&6
+TOOLSDIR=$wine_cv_toolsdir
+
+
+
 
 echo "$as_me:$LINENO: checking for X" >&5
 echo $ECHO_N "checking for X... $ECHO_C" >&6
@@ -3906,6 +3914,87 @@
 echo "$as_me: error: no suitable lex found. Please install the 'flex' package." >&2;}
    { (exit 1); exit 1; }; }
 fi
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_AR+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AR="${ac_tool_prefix}ar"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  echo "$as_me:$LINENO: result: $AR" >&5
+echo "${ECHO_T}$AR" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+  ac_ct_AR=$AR
+  # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_AR+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_AR="ar"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_prog_ac_ct_AR" && ac_cv_prog_ac_ct_AR="ar"
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  echo "$as_me:$LINENO: result: $ac_ct_AR" >&5
+echo "${ECHO_T}$ac_ct_AR" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  AR=$ac_ct_AR
+else
+  AR="$ac_cv_prog_AR"
+fi
+
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
@@ -3986,6 +4075,166 @@
   RANLIB="$ac_cv_prog_RANLIB"
 fi
 
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_STRIP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  echo "$as_me:$LINENO: result: $STRIP" >&5
+echo "${ECHO_T}$STRIP" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP="strip"
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
+echo "${ECHO_T}$ac_ct_STRIP" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  STRIP=$ac_ct_STRIP
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args.
+set dummy ${ac_tool_prefix}windres; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_WINDRES+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$WINDRES"; then
+  ac_cv_prog_WINDRES="$WINDRES" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_WINDRES="${ac_tool_prefix}windres"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+WINDRES=$ac_cv_prog_WINDRES
+if test -n "$WINDRES"; then
+  echo "$as_me:$LINENO: result: $WINDRES" >&5
+echo "${ECHO_T}$WINDRES" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_WINDRES"; then
+  ac_ct_WINDRES=$WINDRES
+  # Extract the first word of "windres", so it can be a program name with args.
+set dummy windres; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_WINDRES+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_WINDRES"; then
+  ac_cv_prog_ac_ct_WINDRES="$ac_ct_WINDRES" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_WINDRES="windres"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_prog_ac_ct_WINDRES" && ac_cv_prog_ac_ct_WINDRES="false"
+fi
+fi
+ac_ct_WINDRES=$ac_cv_prog_ac_ct_WINDRES
+if test -n "$ac_ct_WINDRES"; then
+  echo "$as_me:$LINENO: result: $ac_ct_WINDRES" >&5
+echo "${ECHO_T}$ac_ct_WINDRES" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  WINDRES=$ac_ct_WINDRES
+else
+  WINDRES="$ac_cv_prog_WINDRES"
+fi
+
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
 # incompatible versions:
@@ -4151,6 +4400,171 @@
 fi
 
 
+case $host_os in
+   cygwin*|mingw32*)
+      if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ld -r --enable-stdcall-fixup", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ld -r --enable-stdcall-fixup; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_LDCOMBINE+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$LDCOMBINE"; then
+  ac_cv_prog_LDCOMBINE="$LDCOMBINE" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_LDCOMBINE="${ac_tool_prefix}ld -r --enable-stdcall-fixup"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+LDCOMBINE=$ac_cv_prog_LDCOMBINE
+if test -n "$LDCOMBINE"; then
+  echo "$as_me:$LINENO: result: $LDCOMBINE" >&5
+echo "${ECHO_T}$LDCOMBINE" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_LDCOMBINE"; then
+  ac_ct_LDCOMBINE=$LDCOMBINE
+  # Extract the first word of "ld -r --enable-stdcall-fixup", so it can be a program name with args.
+set dummy ld -r --enable-stdcall-fixup; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_LDCOMBINE+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_LDCOMBINE"; then
+  ac_cv_prog_ac_ct_LDCOMBINE="$ac_ct_LDCOMBINE" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_LDCOMBINE="ld -r --enable-stdcall-fixup"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_prog_ac_ct_LDCOMBINE" && ac_cv_prog_ac_ct_LDCOMBINE="ld -r --enable-stdcall-fixup"
+fi
+fi
+ac_ct_LDCOMBINE=$ac_cv_prog_ac_ct_LDCOMBINE
+if test -n "$ac_ct_LDCOMBINE"; then
+  echo "$as_me:$LINENO: result: $ac_ct_LDCOMBINE" >&5
+echo "${ECHO_T}$ac_ct_LDCOMBINE" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  LDCOMBINE=$ac_ct_LDCOMBINE
+else
+  LDCOMBINE="$ac_cv_prog_LDCOMBINE"
+fi
+ ;;
+   *)
+      if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ld -r", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ld -r; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_LDCOMBINE+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$LDCOMBINE"; then
+  ac_cv_prog_LDCOMBINE="$LDCOMBINE" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_LDCOMBINE="${ac_tool_prefix}ld -r"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+LDCOMBINE=$ac_cv_prog_LDCOMBINE
+if test -n "$LDCOMBINE"; then
+  echo "$as_me:$LINENO: result: $LDCOMBINE" >&5
+echo "${ECHO_T}$LDCOMBINE" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_LDCOMBINE"; then
+  ac_ct_LDCOMBINE=$LDCOMBINE
+  # Extract the first word of "ld -r", so it can be a program name with args.
+set dummy ld -r; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_LDCOMBINE+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_LDCOMBINE"; then
+  ac_cv_prog_ac_ct_LDCOMBINE="$ac_ct_LDCOMBINE" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_LDCOMBINE="ld -r"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_prog_ac_ct_LDCOMBINE" && ac_cv_prog_ac_ct_LDCOMBINE="ld -r"
+fi
+fi
+ac_ct_LDCOMBINE=$ac_cv_prog_ac_ct_LDCOMBINE
+if test -n "$ac_ct_LDCOMBINE"; then
+  echo "$as_me:$LINENO: result: $ac_ct_LDCOMBINE" >&5
+echo "${ECHO_T}$ac_ct_LDCOMBINE" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  LDCOMBINE=$ac_ct_LDCOMBINE
+else
+  LDCOMBINE="$ac_cv_prog_LDCOMBINE"
+fi
+ ;;
+esac
+
 for ac_prog in lclint lint
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
@@ -4198,12 +4612,6 @@
 
 
 
-case $host_os in
-  *cygwin*) LDCOMBINE="ld -r --enable-stdcall-fixup" ;;
-         *) LDCOMBINE="ld -r" ;;
-esac
-
-
 
 
 echo "$as_me:$LINENO: checking for sqrt in -lm" >&5
@@ -9198,10 +9606,11 @@
 LDDLLFLAGS=""
 DLLIBS=""
 
-case $target_os in
-  cygwin|mingw32)
-    # Extract the first word of "dllwrap", so it can be a program name with args.
-set dummy dllwrap; ac_word=$2
+case $host_os in
+  cygwin*|mingw32*)
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dllwrap", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dllwrap; ac_word=$2
 echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_DLLWRAP+set}" = set; then
@@ -9217,14 +9626,13 @@
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
   if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_DLLWRAP="dllwrap"
+    ac_cv_prog_DLLWRAP="${ac_tool_prefix}dllwrap"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
 
-  test -z "$ac_cv_prog_DLLWRAP" && ac_cv_prog_DLLWRAP="false"
 fi
 fi
 DLLWRAP=$ac_cv_prog_DLLWRAP
@@ -9236,10 +9644,54 @@
 echo "${ECHO_T}no" >&6
 fi
 
-    if test "$DLLWRAP" = "dllwrap"; then
-            LIBEXT="dll"
-    else
+fi
+if test -z "$ac_cv_prog_DLLWRAP"; then
+  ac_ct_DLLWRAP=$DLLWRAP
+  # Extract the first word of "dllwrap", so it can be a program name with args.
+set dummy dllwrap; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_DLLWRAP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_DLLWRAP"; then
+  ac_cv_prog_ac_ct_DLLWRAP="$ac_ct_DLLWRAP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_DLLWRAP="dllwrap"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_prog_ac_ct_DLLWRAP" && ac_cv_prog_ac_ct_DLLWRAP="false"
+fi
+fi
+ac_ct_DLLWRAP=$ac_cv_prog_ac_ct_DLLWRAP
+if test -n "$ac_ct_DLLWRAP"; then
+  echo "$as_me:$LINENO: result: $ac_ct_DLLWRAP" >&5
+echo "${ECHO_T}$ac_ct_DLLWRAP" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  DLLWRAP=$ac_ct_DLLWRAP
+else
+  DLLWRAP="$ac_cv_prog_DLLWRAP"
+fi
+
+    if test "$DLLWRAP" = "false"; then
       LIBEXT="a"
+    else
+            LIBEXT="dll"
     fi
     ;;
   *)
@@ -9632,18 +10084,22 @@
 fi
 
 DLLFLAGS=""
-LDPATH=""
 
 if test "$LIBEXT" = "so"; then
     DLLFLAGS="-fPIC"
     DLLEXT=".so"
-    LDPATH="LD_LIBRARY_PATH=\"\$(TOPOBJDIR)/library:\$(TOPOBJDIR)/unicode:\$\$LD_LIBRARY_PATH\""
 elif test "$LIBEXT" = "dll"; then
     #DLLFLAGS="-fPIC" # -fPIC doesn't work(at least in cygwin-b20) - FIXME
     DLLEXT=""
-    LDPATH="PATH=\"\$(TOPOBJDIR)/library:\$(TOPOBJDIR)/unicode:\$\$PATH\""
 fi
 
+case $build_os in
+  cygwin*|mingw32*)
+    LDPATH="PATH=\"\$(TOOLSDIR)/library:\$(TOOLSDIR)/unicode:\$\$PATH\"" ;;
+  *)
+    LDPATH="LD_LIBRARY_PATH=\"\$(TOOLSDIR)/library:\$(TOOLSDIR)/unicode:\$\$LD_LIBRARY_PATH\"" ;;
+esac
+
 
 
 
@@ -12320,7 +12776,7 @@
 
 
 
-case $target_cpu in
+case $host_cpu in
   *i345678986* )
     echo "$as_me:$LINENO: checking whether we need to define __i386__" >&5
 echo $ECHO_N "checking whether we need to define __i386__... $ECHO_C" >&6
@@ -13155,10 +13611,6 @@
 s,@host_cpu@,$host_cpu,;t t
 s,@host_vendor@,$host_vendor,;t t
 s,@host_os@,$host_os,;t t
-s,@target@,$target,;t t
-s,@target_cpu@,$target_cpu,;t t
-s,@target_vendor@,$target_vendor,;t t
-s,@target_os@,$target_os,;t t
 s,@SET_MAKE@,$SET_MAKE,;t t
 s,@CC@,$CC,;t t
 s,@CFLAGS@,$CFLAGS,;t t
@@ -13168,6 +13620,7 @@
 s,@EXEEXT@,$EXEEXT,;t t
 s,@OBJEXT@,$OBJEXT,;t t
 s,@CPP@,$CPP,;t t
+s,@TOOLSDIR@,$TOOLSDIR,;t t
 s,@X_CFLAGS@,$X_CFLAGS,;t t
 s,@X_PRE_LIBS@,$X_PRE_LIBS,;t t
 s,@X_LIBS@,$X_LIBS,;t t
@@ -13178,17 +13631,24 @@
 s,@LEX_OUTPUT_ROOT@,$LEX_OUTPUT_ROOT,;t t
 s,@XYACC@,$XYACC,;t t
 s,@XLEX@,$XLEX,;t t
+s,@AR@,$AR,;t t
+s,@ac_ct_AR@,$ac_ct_AR,;t t
 s,@RANLIB@,$RANLIB,;t t
 s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
+s,@STRIP@,$STRIP,;t t
+s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t
+s,@WINDRES@,$WINDRES,;t t
+s,@ac_ct_WINDRES@,$ac_ct_WINDRES,;t t
 s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
 s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
 s,@INSTALL_DATA@,$INSTALL_DATA,;t t
 s,@LN_S@,$LN_S,;t t
 s,@C2MAN@,$C2MAN,;t t
 s,@LDCONFIG@,$LDCONFIG,;t t
+s,@LDCOMBINE@,$LDCOMBINE,;t t
+s,@ac_ct_LDCOMBINE@,$ac_ct_LDCOMBINE,;t t
 s,@LINT@,$LINT,;t t
 s,@LINTFLAGS@,$LINTFLAGS,;t t
-s,@LDCOMBINE@,$LDCOMBINE,;t t
 s,@JPEGLIB@,$JPEGLIB,;t t
 s,@XLIB@,$XLIB,;t t
 s,@XFILES@,$XFILES,;t t
@@ -13206,6 +13666,7 @@
 s,@ARTSLIBS@,$ARTSLIBS,;t t
 s,@ARTSINCL@,$ARTSINCL,;t t
 s,@DLLWRAP@,$DLLWRAP,;t t
+s,@ac_ct_DLLWRAP@,$ac_ct_DLLWRAP,;t t
 s,@DLLIBS@,$DLLIBS,;t t
 s,@DLLFLAGS@,$DLLFLAGS,;t t
 s,@DLLEXT@,$DLLEXT,;t t
diff --git a/configure.ac b/configure.ac
index 6bd8b7b..0a34c06 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,7 +18,8 @@
 AC_ARG_ENABLE(debug, AC_HELP_STRING([--disable-debug],[compile out all debugging messages]))
 AC_ARG_ENABLE(trace, AC_HELP_STRING([--disable-trace],[compile out TRACE messages]))
 AC_ARG_ENABLE(opengl,AC_HELP_STRING([--enable-opengl],[force usage of OpenGL even if the latter is thread-safe via pthread]))
-AC_ARG_WITH(curses,     AC_HELP_STRING([--without-curses],[do not use curses]))
+AC_ARG_WITH(curses,    AC_HELP_STRING([--without-curses],[do not use curses]))
+AC_ARG_WITH(wine-tools,AC_HELP_STRING([--with-wine-tools=<dir>],[use Wine tools from directory <dir>]))
 
 AC_SUBST(OPTIONS)
 if test "x$enable_debug" = "xno"
@@ -32,10 +33,28 @@
 
 dnl **** Check for some programs ****
 
-AC_CANONICAL_TARGET
+AC_CANONICAL_HOST
 AC_PROG_MAKE_SET
 AC_PROG_CC
 AC_PROG_CPP
+
+AC_CACHE_CHECK([for the directory containing the Wine tools], wine_cv_toolsdir,
+  [if test -z "$with_wine_tools"; then
+     if test "$cross_compiling" = "yes"; then
+       AC_MSG_ERROR([you must use the --with-wine-tools option when cross-compiling.])
+     else
+       wine_cv_toolsdir="\$(TOPOBJDIR)"
+     fi
+   elif test -d "$with_wine_tools/tools/winebuild"; then
+     case $with_wine_tools in
+       /*) wine_cv_toolsdir="$with_wine_tools" ;;
+       *)  wine_cv_toolsdir="\$(TOPOBJDIR)/$with_wine_tools" ;;
+     esac
+   else
+     AC_MSG_ERROR([could not find Wine tools in $with_wine_tools.])
+   fi])
+AC_SUBST(TOOLSDIR,$wine_cv_toolsdir)
+
 AC_PATH_XTRA
 AC_PROG_YACC
 AC_PROG_LEX
@@ -52,12 +71,23 @@
 then
   AC_MSG_ERROR([no suitable lex found. Please install the 'flex' package.])
 fi
+
+AC_CHECK_TOOL(AR,ar,ar)
 AC_PROG_RANLIB
+AC_CHECK_TOOL(STRIP,strip,strip)
+AC_CHECK_TOOL(WINDRES,windres,false)
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_CHECK_PROG(C2MAN,c2man,c2man,\$(TOPSRCDIR)/tools/c2man.pl)
 AC_PATH_PROG(LDCONFIG, ldconfig, true, [/sbin /usr/sbin $PATH])
 
+case $host_os in
+   cygwin*|mingw32*)
+      AC_CHECK_TOOL(LDCOMBINE,[ld -r --enable-stdcall-fixup],[ld -r --enable-stdcall-fixup]) ;;
+   *)
+      AC_CHECK_TOOL(LDCOMBINE,[ld -r],[ld -r]) ;;
+esac
+
 dnl Check for lint
 AC_CHECK_PROGS(LINT, lclint lint)
 if test "$LINT" = "lint"
@@ -68,12 +98,6 @@
 AC_SUBST(LINT)
 AC_SUBST(LINTFLAGS)
 
-case $host_os in
-  *cygwin*) LDCOMBINE="ld -r --enable-stdcall-fixup" ;;
-         *) LDCOMBINE="ld -r" ;;
-esac
-AC_SUBST(LDCOMBINE)
-
 dnl **** Check for some libraries ****
 
 dnl Check for -lm
@@ -700,14 +724,14 @@
 LDDLLFLAGS=""
 DLLIBS=""
 
-case $target_os in
-  cygwin|mingw32)
-    AC_CHECK_PROG(DLLWRAP,dllwrap,dllwrap,false)
-    if test "$DLLWRAP" = "dllwrap"; then
+case $host_os in
+  cygwin*|mingw32*)
+    AC_CHECK_TOOL(DLLWRAP,dllwrap,false)
+    if test "$DLLWRAP" = "false"; then
+      LIBEXT="a"
+    else
       dnl FIXME - check whether dllwrap works correctly...
       LIBEXT="dll"
-    else
-      LIBEXT="a"
     fi
     ;;
   *)
@@ -759,18 +783,22 @@
 fi
 
 DLLFLAGS=""
-LDPATH=""
 
 if test "$LIBEXT" = "so"; then
     DLLFLAGS="-fPIC"
     DLLEXT=".so"
-    LDPATH="LD_LIBRARY_PATH=\"\$(TOPOBJDIR)/library:\$(TOPOBJDIR)/unicode:\$\$LD_LIBRARY_PATH\""
 elif test "$LIBEXT" = "dll"; then
     #DLLFLAGS="-fPIC" # -fPIC doesn't work(at least in cygwin-b20) - FIXME
     DLLEXT=""
-    LDPATH="PATH=\"\$(TOPOBJDIR)/library:\$(TOPOBJDIR)/unicode:\$\$PATH\""
 fi
 
+case $build_os in
+  cygwin*|mingw32*)
+    LDPATH="PATH=\"\$(TOOLSDIR)/library:\$(TOOLSDIR)/unicode:\$\$PATH\"" ;;
+  *)
+    LDPATH="LD_LIBRARY_PATH=\"\$(TOOLSDIR)/library:\$(TOOLSDIR)/unicode:\$\$LD_LIBRARY_PATH\"" ;;
+esac
+
 AC_SUBST(DLLIBS)
 AC_SUBST(DLLFLAGS)
 AC_SUBST(DLLEXT)
@@ -1191,7 +1219,7 @@
 
 dnl *** check for the need to define __i386__
 
-case $target_cpu in
+case $host_cpu in
   *i[3456789]86* )
     AC_CACHE_CHECK([whether we need to define __i386__],ac_cv_cpp_def_i386,
       AC_EGREP_CPP(yes,[#ifndef __i386__
diff --git a/dlls/kernel/tests/process.c b/dlls/kernel/tests/process.c
index 2fb4cfd..267a37b 100644
--- a/dlls/kernel/tests/process.c
+++ b/dlls/kernel/tests/process.c
@@ -137,29 +137,7 @@
 {
     myARGC = winetest_get_mainargs( &myARGV );
     if (!GetCurrentDirectoryA(sizeof(base), base)) return 0;
-
-    if (strcmp(winetest_platform, "windows"))
-    {
-        char* ptr = getenv("WINELOADER");
-        char* root;
-
-        if (!ptr) return 0;
-        root = grab_memory(strlen(ptr) + 1);
-        strcpy(root, ptr);
-        ptr = strrchr(root, '/');
-        if (!ptr) return 0;
-        *ptr = '\0';
-
-        /* be sure to use absolute pathnames so we can change dirs whenever we want */
-        sprintf(selfname, 
-                "%s/programs/winetest/runtest -q -P wine -M kernel32.dll -T %s -p %s/dlls/kernel/tests/kernel32_test",
-                root, root, root);
-    }
-    else
-    {
-        strcpy(selfname, myARGV[0]);
-    }
-
+    strcpy(selfname, myARGV[0]);
     return 1;
 }
 
diff --git a/library/Makefile.in b/library/Makefile.in
index 39a7140..34b106b 100644
--- a/library/Makefile.in
+++ b/library/Makefile.in
@@ -43,10 +43,14 @@
 	$(MKINSTALLDIRS) $(libdir)
 	$(INSTALL_DATA) libwine.a $(libdir)/libwine.a
 
-install:: all $(LIBEXT:%=install_%)
+install_dll: libwine.dll
+	$(MKINSTALLDIRS) $(libdir)
+	$(INSTALL_DATA) libwine.dll $(libdir)/libwine.dll
+
+install:: $(LIBEXT:%=install_%)
 
 uninstall::
-	$(RM) $(libdir)/libwine.a $(libdir)/libwine.so $(libdir)/libwine.so.$(SOVERSION)
+	$(RM) $(libdir)/libwine.a $(libdir)/libwine.dll $(libdir)/libwine.so $(libdir)/libwine.so.$(SOVERSION)
 
 clean::
 	$(RM) libwine.so.$(SOVERSION)
diff --git a/programs/Makeprog.rules.in b/programs/Makeprog.rules.in
index d3b78f9..3c1b3ee 100644
--- a/programs/Makeprog.rules.in
+++ b/programs/Makeprog.rules.in
@@ -11,21 +11,21 @@
 
 DEFS        = @DLLFLAGS@ -DSTRICT -DNONAMELESSUNION -DNONAMELESSSTRUCT $(EXTRADEFS)
 LDDLLFLAGS  = @LDDLLFLAGS@
-ALL_OBJS    = $(MODULE).spec.o $(OBJS)
 ALL_LIBS    = $(LIBWINE) $(EXTRALIBS) $(LIBS)
 SYMBOLFILE  = $(MODULE).tmp.o
 TESTIMPORTS = $(DELAYIMPORTS) $(IMPORTS)
-
-all: $(MODULE)
+RCOBJS      = $(RC_SRCS:.rc=.res.o)
 
 @MAKE_RULES@
 
+all: $(MODULE)$(EXEEXT)
+
 # Rule for main module spec file
 
 $(MODULE).spec.c: $(RC_SRCS:.rc=.res) $(SYMBOLFILE) $(WINEBUILD)
 	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ $(SYMBOLFILE:%=-sym %) -o $@ -exe $(MODULE) $(APPMODE:%=-m%) $(RC_SRCS:%.rc=-res %.res) -L$(DLLDIR) $(DELAYIMPORTS:%=-dl%) $(IMPORTS:%=-l%)
 
-# Rules for main module
+# Rules for .so main module
 
 $(MODULE).so: $(MODULE).spec.o $(OBJS) Makefile.in
 	$(LDSHARED) $(LDDLLFLAGS) $(MODULE).spec.o $(OBJS) -o $@ $(ALL_LIBS)
@@ -33,6 +33,11 @@
 $(MODULE): $(MODULE).so
 	$(RM) $(MODULE) && $(LN_S) $(TOPOBJDIR)/wine $(MODULE)
 
+# Rules for .exe main module
+
+$(MODULE).exe: $(OBJS) $(RCOBJS) Makefile.in
+	$(CC) $(OBJS) $(RCOBJS) -o $@ $(DELAYIMPORTS:%=-l%) $(IMPORTS:%=-l%) $(ALL_LIBS)
+
 # Rules for checking that no imports are missing
 
 checklink:: $(MODULE).so
@@ -49,13 +54,21 @@
 
 # Rules for installation
 
-install:: $(MODULE).so
+.PHONY: install_prog$(EXEEXT)
+
+install_prog:: $(MODULE).so
 	$(MKINSTALLDIRS) $(bindir)
 	$(INSTALL_PROGRAM) $(MODULE).so $(bindir)/$(MODULE).so
 	cd $(bindir) && $(RM) $(MODULE) && $(LN_S) wine $(MODULE)
 
+install_prog.exe:: $(MODULE).exe
+	$(MKINSTALLDIRS) $(bindir)
+	$(INSTALL_PROGRAM) $(MODULE).exe $(bindir)/$(MODULE).exe
+
+install:: install_prog$(EXEEXT)
+
 uninstall::
-	$(RM) $(bindir)/$(MODULE) $(bindir)/$(MODULE).so
+	$(RM) $(bindir)/$(MODULE)$(EXEEXT) $(bindir)/$(MODULE).so
 
 clean::
-	$(RM) $(MODULE)
+	$(RM) $(MODULE)$(EXEEXT)
diff --git a/programs/winetest/runtest b/programs/winetest/runtest
index 5dc0c56..5b3974b 100755
--- a/programs/winetest/runtest
+++ b/programs/winetest/runtest
@@ -123,9 +123,7 @@
     $ENV{WINESERVER} = $topobjdir . "/server/wineserver";
     $ENV{WINELOADER} = $topobjdir . "/wine";
     $ENV{WINETEST_PLATFORM} = $platform || "wine";
-    $ENV{WINEPRELOAD}=($program || ($topobjdir . "/programs/winetest/winetest")) . ".so";
-    # try to exec the wine loader directly; if it fails continue on to normal exec
-    exec $ENV{WINELOADER}, $infile, @ARGV;
+    $program ||= $topobjdir . "/programs/winetest/winetest";
 }
 else
 {
diff --git a/unicode/Makefile.in b/unicode/Makefile.in
index 9ab2798..e119840 100644
--- a/unicode/Makefile.in
+++ b/unicode/Makefile.in
@@ -95,9 +95,9 @@
 	$(AR) $@ $(OBJS)
 	$(RANLIB) $@
 
-# --export-all don't work correctly because of dllwrap's bug
+# --export-all doesn't work correctly because of dllwrap's bug
 libwine_unicode.dll: $(OBJS) wine_unicode.def
-	$(DLLWRAP) $(DLLWRAPFLAGS) --def wine_unicode.def --implib libwine_unicode.a -o libwine_unicode.dll $(OBJS)
+	$(DLLWRAP) $(DLLWRAPFLAGS) --def $(SRCDIR)/wine_unicode.def --implib libwine_unicode.a -o libwine_unicode.dll $(OBJS)
 
 install_so: libwine_unicode.so.$(SOVERSION)
 	$(MKINSTALLDIRS) $(libdir)
@@ -108,10 +108,14 @@
 	$(MKINSTALLDIRS) $(libdir)
 	$(INSTALL_DATA) libwine_unicode.a $(libdir)/libwine_unicode.a
 
-install:: all $(LIBEXT:%=install_%)
+install_dll: libwine_unicode.dll
+	$(MKINSTALLDIRS) $(libdir)
+	$(INSTALL_DATA) libwine_unicode.dll $(libdir)/libwine_unicode.dll
+
+install:: $(LIBEXT:%=install_%)
 
 uninstall::
-	$(RM) $(libdir)/libwine_unicode.a $(libdir)/libwine_unicode.so $(libdir)/libwine_unicode.so.$(SOVERSION)
+	$(RM) $(libdir)/libwine_unicode.a $(libdir)/libwine_unicode.dll $(libdir)/libwine_unicode.so $(libdir)/libwine_unicode.so.$(SOVERSION)
 
 clean::
 	$(RM) libwine_unicode.so.$(SOVERSION)