Implemented import libraries; on Unix we import the .def file
directly, on Mingw we use it to build the .a library.

diff --git a/Make.rules.in b/Make.rules.in
index 90cf965..8938ca3 100644
--- a/Make.rules.in
+++ b/Make.rules.in
@@ -34,8 +34,10 @@
 OBJEXT    = @OBJEXT@
 LIBEXT    = @LIBEXT@
 DLLEXT    = @DLLEXT@
+IMPLIBEXT = @IMPLIBEXT@
 CROSSCC   = @CROSSCC@
 LDSHARED  = @LDSHARED@
+DLLTOOL   = @DLLTOOL@
 DLLWRAP   = @DLLWRAP@
 DLLWRAPFLAGS = --add-stdcall-alias
 AR        = @AR@ rc
@@ -240,7 +242,8 @@
 
 uninstall:: $(INSTALLSUBDIRS:%=%/__uninstall__)
 
-.PHONY: install uninstall $(INSTALLSUBDIRS:%=%/__install__) $(INSTALLSUBDIRS:%=%/__uninstall__)
+.PHONY: install install-lib install-dev uninstall \
+	$(INSTALLSUBDIRS:%=%/__install__) $(INSTALLSUBDIRS:%=%/__uninstall__)
 
 # Rules for checking that no imports are missing
 
diff --git a/Makefile.in b/Makefile.in
index 72746c4..d9a4640 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -40,7 +40,6 @@
 
 # Sub-directories to install for install-lib
 INSTALLLIBSUBDIRS = \
-	dlls \
 	documentation \
 	library \
 	miscemu \
@@ -54,6 +53,9 @@
 	ole \
 	tools
 
+# Sub-directories to install for both install-lib and install-dev
+INSTALLBOTHSUBDIRS = dlls
+
 INSTALLSUBDIRS = $(INSTALLDEVSUBDIRS) $(INSTALLLIBSUBDIRS)
 
 # Sub-directories to run make test into
@@ -81,11 +83,11 @@
 	$(MKINSTALLDIRS) $(datadir)/aclocal
 	$(INSTALL_DATA) $(SRCDIR)/aclocal.m4 $(datadir)/aclocal/wine.m4
 
-install-lib:: $(INSTALLLIBSUBDIRS:%=%/__install__)
+install-lib:: $(INSTALLLIBSUBDIRS:%=%/__install__) $(INSTALLBOTHSUBDIRS:%=%/__install-lib__)
 
-install-dev:: $(INSTALLDEVSUBDIRS:%=%/__install__) install-aclocal
+install-dev:: $(INSTALLDEVSUBDIRS:%=%/__install__) $(INSTALLBOTHSUBDIRS:%=%/__install-dev__) install-aclocal
 
-install:: install-aclocal
+install:: install-lib install-dev install-aclocal
 	-$(LDCONFIG)
 	@if test -n "`LANG=C $(LDD) $(bindir)/wine|grep not.found`";	\
 	then								\
@@ -99,11 +101,20 @@
 		echo "*************************************************" ; \
 	fi
 
-uninstall::
+uninstall:: $(INSTALLBOTHSUBDIRS:%=%/__uninstall__)
 	$(RM) $(datadir)/aclocal/wine.m4
 	-rmdir $(datadir)/aclocal
 
-.PHONY: install-aclocal install-lib install-dev
+$(INSTALLBOTHSUBDIRS:%=%/__install-lib__): dummy
+	cd `dirname $@` && $(MAKE) install-lib
+
+$(INSTALLBOTHSUBDIRS:%=%/__install-dev__): dummy
+	cd `dirname $@` && $(MAKE) install-dev
+
+$(INSTALLBOTHSUBDIRS:%=%/__uninstall__): dummy
+	cd `dirname $@` && $(MAKE) uninstall
+
+.PHONY: install-aclocal $(INSTALLBOTHSUBDIRS:%=%/__install-lib__) $(INSTALLBOTHSUBDIRS:%=%/__install-dev__) $(INSTALLBOTHSUBDIRS:%=%/__uninstall__)
 
 # Dependencies between directories
 
@@ -113,9 +124,9 @@
 miscemu programs: dlls library ole tools unicode
 tools: library unicode
 
-dlls/__install__: library ole tools unicode
+dlls/__install-lib__ dlls/__install-dev__: library ole tools unicode
 server/__install__: library tools unicode
-miscemu/__install__ programs/__install__: library ole tools unicode dlls/__install__
+miscemu/__install__ programs/__install__: library ole tools unicode dlls/__install-lib__
 library/__install__: library
 ole/__install__: ole
 tools/__install__: tools
diff --git a/configure b/configure
index 5c1c8b1..f0ace80 100755
--- a/configure
+++ b/configure
@@ -305,7 +305,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS LIBEXT OPTIONS WIN16_FILES WIN16_INSTALL build build_cpu build_vendor build_os host host_cpu host_vendor host_os SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP TOOLSDIR X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS YACC LEX LEXLIB LEX_OUTPUT_ROOT XYACC XLEX LD ac_ct_LD AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP WINDRES ac_ct_WINDRES INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S LN C2MAN LDCONFIG LINT LINTFLAGS DB2HTML DB2PDF DB2PS JPEGLIB EGREP XLIB XFILES OPENGLFILES GLU32FILES OPENGL_LIBS NASLIBS CURSESLIBS sane_devel SANELIBS SANEINCL ft_devel ft_devel2 FREETYPEINCL ARTSCCONFIG ARTSLIBS ARTSINCL ALSALIBS AUDIOIOLIBS DLLEXT DLLFLAGS DLLIBS LDDLLFLAGS LDSHARED DLLWRAP ac_ct_DLLWRAP CROSSTEST CROSSCC DLLTOOL LDPATH CRTLIBS LDD ALLOCA LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS OPTIONS WIN16_FILES WIN16_INSTALL build build_cpu build_vendor build_os host host_cpu host_vendor host_os SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP TOOLSDIR X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS YACC LEX LEXLIB LEX_OUTPUT_ROOT XYACC XLEX LD ac_ct_LD AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP WINDRES ac_ct_WINDRES INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S LN C2MAN LDCONFIG LINT LINTFLAGS DB2HTML DB2PDF DB2PS JPEGLIB EGREP XLIB XFILES OPENGLFILES GLU32FILES OPENGL_LIBS NASLIBS CURSESLIBS sane_devel SANELIBS SANEINCL ft_devel ft_devel2 FREETYPEINCL ARTSCCONFIG ARTSLIBS ARTSINCL ALSALIBS AUDIOIOLIBS DLLEXT DLLFLAGS DLLIBS LDDLLFLAGS LDSHARED LIBEXT IMPLIBEXT DLLTOOL ac_ct_DLLTOOL DLLWRAP ac_ct_DLLWRAP CROSSTEST CROSSCC LDPATH CRTLIBS LDD ALLOCA LIBOBJS LTLIBOBJS'
 ac_subst_files='MAKE_RULES MAKE_DLL_RULES MAKE_TEST_RULES MAKE_PROG_RULES'
 
 # Initialize some variables set by options.
@@ -1283,9 +1283,6 @@
 
 
 
-LIBEXT="so"
-
-
 # Check whether --enable-win16 or --disable-win16 was given.
 if test "${enable_win16+set}" = set; then
   enableval="$enable_win16"
@@ -9883,10 +9880,94 @@
 
 LDSHARED=""
 
+LIBEXT="so"
+
+IMPLIBEXT="def"
+
 
 case $host_os in
   cygwin*|mingw32*)
     if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dlltool; 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_DLLTOOL+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$DLLTOOL"; then
+  ac_cv_prog_DLLTOOL="$DLLTOOL" # 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_DLLTOOL="${ac_tool_prefix}dlltool"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+DLLTOOL=$ac_cv_prog_DLLTOOL
+if test -n "$DLLTOOL"; then
+  echo "$as_me:$LINENO: result: $DLLTOOL" >&5
+echo "${ECHO_T}$DLLTOOL" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_DLLTOOL"; then
+  ac_ct_DLLTOOL=$DLLTOOL
+  # Extract the first word of "dlltool", so it can be a program name with args.
+set dummy dlltool; 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_DLLTOOL+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_DLLTOOL"; then
+  ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # 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_DLLTOOL="dlltool"
+    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_DLLTOOL" && ac_cv_prog_ac_ct_DLLTOOL="false"
+fi
+fi
+ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
+if test -n "$ac_ct_DLLTOOL"; then
+  echo "$as_me:$LINENO: result: $ac_ct_DLLTOOL" >&5
+echo "${ECHO_T}$ac_ct_DLLTOOL" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  DLLTOOL=$ac_ct_DLLTOOL
+else
+  DLLTOOL="$ac_cv_prog_DLLTOOL"
+fi
+
+    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
@@ -9971,6 +10052,7 @@
     else
             LIBEXT="dll"
     fi
+    IMPLIBEXT="a"
     ;;
   *)
 
@@ -14554,7 +14636,6 @@
 s,@ECHO_N@,$ECHO_N,;t t
 s,@ECHO_T@,$ECHO_T,;t t
 s,@LIBS@,$LIBS,;t t
-s,@LIBEXT@,$LIBEXT,;t t
 s,@OPTIONS@,$OPTIONS,;t t
 s,@WIN16_FILES@,$WIN16_FILES,;t t
 s,@WIN16_INSTALL@,$WIN16_INSTALL,;t t
@@ -14633,11 +14714,14 @@
 s,@DLLIBS@,$DLLIBS,;t t
 s,@LDDLLFLAGS@,$LDDLLFLAGS,;t t
 s,@LDSHARED@,$LDSHARED,;t t
+s,@LIBEXT@,$LIBEXT,;t t
+s,@IMPLIBEXT@,$IMPLIBEXT,;t t
+s,@DLLTOOL@,$DLLTOOL,;t t
+s,@ac_ct_DLLTOOL@,$ac_ct_DLLTOOL,;t t
 s,@DLLWRAP@,$DLLWRAP,;t t
 s,@ac_ct_DLLWRAP@,$ac_ct_DLLWRAP,;t t
 s,@CROSSTEST@,$CROSSTEST,;t t
 s,@CROSSCC@,$CROSSCC,;t t
-s,@DLLTOOL@,$DLLTOOL,;t t
 s,@LDPATH@,$LDPATH,;t t
 s,@CRTLIBS@,$CRTLIBS,;t t
 s,@LDD@,$LDD,;t t
diff --git a/configure.ac b/configure.ac
index ab571d3..edbdc67 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,9 +12,6 @@
 
 dnl **** Command-line arguments ****
 
-dnl Library type .so or .a
-AC_SUBST(LIBEXT,"so")
-
 AC_ARG_ENABLE(win16, AC_HELP_STRING([--disable-win16],[do not include Win16 support]))
 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]))
@@ -752,9 +749,12 @@
 AC_SUBST(DLLIBS,"")
 AC_SUBST(LDDLLFLAGS,"")
 AC_SUBST(LDSHARED,"")
+AC_SUBST(LIBEXT,"so")
+AC_SUBST(IMPLIBEXT,"def")
 
 case $host_os in
   cygwin*|mingw32*)
+    AC_CHECK_TOOL(DLLTOOL,dlltool,false)
     AC_CHECK_TOOL(DLLWRAP,dllwrap,false)
     if test "$DLLWRAP" = "false"; then
       LIBEXT="a"
@@ -762,6 +762,7 @@
       dnl FIXME - check whether dllwrap works correctly...
       LIBEXT="dll"
     fi
+    IMPLIBEXT="a"
     ;;
   *)
     AC_CHECK_HEADERS(dlfcn.h,
diff --git a/dlls/Makedll.rules.in b/dlls/Makedll.rules.in
index 593eed5..ed32ef9 100644
--- a/dlls/Makedll.rules.in
+++ b/dlls/Makedll.rules.in
@@ -18,13 +18,15 @@
 ALL_OBJS    = @WIN16_FILES@ $(OBJS) $(MODULE).dbg.o
 ALL_LIBS    = $(LIBWINE) $(EXTRALIBS) $(LIBS)
 
-all: $(MODULE)$(DLLEXT)
+all: $(MODULE)$(DLLEXT) $(SUBDIRS)
 
 @MAKE_RULES@
 
+IMPORTLIBS = $(DELAYIMPORTS:%=$(DLLDIR)/lib%.$(IMPLIBEXT)) $(IMPORTS:%=$(DLLDIR)/lib%.$(IMPLIBEXT))
+
 # Rules for .so files
 
-$(MAINSPEC).c: $(MAINSPEC) $(RC_SRCS:.rc=.res) $(SYMBOLFILE) $(WINEBUILD)
+$(MAINSPEC).c: $(MAINSPEC) $(RC_SRCS:.rc=.res) $(SYMBOLFILE) $(IMPORTLIBS) $(WINEBUILD)
 	$(LDPATH) $(WINEBUILD) $(DEFS) -o $@ --spec $(SRCDIR)/$(MAINSPEC) $(RC_SRCS:.rc=.res) $(SYMBOLFILE) $(DLLMAIN:%=-e %) -L$(DLLDIR) $(DELAYIMPORTS:%=-d%) $(IMPORTS:%=-l%)
 
 $(MODULE).so: $(MAINSPEC).o $(ALL_OBJS) Makefile.in
@@ -41,8 +43,8 @@
 
 # Rules for .dll files
 
-$(MODULE): $(RCOBJS) $(OBJS) $(MODULE).dbg.o $(SPEC_DEF) Makefile.in
-	$(DLLWRAP) $(DLLWRAPFLAGS) --def $(SPEC_DEF) --implib lib$(MODULE:.dll=.a) -o $@ $(RCOBJS) $(OBJS) $(MODULE).dbg.o $(DLLMAIN:%=--entry %) -L$(DLLDIR) $(DELAYIMPORTS:%=-l%) $(IMPORTS:%=-l%) $(ALL_LIBS)
+$(MODULE): $(RCOBJS) $(OBJS) $(MODULE).dbg.o $(SPEC_DEF) $(IMPORTLIBS) Makefile.in
+	$(DLLWRAP) -k --def $(SPEC_DEF) -o $@ $(RCOBJS) $(OBJS) $(MODULE).dbg.o $(DLLMAIN:%=--entry %) -L$(DLLDIR) $(DELAYIMPORTS:%=-l%) $(IMPORTS:%=-l%) $(ALL_LIBS)
 
 $(SPEC_DEF): $(WINEBUILD)
 
diff --git a/dlls/Makefile.in b/dlls/Makefile.in
index 28a7c3f..55d2e6c 100644
--- a/dlls/Makefile.in
+++ b/dlls/Makefile.in
@@ -567,6 +567,567 @@
 x11drv.dll$(DLLEXT): x11drv/x11drv.dll$(DLLEXT)
 	$(RM) $@ && $(LN_S) x11drv/x11drv.dll$(DLLEXT) $@
 
+
+# Import libraries
+
+IMPORT_LIBS = \
+	libadvapi32.$(IMPLIBEXT) \
+	libavicap32.$(IMPLIBEXT) \
+	libavifil32.$(IMPLIBEXT) \
+	libcabinet.$(IMPLIBEXT) \
+	libcomcat.$(IMPLIBEXT) \
+	libcomctl32.$(IMPLIBEXT) \
+	libcomdlg32.$(IMPLIBEXT) \
+	libcrtdll.$(IMPLIBEXT) \
+	libcrypt32.$(IMPLIBEXT) \
+	libd3d8.$(IMPLIBEXT) \
+	libdciman32.$(IMPLIBEXT) \
+	libddraw.$(IMPLIBEXT) \
+	libdevenum.$(IMPLIBEXT) \
+	libdinput.$(IMPLIBEXT) \
+	libdinput8.$(IMPLIBEXT) \
+	libdplay.$(IMPLIBEXT) \
+	libdplayx.$(IMPLIBEXT) \
+	libdsound.$(IMPLIBEXT) \
+	libgdi32.$(IMPLIBEXT) \
+	libglu32.$(IMPLIBEXT) \
+	libicmp.$(IMPLIBEXT) \
+	libimagehlp.$(IMPLIBEXT) \
+	libimm32.$(IMPLIBEXT) \
+	libkernel32.$(IMPLIBEXT) \
+	liblz32.$(IMPLIBEXT) \
+	libmapi32.$(IMPLIBEXT) \
+	libmpr.$(IMPLIBEXT) \
+	libmsacm32.$(IMPLIBEXT) \
+	libmsdmo.$(IMPLIBEXT) \
+	libmsimg32.$(IMPLIBEXT) \
+	libmsnet32.$(IMPLIBEXT) \
+	libmsrle32.$(IMPLIBEXT) \
+	libmsvcrt.$(IMPLIBEXT) \
+	libmsvcrt20.$(IMPLIBEXT) \
+	libmsvfw32.$(IMPLIBEXT) \
+	libnetapi32.$(IMPLIBEXT) \
+	libntdll.$(IMPLIBEXT) \
+	libodbc32.$(IMPLIBEXT) \
+	libole32.$(IMPLIBEXT) \
+	liboleaut32.$(IMPLIBEXT) \
+	libolecli32.$(IMPLIBEXT) \
+	liboledlg.$(IMPLIBEXT) \
+	libolepro32.$(IMPLIBEXT) \
+	libolesvr32.$(IMPLIBEXT) \
+	libopengl32.$(IMPLIBEXT) \
+	libpsapi.$(IMPLIBEXT) \
+	libqcap.$(IMPLIBEXT) \
+	libquartz.$(IMPLIBEXT) \
+	librasapi32.$(IMPLIBEXT) \
+	libriched32.$(IMPLIBEXT) \
+	librpcrt4.$(IMPLIBEXT) \
+	libserialui.$(IMPLIBEXT) \
+	libsetupapi.$(IMPLIBEXT) \
+	libshdocvw.$(IMPLIBEXT) \
+	libshell32.$(IMPLIBEXT) \
+	libshfolder.$(IMPLIBEXT) \
+	libshlwapi.$(IMPLIBEXT) \
+	libsnmpapi.$(IMPLIBEXT) \
+	libsti.$(IMPLIBEXT) \
+	libtapi32.$(IMPLIBEXT) \
+	libttydrv.$(IMPLIBEXT) \
+	libtwain_32.$(IMPLIBEXT) \
+	liburl.$(IMPLIBEXT) \
+	liburlmon.$(IMPLIBEXT) \
+	libuser32.$(IMPLIBEXT) \
+	libversion.$(IMPLIBEXT) \
+	libw32skrnl.$(IMPLIBEXT) \
+	libwinedos.$(IMPLIBEXT) \
+	libwineps.$(IMPLIBEXT) \
+	libwininet.$(IMPLIBEXT) \
+	libwinmm.$(IMPLIBEXT) \
+	libwinnls32.$(IMPLIBEXT) \
+	libwinspool.$(IMPLIBEXT) \
+	libwintrust.$(IMPLIBEXT) \
+	libwnaspi32.$(IMPLIBEXT) \
+	libwow32.$(IMPLIBEXT) \
+	libws2_32.$(IMPLIBEXT) \
+	libwsock32.$(IMPLIBEXT) \
+	libx11drv.$(IMPLIBEXT)
+
+libadvapi32.def: advapi32/advapi32.spec.def
+	$(RM) $@ && $(LN_S) advapi32/advapi32.spec.def $@
+libadvapi32.a: advapi32/advapi32.spec.def
+	$(DLLTOOL) -k -l $@ -d advapi32/advapi32.spec.def
+
+libavicap32.def: avicap32/avicap32.spec.def
+	$(RM) $@ && $(LN_S) avicap32/avicap32.spec.def $@
+libavicap32.a: avicap32/avicap32.spec.def
+	$(DLLTOOL) -k -l $@ -d avicap32/avicap32.spec.def
+
+libavifil32.def: avifil32/avifil32.spec.def
+	$(RM) $@ && $(LN_S) avifil32/avifil32.spec.def $@
+libavifil32.a: avifil32/avifil32.spec.def
+	$(DLLTOOL) -k -l $@ -d avifil32/avifil32.spec.def
+
+libcabinet.def: cabinet/cabinet.spec.def
+	$(RM) $@ && $(LN_S) cabinet/cabinet.spec.def $@
+libcabinet.a: cabinet/cabinet.spec.def
+	$(DLLTOOL) -k -l $@ -d cabinet/cabinet.spec.def
+
+libcomcat.def: comcat/comcat.spec.def
+	$(RM) $@ && $(LN_S) comcat/comcat.spec.def $@
+libcomcat.a: comcat/comcat.spec.def
+	$(DLLTOOL) -k -l $@ -d comcat/comcat.spec.def
+
+libcomctl32.def: comctl32/comctl32.spec.def
+	$(RM) $@ && $(LN_S) comctl32/comctl32.spec.def $@
+libcomctl32.a: comctl32/comctl32.spec.def
+	$(DLLTOOL) -k -l $@ -d comctl32/comctl32.spec.def
+
+libcomdlg32.def: commdlg/comdlg32.spec.def
+	$(RM) $@ && $(LN_S) commdlg/comdlg32.spec.def $@
+libcomdlg32.a: commdlg/comdlg32.spec.def
+	$(DLLTOOL) -k -l $@ -d commdlg/comdlg32.spec.def
+
+libcrtdll.def: crtdll/crtdll.spec.def
+	$(RM) $@ && $(LN_S) crtdll/crtdll.spec.def $@
+libcrtdll.a: crtdll/crtdll.spec.def
+	$(DLLTOOL) -k -l $@ -d crtdll/crtdll.spec.def
+
+libcrypt32.def: crypt32/crypt32.spec.def
+	$(RM) $@ && $(LN_S) crypt32/crypt32.spec.def $@
+libcrypt32.a: crypt32/crypt32.spec.def
+	$(DLLTOOL) -k -l $@ -d crypt32/crypt32.spec.def
+
+libd3d8.def: d3d8/d3d8.spec.def
+	$(RM) $@ && $(LN_S) d3d8/d3d8.spec.def $@
+libd3d8.a: d3d8/d3d8.spec.def
+	$(DLLTOOL) -k -l $@ -d d3d8/d3d8.spec.def
+
+libdciman32.def: dciman32/dciman32.spec.def
+	$(RM) $@ && $(LN_S) dciman32/dciman32.spec.def $@
+libdciman32.a: dciman32/dciman32.spec.def
+	$(DLLTOOL) -k -l $@ -d dciman32/dciman32.spec.def
+
+libddraw.def: ddraw/ddraw.spec.def
+	$(RM) $@ && $(LN_S) ddraw/ddraw.spec.def $@
+libddraw.a: ddraw/ddraw.spec.def
+	$(DLLTOOL) -k -l $@ -d ddraw/ddraw.spec.def
+
+libdevenum.def: devenum/devenum.spec.def
+	$(RM) $@ && $(LN_S) devenum/devenum.spec.def $@
+libdevenum.a: devenum/devenum.spec.def
+	$(DLLTOOL) -k -l $@ -d devenum/devenum.spec.def
+
+libdinput.def: dinput/dinput.spec.def
+	$(RM) $@ && $(LN_S) dinput/dinput.spec.def $@
+libdinput.a: dinput/dinput.spec.def
+	$(DLLTOOL) -k -l $@ -d dinput/dinput.spec.def
+
+libdinput8.def: dinput8/dinput8.spec.def
+	$(RM) $@ && $(LN_S) dinput8/dinput8.spec.def $@
+libdinput8.a: dinput8/dinput8.spec.def
+	$(DLLTOOL) -k -l $@ -d dinput8/dinput8.spec.def
+
+libdplay.def: dplay/dplay.spec.def
+	$(RM) $@ && $(LN_S) dplay/dplay.spec.def $@
+libdplay.a: dplay/dplay.spec.def
+	$(DLLTOOL) -k -l $@ -d dplay/dplay.spec.def
+
+libdplayx.def: dplayx/dplayx.spec.def
+	$(RM) $@ && $(LN_S) dplayx/dplayx.spec.def $@
+libdplayx.a: dplayx/dplayx.spec.def
+	$(DLLTOOL) -k -l $@ -d dplayx/dplayx.spec.def
+
+libdsound.def: dsound/dsound.spec.def
+	$(RM) $@ && $(LN_S) dsound/dsound.spec.def $@
+libdsound.a: dsound/dsound.spec.def
+	$(DLLTOOL) -k -l $@ -d dsound/dsound.spec.def
+
+libgdi32.def: gdi/gdi32.spec.def
+	$(RM) $@ && $(LN_S) gdi/gdi32.spec.def $@
+libgdi32.a: gdi/gdi32.spec.def
+	$(DLLTOOL) -k -l $@ -d gdi/gdi32.spec.def
+
+libglu32.def: glu32/glu32.spec.def
+	$(RM) $@ && $(LN_S) glu32/glu32.spec.def $@
+libglu32.a: glu32/glu32.spec.def
+	$(DLLTOOL) -k -l $@ -d glu32/glu32.spec.def
+
+libicmp.def: icmp/icmp.spec.def
+	$(RM) $@ && $(LN_S) icmp/icmp.spec.def $@
+libicmp.a: icmp/icmp.spec.def
+	$(DLLTOOL) -k -l $@ -d icmp/icmp.spec.def
+
+libimagehlp.def: imagehlp/imagehlp.spec.def
+	$(RM) $@ && $(LN_S) imagehlp/imagehlp.spec.def $@
+libimagehlp.a: imagehlp/imagehlp.spec.def
+	$(DLLTOOL) -k -l $@ -d imagehlp/imagehlp.spec.def
+
+libimm32.def: imm32/imm32.spec.def
+	$(RM) $@ && $(LN_S) imm32/imm32.spec.def $@
+libimm32.a: imm32/imm32.spec.def
+	$(DLLTOOL) -k -l $@ -d imm32/imm32.spec.def
+
+libkernel32.def: kernel/kernel32.spec.def
+	$(RM) $@ && $(LN_S) kernel/kernel32.spec.def $@
+libkernel32.a: kernel/kernel32.spec.def
+	$(DLLTOOL) -k -l $@ -d kernel/kernel32.spec.def
+
+liblz32.def: lzexpand/lz32.spec.def
+	$(RM) $@ && $(LN_S) lzexpand/lz32.spec.def $@
+liblz32.a: lzexpand/lz32.spec.def
+	$(DLLTOOL) -k -l $@ -d lzexpand/lz32.spec.def
+
+libmapi32.def: mapi32/mapi32.spec.def
+	$(RM) $@ && $(LN_S) mapi32/mapi32.spec.def $@
+libmapi32.a: mapi32/mapi32.spec.def
+	$(DLLTOOL) -k -l $@ -d mapi32/mapi32.spec.def
+
+libmpr.def: mpr/mpr.spec.def
+	$(RM) $@ && $(LN_S) mpr/mpr.spec.def $@
+libmpr.a: mpr/mpr.spec.def
+	$(DLLTOOL) -k -l $@ -d mpr/mpr.spec.def
+
+libmsacm32.def: msacm/msacm32.spec.def
+	$(RM) $@ && $(LN_S) msacm/msacm32.spec.def $@
+libmsacm32.a: msacm/msacm32.spec.def
+	$(DLLTOOL) -k -l $@ -d msacm/msacm32.spec.def
+
+libmsdmo.def: msdmo/msdmo.spec.def
+	$(RM) $@ && $(LN_S) msdmo/msdmo.spec.def $@
+libmsdmo.a: msdmo/msdmo.spec.def
+	$(DLLTOOL) -k -l $@ -d msdmo/msdmo.spec.def
+
+libmsimg32.def: msimg32/msimg32.spec.def
+	$(RM) $@ && $(LN_S) msimg32/msimg32.spec.def $@
+libmsimg32.a: msimg32/msimg32.spec.def
+	$(DLLTOOL) -k -l $@ -d msimg32/msimg32.spec.def
+
+libmsnet32.def: msnet32/msnet32.spec.def
+	$(RM) $@ && $(LN_S) msnet32/msnet32.spec.def $@
+libmsnet32.a: msnet32/msnet32.spec.def
+	$(DLLTOOL) -k -l $@ -d msnet32/msnet32.spec.def
+
+libmsrle32.def: msvideo/msrle32/msrle32.spec.def
+	$(RM) $@ && $(LN_S) msvideo/msrle32/msrle32.spec.def $@
+libmsrle32.a: msvideo/msrle32/msrle32.spec.def
+	$(DLLTOOL) -k -l $@ -d msvideo/msrle32/msrle32.spec.def
+
+libmsvcrt.def: msvcrt/msvcrt.spec.def
+	$(RM) $@ && $(LN_S) msvcrt/msvcrt.spec.def $@
+libmsvcrt.a: msvcrt/msvcrt.spec.def
+	$(DLLTOOL) -k -l $@ -d msvcrt/msvcrt.spec.def
+
+libmsvcrt20.def: msvcrt20/msvcrt20.spec.def
+	$(RM) $@ && $(LN_S) msvcrt20/msvcrt20.spec.def $@
+libmsvcrt20.a: msvcrt20/msvcrt20.spec.def
+	$(DLLTOOL) -k -l $@ -d msvcrt20/msvcrt20.spec.def
+
+libmsvfw32.def: msvideo/msvfw32.spec.def
+	$(RM) $@ && $(LN_S) msvideo/msvfw32.spec.def $@
+libmsvfw32.a: msvideo/msvfw32.spec.def
+	$(DLLTOOL) -k -l $@ -d msvideo/msvfw32.spec.def
+
+libnetapi32.def: netapi32/netapi32.spec.def
+	$(RM) $@ && $(LN_S) netapi32/netapi32.spec.def $@
+libnetapi32.a: netapi32/netapi32.spec.def
+	$(DLLTOOL) -k -l $@ -d netapi32/netapi32.spec.def
+
+libntdll.def: ntdll/ntdll.spec.def
+	$(RM) $@ && $(LN_S) ntdll/ntdll.spec.def $@
+libntdll.a: ntdll/ntdll.spec.def
+	$(DLLTOOL) -k -l $@ -d ntdll/ntdll.spec.def
+
+libodbc32.def: odbc32/odbc32.spec.def
+	$(RM) $@ && $(LN_S) odbc32/odbc32.spec.def $@
+libodbc32.a: odbc32/odbc32.spec.def
+	$(DLLTOOL) -k -l $@ -d odbc32/odbc32.spec.def
+
+libole32.def: ole32/ole32.spec.def
+	$(RM) $@ && $(LN_S) ole32/ole32.spec.def $@
+libole32.a: ole32/ole32.spec.def
+	$(DLLTOOL) -k -l $@ -d ole32/ole32.spec.def
+
+liboleaut32.def: oleaut32/oleaut32.spec.def
+	$(RM) $@ && $(LN_S) oleaut32/oleaut32.spec.def $@
+liboleaut32.a: oleaut32/oleaut32.spec.def
+	$(DLLTOOL) -k -l $@ -d oleaut32/oleaut32.spec.def
+
+libolecli32.def: olecli/olecli32.spec.def
+	$(RM) $@ && $(LN_S) olecli/olecli32.spec.def $@
+libolecli32.a: olecli/olecli32.spec.def
+	$(DLLTOOL) -k -l $@ -d olecli/olecli32.spec.def
+
+liboledlg.def: oledlg/oledlg.spec.def
+	$(RM) $@ && $(LN_S) oledlg/oledlg.spec.def $@
+liboledlg.a: oledlg/oledlg.spec.def
+	$(DLLTOOL) -k -l $@ -d oledlg/oledlg.spec.def
+
+libolepro32.def: olepro32/olepro32.spec.def
+	$(RM) $@ && $(LN_S) olepro32/olepro32.spec.def $@
+libolepro32.a: olepro32/olepro32.spec.def
+	$(DLLTOOL) -k -l $@ -d olepro32/olepro32.spec.def
+
+libolesvr32.def: olesvr/olesvr32.spec.def
+	$(RM) $@ && $(LN_S) olesvr/olesvr32.spec.def $@
+libolesvr32.a: olesvr/olesvr32.spec.def
+	$(DLLTOOL) -k -l $@ -d olesvr/olesvr32.spec.def
+
+libopengl32.def: opengl32/opengl32.spec.def
+	$(RM) $@ && $(LN_S) opengl32/opengl32.spec.def $@
+libopengl32.a: opengl32/opengl32.spec.def
+	$(DLLTOOL) -k -l $@ -d opengl32/opengl32.spec.def
+
+libpsapi.def: psapi/psapi.spec.def
+	$(RM) $@ && $(LN_S) psapi/psapi.spec.def $@
+libpsapi.a: psapi/psapi.spec.def
+	$(DLLTOOL) -k -l $@ -d psapi/psapi.spec.def
+
+libqcap.def: qcap/qcap.spec.def
+	$(RM) $@ && $(LN_S) qcap/qcap.spec.def $@
+libqcap.a: qcap/qcap.spec.def
+	$(DLLTOOL) -k -l $@ -d qcap/qcap.spec.def
+
+libquartz.def: quartz/quartz.spec.def
+	$(RM) $@ && $(LN_S) quartz/quartz.spec.def $@
+libquartz.a: quartz/quartz.spec.def
+	$(DLLTOOL) -k -l $@ -d quartz/quartz.spec.def
+
+librasapi32.def: rasapi32/rasapi32.spec.def
+	$(RM) $@ && $(LN_S) rasapi32/rasapi32.spec.def $@
+librasapi32.a: rasapi32/rasapi32.spec.def
+	$(DLLTOOL) -k -l $@ -d rasapi32/rasapi32.spec.def
+
+libriched32.def: richedit/riched32.spec.def
+	$(RM) $@ && $(LN_S) richedit/riched32.spec.def $@
+libriched32.a: richedit/riched32.spec.def
+	$(DLLTOOL) -k -l $@ -d richedit/riched32.spec.def
+
+librpcrt4.def: rpcrt4/rpcrt4.spec.def
+	$(RM) $@ && $(LN_S) rpcrt4/rpcrt4.spec.def $@
+librpcrt4.a: rpcrt4/rpcrt4.spec.def
+	$(DLLTOOL) -k -l $@ -d rpcrt4/rpcrt4.spec.def
+
+libserialui.def: serialui/serialui.spec.def
+	$(RM) $@ && $(LN_S) serialui/serialui.spec.def $@
+libserialui.a: serialui/serialui.spec.def
+	$(DLLTOOL) -k -l $@ -d serialui/serialui.spec.def
+
+libsetupapi.def: setupapi/setupapi.spec.def
+	$(RM) $@ && $(LN_S) setupapi/setupapi.spec.def $@
+libsetupapi.a: setupapi/setupapi.spec.def
+	$(DLLTOOL) -k -l $@ -d setupapi/setupapi.spec.def
+
+libshdocvw.def: shdocvw/shdocvw.spec.def
+	$(RM) $@ && $(LN_S) shdocvw/shdocvw.spec.def $@
+libshdocvw.a: shdocvw/shdocvw.spec.def
+	$(DLLTOOL) -k -l $@ -d shdocvw/shdocvw.spec.def
+
+libshell32.def: shell32/shell32.spec.def
+	$(RM) $@ && $(LN_S) shell32/shell32.spec.def $@
+libshell32.a: shell32/shell32.spec.def
+	$(DLLTOOL) -k -l $@ -d shell32/shell32.spec.def
+
+libshfolder.def: shfolder/shfolder.spec.def
+	$(RM) $@ && $(LN_S) shfolder/shfolder.spec.def $@
+libshfolder.a: shfolder/shfolder.spec.def
+	$(DLLTOOL) -k -l $@ -d shfolder/shfolder.spec.def
+
+libshlwapi.def: shlwapi/shlwapi.spec.def
+	$(RM) $@ && $(LN_S) shlwapi/shlwapi.spec.def $@
+libshlwapi.a: shlwapi/shlwapi.spec.def
+	$(DLLTOOL) -k -l $@ -d shlwapi/shlwapi.spec.def
+
+libsnmpapi.def: snmpapi/snmpapi.spec.def
+	$(RM) $@ && $(LN_S) snmpapi/snmpapi.spec.def $@
+libsnmpapi.a: snmpapi/snmpapi.spec.def
+	$(DLLTOOL) -k -l $@ -d snmpapi/snmpapi.spec.def
+
+libsti.def: sti/sti.spec.def
+	$(RM) $@ && $(LN_S) sti/sti.spec.def $@
+libsti.a: sti/sti.spec.def
+	$(DLLTOOL) -k -l $@ -d sti/sti.spec.def
+
+libtapi32.def: tapi32/tapi32.spec.def
+	$(RM) $@ && $(LN_S) tapi32/tapi32.spec.def $@
+libtapi32.a: tapi32/tapi32.spec.def
+	$(DLLTOOL) -k -l $@ -d tapi32/tapi32.spec.def
+
+libttydrv.def: ttydrv/ttydrv.spec.def
+	$(RM) $@ && $(LN_S) ttydrv/ttydrv.spec.def $@
+libttydrv.a: ttydrv/ttydrv.spec.def
+	$(DLLTOOL) -k -l $@ -d ttydrv/ttydrv.spec.def
+
+libtwain_32.def: twain/twain_32.spec.def
+	$(RM) $@ && $(LN_S) twain/twain_32.spec.def $@
+libtwain_32.a: twain/twain_32.spec.def
+	$(DLLTOOL) -k -l $@ -d twain/twain_32.spec.def
+
+liburl.def: url/url.spec.def
+	$(RM) $@ && $(LN_S) url/url.spec.def $@
+liburl.a: url/url.spec.def
+	$(DLLTOOL) -k -l $@ -d url/url.spec.def
+
+liburlmon.def: urlmon/urlmon.spec.def
+	$(RM) $@ && $(LN_S) urlmon/urlmon.spec.def $@
+liburlmon.a: urlmon/urlmon.spec.def
+	$(DLLTOOL) -k -l $@ -d urlmon/urlmon.spec.def
+
+libuser32.def: user/user32.spec.def
+	$(RM) $@ && $(LN_S) user/user32.spec.def $@
+libuser32.a: user/user32.spec.def
+	$(DLLTOOL) -k -l $@ -d user/user32.spec.def
+
+libversion.def: version/version.spec.def
+	$(RM) $@ && $(LN_S) version/version.spec.def $@
+libversion.a: version/version.spec.def
+	$(DLLTOOL) -k -l $@ -d version/version.spec.def
+
+libw32skrnl.def: win32s/w32skrnl.spec.def
+	$(RM) $@ && $(LN_S) win32s/w32skrnl.spec.def $@
+libw32skrnl.a: win32s/w32skrnl.spec.def
+	$(DLLTOOL) -k -l $@ -d win32s/w32skrnl.spec.def
+
+libwinedos.def: winedos/winedos.spec.def
+	$(RM) $@ && $(LN_S) winedos/winedos.spec.def $@
+libwinedos.a: winedos/winedos.spec.def
+	$(DLLTOOL) -k -l $@ -d winedos/winedos.spec.def
+
+libwineps.def: wineps/wineps.spec.def
+	$(RM) $@ && $(LN_S) wineps/wineps.spec.def $@
+libwineps.a: wineps/wineps.spec.def
+	$(DLLTOOL) -k -l $@ -d wineps/wineps.spec.def
+
+libwininet.def: wininet/wininet.spec.def
+	$(RM) $@ && $(LN_S) wininet/wininet.spec.def $@
+libwininet.a: wininet/wininet.spec.def
+	$(DLLTOOL) -k -l $@ -d wininet/wininet.spec.def
+
+libwinmm.def: winmm/winmm.spec.def
+	$(RM) $@ && $(LN_S) winmm/winmm.spec.def $@
+libwinmm.a: winmm/winmm.spec.def
+	$(DLLTOOL) -k -l $@ -d winmm/winmm.spec.def
+
+libwinnls32.def: winnls/winnls32.spec.def
+	$(RM) $@ && $(LN_S) winnls/winnls32.spec.def $@
+libwinnls32.a: winnls/winnls32.spec.def
+	$(DLLTOOL) -k -l $@ -d winnls/winnls32.spec.def
+
+libwinspool.def: winspool/winspool.drv.spec.def
+	$(RM) $@ && $(LN_S) winspool/winspool.drv.spec.def $@
+libwinspool.a: winspool/winspool.drv.spec.def
+	$(DLLTOOL) -k -l $@ -d winspool/winspool.drv.spec.def
+
+libwintrust.def: wintrust/wintrust.spec.def
+	$(RM) $@ && $(LN_S) wintrust/wintrust.spec.def $@
+libwintrust.a: wintrust/wintrust.spec.def
+	$(DLLTOOL) -k -l $@ -d wintrust/wintrust.spec.def
+
+libwnaspi32.def: winaspi/wnaspi32.spec.def
+	$(RM) $@ && $(LN_S) winaspi/wnaspi32.spec.def $@
+libwnaspi32.a: winaspi/wnaspi32.spec.def
+	$(DLLTOOL) -k -l $@ -d winaspi/wnaspi32.spec.def
+
+libwow32.def: wow32/wow32.spec.def
+	$(RM) $@ && $(LN_S) wow32/wow32.spec.def $@
+libwow32.a: wow32/wow32.spec.def
+	$(DLLTOOL) -k -l $@ -d wow32/wow32.spec.def
+
+libws2_32.def: winsock/ws2_32.spec.def
+	$(RM) $@ && $(LN_S) winsock/ws2_32.spec.def $@
+libws2_32.a: winsock/ws2_32.spec.def
+	$(DLLTOOL) -k -l $@ -d winsock/ws2_32.spec.def
+
+libwsock32.def: wsock32/wsock32.spec.def
+	$(RM) $@ && $(LN_S) wsock32/wsock32.spec.def $@
+libwsock32.a: wsock32/wsock32.spec.def
+	$(DLLTOOL) -k -l $@ -d wsock32/wsock32.spec.def
+
+libx11drv.def: x11drv/x11drv.spec.def
+	$(RM) $@ && $(LN_S) x11drv/x11drv.spec.def $@
+libx11drv.a: x11drv/x11drv.spec.def
+	$(DLLTOOL) -k -l $@ -d x11drv/x11drv.spec.def
+
+advapi32/advapi32.spec.def: $(WINEBUILD)
+avicap32/avicap32.spec.def: $(WINEBUILD)
+avifil32/avifil32.spec.def: $(WINEBUILD)
+cabinet/cabinet.spec.def: $(WINEBUILD)
+comcat/comcat.spec.def: $(WINEBUILD)
+comctl32/comctl32.spec.def: $(WINEBUILD)
+commdlg/comdlg32.spec.def: $(WINEBUILD)
+crtdll/crtdll.spec.def: $(WINEBUILD)
+crypt32/crypt32.spec.def: $(WINEBUILD)
+d3d8/d3d8.spec.def: $(WINEBUILD)
+dciman32/dciman32.spec.def: $(WINEBUILD)
+ddraw/ddraw.spec.def: $(WINEBUILD)
+devenum/devenum.spec.def: $(WINEBUILD)
+dinput/dinput.spec.def: $(WINEBUILD)
+dinput8/dinput8.spec.def: $(WINEBUILD)
+dplay/dplay.spec.def: $(WINEBUILD)
+dplayx/dplayx.spec.def: $(WINEBUILD)
+dsound/dsound.spec.def: $(WINEBUILD)
+gdi/gdi32.spec.def: $(WINEBUILD)
+glu32/glu32.spec.def: $(WINEBUILD)
+icmp/icmp.spec.def: $(WINEBUILD)
+imagehlp/imagehlp.spec.def: $(WINEBUILD)
+imm32/imm32.spec.def: $(WINEBUILD)
+kernel/kernel32.spec.def: $(WINEBUILD)
+lzexpand/lz32.spec.def: $(WINEBUILD)
+mapi32/mapi32.spec.def: $(WINEBUILD)
+mpr/mpr.spec.def: $(WINEBUILD)
+msacm/msacm32.spec.def: $(WINEBUILD)
+msdmo/msdmo.spec.def: $(WINEBUILD)
+msimg32/msimg32.spec.def: $(WINEBUILD)
+msnet32/msnet32.spec.def: $(WINEBUILD)
+msvideo/msrle32/msrle32.spec.def: $(WINEBUILD)
+msvcrt/msvcrt.spec.def: $(WINEBUILD)
+msvcrt20/msvcrt20.spec.def: $(WINEBUILD)
+msvideo/msvfw32.spec.def: $(WINEBUILD)
+netapi32/netapi32.spec.def: $(WINEBUILD)
+ntdll/ntdll.spec.def: $(WINEBUILD)
+odbc32/odbc32.spec.def: $(WINEBUILD)
+ole32/ole32.spec.def: $(WINEBUILD)
+oleaut32/oleaut32.spec.def: $(WINEBUILD)
+olecli/olecli32.spec.def: $(WINEBUILD)
+oledlg/oledlg.spec.def: $(WINEBUILD)
+olepro32/olepro32.spec.def: $(WINEBUILD)
+olesvr/olesvr32.spec.def: $(WINEBUILD)
+opengl32/opengl32.spec.def: $(WINEBUILD)
+psapi/psapi.spec.def: $(WINEBUILD)
+qcap/qcap.spec.def: $(WINEBUILD)
+quartz/quartz.spec.def: $(WINEBUILD)
+rasapi32/rasapi32.spec.def: $(WINEBUILD)
+richedit/riched32.spec.def: $(WINEBUILD)
+rpcrt4/rpcrt4.spec.def: $(WINEBUILD)
+serialui/serialui.spec.def: $(WINEBUILD)
+setupapi/setupapi.spec.def: $(WINEBUILD)
+shdocvw/shdocvw.spec.def: $(WINEBUILD)
+shell32/shell32.spec.def: $(WINEBUILD)
+shfolder/shfolder.spec.def: $(WINEBUILD)
+shlwapi/shlwapi.spec.def: $(WINEBUILD)
+snmpapi/snmpapi.spec.def: $(WINEBUILD)
+sti/sti.spec.def: $(WINEBUILD)
+tapi32/tapi32.spec.def: $(WINEBUILD)
+ttydrv/ttydrv.spec.def: $(WINEBUILD)
+twain/twain_32.spec.def: $(WINEBUILD)
+url/url.spec.def: $(WINEBUILD)
+urlmon/urlmon.spec.def: $(WINEBUILD)
+user/user32.spec.def: $(WINEBUILD)
+version/version.spec.def: $(WINEBUILD)
+win32s/w32skrnl.spec.def: $(WINEBUILD)
+winedos/winedos.spec.def: $(WINEBUILD)
+wineps/wineps.spec.def: $(WINEBUILD)
+wininet/wininet.spec.def: $(WINEBUILD)
+winmm/winmm.spec.def: $(WINEBUILD)
+winnls/winnls32.spec.def: $(WINEBUILD)
+winspool/winspool.drv.spec.def: $(WINEBUILD)
+wintrust/wintrust.spec.def: $(WINEBUILD)
+winaspi/wnaspi32.spec.def: $(WINEBUILD)
+wow32/wow32.spec.def: $(WINEBUILD)
+winsock/ws2_32.spec.def: $(WINEBUILD)
+wsock32/wsock32.spec.def: $(WINEBUILD)
+x11drv/x11drv.spec.def: $(WINEBUILD)
+
+$(SUBDIRS): $(IMPORT_LIBS)
+
 # Map library name to the corresponding directory
 
 advapi32/advapi32.dll$(DLLEXT): advapi32
@@ -767,117 +1328,6 @@
 wsock32/__install__: wsock32.dll$(DLLEXT)
 x11drv/__install__: x11drv.dll$(DLLEXT)
 
-# Inter-dll dependencies
-
-advapi32: kernel32.dll$(DLLEXT) ntdll.dll$(DLLEXT)
-avicap32: ntdll.dll$(DLLEXT)
-avifil32: msacm32.dll$(DLLEXT) msvfw32.dll$(DLLEXT) shell32.dll$(DLLEXT) winmm.dll$(DLLEXT) \
-          user32.dll$(DLLEXT) advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-cabinet:  kernel32.dll$(DLLEXT)
-comcat:   ole32.dll$(DLLEXT) user32.dll$(DLLEXT) advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-comctl32: user32.dll$(DLLEXT) gdi32.dll$(DLLEXT) advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT) \
-          winmm.dll$(DLLEXT)
-commdlg:  shell32.dll$(DLLEXT) shlwapi.dll$(DLLEXT) comctl32.dll$(DLLEXT) winspool.drv$(DLLEXT) \
-          user32.dll$(DLLEXT) gdi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-crtdll:   msvcrt.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-crypt32:  advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-d3d8:     user32.dll$(DLLEXT) gdi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-dciman32: kernel32.dll$(DLLEXT)
-ddraw:    user32.dll$(DLLEXT) gdi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-devenum:  kernel32.dll$(DLLEXT)
-dinput8:  dinput.dll$(DLLEXT)
-dinput:   user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-dplay:    dplayx.dll$(DLLEXT)
-dplayx:   winmm.dll$(DLLEXT) ole32.dll$(DLLEXT) user32.dll$(DLLEXT) advapi32.dll$(DLLEXT) \
-          kernel32.dll$(DLLEXT)
-dsound:   winmm.dll$(DLLEXT) advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT) ntdll.dll$(DLLEXT)
-gdi:      advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-glu32:    kernel32.dll$(DLLEXT)
-icmp:     kernel32.dll$(DLLEXT)
-imagehlp: kernel32.dll$(DLLEXT)
-imm32:    kernel32.dll$(DLLEXT)
-kernel:   ntdll.dll$(DLLEXT) libntdll.dll.$(LIBEXT)
-lzexpand: kernel32.dll$(DLLEXT)
-mapi32:   kernel32.dll$(DLLEXT)
-mpr:      advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-msacm/imaadp32: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-msacm/msadp32: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-msacm/msg711: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-msacm/winemp3: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-msacm:    winmm.dll$(DLLEXT) user32.dll$(DLLEXT) advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-msdmo:    kernel32.dll$(DLLEXT)
-msimg32:  kernel32.dll$(DLLEXT)
-msisys:   kernel32.dll$(DLLEXT)
-msnet32:  kernel32.dll$(DLLEXT)
-msvcrt20: msvcrt.dll$(DLLEXT)
-msvcrt:   kernel32.dll$(DLLEXT) ntdll.dll$(DLLEXT)
-msvideo/msrle32: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-msvideo:  winmm.dll$(DLLEXT) comctl32.dll$(DLLEXT) version.dll$(DLLEXT) user32.dll$(DLLEXT) \
-          gdi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-netapi32: advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-odbc32:   kernel32.dll$(DLLEXT)
-ole32:    advapi32.dll$(DLLEXT) user32.dll$(DLLEXT) gdi32.dll$(DLLEXT) rpcrt4.dll$(DLLEXT) \
-          kernel32.dll$(DLLEXT) ntdll.dll$(DLLEXT)
-oleaut32: ole32.dll$(DLLEXT) user32.dll$(DLLEXT) gdi32.dll$(DLLEXT) advapi32.dll$(DLLEXT) \
-          kernel32.dll$(DLLEXT) comctl32.dll$(DLLEXT)
-olecli:   ole32.dll$(DLLEXT) gdi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-oledlg:   kernel32.dll$(DLLEXT)
-olepro32: oleaut32.dll$(DLLEXT)
-olesvr:   kernel32.dll$(DLLEXT)
-opengl32: user32.dll$(DLLEXT) gdi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-psapi:    kernel32.dll$(DLLEXT) ntdll.dll$(DLLEXT)
-qcap:     kernel32.dll$(DLLEXT)
-quartz:   kernel32.dll$(DLLEXT)
-rasapi32: kernel32.dll$(DLLEXT)
-richedit: user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-rpcrt4:   advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-serialui: user32.dll$(DLLEXT) advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-setupapi: user32.dll$(DLLEXT) advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT) ntdll.dll$(DLLEXT)
-shdocvw:  ole32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-shell32:  ole32.dll$(DLLEXT) shlwapi.dll$(DLLEXT) comctl32.dll$(DLLEXT) user32.dll$(DLLEXT) \
-          gdi32.dll$(DLLEXT) advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-shfolder: shell32.dll$(DLLEXT)
-shlwapi:  ole32.dll$(DLLEXT) user32.dll$(DLLEXT) gdi32.dll$(DLLEXT) advapi32.dll$(DLLEXT) \
-          kernel32.dll$(DLLEXT)
-snmpapi:  kernel32.dll$(DLLEXT)
-sti:      kernel32.dll$(DLLEXT)
-tapi32:   advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-ttydrv:   user32.dll$(DLLEXT) gdi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-twain:    user32.dll$(DLLEXT) gdi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-url:      kernel32.dll$(DLLEXT)
-urlmon:   ole32.dll$(DLLEXT) wininet.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-user:     gdi32.dll$(DLLEXT) advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-version:  lz32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-win32s:   kernel32.dll$(DLLEXT)
-winaspi:  advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-winedos:  user32.dll$(DLLEXT) kernel32.dll$(DLLEXT) ntdll.dll$(DLLEXT)
-wineps:   user32.dll$(DLLEXT) gdi32.dll$(DLLEXT) winspool.drv$(DLLEXT) advapi32.dll$(DLLEXT) \
-          kernel32.dll$(DLLEXT)
-wininet:  shlwapi.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-winmm/joystick: winmm.dll$(DLLEXT) user32.dll$(DLLEXT)
-winmm/mcianim: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-winmm/mciavi: msvfw32.dll$(DLLEXT) winmm.dll$(DLLEXT) user32.dll$(DLLEXT) gdi32.dll$(DLLEXT) \
-          kernel32.dll$(DLLEXT)
-winmm/mcicda: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-winmm/mciseq: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-winmm/mciwave: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-winmm/midimap: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-winmm/wavemap: msacm32.dll$(DLLEXT) winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-winmm/winealsa: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT) ntdll.dll$(DLLEXT)
-winmm/winearts: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-winmm/wineaudioio: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT) ntdll.dll$(DLLEXT)
-winmm/winenas: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-winmm/wineoss: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-winmm:    user32.dll$(DLLEXT) advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-winnls:   kernel32.dll$(DLLEXT)
-winsock:  user32.dll$(DLLEXT) kernel32.dll$(DLLEXT) ntdll.dll$(DLLEXT)
-winspool: advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-wintrust: kernel32.dll$(DLLEXT)
-wow32:    kernel32.dll$(DLLEXT)
-wsock32:  ws2_32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
-x11drv:   user32.dll$(DLLEXT) gdi32.dll$(DLLEXT) advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT) \
-          ntdll.dll$(DLLEXT)
-
 # Special targets for dlls that we need to link to
 
 LINKABLE_DLLS = ntdll.dll
@@ -885,10 +1335,12 @@
 libntdll.dll.$(LIBEXT): ntdll/ntdll.dll$(DLLEXT)
 	$(RM) $@ && $(LN_S) ntdll/ntdll.dll$(DLLEXT) $@
 
+kernel: libntdll.dll.$(LIBEXT)
+
 uninstall::
 	$(RM) $(LINKABLE_DLLS:%=$(libdir)/lib%.$(LIBEXT))
 
-install::
+install install-lib::
 	$(RM) $(LINKABLE_DLLS:%=$(libdir)/lib%.$(LIBEXT))
 	cd $(libdir) && if [ "$(dlldir)" = "$(libdir)/wine" ]; \
 	then \
@@ -899,9 +1351,19 @@
 
 # Misc rules
 
+install install-dev:: $(IMPORT_LIBS)
+	$(MKINSTALLDIRS) $(dlldir)
+	for f in $(IMPORT_LIBS); do $(INSTALL_DATA) $$f $(dlldir)/$$f; done
+
+install install-lib:: $(INSTALLSUBDIRS:%=%/__install__)
+
 uninstall::
+	$(RM) $(IMPORT_LIBS:%=$(dlldir)/%)
 	-rmdir $(dlldir)
 
+clean::
+	$(RM) $(IMPORT_LIBS)
+
 check test:: $(BUILDSUBDIRS:%=%/__test__)
 
 crosstest:: $(BUILDSUBDIRS:%=%/__crosstest__)
diff --git a/dlls/commdlg/Makefile.in b/dlls/commdlg/Makefile.in
index 4d369cf..4ba1147 100644
--- a/dlls/commdlg/Makefile.in
+++ b/dlls/commdlg/Makefile.in
@@ -3,7 +3,7 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = comdlg32.dll
-IMPORTS   = shell32 shlwapi comctl32 winspool.drv user32 gdi32 kernel32
+IMPORTS   = shell32 shlwapi comctl32 winspool user32 gdi32 kernel32
 ALTNAMES  = commdlg.dll
 EXTRALIBS = $(LIBUUID)
 
diff --git a/dlls/make_dlls b/dlls/make_dlls
index 2d46231..fb53c5a 100755
--- a/dlls/make_dlls
+++ b/dlls/make_dlls
@@ -202,6 +202,48 @@
 
 
 ################################################################
+# output the import libraries rules
+
+my @implibs = grep /\.dll$/, keys %directories;
+push @implibs, "winspool.drv";
+
+print NEWMAKE "\n# Import libraries\n\nIMPORT_LIBS =";
+foreach my $mod (sort @implibs)
+{
+    my $def = $mod;
+    $def =~ s/\.(dll|drv)$/.\$(IMPLIBEXT)/;
+    printf NEWMAKE " \\\n\tlib%s", $def;
+}
+print NEWMAKE "\n\n";
+
+foreach my $mod (sort @implibs)
+{
+    my $dir = $directories{$mod};
+    my $def = $mod;
+    my $spec = $mod;
+    $spec =~ s/\.dll$//;
+    $def =~ s/\.(dll|drv)$//;
+    printf NEWMAKE "lib%s.def: %s/%s.spec.def\n", $def, $dir, $spec;
+    printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s.spec.def \$@\n", $dir, $spec;
+    printf NEWMAKE "lib%s.a: %s/%s.spec.def\n", $def, $dir, $spec;
+    printf NEWMAKE "\t\$(DLLTOOL) -k -l \$@ -d %s/%s.spec.def\n\n", $dir, $spec;
+}
+foreach my $mod (sort @implibs)
+{
+    my $dir = $directories{$mod};
+    my $spec = $mod;
+    $spec =~ s/\.dll$//;
+    printf NEWMAKE "%s/%s.spec.def: \$(WINEBUILD)\n", $dir, $spec;
+}
+
+
+print NEWMAKE <<EOF;
+
+\$(SUBDIRS): \$(IMPORT_LIBS)
+
+EOF
+
+################################################################
 # output the inter-dll dependencies and rules
 
 print NEWMAKE "# Map library name to the corresponding directory\n\n";
@@ -218,38 +260,6 @@
     printf NEWMAKE "%s/__install__: %s\$(DLLEXT)\n", $directories{$mod}, $mod;
 }
 
-print NEWMAKE "\n# Inter-dll dependencies\n\n";
-
-my @depends = ();
-foreach my $mod (sort keys %imports)
-{
-    next unless @{$imports{$mod}};
-    my $count = 0;
-    my $dep = sprintf("%s:", $directories{$mod});
-    $dep .= " " x (8-length($directories{$mod}));
-    foreach my $i (@{$imports{$mod}})
-    {
-        if ($count++ >= 4)
-        {
-            $count = 1;
-            $dep .= " \\\n" . " " x 9;
-        }
-        $dep .= sprintf(" %s\$(DLLEXT)", $i);
-    }
-    foreach my $i (@{$linked_dlls{$mod}})
-    {
-        if ($count++ >= 4)
-        {
-            $count = 1;
-            $dep .= " \\\n" . " " x 9;
-        }
-        $dep .= sprintf(" lib%s.\$(LIBEXT)", $i);
-    }
-    push @depends, $dep . "\n";
-}
-print NEWMAKE sort @depends;
-
-
 ################################################################
 # output the linkable dlls special links
 
@@ -268,11 +278,19 @@
     printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
 }
 
+foreach my $mod (keys %imports)
+{
+    my $deps = "";
+    foreach my $i (@{$linked_dlls{$mod}}) { $deps .= " lib$i.\$(LIBEXT)"; }
+    if ($deps) { printf NEWMAKE "%s:%s\n", $directories{$mod}, $deps; }
+}
+
 print NEWMAKE <<EOF;
+
 uninstall::
 	\$(RM) \$(LINKABLE_DLLS:%=\$(libdir)/lib%.\$(LIBEXT))
 
-install::
+install install-lib::
 	\$(RM) \$(LINKABLE_DLLS:%=\$(libdir)/lib%.\$(LIBEXT))
 	cd \$(libdir) && if [ "\$(dlldir)" = "\$(libdir)/wine" ]; \\
 	then \\
@@ -294,9 +312,19 @@
 print NEWMAKE <<EOF;
 # Misc rules
 
+install install-dev:: \$(IMPORT_LIBS)
+	\$(MKINSTALLDIRS) \$(dlldir)
+	for f in \$(IMPORT_LIBS); do \$(INSTALL_DATA) \$\$f \$(dlldir)/\$\$f; done
+
+install install-lib:: \$(INSTALLSUBDIRS:%=%/__install__)
+
 uninstall::
+	\$(RM) \$(IMPORT_LIBS:%=\$(dlldir)/%)
 	-rmdir \$(dlldir)
 
+clean::
+	\$(RM) \$(IMPORT_LIBS)
+
 check test:: \$(BUILDSUBDIRS:%=%/__test__)
 
 crosstest:: \$(BUILDSUBDIRS:%=%/__crosstest__)
diff --git a/dlls/wineps/Makefile.in b/dlls/wineps/Makefile.in
index cfc0cfa..bb06f41 100644
--- a/dlls/wineps/Makefile.in
+++ b/dlls/wineps/Makefile.in
@@ -3,7 +3,7 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = wineps.dll
-IMPORTS   = user32 gdi32 winspool.drv advapi32 kernel32
+IMPORTS   = user32 gdi32 winspool advapi32 kernel32
 ALTNAMES  = wineps16.dll
 EXTRAINCL = @FREETYPEINCL@
 
diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c
index fdaa2fd..d28e7e9 100644
--- a/tools/winebuild/import.c
+++ b/tools/winebuild/import.c
@@ -34,7 +34,7 @@
 
 struct func
 {
-    const char *name;         /* function name */
+    char       *name;         /* function name */
     int         ordinal;      /* function ordinal */
     int         ord_only;     /* non-zero if function is imported by ordinal */
 };
@@ -150,7 +150,7 @@
 {
     struct func func, *res = NULL;
 
-    func.name = name;
+    func.name = (char *)name;
     func.ordinal = -1;
     if (table) res = bsearch( &func, table, size, sizeof(*table), func_cmp );
     return res;
@@ -163,12 +163,37 @@
         qsort( table, size, sizeof(*table), name_cmp );
 }
 
+/* free an import structure */
+static void free_imports( struct import *imp )
+{
+    int i;
+
+    for (i = 0; i < imp->nb_exports; i++) free( imp->exports[i].name );
+    for (i = 0; i < imp->nb_imports; i++) free( imp->imports[i].name );
+    free( imp->exports );
+    free( imp->imports );
+    free( imp->dll );
+    free( imp );
+}
+
 /* remove the temp file at exit */
 static void remove_ld_tmp_file(void)
 {
     if (ld_tmp_file) unlink( ld_tmp_file );
 }
 
+/* check whether a given dll has already been imported */
+static int is_already_imported( const char *name )
+{
+    int i;
+
+    for (i = 0; i < nb_imports; i++)
+    {
+        if (!strcmp( dll_imports[i]->dll, name )) return 1;
+    }
+    return 0;
+}
+
 /* open the .so library for a given dll in a specified path */
 static char *try_library_path( const char *path, const char *name )
 {
@@ -176,8 +201,8 @@
     int fd;
 
     buffer = xmalloc( strlen(path) + strlen(name) + 9 );
-    sprintf( buffer, "%s/%s", path, name );
-    strcat( buffer, ".so" );
+    sprintf( buffer, "%s/lib%s.def", path, name );
+
     /* check if the file exists */
     if ((fd = open( buffer, O_RDONLY )) != -1)
     {
@@ -199,66 +224,124 @@
         if ((fullname = try_library_path( lib_path[i], name ))) return fullname;
     }
     if (!(fullname = try_library_path( ".", name )))
-        fatal_error( "could not open .so file for %s\n", name );
+        fatal_error( "could not open .def file for %s\n", name );
     return fullname;
 }
 
-/* read in the list of exported symbols of a .so */
-static void read_exported_symbols( const char *name, struct import *imp )
+/* skip whitespace until the next token */
+static char *skip_whitespace( char *p )
+{
+    while (*p && isspace(*p)) p++;
+    if (!*p || *p == ';') p = NULL;
+    return p;
+}
+
+/* skip to the start of the next token, null terminating the current one */
+static char *next_token( char *p )
+{
+    while (*p && !isspace(*p)) p++;
+    if (*p) *p++ = 0;
+    return skip_whitespace( p );
+}
+
+/* remove the @nn suffix from stdcall names */
+static char *remove_stdcall_decoration( char *buffer )
+{
+    char *p = buffer + strlen(buffer) - 1;
+    while (p > buffer && isdigit(*p)) p--;
+    if (p > buffer && *p == '@') *p = 0;
+    return buffer;
+}
+
+/* read in the list of exported symbols of an import library */
+static int read_import_lib( const char *name, struct import *imp )
 {
     FILE *f;
-    char buffer[1024], prefix[80], ord_prefix[80];
-    char *fullname, *cmdline;
-    int size, err;
+    char buffer[1024];
+    char *fullname;
+    int size;
 
     imp->exports    = NULL;
     imp->nb_exports = size = 0;
 
-    if (!(fullname = open_library( name ))) return;
-    cmdline = xmalloc( strlen(fullname) + 7 );
-    sprintf( cmdline, "nm -D %s", fullname );
+    fullname = open_library( name );
+    f = open_input_file( NULL, fullname );
     free( fullname );
 
-    if (!(f = popen( cmdline, "r" )))
-        fatal_error( "Cannot execute '%s'\n", cmdline );
-
-    sprintf( prefix, "__wine_dllexport_%s_", make_c_identifier(name) );
-    sprintf( ord_prefix, "__wine_ordexport_%s_", make_c_identifier(name) );
-
     while (fgets( buffer, sizeof(buffer), f ))
     {
+        char *name, *flags;
         int ordinal = 0, ord_only = 0;
+
         char *p = buffer + strlen(buffer) - 1;
-        if (p < buffer) continue;
+        if (p < buffer) goto next;
         if (*p == '\n') *p-- = 0;
-        if (!(p = strstr( buffer, prefix )))
+
+        p = buffer;
+        if (!(p = skip_whitespace(p))) goto next;
+        name = p;
+        p = next_token( name );
+
+        if (!strcmp( name, "LIBRARY" ))
         {
-            if (!(p = strstr( buffer, ord_prefix ))) continue;
-            ord_only = 1;
+            if (!p) fatal_error( "Expected name after LIBRARY\n" );
+            name = p;
+            p = next_token( name );
+            if (p) fatal_error( "Garbage after LIBRARY statement\n" );
+            if (is_already_imported( name ))
+            {
+                close_input_file( f );
+                return 0;  /* ignore this dll */
+            }
+            free( imp->dll );
+            imp->dll = xstrdup( name );
+            goto next;
         }
-        p += strlen(prefix);
-        if (isdigit(*p))
+        if (!strcmp( name, "EXPORTS" )) goto next;
+
+        /* check for ordinal */
+        if (!p) fatal_error( "Expected ordinal after function name\n" );
+        if (*p != '@' || !isdigit(p[1]))
+            fatal_error( "Expected ordinal after function name '%s'\n", name );
+        ordinal = strtol( p+1, &p, 10 );
+        if (ordinal >= MAX_ORDINALS) fatal_error( "Invalid ordinal number %d\n", ordinal );
+
+        /* check for optional flags */
+        while (p && (p = skip_whitespace(p)))
         {
-            ordinal = strtol( p, &p, 10 );
-            if (*p++ != '_') continue;
-            if (ordinal >= MAX_ORDINALS) continue;
+            flags = p;
+            p = next_token( flags );
+            if (!strcmp( flags, "NONAME" ))
+            {
+                ord_only = 1;
+                if (!ordinal) fatal_error( "Invalid ordinal number %d\n", ordinal );
+            }
+            else if (!strcmp( flags, "CONSTANT" ) || !strcmp( flags, "DATA" ))
+            {
+                /* we don't support importing non-function entry points */
+                goto next;
+            }
+            else fatal_error( "Garbage after ordinal declaration\n" );
         }
-        if (ord_only && !ordinal) continue;
 
         if (imp->nb_exports == size)
         {
             size += 128;
             imp->exports = xrealloc( imp->exports, size * sizeof(*imp->exports) );
         }
-        imp->exports[imp->nb_exports].name     = xstrdup( p );
+        if ((p = strchr( name, '=' ))) *p = 0;
+        remove_stdcall_decoration( name );
+        imp->exports[imp->nb_exports].name     = xstrdup( name );
         imp->exports[imp->nb_exports].ordinal  = ordinal;
         imp->exports[imp->nb_exports].ord_only = ord_only;
         imp->nb_exports++;
+    next:
+        current_line++;
     }
-    if ((err = pclose( f ))) fatal_error( "%s error %d\n", cmdline, err );
-    free( cmdline );
+    close_input_file( f );
     if (imp->nb_exports)
         qsort( imp->exports, imp->nb_exports, sizeof(*imp->exports), func_cmp );
+    return 1;
 }
 
 /* add a dll to the list of imports */
@@ -266,20 +349,16 @@
 {
     struct import *imp;
     char *fullname;
-    int i;
 
     fullname = xmalloc( strlen(name) + 5 );
     strcpy( fullname, name );
     if (!strchr( fullname, '.' )) strcat( fullname, ".dll" );
 
     /* check if we already imported it */
-    for (i = 0; i < nb_imports; i++)
+    if (is_already_imported( fullname ))
     {
-        if (!strcmp( dll_imports[i]->dll, fullname ))
-        {
-            free( fullname );
-            return;
-        }
+        free( fullname );
+        return;
     }
 
     imp = xmalloc( sizeof(*imp) );
@@ -289,10 +368,13 @@
     imp->nb_imports = 0;
 
     if (delay) nb_delayed++;
-    read_exported_symbols( fullname, imp );
 
-    dll_imports = xrealloc( dll_imports, (nb_imports+1) * sizeof(*dll_imports) );
-    dll_imports[nb_imports++] = imp;
+    if (read_import_lib( name, imp ))
+    {
+        dll_imports = xrealloc( dll_imports, (nb_imports+1) * sizeof(*dll_imports) );
+        dll_imports[nb_imports++] = imp;
+    }
+    else free_imports( imp );
 }
 
 /* initialize the list of ignored symbols */
diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c
index ea94ee6..d166623 100644
--- a/tools/winebuild/spec32.c
+++ b/tools/winebuild/spec32.c
@@ -129,7 +129,6 @@
 static int output_exports( FILE *outfile, int nr_exports )
 {
     int i, fwd_size = 0, total_size = 0;
-    char *p;
 
     if (!nr_exports) return 0;
 
@@ -296,39 +295,6 @@
         }
     }
 
-
-    /* output __wine_dllexport symbols */
-
-    for (i = 0; i < nb_names; i++)
-    {
-        /* check for invalid characters in the name */
-        for (p = Names[i]->name; *p; p++)
-            if (!isalnum(*p) && *p != '_' && *p != '.') break;
-        if (*p) continue;
-        fprintf( outfile, "    \"\\t.globl " __ASM_NAME("__wine_dllexport_%s_%d_%s") "\\n\"\n",
-                 make_c_identifier(DLLFileName), i, Names[i]->name );
-        fprintf( outfile, "    \"" __ASM_NAME("__wine_dllexport_%s_%d_%s") ":\\n\"\n",
-                 make_c_identifier(DLLFileName), i, Names[i]->name );
-    }
-
-    /* output ordinal exports */
-
-    for (i = 0; i < nb_entry_points; i++)
-    {
-        ORDDEF *odp = EntryPoints[i];
-
-        if (odp->name || !odp->export_name) continue;
-        /* check for invalid characters in the name */
-        for (p = odp->export_name; *p; p++)
-            if (!isalnum(*p) && *p != '_' && *p != '.') break;
-        if (*p) continue;
-        fprintf( outfile, "    \"\\t.globl " __ASM_NAME("__wine_ordexport_%s_%d_%s") "\\n\"\n",
-                 make_c_identifier(DLLFileName), odp->ordinal, odp->export_name );
-        fprintf( outfile, "    \"" __ASM_NAME("__wine_ordexport_%s_%d_%s") ":\\n\"\n",
-                 make_c_identifier(DLLFileName), odp->ordinal, odp->export_name );
-    }
-    fprintf( outfile, "    \"\\t.long 0xffffffff\\n\"\n" );
-
     /* output variables */
 
     for (i = 0; i < nb_entry_points; i++)