From 32459912dc18ec4433b88977fac962a502414f95 Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Thu, 9 May 2002 00:05:48 +0000
Subject: [PATCH] Moved imports specification from the .spec into the Makefile
 so that it can be used on platforms that don't build a .spec.c file.

---
 Make.rules.in                               |  6 ++++--
 Makefile.in                                 |  8 +++----
 debugger/Makefile.in                        |  2 ++
 debugger/winedbg.spec                       |  5 -----
 dlls/Makedll.rules.in                       | 23 +++++++++++----------
 dlls/advapi32/Makefile.in                   |  1 +
 dlls/advapi32/advapi32.spec                 |  3 ---
 dlls/avicap32/Makefile.in                   |  1 +
 dlls/avicap32/avicap32.spec                 |  2 --
 dlls/avifil32/Makefile.in                   |  1 +
 dlls/avifil32/avifil32.spec                 |  4 ----
 dlls/comctl32/Makefile.in                   |  2 ++
 dlls/comctl32/comctl32.spec                 |  7 -------
 dlls/commdlg/Makefile.in                    |  1 +
 dlls/commdlg/comdlg32.spec                  |  9 --------
 dlls/crtdll/Makefile.in                     |  1 +
 dlls/crtdll/crtdll.spec                     |  4 ----
 dlls/crypt32/Makefile.in                    |  1 +
 dlls/crypt32/crypt32.spec                   |  4 ----
 dlls/dciman32/Makefile.in                   |  1 +
 dlls/dciman32/dciman32.spec                 |  3 ---
 dlls/ddraw/Makefile.in                      |  3 ++-
 dlls/ddraw/ddraw.spec                       |  5 -----
 dlls/devenum/Makefile.in                    |  1 +
 dlls/devenum/devenum.spec                   |  2 --
 dlls/dinput/Makefile.in                     |  1 +
 dlls/dinput/dinput.spec                     |  4 ----
 dlls/dplay/Makefile.in                      |  1 +
 dlls/dplay/dplay.spec                       |  2 --
 dlls/dplayx/Makefile.in                     |  1 +
 dlls/dplayx/dplayx.spec                     |  7 -------
 dlls/dsound/Makefile.in                     |  1 +
 dlls/dsound/dsound.spec                     |  4 ----
 dlls/gdi/Makefile.in                        |  3 ++-
 dlls/gdi/gdi32.spec                         |  4 ----
 dlls/icmp/Makefile.in                       |  1 +
 dlls/icmp/icmp.spec                         |  3 ---
 dlls/imagehlp/Makefile.in                   |  1 +
 dlls/imagehlp/imagehlp.spec                 |  3 ---
 dlls/imm32/Makefile.in                      |  1 +
 dlls/imm32/imm32.spec                       |  3 ---
 dlls/kernel/Makefile.in                     |  3 ++-
 dlls/kernel/kernel32.spec                   |  2 --
 dlls/kernel/tests/kernel32_test.spec        |  2 --
 dlls/lzexpand/Makefile.in                   |  1 +
 dlls/lzexpand/lz32.spec                     |  3 ---
 dlls/mapi32/Makefile.in                     |  1 +
 dlls/mapi32/mapi32.spec                     |  2 --
 dlls/mpr/Makefile.in                        |  1 +
 dlls/mpr/mpr.spec                           |  3 ---
 dlls/msacm/Makefile.in                      |  1 +
 dlls/msacm/imaadp32/Makefile.in             |  1 +
 dlls/msacm/imaadp32/imaadp32.acm.spec       |  2 --
 dlls/msacm/msacm32.spec                     |  6 ------
 dlls/msacm/msg711/Makefile.in               |  1 +
 dlls/msacm/msg711/msg711.drv.spec           |  2 --
 dlls/msdmo/Makefile.in                      |  1 +
 dlls/msdmo/msdmo.spec                       |  2 --
 dlls/msimg32/Makefile.in                    |  1 +
 dlls/msimg32/msimg32.spec                   |  2 --
 dlls/msisys/Makefile.in                     |  1 +
 dlls/msisys/msisys.ocx.spec                 |  2 --
 dlls/msnet32/Makefile.in                    |  1 +
 dlls/msnet32/msnet32.spec                   |  2 --
 dlls/msrle32/Makefile.in                    |  1 +
 dlls/msrle32/msrle32.spec                   |  2 --
 dlls/msvcrt/Makefile.in                     |  1 +
 dlls/msvcrt/msvcrt.spec                     |  3 ---
 dlls/msvcrt20/Makefile.in                   |  1 +
 dlls/msvcrt20/msvcrt20.spec                 |  3 ---
 dlls/msvideo/Makefile.in                    |  1 +
 dlls/msvideo/msvfw32.spec                   |  8 -------
 dlls/netapi32/Makefile.in                   |  1 +
 dlls/netapi32/netapi32.spec                 |  5 -----
 dlls/odbc32/Makefile.in                     |  1 +
 dlls/odbc32/odbc32.spec                     |  2 --
 dlls/ole32/Makefile.in                      |  1 +
 dlls/ole32/ole32.spec                       |  7 -------
 dlls/oleaut32/Makefile.in                   |  2 ++
 dlls/oleaut32/oleaut32.spec                 |  8 -------
 dlls/oleaut32/tests/oleaut32_test.spec      |  5 -----
 dlls/olecli/Makefile.in                     |  1 +
 dlls/olecli/olecli32.spec                   |  5 -----
 dlls/oledlg/Makefile.in                     |  1 +
 dlls/oledlg/oledlg.spec                     |  3 ---
 dlls/olepro32/Makefile.in                   |  1 +
 dlls/olepro32/olepro32.spec                 |  3 ---
 dlls/olesvr/Makefile.in                     |  1 +
 dlls/olesvr/olesvr32.spec                   |  3 ---
 dlls/opengl32/Makefile.in                   |  1 +
 dlls/opengl32/opengl32.spec                 |  5 -----
 dlls/psapi/Makefile.in                      |  1 +
 dlls/psapi/psapi.spec                       |  3 ---
 dlls/qcap/Makefile.in                       |  1 +
 dlls/qcap/qcap.spec                         |  2 --
 dlls/quartz/Makefile.in                     |  1 +
 dlls/quartz/quartz.spec                     |  2 --
 dlls/rasapi32/Makefile.in                   |  1 +
 dlls/rasapi32/rasapi32.spec                 |  3 ---
 dlls/richedit/Makefile.in                   |  1 +
 dlls/richedit/riched32.spec                 |  4 ----
 dlls/rpcrt4/Makefile.in                     |  1 +
 dlls/rpcrt4/rpcrt4.spec                     |  3 ---
 dlls/serialui/Makefile.in                   |  1 +
 dlls/serialui/serialui.spec                 |  5 -----
 dlls/setupapi/Makefile.in                   |  1 +
 dlls/setupapi/setupapi.spec                 |  5 -----
 dlls/shdocvw/Makefile.in                    |  1 +
 dlls/shdocvw/shdocvw.spec                   |  4 ----
 dlls/shell32/Makefile.in                    |  2 ++
 dlls/shell32/shell32.spec                   | 11 ----------
 dlls/shfolder/Makefile.in                   |  1 +
 dlls/shfolder/shfolder.spec                 |  2 --
 dlls/shlwapi/Makefile.in                    |  1 +
 dlls/shlwapi/shlwapi.spec                   |  6 ------
 dlls/snmpapi/Makefile.in                    |  1 +
 dlls/snmpapi/snmpapi.spec                   |  2 --
 dlls/sti/Makefile.in                        |  1 +
 dlls/sti/sti.spec                           |  2 --
 dlls/tapi32/Makefile.in                     |  1 +
 dlls/tapi32/tapi32.spec                     |  3 ---
 dlls/ttydrv/Makefile.in                     |  1 +
 dlls/ttydrv/ttydrv.spec                     |  5 -----
 dlls/twain/Makefile.in                      |  1 +
 dlls/twain/twain_32.spec                    |  5 -----
 dlls/url/Makefile.in                        |  1 +
 dlls/url/url.spec                           |  2 --
 dlls/urlmon/Makefile.in                     |  1 +
 dlls/urlmon/urlmon.spec                     |  3 ---
 dlls/user/Makefile.in                       |  3 ++-
 dlls/user/tests/user32_test.spec            |  6 ------
 dlls/user/user32.spec                       |  5 -----
 dlls/version/Makefile.in                    |  1 +
 dlls/version/version.spec                   |  4 ----
 dlls/win32s/Makefile.in                     |  1 +
 dlls/win32s/w32skrnl.spec                   |  3 ---
 dlls/winaspi/Makefile.in                    |  1 +
 dlls/winaspi/wnaspi32.spec                  |  4 ----
 dlls/winedos/Makefile.in                    |  1 +
 dlls/winedos/winedos.spec                   |  4 ----
 dlls/wineps/Makefile.in                     |  1 +
 dlls/wineps/wineps.spec                     |  7 -------
 dlls/wininet/Makefile.in                    |  1 +
 dlls/wininet/wininet.spec                   |  5 -----
 dlls/winmm/Makefile.in                      |  1 +
 dlls/winmm/joystick/Makefile.in             |  1 +
 dlls/winmm/joystick/joystick.drv.spec       |  4 ----
 dlls/winmm/mcianim/Makefile.in              |  1 +
 dlls/winmm/mcianim/mcianim.drv.spec         |  5 -----
 dlls/winmm/mciavi/Makefile.in               |  1 +
 dlls/winmm/mciavi/mciavi.drv.spec           |  7 -------
 dlls/winmm/mcicda/Makefile.in               |  2 ++
 dlls/winmm/mcicda/mcicda.drv.spec           |  5 -----
 dlls/winmm/mciseq/Makefile.in               |  2 ++
 dlls/winmm/mciseq/mciseq.drv.spec           |  5 -----
 dlls/winmm/mciwave/Makefile.in              |  2 ++
 dlls/winmm/mciwave/mciwave.drv.spec         |  5 -----
 dlls/winmm/midimap/Makefile.in              |  1 +
 dlls/winmm/midimap/midimap.drv.spec         |  6 ------
 dlls/winmm/wavemap/Makefile.in              |  1 +
 dlls/winmm/wavemap/msacm.drv.spec           |  6 ------
 dlls/winmm/winearts/Makefile.in             |  1 +
 dlls/winmm/winearts/winearts.drv.spec       |  5 -----
 dlls/winmm/wineoss/Makefile.in              |  1 +
 dlls/winmm/wineoss/wineoss.drv.spec         |  5 -----
 dlls/winmm/winmm.spec                       |  5 -----
 dlls/winnls/Makefile.in                     |  1 +
 dlls/winnls/winnls32.spec                   |  3 ---
 dlls/winsock/Makefile.in                    |  1 +
 dlls/winsock/tests/ws2_32_test.spec         |  4 ----
 dlls/winsock/ws2_32.spec                    |  4 ----
 dlls/winspool/Makefile.in                   |  1 +
 dlls/winspool/winspool.drv.spec             |  4 ----
 dlls/wintrust/Makefile.in                   |  1 +
 dlls/wintrust/wintrust.spec                 |  2 --
 dlls/wow32/Makefile.in                      |  1 +
 dlls/wow32/wow32.spec                       |  2 --
 dlls/wsock32/Makefile.in                    |  1 +
 dlls/wsock32/wsock32.spec                   |  4 ----
 dlls/x11drv/Makefile.in                     |  3 ++-
 dlls/x11drv/x11drv.spec                     |  6 ------
 libtest/Makefile.in                         | 20 +++++++++---------
 libtest/expand.spec                         |  4 ----
 libtest/hello.spec                          |  5 -----
 libtest/hello2.spec                         |  4 ----
 libtest/hello3.spec                         |  6 ------
 libtest/hello4.spec                         |  5 -----
 libtest/hello5.spec                         |  4 ----
 libtest/new.spec                            |  5 -----
 libtest/rolex.spec                          |  5 -----
 libtest/volinfo.spec                        |  3 ---
 miscemu/Makefile.in                         |  1 +
 miscemu/wine.spec                           |  2 --
 programs/Makeprog.rules.in                  | 13 ++++++------
 programs/avitools/Makefile.in               | 12 +++++------
 programs/avitools/aviinfo.spec              |  3 ---
 programs/avitools/aviplay.spec              |  4 ----
 programs/avitools/icinfo.spec               |  4 ----
 programs/clock/Makefile.in                  |  1 +
 programs/clock/clock.spec                   |  6 ------
 programs/cmdlgtst/Makefile.in               |  1 +
 programs/cmdlgtst/cmdlgtst.spec             |  5 -----
 programs/control/Makefile.in                |  1 +
 programs/control/control.spec               |  4 ----
 programs/notepad/Makefile.in                |  1 +
 programs/notepad/notepad.spec               |  6 ------
 programs/osversioncheck/Makefile.in         |  1 +
 programs/osversioncheck/osversioncheck.spec |  2 --
 programs/progman/Makefile.in                |  1 +
 programs/progman/progman.spec               |  6 ------
 programs/regapi/Makefile.in                 |  1 +
 programs/regapi/regapi.spec                 |  3 ---
 programs/regedit/Makefile.in                |  1 +
 programs/regedit/regedit.spec               |  4 ----
 programs/regsvr32/Makefile.in               |  1 +
 programs/regsvr32/regsvr32.spec             |  3 ---
 programs/regtest/Makefile.in                |  1 +
 programs/regtest/regtest.spec               |  3 ---
 programs/uninstaller/Makefile.in            |  1 +
 programs/uninstaller/uninstaller.spec       |  5 -----
 programs/view/Makefile.in                   |  1 +
 programs/view/view.spec                     |  5 -----
 programs/wcmd/Makefile.in                   |  1 +
 programs/wcmd/wcmd.spec                     |  4 ----
 programs/wineconsole/Makefile.in            |  2 ++
 programs/wineconsole/wineconsole.spec       |  6 ------
 programs/winemine/Makefile.in               |  1 +
 programs/winemine/winemine.spec             |  5 -----
 programs/winepath/Makefile.in               |  1 +
 programs/winepath/winepath.spec             |  2 --
 programs/winetest/Makefile.in               |  1 +
 programs/winetest/winetest.spec             |  2 --
 programs/winhelp/Makefile.in                |  2 +-
 programs/winhelp/winhelp.spec               |  6 ------
 programs/winver/Makefile.in                 |  1 +
 programs/winver/winver.spec                 |  3 ---
 tools/winebuild/import.c                    |  9 +++++++-
 tools/winebuild/main.c                      | 14 +++++++++++++
 238 files changed, 185 insertions(+), 547 deletions(-)

diff --git a/Make.rules.in b/Make.rules.in
index 33365bc6823..b2c8e7a49d1 100644
--- a/Make.rules.in
+++ b/Make.rules.in
@@ -16,6 +16,8 @@
 # GLUE         : C sources for which glue code needs to be generated
 # EXTRA_SRCS   : extra source files for make depend
 # EXTRA_OBJS   : extra object files
+# IMPORTS      : dlls to import
+# DELAYIMPORTS : dlls to import in delayed mode
 # SUBDIRS      : subdirectories that contain a Makefile
 # EXTRASUBDIRS : subdirectories that do not contain a Makefile
 # PLTESTS      : Perl test scripts
@@ -162,7 +164,7 @@ $(MODULE).tmp.o: $(OBJS) Makefile.in
 # Rule for main module spec file
 
 $(MAINSPEC).c: $(MAINSPEC) $(RC_SRCS:.rc=.res) $(SYMBOLFILE) $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) $(SYMBOLFILE:%=-sym %) -o $@ -spec $(SRCDIR)/$(MAINSPEC)
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ $(SYMBOLFILE:%=-sym %) -o $@ -spec $(SRCDIR)/$(MAINSPEC) -L$(DLLDIR) $(DELAYIMPORTS:%=-dl%) $(IMPORTS:%=-l%)
 
 # Rule to rebuild the resource compiler
 
@@ -282,7 +284,7 @@ $(TESTPROGRAM).tmp.o: $(TESTOBJS)
 	-strip --strip-unneeded $@
 
 $(TESTPROGRAM).spec.c: $(TESTPROGRAM).spec $(TESTPROGRAM).tmp.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) -sym $(TESTPROGRAM).tmp.o -o $@ -spec $(SRCDIR)/$(TESTPROGRAM).spec
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym $(TESTPROGRAM).tmp.o -o $@ -spec $(SRCDIR)/$(TESTPROGRAM).spec -L$(DLLDIR) $(TESTIMPORTS:%=-l%)
 
 # Misc. rules
 
diff --git a/Makefile.in b/Makefile.in
index 2d3302b4cec..7aa0bd3c8e6 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -21,7 +21,7 @@ VPATH     = @srcdir@
 LIBEXT    = @LIBEXT@
 LDCONFIG  = @LDCONFIG@
 MODULE    = wine
-IMPORTS   = ntdll.dll
+LDIMPORTS = ntdll.dll
 
 # Stand-alone programs
 PROGRAMS = \
@@ -89,8 +89,8 @@ Make.rules: Make.rules.in configure
 	@echo $? is newer than 'Make.rules', please rerun ./configure!
 	@exit 1
 
-wine: $(EMUOBJS) $(IMPORTS:%=lib%.$(LIBEXT)) library/libwine.$(LIBEXT) unicode/libwine_unicode.$(LIBEXT)
-	$(CC) -o wine $(EMUOBJS) -L. $(IMPORTS:%=-l%) $(LIBWINE) $(LIBUNICODE) $(LIBS) $(LDFLAGS)
+wine: $(EMUOBJS) $(LDIMPORTS:%=lib%.$(LIBEXT)) library/libwine.$(LIBEXT) unicode/libwine_unicode.$(LIBEXT)
+	$(CC) -o wine $(EMUOBJS) -L. $(LDIMPORTS:%=-l%) $(LIBWINE) $(LIBUNICODE) $(LIBS) $(LDFLAGS)
 
 install_wine: dummy
 	[ -d $(bindir) ] || $(MKDIR) $(bindir)
@@ -146,7 +146,7 @@ server tools: $(LIBRARIES)
 dlls: tools $(LIBRARIES)
 
 checklink::
-	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c $(LIBWINE) $(LIBS) && $(RM) checklink
+	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c && $(RM) checklink
 
 checklink::
 	@cd dlls && $(MAKE) checklink
diff --git a/debugger/Makefile.in b/debugger/Makefile.in
index a746da4347a..154fac4885c 100644
--- a/debugger/Makefile.in
+++ b/debugger/Makefile.in
@@ -4,6 +4,8 @@ TOPOBJDIR = ..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = winedbg
+IMPORTS   = advapi32.dll kernel32.dll ntdll.dll
+DELAYIMPORTS = user32.dll
 
 C_SRCS = \
 	break.c \
diff --git a/debugger/winedbg.spec b/debugger/winedbg.spec
index e125fb0b2a2..7c926867338 100644
--- a/debugger/winedbg.spec
+++ b/debugger/winedbg.spec
@@ -2,8 +2,3 @@ name	winedbg
 mode	cuiexe
 type	win32
 init	DEBUG_main
-
-import -delay user32.dll
-import	advapi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/dlls/Makedll.rules.in b/dlls/Makedll.rules.in
index ff2293d90da..aaf62c963ff 100644
--- a/dlls/Makedll.rules.in
+++ b/dlls/Makedll.rules.in
@@ -3,18 +3,19 @@
 # Each individual makefile should define the following variables:
 # MODULE       : name of the main module being built
 # ALTNAMES     : alternate names for this dll (optional)
-# IMPORTS      : dlls to import (optional)
 # EXTRALIBS    : extra libraries to link in (optional)
 #
 # plus all variables required by the global Make.rules.in
 #
 
-DEFS       = @DLLFLAGS@ -D__WINE__ $(EXTRADEFS)
-DLLEXT     = @DLLEXT@
-ALTSPECS   = $(ALTNAMES:%.dll=%)
-SPEC_SRCS  = $(ALTSPECS:%=%.spec)
-ALL_OBJS   = $(MODULE:%.dll=%).spec.o $(OBJS)
-ALL_LIBS   = $(LIBWINE) $(EXTRALIBS) $(LIBS)
+DEFS        = @DLLFLAGS@ -D__WINE__ $(EXTRADEFS)
+DLLEXT      = @DLLEXT@
+ALTSPECS    = $(ALTNAMES:%.dll=%)
+SPEC_SRCS   = $(ALTSPECS:%=%.spec)
+ALL_OBJS    = $(MODULE:%.dll=%).spec.o $(OBJS)
+ALL_LIBS    = $(LIBWINE) $(EXTRALIBS) $(LIBS)
+SPEC_DEF    = $(MODULE:%.dll=%).spec.def
+TESTIMPORTS = $(MODULE) $(DELAYIMPORTS) $(IMPORTS)
 
 all: $(MODULE)$(DLLEXT)
 
@@ -23,17 +24,17 @@ all: $(MODULE)$(DLLEXT)
 # Rules for .so files
 
 $(MODULE).so: $(ALL_OBJS) Makefile.in
-	$(LDSHARED) $(LDDLLFLAGS) $(ALL_OBJS) -o $@ -L$(DLLDIR) $(IMPORTS:%=-l%) $(ALL_LIBS)
+	$(LDSHARED) $(LDDLLFLAGS) $(ALL_OBJS) -o $@ -L$(DLLDIR) $(LDIMPORTS:%=-l%) $(ALL_LIBS)
 
 # Rules for .dll files
 
-$(MODULE): $(ALL_OBJS) Makefile.in
-	$(DLLWRAP) $(DLLWRAPFLAGS) --implib $(MODULE:.dll=.a) -o $(MODULE) $(ALL_OBJS) -L$(DLLDIR) $(IMPORTS:%=-l%) $(ALL_LIBS)
+$(MODULE): $(ALL_OBJS) $(SPEC_DEF) Makefile.in
+	$(DLLWRAP) $(DLLWRAPFLAGS) --def $(SPEC_DEF) --implib $(MODULE:.dll=.a) -o $(MODULE) $(ALL_OBJS) -L$(DLLDIR) $(LDIMPORTS:%=-l%) $(ALL_LIBS)
 
 # Rules for checking that no imports are missing
 
 checklink:: $(MODULE)$(DLLEXT)
-	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c $(MODULE)$(DLLEXT) $(ALL_LIBS) && $(RM) checklink
+	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c $(MODULE)$(DLLEXT) && $(RM) checklink
 
 # Rules for testing
 
diff --git a/dlls/advapi32/Makefile.in b/dlls/advapi32/Makefile.in
index 2dcd55018b9..b50443a89e5 100644
--- a/dlls/advapi32/Makefile.in
+++ b/dlls/advapi32/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = advapi32.dll
+IMPORTS   = kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec
index 1ee6cd7802d..f7327cfdfec 100644
--- a/dlls/advapi32/advapi32.spec
+++ b/dlls/advapi32/advapi32.spec
@@ -1,9 +1,6 @@
 name	advapi32
 type	win32
 
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (advapi crypt reg)
 
 @ stdcall AbortSystemShutdownA(ptr) AbortSystemShutdownA
diff --git a/dlls/avicap32/Makefile.in b/dlls/avicap32/Makefile.in
index e5e69c8fc4f..317c527139d 100644
--- a/dlls/avicap32/Makefile.in
+++ b/dlls/avicap32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = avicap32.dll
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/avicap32/avicap32.spec b/dlls/avicap32/avicap32.spec
index 7d5efd851ed..7145dbb8518 100644
--- a/dlls/avicap32/avicap32.spec
+++ b/dlls/avicap32/avicap32.spec
@@ -1,6 +1,4 @@
 name avicap32
 type win32
 
-import ntdll.dll
-
 debug_channels ()
diff --git a/dlls/avifil32/Makefile.in b/dlls/avifil32/Makefile.in
index 5d2ecdfb1aa..032dedaa9c0 100644
--- a/dlls/avifil32/Makefile.in
+++ b/dlls/avifil32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = avifil32.dll
+IMPORTS   = msvfw32.dll kernel32.dll ntdll.dll
 ALTNAMES  = avifile.dll
 EXTRALIBS = $(LIBUUID)
 
diff --git a/dlls/avifil32/avifil32.spec b/dlls/avifil32/avifil32.spec
index d19a3962422..4d74ecfb701 100644
--- a/dlls/avifil32/avifil32.spec
+++ b/dlls/avifil32/avifil32.spec
@@ -1,10 +1,6 @@
 name	avifil32
 type	win32
 
-import msvfw32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (avifile)
 
 @ stub    AVIBuildFilter
diff --git a/dlls/comctl32/Makefile.in b/dlls/comctl32/Makefile.in
index 92a83ae6cbc..b05c94d6493 100644
--- a/dlls/comctl32/Makefile.in
+++ b/dlls/comctl32/Makefile.in
@@ -4,6 +4,8 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = comctl32.dll
+IMPORTS   = user32.dll gdi32.dll advapi32.dll kernel32.dll ntdll.dll
+DELAYIMPORTS = winmm.dll
 EXTRALIBS = $(LIBUNICODE)
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/comctl32/comctl32.spec b/dlls/comctl32/comctl32.spec
index d0b5e48e329..df980ec1f68 100644
--- a/dlls/comctl32/comctl32.spec
+++ b/dlls/comctl32/comctl32.spec
@@ -3,13 +3,6 @@ type	win32
 init	COMCTL32_LibMain
 rsrc	rsrc.res
 
-import -delay winmm.dll
-import	user32.dll
-import	gdi32.dll
-import	advapi32.dll
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (animate comboex commctrl datetime header hotkey imagelist ipaddress
                 listview message monthcal nativefont pager progress propsheet
                 rebar statusbar tab toolbar tooltips trackbar treeview updown)
diff --git a/dlls/commdlg/Makefile.in b/dlls/commdlg/Makefile.in
index 2a2aa4a30f3..82ae9d1d722 100644
--- a/dlls/commdlg/Makefile.in
+++ b/dlls/commdlg/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = comdlg32.dll
+IMPORTS   = shell32.dll shlwapi.dll comctl32.dll winspool.drv user32.dll gdi32.dll kernel32.dll ntdll.dll
 ALTNAMES  = commdlg.dll
 EXTRALIBS = $(LIBUUID)
 
diff --git a/dlls/commdlg/comdlg32.spec b/dlls/commdlg/comdlg32.spec
index 72f0ddf7315..1aa8c0fa245 100644
--- a/dlls/commdlg/comdlg32.spec
+++ b/dlls/commdlg/comdlg32.spec
@@ -3,15 +3,6 @@ type	win32
 init	COMDLG32_DllEntryPoint
 rsrc	rsrc.res
 
-import shell32.dll
-import shlwapi.dll
-import comctl32.dll
-import winspool.drv
-import user32.dll
-import gdi32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (commdlg)
 
 @ stdcall ChooseColorA(ptr) ChooseColorA
diff --git a/dlls/crtdll/Makefile.in b/dlls/crtdll/Makefile.in
index 6098756f0d8..d9ceea309d8 100644
--- a/dlls/crtdll/Makefile.in
+++ b/dlls/crtdll/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = crtdll.dll
+IMPORTS   = msvcrt.dll kernel32.dll ntdll.dll
 EXTRALIBS = $(LIBUNICODE)
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/crtdll/crtdll.spec b/dlls/crtdll/crtdll.spec
index 87bf5baac4a..ff5c6c2a753 100644
--- a/dlls/crtdll/crtdll.spec
+++ b/dlls/crtdll/crtdll.spec
@@ -3,10 +3,6 @@ name    crtdll
 type    win32
 init    CRTDLL_Init
 
-import msvcrt.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (crtdll)
 
 @ forward ??2@YAPAXI@Z msvcrt.??2@YAPAXI@Z
diff --git a/dlls/crypt32/Makefile.in b/dlls/crypt32/Makefile.in
index fc7d74e3cbb..1af3f76ada6 100644
--- a/dlls/crypt32/Makefile.in
+++ b/dlls/crypt32/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = crypt32.dll
+IMPORTS   = advapi32.dll kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/crypt32/crypt32.spec b/dlls/crypt32/crypt32.spec
index edb9c938347..469c1214dc1 100644
--- a/dlls/crypt32/crypt32.spec
+++ b/dlls/crypt32/crypt32.spec
@@ -1,10 +1,6 @@
 name crypt32
 type win32
 
-import advapi32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels ()
 
 @ stub CertAddCRLContextToStore
diff --git a/dlls/dciman32/Makefile.in b/dlls/dciman32/Makefile.in
index 437eab916e5..c89d0b75242 100644
--- a/dlls/dciman32/Makefile.in
+++ b/dlls/dciman32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = dciman32.dll
+IMPORTS   = kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/dciman32/dciman32.spec b/dlls/dciman32/dciman32.spec
index b91bcfa5a58..b19b9026fe7 100644
--- a/dlls/dciman32/dciman32.spec
+++ b/dlls/dciman32/dciman32.spec
@@ -1,9 +1,6 @@
 name	dciman32
 type	win32
 
-import	kernel32.dll
-import	ntdll.dll
-
 @ stub    DCIBeginAccess
 @ stdcall DCICloseProvider(long) DCICloseProvider
 @ stub    DCICreateOffscreen
diff --git a/dlls/ddraw/Makefile.in b/dlls/ddraw/Makefile.in
index 0a107f4e58f..2262ddccc63 100644
--- a/dlls/ddraw/Makefile.in
+++ b/dlls/ddraw/Makefile.in
@@ -3,8 +3,9 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = ddraw.dll
-EXTRALIBS = $(LIBUUID) $(LIBTSX11) $(X_LIBS) $(XLIB)
 IMPORTS   = user32.dll gdi32.dll kernel32.dll ntdll.dll
+EXTRALIBS = $(LIBUUID) $(LIBTSX11) $(X_LIBS) $(XLIB)
+LDIMPORTS = user32.dll gdi32.dll kernel32.dll ntdll.dll
 
 OPENGLFILES = \
 	d3dcommon.c \
diff --git a/dlls/ddraw/ddraw.spec b/dlls/ddraw/ddraw.spec
index b9cbdb09379..ea4d46d7042 100644
--- a/dlls/ddraw/ddraw.spec
+++ b/dlls/ddraw/ddraw.spec
@@ -3,11 +3,6 @@ type win32
 init DDRAW_DllMain
 rsrc version.res
 
-import user32.dll
-import gdi32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (ddraw)
 
 @ stub DDHAL32_VidMemAlloc
diff --git a/dlls/devenum/Makefile.in b/dlls/devenum/Makefile.in
index 7637becbff7..c0bb04a1453 100644
--- a/dlls/devenum/Makefile.in
+++ b/dlls/devenum/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = devenum.dll
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/devenum/devenum.spec b/dlls/devenum/devenum.spec
index 15cd9ae47bb..d0b3e7dbcc3 100644
--- a/dlls/devenum/devenum.spec
+++ b/dlls/devenum/devenum.spec
@@ -1,8 +1,6 @@
 name devenum
 type win32
 
-import ntdll.dll
-
 debug_channels()
 
 @ stub DllCanUnloadNow
diff --git a/dlls/dinput/Makefile.in b/dlls/dinput/Makefile.in
index fae2dc2daf9..fe24beccc97 100644
--- a/dlls/dinput/Makefile.in
+++ b/dlls/dinput/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = dinput.dll
+IMPORTS   = user32.dll kernel32.dll ntdll.dll
 EXTRALIBS = $(LIBUUID)
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/dinput/dinput.spec b/dlls/dinput/dinput.spec
index 628bfae95e3..74288c648af 100644
--- a/dlls/dinput/dinput.spec
+++ b/dlls/dinput/dinput.spec
@@ -1,10 +1,6 @@
 name dinput
 type win32
 
-import user32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (dinput)
 
 @ stdcall DirectInputCreateA(long long ptr ptr) DirectInputCreateA
diff --git a/dlls/dplay/Makefile.in b/dlls/dplay/Makefile.in
index 2cc81787149..f13efb1feab 100644
--- a/dlls/dplay/Makefile.in
+++ b/dlls/dplay/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = dplay.dll
+IMPORTS   = dplayx.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/dplay/dplay.spec b/dlls/dplay/dplay.spec
index b05a832b8e5..1979d4c8c76 100644
--- a/dlls/dplay/dplay.spec
+++ b/dlls/dplay/dplay.spec
@@ -2,7 +2,5 @@
 name dplay
 type win32
 
-import dplayx.dll
-
 @ forward DirectPlayCreate dplayx.DirectPlayCreate
 @ forward DirectPlayEnumerate dplayx.DirectPlayEnumerate
diff --git a/dlls/dplayx/Makefile.in b/dlls/dplayx/Makefile.in
index 2c36e889156..447fec9d40b 100644
--- a/dlls/dplayx/Makefile.in
+++ b/dlls/dplayx/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = dplayx.dll
+IMPORTS   = winmm.dll ole32.dll user32.dll advapi32.dll kernel32.dll ntdll.dll
 EXTRALIBS = $(LIBUUID)
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/dplayx/dplayx.spec b/dlls/dplayx/dplayx.spec
index 12735ba13df..06754c16522 100644
--- a/dlls/dplayx/dplayx.spec
+++ b/dlls/dplayx/dplayx.spec
@@ -3,13 +3,6 @@ type win32
 init DPLAYX_LibMain
 rsrc version.res
 
-import winmm.dll
-import ole32.dll
-import user32.dll
-import advapi32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (dplay)
 
   1 stdcall DirectPlayCreate(ptr ptr ptr) DirectPlayCreate
diff --git a/dlls/dsound/Makefile.in b/dlls/dsound/Makefile.in
index e2181ab6b26..60a09e97f98 100644
--- a/dlls/dsound/Makefile.in
+++ b/dlls/dsound/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = dsound.dll
+IMPORTS   = winmm.dll kernel32.dll ntdll.dll
 EXTRALIBS = $(LIBUUID)
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/dsound/dsound.spec b/dlls/dsound/dsound.spec
index 4594181693d..8cb2f9c3d9f 100644
--- a/dlls/dsound/dsound.spec
+++ b/dlls/dsound/dsound.spec
@@ -1,10 +1,6 @@
 name dsound
 type win32
 
-import winmm.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (dsound)
 
 0 stub DirectSoundUnknown
diff --git a/dlls/gdi/Makefile.in b/dlls/gdi/Makefile.in
index 7a41922a36b..64783b4faa8 100644
--- a/dlls/gdi/Makefile.in
+++ b/dlls/gdi/Makefile.in
@@ -4,8 +4,9 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = gdi32.dll
+IMPORTS   = advapi32.dll kernel32.dll ntdll.dll
 ALTNAMES  = gdi.exe dispdib.dll wing.dll
-IMPORTS   = kernel32.dll ntdll.dll
+LDIMPORTS = kernel32.dll ntdll.dll
 EXTRAINCL = @FREETYPEINCL@
 
 C_SRCS = \
diff --git a/dlls/gdi/gdi32.spec b/dlls/gdi/gdi32.spec
index 426fff29e46..98c5ab5999c 100644
--- a/dlls/gdi/gdi32.spec
+++ b/dlls/gdi/gdi32.spec
@@ -3,10 +3,6 @@ type    win32
 init    MAIN_GdiInit
 rsrc    version.res
 
-import	advapi32.dll
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (bitblt bitmap clipping dc ddraw driver enhmetafile font gdi
                 metafile palette print region text win16drv wing)
 
diff --git a/dlls/icmp/Makefile.in b/dlls/icmp/Makefile.in
index 741987d81a1..6bc157bec84 100644
--- a/dlls/icmp/Makefile.in
+++ b/dlls/icmp/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = icmp.dll
+IMPORTS   = kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/icmp/icmp.spec b/dlls/icmp/icmp.spec
index 2ecf2189d55..731c1fc36c5 100644
--- a/dlls/icmp/icmp.spec
+++ b/dlls/icmp/icmp.spec
@@ -1,9 +1,6 @@
 name icmp
 type win32
 
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (icmp)
 
 @ stdcall IcmpCloseHandle(ptr) IcmpCloseHandle
diff --git a/dlls/imagehlp/Makefile.in b/dlls/imagehlp/Makefile.in
index 7a8f269ce72..a5e45775649 100644
--- a/dlls/imagehlp/Makefile.in
+++ b/dlls/imagehlp/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = imagehlp.dll
+IMPORTS   = kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/imagehlp/imagehlp.spec b/dlls/imagehlp/imagehlp.spec
index ee9d35ab3ec..b9531d295ca 100644
--- a/dlls/imagehlp/imagehlp.spec
+++ b/dlls/imagehlp/imagehlp.spec
@@ -2,9 +2,6 @@ name	imagehlp
 type	win32
 init	IMAGEHLP_LibMain
 
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (imagehlp)
 
 @ stdcall BindImage(str str str) BindImage
diff --git a/dlls/imm32/Makefile.in b/dlls/imm32/Makefile.in
index a2cb2611322..783f47b21b2 100644
--- a/dlls/imm32/Makefile.in
+++ b/dlls/imm32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = imm32.dll
+IMPORTS   = kernel32.dll ntdll.dll
 ALTNAMES  = imm.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/imm32/imm32.spec b/dlls/imm32/imm32.spec
index a87e52689a3..3347812b613 100644
--- a/dlls/imm32/imm32.spec
+++ b/dlls/imm32/imm32.spec
@@ -1,9 +1,6 @@
 name	imm32
 type	win32
 
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (imm)
 
 @ stdcall ImmAssociateContext(long long) ImmAssociateContext
diff --git a/dlls/kernel/Makefile.in b/dlls/kernel/Makefile.in
index 832d8a76cc2..05cd32bc5ea 100644
--- a/dlls/kernel/Makefile.in
+++ b/dlls/kernel/Makefile.in
@@ -3,8 +3,9 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = kernel32.dll
-ALTNAMES  = krnl386.exe comm.dll stress.dll system.dll toolhelp.dll windebug.dll win87em.dll wprocs.dll
 IMPORTS   = ntdll.dll
+ALTNAMES  = krnl386.exe comm.dll stress.dll system.dll toolhelp.dll windebug.dll win87em.dll wprocs.dll
+LDIMPORTS = ntdll.dll
 
 C_SRCS = \
 	comm.c \
diff --git a/dlls/kernel/kernel32.spec b/dlls/kernel/kernel32.spec
index 48dc90794c2..ea29fbe9319 100644
--- a/dlls/kernel/kernel32.spec
+++ b/dlls/kernel/kernel32.spec
@@ -3,8 +3,6 @@ type	win32
 init	MAIN_KernelInit
 rsrc	kernel.res
 
-import  ntdll.dll
-
 debug_channels (comm console debugstr dll int resource stress thunk toolhelp
                 win32)
 
diff --git a/dlls/kernel/tests/kernel32_test.spec b/dlls/kernel/tests/kernel32_test.spec
index ba8dcd0d248..99d0a50e950 100644
--- a/dlls/kernel/tests/kernel32_test.spec
+++ b/dlls/kernel/tests/kernel32_test.spec
@@ -1,5 +1,3 @@
 name	kernel32_test
 type	win32
 mode	cuiexe
-
-import kernel32.dll
diff --git a/dlls/lzexpand/Makefile.in b/dlls/lzexpand/Makefile.in
index 633a0cd0890..d365e4ecaaf 100644
--- a/dlls/lzexpand/Makefile.in
+++ b/dlls/lzexpand/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = lz32.dll
+IMPORTS   = kernel32.dll ntdll.dll
 ALTNAMES  = lzexpand.dll
 EXTRALIBS = $(LIBUNICODE)
 
diff --git a/dlls/lzexpand/lz32.spec b/dlls/lzexpand/lz32.spec
index 172079dce2e..7b158b2f5cc 100644
--- a/dlls/lzexpand/lz32.spec
+++ b/dlls/lzexpand/lz32.spec
@@ -1,9 +1,6 @@
 name	lz32
 type	win32
 
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (file)
 
 @ stdcall CopyLZFile(long long) CopyLZFile
diff --git a/dlls/mapi32/Makefile.in b/dlls/mapi32/Makefile.in
index d21fdfbdc63..0ba88031a9d 100644
--- a/dlls/mapi32/Makefile.in
+++ b/dlls/mapi32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = mapi32.dll
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/mapi32/mapi32.spec b/dlls/mapi32/mapi32.spec
index e2c4fbb2310..d682641ce40 100644
--- a/dlls/mapi32/mapi32.spec
+++ b/dlls/mapi32/mapi32.spec
@@ -1,8 +1,6 @@
 name mapi32
 type win32
 
-import ntdll.dll
-
 debug_channels (mapi)
 
 @ stub BMAPIAddress
diff --git a/dlls/mpr/Makefile.in b/dlls/mpr/Makefile.in
index 9051e1c4d3e..5eb3974b0b9 100644
--- a/dlls/mpr/Makefile.in
+++ b/dlls/mpr/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = mpr.dll
+IMPORTS   = kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/mpr/mpr.spec b/dlls/mpr/mpr.spec
index e2ea0ce6418..e20e614a22b 100644
--- a/dlls/mpr/mpr.spec
+++ b/dlls/mpr/mpr.spec
@@ -1,9 +1,6 @@
 name mpr
 type win32
 
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (mpr)
 
 # ordinal exports
diff --git a/dlls/msacm/Makefile.in b/dlls/msacm/Makefile.in
index 748c6344f8a..b2db1fcf5f5 100644
--- a/dlls/msacm/Makefile.in
+++ b/dlls/msacm/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = msacm32.dll
+IMPORTS   = winmm.dll user32.dll advapi32.dll kernel32.dll ntdll.dll
 ALTNAMES  = msacm.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/msacm/imaadp32/Makefile.in b/dlls/msacm/imaadp32/Makefile.in
index 0e60c8c1428..7ee045070bd 100644
--- a/dlls/msacm/imaadp32/Makefile.in
+++ b/dlls/msacm/imaadp32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = imaadp32.acm
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/msacm/imaadp32/imaadp32.acm.spec b/dlls/msacm/imaadp32/imaadp32.acm.spec
index 137c121c3e8..9bcb035236b 100644
--- a/dlls/msacm/imaadp32/imaadp32.acm.spec
+++ b/dlls/msacm/imaadp32/imaadp32.acm.spec
@@ -2,8 +2,6 @@ name imaadp32
 file imaadp32.acm
 type win32
 
-import ntdll.dll
-
 debug_channels ()
 
 @ stub DriverProc #(long long long long long)
diff --git a/dlls/msacm/msacm32.spec b/dlls/msacm/msacm32.spec
index 48820a851f7..8e207764f9e 100644
--- a/dlls/msacm/msacm32.spec
+++ b/dlls/msacm/msacm32.spec
@@ -3,12 +3,6 @@ type win32
 init MSACM32_LibMain
 rsrc msacm.res
 
-import winmm.dll
-import user32.dll
-import advapi32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (msacm)
 
 @ stdcall acmDriverAddA(ptr long long long long) acmDriverAddA
diff --git a/dlls/msacm/msg711/Makefile.in b/dlls/msacm/msg711/Makefile.in
index c6495f73c61..f444c24de80 100644
--- a/dlls/msacm/msg711/Makefile.in
+++ b/dlls/msacm/msg711/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = msg711.drv
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/msacm/msg711/msg711.drv.spec b/dlls/msacm/msg711/msg711.drv.spec
index c746865b0a8..3df1a287119 100644
--- a/dlls/msacm/msg711/msg711.drv.spec
+++ b/dlls/msacm/msg711/msg711.drv.spec
@@ -2,8 +2,6 @@ name msg711
 file msg711.drv
 type win32
 
-import ntdll.dll
-
 debug_channels ()
 
 @ stub DriverProc #(long long long long long)
diff --git a/dlls/msdmo/Makefile.in b/dlls/msdmo/Makefile.in
index d6034bfe342..7a9c6e81bb9 100644
--- a/dlls/msdmo/Makefile.in
+++ b/dlls/msdmo/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = msdmo.dll
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/msdmo/msdmo.spec b/dlls/msdmo/msdmo.spec
index 6ea33bef770..9e962d3b0b6 100644
--- a/dlls/msdmo/msdmo.spec
+++ b/dlls/msdmo/msdmo.spec
@@ -1,8 +1,6 @@
 name msdmo
 type win32
 
-import ntdll.dll
-
 debug_channels ()
 
 @ stub DMOEnum
diff --git a/dlls/msimg32/Makefile.in b/dlls/msimg32/Makefile.in
index c829618f55e..0db384291cf 100644
--- a/dlls/msimg32/Makefile.in
+++ b/dlls/msimg32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = msimg32.dll
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/msimg32/msimg32.spec b/dlls/msimg32/msimg32.spec
index 580532935e8..748c8c99a42 100644
--- a/dlls/msimg32/msimg32.spec
+++ b/dlls/msimg32/msimg32.spec
@@ -1,8 +1,6 @@
 name msimg32
 type win32
 
-import ntdll.dll
-
 debug_channels (msimg32)
 
 @ stdcall AlphaBlend(long long long long long long long long long long long) AlphaBlend
diff --git a/dlls/msisys/Makefile.in b/dlls/msisys/Makefile.in
index 2433508ccf0..acaf1f94331 100644
--- a/dlls/msisys/Makefile.in
+++ b/dlls/msisys/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = msisys.ocx
+IMPORTS   = ntdll.dll
 EXTRALIBS = $(LIBUUID)
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/msisys/msisys.ocx.spec b/dlls/msisys/msisys.ocx.spec
index 628efb9d5c5..6c6ae61967d 100644
--- a/dlls/msisys/msisys.ocx.spec
+++ b/dlls/msisys/msisys.ocx.spec
@@ -3,8 +3,6 @@ file	msisys.ocx
 type	win32
 init	MSISYS_DllMain
 
-import ntdll.dll
-
 debug_channels (msisys)
 
 @ stdcall DllCanUnloadNow() MSISYS_DllCanUnloadNow
diff --git a/dlls/msnet32/Makefile.in b/dlls/msnet32/Makefile.in
index b0daaa88305..a46ef65851e 100644
--- a/dlls/msnet32/Makefile.in
+++ b/dlls/msnet32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = msnet32.dll
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/msnet32/msnet32.spec b/dlls/msnet32/msnet32.spec
index aade69a9546..07dbe95c82e 100644
--- a/dlls/msnet32/msnet32.spec
+++ b/dlls/msnet32/msnet32.spec
@@ -1,8 +1,6 @@
 name msnet32
 type win32
 
-import ntdll.dll
-
   1 stub @
   2 stub @
   3 stub @
diff --git a/dlls/msrle32/Makefile.in b/dlls/msrle32/Makefile.in
index 0717476c57b..350060678a0 100644
--- a/dlls/msrle32/Makefile.in
+++ b/dlls/msrle32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = msrle32.dll
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/msrle32/msrle32.spec b/dlls/msrle32/msrle32.spec
index d9c4dec9ea4..f64d3df90fd 100644
--- a/dlls/msrle32/msrle32.spec
+++ b/dlls/msrle32/msrle32.spec
@@ -1,8 +1,6 @@
 name msrle32
 type win32
 
-import ntdll.dll
-
 debug_channels()
 
 @ stub DriverProc #(long long long long long)
diff --git a/dlls/msvcrt/Makefile.in b/dlls/msvcrt/Makefile.in
index 56c06b505b6..3440c0f982b 100644
--- a/dlls/msvcrt/Makefile.in
+++ b/dlls/msvcrt/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = msvcrt.dll
+IMPORTS   = kernel32.dll ntdll.dll
 EXTRALIBS = $(LIBUNICODE)
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index 30e56e03909..2f3475d8dfe 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -3,9 +3,6 @@ name    msvcrt
 type    win32
 init    MSVCRT_Init
 
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (msvcrt)
 
 @ cdecl $I10_OUTPUT() MSVCRT_I10_OUTPUT
diff --git a/dlls/msvcrt20/Makefile.in b/dlls/msvcrt20/Makefile.in
index 3e37644fc97..dd887e918f8 100644
--- a/dlls/msvcrt20/Makefile.in
+++ b/dlls/msvcrt20/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = msvcrt20.dll
+IMPORTS   = msvcrt.dll ntdll.dll
 EXTRALIBS = $(LIBUNICODE)
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/msvcrt20/msvcrt20.spec b/dlls/msvcrt20/msvcrt20.spec
index e725dd64488..f22911cdc5a 100644
--- a/dlls/msvcrt20/msvcrt20.spec
+++ b/dlls/msvcrt20/msvcrt20.spec
@@ -2,9 +2,6 @@
 name    msvcrt20
 type    win32
 
-import msvcrt.dll
-import ntdll.dll
-
 debug_channels (msvcrt) 
 
 @ stub ??0Iostream_init@@QAE@AAVios@@H@Z  #
diff --git a/dlls/msvideo/Makefile.in b/dlls/msvideo/Makefile.in
index fc57a746ba8..1839fe245a2 100644
--- a/dlls/msvideo/Makefile.in
+++ b/dlls/msvideo/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = msvfw32.dll
+IMPORTS   = winmm.dll comctl32.dll version.dll user32.dll gdi32.dll kernel32.dll ntdll.dll
 ALTNAMES  = msvideo.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/msvideo/msvfw32.spec b/dlls/msvideo/msvfw32.spec
index 05a39247bfe..501c064208d 100644
--- a/dlls/msvideo/msvfw32.spec
+++ b/dlls/msvideo/msvfw32.spec
@@ -1,14 +1,6 @@
 name	msvfw32
 type	win32
 
-import winmm.dll
-import comctl32.dll
-import version.dll
-import user32.dll
-import gdi32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (mci msvideo)
 
 # Yes, ICCompress,ICDecompress,MCIWnd* and ICDraw* are cdecl (VFWAPIV).
diff --git a/dlls/netapi32/Makefile.in b/dlls/netapi32/Makefile.in
index 9bce845df6d..af978ec5c8b 100644
--- a/dlls/netapi32/Makefile.in
+++ b/dlls/netapi32/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = netapi32.dll
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/netapi32/netapi32.spec b/dlls/netapi32/netapi32.spec
index 077211cdc72..a321c858f6a 100644
--- a/dlls/netapi32/netapi32.spec
+++ b/dlls/netapi32/netapi32.spec
@@ -2,11 +2,6 @@ name	netapi32
 type    win32
 init	NETAPI32_LibMain
 
-#import	user32.dll
-#import	advapi32.dll
-#import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (netbios)
 
 1 stdcall Netbios(ptr) Netbios
diff --git a/dlls/odbc32/Makefile.in b/dlls/odbc32/Makefile.in
index 346e37ce083..1a1615a6de9 100644
--- a/dlls/odbc32/Makefile.in
+++ b/dlls/odbc32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = odbc32.dll
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/odbc32/odbc32.spec b/dlls/odbc32/odbc32.spec
index 02503340b2e..bfa1c9ce575 100644
--- a/dlls/odbc32/odbc32.spec
+++ b/dlls/odbc32/odbc32.spec
@@ -2,8 +2,6 @@ name	odbc32
 type	win32
 init    MAIN_OdbcInit
 
-import	ntdll.dll
-
 debug_channels (odbc)
 
 001 stdcall SQLAllocConnect(long ptr) SQLAllocConnect
diff --git a/dlls/ole32/Makefile.in b/dlls/ole32/Makefile.in
index d3e9a7921a2..8b68cc8d784 100644
--- a/dlls/ole32/Makefile.in
+++ b/dlls/ole32/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = ole32.dll
+IMPORTS   = advapi32.dll user32.dll gdi32.dll rpcrt4.dll kernel32.dll ntdll.dll
 ALTNAMES  = ole2.dll ole2nls.dll ole2conv.dll ole2prox.dll ole2thk.dll storage.dll compobj.dll
 EXTRALIBS = $(LIBUUID)
 
diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec
index 657604f8248..179b04ccda7 100644
--- a/dlls/ole32/ole32.spec
+++ b/dlls/ole32/ole32.spec
@@ -3,13 +3,6 @@ type	win32
 init	OLE32_DllEntryPoint
 rsrc	ole32res.res
 
-import advapi32.dll
-import user32.dll
-import gdi32.dll
-import rpcrt4.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (accel ole relay storage)
 
   1 stub BindMoniker                # stdcall (ptr long ptr ptr) return 0,ERR_NOTIMPLEMENTED
diff --git a/dlls/oleaut32/Makefile.in b/dlls/oleaut32/Makefile.in
index 2fc0cf1dbd3..35c13e26763 100644
--- a/dlls/oleaut32/Makefile.in
+++ b/dlls/oleaut32/Makefile.in
@@ -3,6 +3,8 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = oleaut32.dll
+IMPORTS   = ole32.dll user32.dll gdi32.dll advapi32.dll kernel32.dll ntdll.dll
+DELAYIMPORTS = comctl32.dll
 ALTNAMES  = ole2disp.dll typelib.dll
 EXTRALIBS = $(LIBUUID) @JPEGLIB@
 
diff --git a/dlls/oleaut32/oleaut32.spec b/dlls/oleaut32/oleaut32.spec
index 737c54df531..995c5b62f9f 100644
--- a/dlls/oleaut32/oleaut32.spec
+++ b/dlls/oleaut32/oleaut32.spec
@@ -2,14 +2,6 @@ name oleaut32
 type win32
 rsrc version.res
 
-import -delay comctl32.dll
-import ole32.dll
-import user32.dll
-import gdi32.dll
-import advapi32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (ole olerelay typelib)
 
 1 stdcall DllGetClassObject(ptr ptr ptr) OLEAUT32_DllGetClassObject
diff --git a/dlls/oleaut32/tests/oleaut32_test.spec b/dlls/oleaut32/tests/oleaut32_test.spec
index 35f7b6430f0..1a0374b4173 100644
--- a/dlls/oleaut32/tests/oleaut32_test.spec
+++ b/dlls/oleaut32/tests/oleaut32_test.spec
@@ -1,8 +1,3 @@
 name	oleaut32_tests
 mode	cuiexe
 type	win32
-
-import	oleaut32.dll
-import	gdi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/dlls/olecli/Makefile.in b/dlls/olecli/Makefile.in
index e4086e696e2..2daf62c815f 100644
--- a/dlls/olecli/Makefile.in
+++ b/dlls/olecli/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = olecli32.dll
+IMPORTS   = ole32.dll gdi32.dll kernel32.dll ntdll.dll
 ALTNAMES  = olecli.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/olecli/olecli32.spec b/dlls/olecli/olecli32.spec
index e0582058bb5..e50bcf5b52c 100644
--- a/dlls/olecli/olecli32.spec
+++ b/dlls/olecli/olecli32.spec
@@ -1,11 +1,6 @@
 name olecli32
 type win32
 
-import ole32.dll
-import gdi32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (ole)
 
    1 stub WEP
diff --git a/dlls/oledlg/Makefile.in b/dlls/oledlg/Makefile.in
index 95d03500bc0..3a993fdcba3 100644
--- a/dlls/oledlg/Makefile.in
+++ b/dlls/oledlg/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = oledlg.dll
+IMPORTS   = kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/oledlg/oledlg.spec b/dlls/oledlg/oledlg.spec
index 28137ba492c..207bf0ae28b 100644
--- a/dlls/oledlg/oledlg.spec
+++ b/dlls/oledlg/oledlg.spec
@@ -1,9 +1,6 @@
 name	oledlg
 type	win32
 
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (ole)
 
   1 stdcall OleUIAddVerbMenuA(ptr str long long long long long long ptr) OleUIAddVerbMenuA
diff --git a/dlls/olepro32/Makefile.in b/dlls/olepro32/Makefile.in
index b1d66f93311..38446efebe3 100644
--- a/dlls/olepro32/Makefile.in
+++ b/dlls/olepro32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = olepro32.dll
+IMPORTS   = oleaut32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/olepro32/olepro32.spec b/dlls/olepro32/olepro32.spec
index 52f6e80ebfb..fd434dda2c0 100644
--- a/dlls/olepro32/olepro32.spec
+++ b/dlls/olepro32/olepro32.spec
@@ -1,9 +1,6 @@
 name olepro32
 type win32
 
-import oleaut32.dll
-import ntdll.dll
-
 debug_channels (ole)
 
 248 forward OleIconToCursor OLEAUT32.OleIconToCursor
diff --git a/dlls/olesvr/Makefile.in b/dlls/olesvr/Makefile.in
index fc7f0e73299..75c62d24cc5 100644
--- a/dlls/olesvr/Makefile.in
+++ b/dlls/olesvr/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = olesvr32.dll
+IMPORTS   = kernel32.dll ntdll.dll
 ALTNAMES  = olesvr.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/olesvr/olesvr32.spec b/dlls/olesvr/olesvr32.spec
index 07525466b56..bfce0af77b8 100644
--- a/dlls/olesvr/olesvr32.spec
+++ b/dlls/olesvr/olesvr32.spec
@@ -1,9 +1,6 @@
 name	olesvr32
 type	win32
 
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (ole)
 
  1 stub WEP
diff --git a/dlls/opengl32/Makefile.in b/dlls/opengl32/Makefile.in
index dcbedc63e4c..34dff133dda 100644
--- a/dlls/opengl32/Makefile.in
+++ b/dlls/opengl32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = opengl32.dll
+IMPORTS   = user32.dll gdi32.dll kernel32.dll ntdll.dll
 EXTRALIBS = $(LIBTSX11) $(X_LIBS) $(XLIB)
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/opengl32/opengl32.spec b/dlls/opengl32/opengl32.spec
index 5d715eabb21..35c03bff704 100644
--- a/dlls/opengl32/opengl32.spec
+++ b/dlls/opengl32/opengl32.spec
@@ -2,11 +2,6 @@ name opengl32
 type win32
 init OpenGL32_Init
 
-import user32.dll
-import gdi32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (opengl)
 
 @  stdcall wglCreateContext(long) wglCreateContext
diff --git a/dlls/psapi/Makefile.in b/dlls/psapi/Makefile.in
index 85b2898d5eb..af28ed3b8d3 100644
--- a/dlls/psapi/Makefile.in
+++ b/dlls/psapi/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = psapi.dll
+IMPORTS   = kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/psapi/psapi.spec b/dlls/psapi/psapi.spec
index 7d01cba3598..d0acd048e2c 100644
--- a/dlls/psapi/psapi.spec
+++ b/dlls/psapi/psapi.spec
@@ -1,9 +1,6 @@
 name    psapi
 type    win32
 
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (psapi)
 
 @ stdcall EmptyWorkingSet(long) EmptyWorkingSet
diff --git a/dlls/qcap/Makefile.in b/dlls/qcap/Makefile.in
index 132dd2c7e0d..1015a0aa37e 100644
--- a/dlls/qcap/Makefile.in
+++ b/dlls/qcap/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = qcap.dll
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/qcap/qcap.spec b/dlls/qcap/qcap.spec
index b8e62e93b43..2ef3d9fad15 100644
--- a/dlls/qcap/qcap.spec
+++ b/dlls/qcap/qcap.spec
@@ -1,8 +1,6 @@
 name qcap
 type win32
 
-import ntdll.dll
-
 debug_channels()
 
 @ stub DllCanUnloadNow
diff --git a/dlls/quartz/Makefile.in b/dlls/quartz/Makefile.in
index 3e51f7103c8..5e14022300a 100644
--- a/dlls/quartz/Makefile.in
+++ b/dlls/quartz/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = quartz.dll
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/quartz/quartz.spec b/dlls/quartz/quartz.spec
index b8c333f1bac..375ea8d04c3 100644
--- a/dlls/quartz/quartz.spec
+++ b/dlls/quartz/quartz.spec
@@ -1,8 +1,6 @@
 name	quartz
 type	win32
 
-import ntdll.dll
-
 debug_channels (quartz)
 
 @ stub AMGetErrorTextA
diff --git a/dlls/rasapi32/Makefile.in b/dlls/rasapi32/Makefile.in
index 161e4de54f1..a8625ef3822 100644
--- a/dlls/rasapi32/Makefile.in
+++ b/dlls/rasapi32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = rasapi32.dll
+IMPORTS   = kernel32.dll ntdll.dll
 ALTNAMES  = rasapi16.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/rasapi32/rasapi32.spec b/dlls/rasapi32/rasapi32.spec
index 2a11655e430..fb8501ceb73 100644
--- a/dlls/rasapi32/rasapi32.spec
+++ b/dlls/rasapi32/rasapi32.spec
@@ -1,9 +1,6 @@
 name	rasapi32
 type	win32
 
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (ras)
 
  1  stub RasAutodialAddressToNetwork
diff --git a/dlls/richedit/Makefile.in b/dlls/richedit/Makefile.in
index ea0f651d84a..14511633395 100644
--- a/dlls/richedit/Makefile.in
+++ b/dlls/richedit/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = riched32.dll
+IMPORTS   = user32.dll kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/richedit/riched32.spec b/dlls/richedit/riched32.spec
index 98532608c9c..8010c665173 100644
--- a/dlls/richedit/riched32.spec
+++ b/dlls/richedit/riched32.spec
@@ -2,10 +2,6 @@ name	riched32
 type	win32
 init	RICHED32_LibMain
 
-import	user32.dll
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (richedit)
 
 2 stdcall DllGetVersion (ptr) RICHED32_DllGetVersion
diff --git a/dlls/rpcrt4/Makefile.in b/dlls/rpcrt4/Makefile.in
index e64507ea446..2674482c785 100644
--- a/dlls/rpcrt4/Makefile.in
+++ b/dlls/rpcrt4/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = rpcrt4.dll
+IMPORTS   = kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/rpcrt4/rpcrt4.spec b/dlls/rpcrt4/rpcrt4.spec
index 029319518bb..8f3857c7fe7 100644
--- a/dlls/rpcrt4/rpcrt4.spec
+++ b/dlls/rpcrt4/rpcrt4.spec
@@ -2,9 +2,6 @@ name	rpcrt4
 type	win32
 init	RPCRT4_LibMain
 
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (ole)
 
 @ stub DceErrorInqTextA
diff --git a/dlls/serialui/Makefile.in b/dlls/serialui/Makefile.in
index ba8dfa54ef4..9cf48533577 100644
--- a/dlls/serialui/Makefile.in
+++ b/dlls/serialui/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = serialui.dll
+IMPORTS   = user32.dll advapi32.dll kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/serialui/serialui.spec b/dlls/serialui/serialui.spec
index 60d20a8b482..4c85e55ad60 100644
--- a/dlls/serialui/serialui.spec
+++ b/dlls/serialui/serialui.spec
@@ -3,11 +3,6 @@ type	win32
 init	SERIALUI_LibMain
 rsrc	serialui_rc.res
 
-import	user32.dll
-import	advapi32.dll
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (comm)
 
 2 stdcall EnumPropPages(ptr ptr ptr) SERIALUI_EnumPropPages
diff --git a/dlls/setupapi/Makefile.in b/dlls/setupapi/Makefile.in
index 262fd42daae..12b14d1265a 100644
--- a/dlls/setupapi/Makefile.in
+++ b/dlls/setupapi/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = setupapi.dll
+IMPORTS   = user32.dll advapi32.dll kernel32.dll ntdll.dll
 ALTNAMES  = setupx.dll
 EXTRALIBS = $(LIBUNICODE)
 
diff --git a/dlls/setupapi/setupapi.spec b/dlls/setupapi/setupapi.spec
index 83147147b7f..82e6487bec1 100644
--- a/dlls/setupapi/setupapi.spec
+++ b/dlls/setupapi/setupapi.spec
@@ -2,11 +2,6 @@ name setupapi
 type win32
 rsrc setupapi.res
 
-import user32.dll
-import advapi32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (setupapi)
 
 @ stub AddMiniIconToList
diff --git a/dlls/shdocvw/Makefile.in b/dlls/shdocvw/Makefile.in
index 26063384555..d505c67b6b7 100644
--- a/dlls/shdocvw/Makefile.in
+++ b/dlls/shdocvw/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = shdocvw.dll
+IMPORTS   = ole32.dll kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/shdocvw/shdocvw.spec b/dlls/shdocvw/shdocvw.spec
index c48107974bf..47eb9f43e81 100644
--- a/dlls/shdocvw/shdocvw.spec
+++ b/dlls/shdocvw/shdocvw.spec
@@ -1,10 +1,6 @@
 name	shdocvw
 type	win32
 
-import	ole32.dll
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (comimpl shdocvw)
 
 # ordinal exports
diff --git a/dlls/shell32/Makefile.in b/dlls/shell32/Makefile.in
index cdd4cb51acd..a3661c9c373 100644
--- a/dlls/shell32/Makefile.in
+++ b/dlls/shell32/Makefile.in
@@ -4,6 +4,8 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = shell32.dll
+# fixme: avoid ole32.dll import
+IMPORTS   = ole32.dll shlwapi.dll comctl32.dll user32.dll gdi32.dll advapi32.dll kernel32.dll ntdll.dll
 ALTNAMES  = shell.dll
 EXTRALIBS = $(LIBUUID) $(LIBUNICODE)
 
diff --git a/dlls/shell32/shell32.spec b/dlls/shell32/shell32.spec
index 4df33ee65d2..105b00c6d72 100644
--- a/dlls/shell32/shell32.spec
+++ b/dlls/shell32/shell32.spec
@@ -3,17 +3,6 @@ type	win32
 init	Shell32LibMain
 rsrc	shres.res
 
-# fixme: avoid this import
-import ole32.dll
-
-import shlwapi.dll
-import comctl32.dll
-import user32.dll
-import gdi32.dll
-import advapi32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (exec pidl shell shlctrl)
 
 # Functions exported by the Win95 shell32.dll 
diff --git a/dlls/shfolder/Makefile.in b/dlls/shfolder/Makefile.in
index d03d3504417..277cbe95e8e 100644
--- a/dlls/shfolder/Makefile.in
+++ b/dlls/shfolder/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = shfolder.dll
+IMPORTS   = shell32.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/shfolder/shfolder.spec b/dlls/shfolder/shfolder.spec
index f1d3a244bad..0d97004456c 100644
--- a/dlls/shfolder/shfolder.spec
+++ b/dlls/shfolder/shfolder.spec
@@ -1,7 +1,5 @@
 name shfolder
 type win32
 
-import shell32.dll
-
 @ forward SHGetFolderPathA shell32.SHGetFolderPathA
 @ forward SHGetFolderPathW shell32.SHGetFolderPathW
diff --git a/dlls/shlwapi/Makefile.in b/dlls/shlwapi/Makefile.in
index 448b1cb4c0c..57387a432da 100644
--- a/dlls/shlwapi/Makefile.in
+++ b/dlls/shlwapi/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = shlwapi.dll
+IMPORTS   = user32.dll gdi32.dll advapi32.dll kernel32.dll ntdll.dll
 EXTRALIBS = $(LIBUUID) $(LIBUNICODE)
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/shlwapi/shlwapi.spec b/dlls/shlwapi/shlwapi.spec
index 489f03eeeaf..66ef7d61350 100644
--- a/dlls/shlwapi/shlwapi.spec
+++ b/dlls/shlwapi/shlwapi.spec
@@ -2,12 +2,6 @@ name shlwapi
 type win32
 init SHLWAPI_LibMain
 
-import advapi32.dll
-import user32.dll
-import gdi32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (shell)
 
 1   stdcall @(str ptr) SHLWAPI_1
diff --git a/dlls/snmpapi/Makefile.in b/dlls/snmpapi/Makefile.in
index 4c6dee25c7d..689955cb533 100644
--- a/dlls/snmpapi/Makefile.in
+++ b/dlls/snmpapi/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = snmpapi.dll
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/snmpapi/snmpapi.spec b/dlls/snmpapi/snmpapi.spec
index 7803ec8f235..6c86eb4b02e 100644
--- a/dlls/snmpapi/snmpapi.spec
+++ b/dlls/snmpapi/snmpapi.spec
@@ -2,8 +2,6 @@ name    snmpapi
 type    win32
 init    SNMPAPI_DllMain
 
-import ntdll.dll
-
 debug_channels (snmpapi)
 
 @ stub SnmpSvcAddrIsIpx
diff --git a/dlls/sti/Makefile.in b/dlls/sti/Makefile.in
index e2054d4e39b..ea8baea3465 100644
--- a/dlls/sti/Makefile.in
+++ b/dlls/sti/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = sti.dll
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/sti/sti.spec b/dlls/sti/sti.spec
index 1b8adbedc2d..f4716d47465 100644
--- a/dlls/sti/sti.spec
+++ b/dlls/sti/sti.spec
@@ -1,8 +1,6 @@
 name sti
 type win32
 
-import ntdll.dll
-
 debug_channels()
 
 @ stub DllCanUnloadNow
diff --git a/dlls/tapi32/Makefile.in b/dlls/tapi32/Makefile.in
index ed298a869ef..2ddf6195326 100644
--- a/dlls/tapi32/Makefile.in
+++ b/dlls/tapi32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = tapi32.dll
+IMPORTS   = kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/tapi32/tapi32.spec b/dlls/tapi32/tapi32.spec
index 030740dd0c2..32402ee2341 100644
--- a/dlls/tapi32/tapi32.spec
+++ b/dlls/tapi32/tapi32.spec
@@ -1,9 +1,6 @@
 name	tapi32
 type	win32
 
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (tapi)
 
 @ stdcall lineAccept(long str long) lineAccept
diff --git a/dlls/ttydrv/Makefile.in b/dlls/ttydrv/Makefile.in
index 65f7c070d61..f41680b0cba 100644
--- a/dlls/ttydrv/Makefile.in
+++ b/dlls/ttydrv/Makefile.in
@@ -4,6 +4,7 @@ SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = ttydrv.dll
 IMPORTS   = user32.dll gdi32.dll kernel32.dll ntdll.dll
+LDIMPORTS = user32.dll gdi32.dll kernel32.dll ntdll.dll
 EXTRALIBS = @CURSESLIBS@
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/ttydrv/ttydrv.spec b/dlls/ttydrv/ttydrv.spec
index c48448f67ab..b8d5aa3e9a3 100644
--- a/dlls/ttydrv/ttydrv.spec
+++ b/dlls/ttydrv/ttydrv.spec
@@ -2,11 +2,6 @@ name	ttydrv
 type	win32
 init	TTYDRV_Init
 
-import	user32.dll
-import	gdi32.dll
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (ttydrv)
 
 # GDI driver
diff --git a/dlls/twain/Makefile.in b/dlls/twain/Makefile.in
index 273e1287033..d53d1a26d83 100644
--- a/dlls/twain/Makefile.in
+++ b/dlls/twain/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = twain_32.dll
+IMPORTS   = user32.dll gdi32.dll kernel32.dll ntdll.dll
 EXTRALIBS = @SANELIBS@
 EXTRAINCL = @SANEINCL@
 
diff --git a/dlls/twain/twain_32.spec b/dlls/twain/twain_32.spec
index cb0a8b3cee0..d337782ed06 100644
--- a/dlls/twain/twain_32.spec
+++ b/dlls/twain/twain_32.spec
@@ -2,11 +2,6 @@ name	twain_32
 type	win32
 init	TWAIN_LibMain
 
-import  user32.dll
-import  gdi32.dll
-import  kernel32.dll
-import  ntdll.dll
-
 debug_channels (twain)
 
 @ stdcall DSM_Entry(ptr ptr long long long ptr) DSM_Entry
diff --git a/dlls/url/Makefile.in b/dlls/url/Makefile.in
index 4ada341f12e..ebf200725a4 100644
--- a/dlls/url/Makefile.in
+++ b/dlls/url/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = url.dll
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/url/url.spec b/dlls/url/url.spec
index 2d06f196b68..d9805c0d412 100644
--- a/dlls/url/url.spec
+++ b/dlls/url/url.spec
@@ -1,8 +1,6 @@
 name url
 type win32
 
-import ntdll.dll
-
 debug_channels()
 
 @ stub AddMIMEFileTypesPS
diff --git a/dlls/urlmon/Makefile.in b/dlls/urlmon/Makefile.in
index 7827f1b3de7..c7b4c544f77 100644
--- a/dlls/urlmon/Makefile.in
+++ b/dlls/urlmon/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = urlmon.dll
+IMPORTS   = ole32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/urlmon/urlmon.spec b/dlls/urlmon/urlmon.spec
index f40bb667e0a..9f05a76a8b1 100644
--- a/dlls/urlmon/urlmon.spec
+++ b/dlls/urlmon/urlmon.spec
@@ -1,9 +1,6 @@
 name    urlmon
 type    win32
 
-import	ole32.dll
-import	ntdll.dll
-
 debug_channels (urlmon win32)
 
 1 stub CDLGetLongPathNameA
diff --git a/dlls/user/Makefile.in b/dlls/user/Makefile.in
index a9f5f0af412..7bb922542c3 100644
--- a/dlls/user/Makefile.in
+++ b/dlls/user/Makefile.in
@@ -4,8 +4,9 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = user32.dll
+IMPORTS   = gdi32.dll advapi32.dll kernel32.dll ntdll.dll
 ALTNAMES  = user.exe keyboard.dll ddeml.dll display.dll mouse.dll
-IMPORTS   = gdi32.dll kernel32.dll ntdll.dll
+LDIMPORTS = gdi32.dll kernel32.dll ntdll.dll
 
 C_SRCS = \
 	bidi16.c \
diff --git a/dlls/user/tests/user32_test.spec b/dlls/user/tests/user32_test.spec
index 1f5b801e36d..9afd03f1770 100644
--- a/dlls/user/tests/user32_test.spec
+++ b/dlls/user/tests/user32_test.spec
@@ -1,9 +1,3 @@
 name    user32_test
 type    win32
 mode    cuiexe
-
-import user32.dll
-import gdi32.dll
-import advapi32.dll
-import kernel32.dll
-import ntdll.dll
diff --git a/dlls/user/user32.spec b/dlls/user/user32.spec
index e9edfb7879e..3f1dab1f87f 100644
--- a/dlls/user/user32.spec
+++ b/dlls/user/user32.spec
@@ -3,11 +3,6 @@ type	win32
 init	UserClientDllInitialize
 rsrc	resources/user32.res
 
-import	gdi32.dll
-import	advapi32.dll
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (accel caret class clipboard combo comm cursor dc ddeml dialog
                 driver edit event graphics hook icon key keyboard listbox local
                 mdi menu message msg nonclient relay resource scroll shell static
diff --git a/dlls/version/Makefile.in b/dlls/version/Makefile.in
index 8c1129ee319..37eda9e63e8 100644
--- a/dlls/version/Makefile.in
+++ b/dlls/version/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = version.dll
+IMPORTS   = lz32.dll kernel32.dll ntdll.dll
 ALTNAMES  = ver.dll
 EXTRALIBS = $(LIBUNICODE)
 
diff --git a/dlls/version/version.spec b/dlls/version/version.spec
index 7c4ab795975..0853d9cacfc 100644
--- a/dlls/version/version.spec
+++ b/dlls/version/version.spec
@@ -1,10 +1,6 @@
 name version
 type win32
 
-import lz32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (ver)
 
 @ stdcall GetFileVersionInfoA(str long long ptr) GetFileVersionInfoA
diff --git a/dlls/win32s/Makefile.in b/dlls/win32s/Makefile.in
index 444f6e74d37..aab0abb737c 100644
--- a/dlls/win32s/Makefile.in
+++ b/dlls/win32s/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = w32skrnl.dll
+IMPORTS   = kernel32.dll ntdll.dll
 ALTNAMES  = w32sys.dll win32s16.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/win32s/w32skrnl.spec b/dlls/win32s/w32skrnl.spec
index 5c1ca53af97..7fa7897f5d7 100644
--- a/dlls/win32s/w32skrnl.spec
+++ b/dlls/win32s/w32skrnl.spec
@@ -1,9 +1,6 @@
 name	w32skrnl
 type	win32
 
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (dll)
 
 1 stub _kSetEnvironmentVariable@8
diff --git a/dlls/winaspi/Makefile.in b/dlls/winaspi/Makefile.in
index af06db7a4ca..31d3f701975 100644
--- a/dlls/winaspi/Makefile.in
+++ b/dlls/winaspi/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = wnaspi32.dll
+IMPORTS   = advapi32.dll kernel32.dll ntdll.dll
 ALTNAMES  = winaspi.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/winaspi/wnaspi32.spec b/dlls/winaspi/wnaspi32.spec
index 289e1554f65..8c9303ba11f 100644
--- a/dlls/winaspi/wnaspi32.spec
+++ b/dlls/winaspi/wnaspi32.spec
@@ -2,10 +2,6 @@ name	wnaspi32
 type	win32
 init	WNASPI32_LibMain
 
-import	advapi32.dll
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (aspi)
 
 # we have several ordinal clashes here, it seems...
diff --git a/dlls/winedos/Makefile.in b/dlls/winedos/Makefile.in
index 168e76b13c5..04e3959b9ea 100644
--- a/dlls/winedos/Makefile.in
+++ b/dlls/winedos/Makefile.in
@@ -4,6 +4,7 @@ SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = winedos.dll
 IMPORTS   = user32.dll kernel32.dll ntdll.dll
+LDIMPORTS = user32.dll kernel32.dll ntdll.dll
 
 C_SRCS = \
 	dosaspi.c \
diff --git a/dlls/winedos/winedos.spec b/dlls/winedos/winedos.spec
index a494defcb10..10dd26621c9 100644
--- a/dlls/winedos/winedos.spec
+++ b/dlls/winedos/winedos.spec
@@ -2,10 +2,6 @@ name winedos
 type win32
 init DOSVM_Init
 
-import user32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (aspi console ddraw int int21 int31 module relay)
 
 @ stdcall LoadDosExe(str long) MZ_LoadImage
diff --git a/dlls/wineps/Makefile.in b/dlls/wineps/Makefile.in
index 77c3a4bca23..ddbdb2ee0be 100644
--- a/dlls/wineps/Makefile.in
+++ b/dlls/wineps/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = wineps.dll
+IMPORTS   = user32.dll gdi32.dll winspool.drv advapi32.dll kernel32.dll ntdll.dll
 ALTNAMES  = wineps16.dll
 EXTRALIBS = @CUPSLIBS@
 EXTRAINCL = @FREETYPEINCL@
diff --git a/dlls/wineps/wineps.spec b/dlls/wineps/wineps.spec
index 6a8e41ed447..38715310e56 100644
--- a/dlls/wineps/wineps.spec
+++ b/dlls/wineps/wineps.spec
@@ -3,13 +3,6 @@ type	win32
 init	PSDRV_Init
 rsrc	rsrc.res
 
-import	user32.dll
-import	gdi32.dll
-import	winspool.drv
-import	advapi32.dll
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (psdrv)
 
 # GDI driver
diff --git a/dlls/wininet/Makefile.in b/dlls/wininet/Makefile.in
index f93ea965902..7105c08131e 100644
--- a/dlls/wininet/Makefile.in
+++ b/dlls/wininet/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = wininet.dll
+IMPORTS   = shlwapi.dll user32.dll kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/wininet/wininet.spec b/dlls/wininet/wininet.spec
index 1189d7af6c2..87faaacb237 100644
--- a/dlls/wininet/wininet.spec
+++ b/dlls/wininet/wininet.spec
@@ -2,11 +2,6 @@ name    wininet
 type    win32
 init    WININET_LibMain
 
-import	shlwapi.dll
-import	user32.dll
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (wininet)
 
 @ stub InternetInitializeAutoProxyDll
diff --git a/dlls/winmm/Makefile.in b/dlls/winmm/Makefile.in
index a9ec514edd3..e51ba7024f1 100644
--- a/dlls/winmm/Makefile.in
+++ b/dlls/winmm/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = winmm.dll
+IMPORTS   = user32.dll advapi32.dll kernel32.dll ntdll.dll
 ALTNAMES  = mmsystem.dll sound.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/winmm/joystick/Makefile.in b/dlls/winmm/joystick/Makefile.in
index 0f967f24fb7..d1b7107370f 100644
--- a/dlls/winmm/joystick/Makefile.in
+++ b/dlls/winmm/joystick/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = joystick.drv
+IMPORTS   = winmm.dll user32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/winmm/joystick/joystick.drv.spec b/dlls/winmm/joystick/joystick.drv.spec
index 11be05e3d26..655886a6473 100644
--- a/dlls/winmm/joystick/joystick.drv.spec
+++ b/dlls/winmm/joystick/joystick.drv.spec
@@ -2,10 +2,6 @@ name joystick
 file joystick.drv
 type win32
 
-import winmm.dll
-import user32.dll
-import ntdll.dll
-
 debug_channels (joystick)
 
 @ stdcall DriverProc(long long long long long) JSTCK_DriverProc
diff --git a/dlls/winmm/mcianim/Makefile.in b/dlls/winmm/mcianim/Makefile.in
index b328e804847..a1e8e39ff6d 100644
--- a/dlls/winmm/mcianim/Makefile.in
+++ b/dlls/winmm/mcianim/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = mcianim.drv
+IMPORTS   = winmm.dll user32.dll kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/winmm/mcianim/mcianim.drv.spec b/dlls/winmm/mcianim/mcianim.drv.spec
index 902d935b2de..9d28dab7ee7 100644
--- a/dlls/winmm/mcianim/mcianim.drv.spec
+++ b/dlls/winmm/mcianim/mcianim.drv.spec
@@ -2,11 +2,6 @@ name mcianim
 file mcianim.drv
 type win32
 
-import winmm.dll
-import user32.dll
-import kernel32.dll
-import	ntdll.dll
-
 debug_channels (mcianim)
 
 @ stdcall DriverProc(long long long long long) MCIANIM_DriverProc
diff --git a/dlls/winmm/mciavi/Makefile.in b/dlls/winmm/mciavi/Makefile.in
index 54cfefa095c..e5c49f4069c 100644
--- a/dlls/winmm/mciavi/Makefile.in
+++ b/dlls/winmm/mciavi/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = mciavi.drv
+IMPORTS   = msvfw32.dll winmm.dll user32.dll gdi32.dll kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/winmm/mciavi/mciavi.drv.spec b/dlls/winmm/mciavi/mciavi.drv.spec
index b9178066b37..2f35fe356ec 100644
--- a/dlls/winmm/mciavi/mciavi.drv.spec
+++ b/dlls/winmm/mciavi/mciavi.drv.spec
@@ -4,13 +4,6 @@ type win32
 init MCIAVI_LibMain
 rsrc mciavi_res.res
 
-import msvfw32.dll
-import winmm.dll
-import user32.dll
-import gdi32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (mciavi)
 
 @ stdcall DriverProc(long long long long long) MCIAVI_DriverProc
diff --git a/dlls/winmm/mcicda/Makefile.in b/dlls/winmm/mcicda/Makefile.in
index 9b1cb25b164..2a38a5dc5de 100644
--- a/dlls/winmm/mcicda/Makefile.in
+++ b/dlls/winmm/mcicda/Makefile.in
@@ -3,6 +3,8 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = mcicda.drv
+IMPORTS   = winmm.dll kernel32.dll ntdll.dll
+DELAYIMPORTS = user32.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/winmm/mcicda/mcicda.drv.spec b/dlls/winmm/mcicda/mcicda.drv.spec
index a615106e7f2..529453719d8 100644
--- a/dlls/winmm/mcicda/mcicda.drv.spec
+++ b/dlls/winmm/mcicda/mcicda.drv.spec
@@ -2,11 +2,6 @@ name mcicda
 file mcicda.drv
 type win32
 
-import winmm.dll
-import -delay user32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (mcicda)
 
 @ stdcall DriverProc(long long long long long) MCICDA_DriverProc
diff --git a/dlls/winmm/mciseq/Makefile.in b/dlls/winmm/mciseq/Makefile.in
index e55a1e7e2ad..f5cb6e4bb64 100644
--- a/dlls/winmm/mciseq/Makefile.in
+++ b/dlls/winmm/mciseq/Makefile.in
@@ -3,6 +3,8 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = mciseq.drv
+IMPORTS   = winmm.dll kernel32.dll ntdll.dll
+DELAYIMPORTS = user32.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/winmm/mciseq/mciseq.drv.spec b/dlls/winmm/mciseq/mciseq.drv.spec
index 8150e25fc59..3377010b2db 100644
--- a/dlls/winmm/mciseq/mciseq.drv.spec
+++ b/dlls/winmm/mciseq/mciseq.drv.spec
@@ -2,11 +2,6 @@ name mciseq
 file mciseq.drv
 type win32
 
-import winmm.dll
-import -delay user32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (mcimidi)
 
 @ stdcall DriverProc(long long long long long) MCIMIDI_DriverProc
diff --git a/dlls/winmm/mciwave/Makefile.in b/dlls/winmm/mciwave/Makefile.in
index 2fd61487d87..fd09d6e590e 100644
--- a/dlls/winmm/mciwave/Makefile.in
+++ b/dlls/winmm/mciwave/Makefile.in
@@ -3,6 +3,8 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = mciwave.drv
+IMPORTS   = winmm.dll kernel32.dll ntdll.dll
+DELAYIMPORTS = user32.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/winmm/mciwave/mciwave.drv.spec b/dlls/winmm/mciwave/mciwave.drv.spec
index 8ca402e3879..7b3147d21c1 100644
--- a/dlls/winmm/mciwave/mciwave.drv.spec
+++ b/dlls/winmm/mciwave/mciwave.drv.spec
@@ -2,11 +2,6 @@ name mciwave
 file mciwave.drv
 type win32
 
-import winmm.dll
-import -delay user32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (mciwave)
 
 @ stdcall DriverProc(long long long long long) MCIWAVE_DriverProc
diff --git a/dlls/winmm/midimap/Makefile.in b/dlls/winmm/midimap/Makefile.in
index 292e59d675b..301d73023b7 100644
--- a/dlls/winmm/midimap/Makefile.in
+++ b/dlls/winmm/midimap/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = midimap.drv
+IMPORTS   = winmm.dll user32.dll advapi32.dll kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/winmm/midimap/midimap.drv.spec b/dlls/winmm/midimap/midimap.drv.spec
index 9749fb89844..454e032b80d 100644
--- a/dlls/winmm/midimap/midimap.drv.spec
+++ b/dlls/winmm/midimap/midimap.drv.spec
@@ -2,12 +2,6 @@ name midimap
 file midimap.drv
 type win32
 
-import winmm.dll
-import user32.dll
-import advapi32.dll
-import kernel32.dll
-import	ntdll.dll
-
 debug_channels (msacm)
 
 @ stdcall DriverProc(long long long long long) MIDIMAP_DriverProc
diff --git a/dlls/winmm/wavemap/Makefile.in b/dlls/winmm/wavemap/Makefile.in
index 727b6e2a820..8511dbb29ba 100644
--- a/dlls/winmm/wavemap/Makefile.in
+++ b/dlls/winmm/wavemap/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = msacm.drv
+IMPORTS   = msacm32.dll winmm.dll user32.dll kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/winmm/wavemap/msacm.drv.spec b/dlls/winmm/wavemap/msacm.drv.spec
index 8d918711fe8..c573e40313d 100644
--- a/dlls/winmm/wavemap/msacm.drv.spec
+++ b/dlls/winmm/wavemap/msacm.drv.spec
@@ -2,12 +2,6 @@ name msacmmap
 file msacm.drv
 type win32
 
-import msacm32.dll
-import winmm.dll
-import user32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (msacm)
 
 @ stdcall DriverProc(long long long long long) WAVEMAP_DriverProc
diff --git a/dlls/winmm/winearts/Makefile.in b/dlls/winmm/winearts/Makefile.in
index 1f1538ca7d8..c6650411ab8 100644
--- a/dlls/winmm/winearts/Makefile.in
+++ b/dlls/winmm/winearts/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = winearts.drv
+IMPORTS   = winmm.dll user32.dll kernel32.dll ntdll.dll
 EXTRADEFS = @ARTSINCL@
 EXTRALIBS = @ARTSLIBS@
 
diff --git a/dlls/winmm/winearts/winearts.drv.spec b/dlls/winmm/winearts/winearts.drv.spec
index 80ffa582b64..b89c8fad36d 100644
--- a/dlls/winmm/winearts/winearts.drv.spec
+++ b/dlls/winmm/winearts/winearts.drv.spec
@@ -2,11 +2,6 @@ name winearts
 file winearts.drv
 type win32
 
-import winmm.dll
-import user32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (wave)
 
 @ stdcall DriverProc(long long long long long) ARTS_DriverProc
diff --git a/dlls/winmm/wineoss/Makefile.in b/dlls/winmm/wineoss/Makefile.in
index 05969da6b95..c501135532b 100644
--- a/dlls/winmm/wineoss/Makefile.in
+++ b/dlls/winmm/wineoss/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = wineoss.drv
+IMPORTS   = winmm.dll user32.dll kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/winmm/wineoss/wineoss.drv.spec b/dlls/winmm/wineoss/wineoss.drv.spec
index 935f55298d9..2171e02f88c 100644
--- a/dlls/winmm/wineoss/wineoss.drv.spec
+++ b/dlls/winmm/wineoss/wineoss.drv.spec
@@ -2,11 +2,6 @@ name wineoss
 file wineoss.drv
 type win32
 
-import winmm.dll
-import user32.dll
-import kernel32.dll
-import	ntdll.dll
-
 debug_channels (midi mmaux wave)
 
   1 stdcall DriverProc(long long long long long) OSS_DriverProc
diff --git a/dlls/winmm/winmm.spec b/dlls/winmm/winmm.spec
index 30a7f54df6f..8771ac6bfae 100644
--- a/dlls/winmm/winmm.spec
+++ b/dlls/winmm/winmm.spec
@@ -3,11 +3,6 @@ type win32
 init WINMM_LibMain
 rsrc winmm_res.res
 
-import user32.dll
-import advapi32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (driver mci mmio mmsys mmtime sound)
 
 # ordinal exports
diff --git a/dlls/winnls/Makefile.in b/dlls/winnls/Makefile.in
index d99fe41140f..be6ff09a913 100644
--- a/dlls/winnls/Makefile.in
+++ b/dlls/winnls/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = winnls32.dll
+IMPORTS   = kernel32.dll ntdll.dll
 ALTNAMES  = winnls.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/winnls/winnls32.spec b/dlls/winnls/winnls32.spec
index e5302fc539d..b452a054fc5 100644
--- a/dlls/winnls/winnls32.spec
+++ b/dlls/winnls/winnls32.spec
@@ -1,9 +1,6 @@
 name	winnls32
 type	win32
 
-import	kernel32.dll
-import	ntdll.dll
-
 1  stub WINNLS32EnableIME
 2  stub WINNLS32GetEnableStatus
 3  stub WINNLS32GetIMEHotKey
diff --git a/dlls/winsock/Makefile.in b/dlls/winsock/Makefile.in
index 037d87c4b33..5017d89e517 100644
--- a/dlls/winsock/Makefile.in
+++ b/dlls/winsock/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = ws2_32.dll
+IMPORTS   = user32.dll kernel32.dll ntdll.dll
 ALTNAMES  = winsock.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/winsock/tests/ws2_32_test.spec b/dlls/winsock/tests/ws2_32_test.spec
index efd7bdc5404..91051180fb2 100644
--- a/dlls/winsock/tests/ws2_32_test.spec
+++ b/dlls/winsock/tests/ws2_32_test.spec
@@ -1,7 +1,3 @@
 name	ws2_32_test
 type	win32
 mode	cuiexe
-
-import ws2_32.dll
-import kernel32.dll
-import ntdll.dll
diff --git a/dlls/winsock/ws2_32.spec b/dlls/winsock/ws2_32.spec
index bf6e5132e84..ca2713701d8 100644
--- a/dlls/winsock/ws2_32.spec
+++ b/dlls/winsock/ws2_32.spec
@@ -6,10 +6,6 @@ name ws2_32
 type win32
 init WS_LibMain
 
-import user32.dll
-import kernel32.dll
-import ntdll.dll
-
 debug_channels (winsock)
 
 #  EXPORTS ***********
diff --git a/dlls/winspool/Makefile.in b/dlls/winspool/Makefile.in
index 5bcace2056c..c0448f45b51 100644
--- a/dlls/winspool/Makefile.in
+++ b/dlls/winspool/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = winspool.drv
+IMPORTS   = advapi32.dll kernel32.dll ntdll.dll
 EXTRALIBS = @CUPSLIBS@
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/winspool/winspool.drv.spec b/dlls/winspool/winspool.drv.spec
index 50322a2ff73..e20f8b9df7f 100644
--- a/dlls/winspool/winspool.drv.spec
+++ b/dlls/winspool/winspool.drv.spec
@@ -3,10 +3,6 @@ type	win32
 file	winspool.drv
 init	WINSPOOL_EntryPoint
 
-import	advapi32.dll
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (winspool)
 
 100 stub @
diff --git a/dlls/wintrust/Makefile.in b/dlls/wintrust/Makefile.in
index 384a5f3253c..7bf48d7e1c9 100644
--- a/dlls/wintrust/Makefile.in
+++ b/dlls/wintrust/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = wintrust.dll
+IMPORTS   = ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/wintrust/wintrust.spec b/dlls/wintrust/wintrust.spec
index 781efd998d2..cdf11e0cd71 100644
--- a/dlls/wintrust/wintrust.spec
+++ b/dlls/wintrust/wintrust.spec
@@ -1,8 +1,6 @@
 name	wintrust
 type	win32
 
-import ntdll.dll
-
 debug_channels (win32)
 
 @ stdcall WinVerifyTrust(long ptr ptr) WinVerifyTrust
diff --git a/dlls/wow32/Makefile.in b/dlls/wow32/Makefile.in
index f68bcdc6d7e..1347ec96ba1 100644
--- a/dlls/wow32/Makefile.in
+++ b/dlls/wow32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = wow32.dll
+IMPORTS   = kernel32.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/wow32/wow32.spec b/dlls/wow32/wow32.spec
index 7a89059db0a..e3012665ac8 100644
--- a/dlls/wow32/wow32.spec
+++ b/dlls/wow32/wow32.spec
@@ -1,8 +1,6 @@
 name	wow32
 type	win32
 
-import kernel32.dll
-
 # ordinal exports
 1 forward WOWGetDescriptor kernel32.K32WOWGetDescriptor
 
diff --git a/dlls/wsock32/Makefile.in b/dlls/wsock32/Makefile.in
index c8accb8ae57..60874df2da2 100644
--- a/dlls/wsock32/Makefile.in
+++ b/dlls/wsock32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = wsock32.dll
+IMPORTS   = ws2_32.dll kernel32.dll ntdll.dll
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/dlls/wsock32/wsock32.spec b/dlls/wsock32/wsock32.spec
index 08c00ad7e9b..308c7dfdc4a 100644
--- a/dlls/wsock32/wsock32.spec
+++ b/dlls/wsock32/wsock32.spec
@@ -1,10 +1,6 @@
 name	wsock32
 type	win32
 
-import	ws2_32.dll
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (winsock)
 
   1 forward accept ws2_32.accept
diff --git a/dlls/x11drv/Makefile.in b/dlls/x11drv/Makefile.in
index a3659ee0fff..0d502a884a8 100644
--- a/dlls/x11drv/Makefile.in
+++ b/dlls/x11drv/Makefile.in
@@ -4,8 +4,9 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = x11drv.dll
+IMPORTS   = user32.dll gdi32.dll advapi32.dll kernel32.dll ntdll.dll
 EXTRALIBS = $(LIBTSX11) $(X_LIBS) $(XLIB)
-IMPORTS   = user32.dll gdi32.dll kernel32.dll
+LDIMPORTS = user32.dll gdi32.dll kernel32.dll
 
 C_SRCS = \
 	desktop.c \
diff --git a/dlls/x11drv/x11drv.spec b/dlls/x11drv/x11drv.spec
index 06d99217734..34a24336a68 100644
--- a/dlls/x11drv/x11drv.spec
+++ b/dlls/x11drv/x11drv.spec
@@ -2,12 +2,6 @@ name	x11drv
 type	win32
 init	X11DRV_Init
 
-import	user32.dll
-import	gdi32.dll
-import	advapi32.dll
-import	kernel32.dll
-import	ntdll.dll
-
 debug_channels (bitblt bitmap clipboard cursor dinput event font gdi graphics
                 key keyboard opengl palette text win x11drv xrender)
 
diff --git a/libtest/Makefile.in b/libtest/Makefile.in
index 97366aadc4a..2a41a255b93 100644
--- a/libtest/Makefile.in
+++ b/libtest/Makefile.in
@@ -38,47 +38,47 @@ all: $(PROGRAMS) $(PROGRAMS:%=%.so)
 @MAKE_RULES@
 
 expand.spec.c: expand.spec expand.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L $(DLLDIR) -sym expand.o -o expand.spec.c -spec expand.spec
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym expand.o -o expand.spec.c -spec expand.spec -L$(DLLDIR) -llz32.dll -lkernel32.dll -lntdll.dll
 expand.so: expand.o expand.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o expand.so $+ $(ALL_LIBS)
 
 hello.spec.c: hello.spec hello.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L $(DLLDIR) -sym hello.o -o hello.spec.c -spec hello.spec
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym hello.o -o hello.spec.c -spec hello.spec -L$(DLLDIR) -luser32.dll -lgdi32.dll -lkernel32.dll -lntdll.dll
 hello.so: hello.o hello.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o hello.so $+ $(ALL_LIBS)
 
 hello2.spec.c: hello2.spec hello2.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L $(DLLDIR) -sym hello2.o -o hello2.spec.c -spec hello2.spec
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym hello2.o -o hello2.spec.c -spec hello2.spec -L$(DLLDIR) -luser32.dll -lkernel32.dll -lntdll.dll
 hello2.so: hello2.o hello2.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o hello2.so $+ $(ALL_LIBS)
 
 hello3.spec.c: hello3.spec hello3.o hello3res.res $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L $(DLLDIR) -sym hello3.o -o hello3.spec.c -spec hello3.spec
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym hello3.o -o hello3.spec.c -spec hello3.spec -L$(DLLDIR) -lcomdlg32.dll -luser32.dll -lgdi32.dll -lkernel32.dll -lntdll.dll
 hello3.so: hello3.o hello3.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o hello3.so $+ $(ALL_LIBS)
 
 hello4.spec.c: hello4.spec hello4.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L $(DLLDIR) -sym hello4.o -o hello4.spec.c -spec hello4.spec
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym hello4.o -o hello4.spec.c -spec hello4.spec -L$(DLLDIR) -luser32.dll -lgdi32.dll -lkernel32.dll -lntdll.dll
 hello4.so: hello4.o hello4.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o hello4.so $+ $(ALL_LIBS)
 
 hello5.spec.c: hello5.spec hello5.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L $(DLLDIR) -sym hello5.o -o hello5.spec.c -spec hello5.spec
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym hello5.o -o hello5.spec.c -spec hello5.spec -L$(DLLDIR) -lkernel32.dll -lntdll.dll
 hello5.so: hello5.o hello5.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o hello5.so $+ $(ALL_LIBS)
 
 new.spec.c: new.spec new.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L $(DLLDIR) -sym new.o -o new.spec.c -spec new.spec
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym new.o -o new.spec.c -spec new.spec -L$(DLLDIR) -luser32.dll -lgdi32.dll -lkernel32.dll -lntdll.dll
 new.so: new.o new.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o new.so $+ $(ALL_LIBS)
 
 rolex.spec.c: rolex.spec rolex.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L $(DLLDIR) -sym rolex.o -o rolex.spec.c -spec rolex.spec
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym rolex.o -o rolex.spec.c -spec rolex.spec -L$(DLLDIR) -luser32.dll -lgdi32.dll -lkernel32.dll -lntdll.dll
 rolex.so: rolex.o rolex.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o rolex.so $+ $(ALL_LIBS)
 
 volinfo.spec.c: volinfo.spec volinfo.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L $(DLLDIR) -sym volinfo.o -o volinfo.spec.c -spec volinfo.spec
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym volinfo.o -o volinfo.spec.c -spec volinfo.spec -L$(DLLDIR) -lkernel32.dll -lntdll.dll
 volinfo.so: volinfo.o volinfo.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o volinfo.so $+ $(ALL_LIBS)
 
@@ -86,7 +86,7 @@ $(PROGRAMS):
 	$(LN_S) $(TOPOBJDIR)/wine $@
 
 $(PROGRAMS:%=%.so/_checklink_): $(PROGRAMS:%=%.so)
-	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c `dirname $@` $(ALL_LIBS) && $(RM) checklink
+	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c `dirname $@` && $(RM) checklink
 
 checklink:: $(PROGRAMS:%=%.so/_checklink_)
 
diff --git a/libtest/expand.spec b/libtest/expand.spec
index a9f4513a10d..a0c73c0094d 100644
--- a/libtest/expand.spec
+++ b/libtest/expand.spec
@@ -1,7 +1,3 @@
 name	expand
 mode	guiexe
 type	win32
-
-import	lz32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/libtest/hello.spec b/libtest/hello.spec
index a42049cd8f7..fcda0d7a4e7 100644
--- a/libtest/hello.spec
+++ b/libtest/hello.spec
@@ -1,8 +1,3 @@
 name	hello
 mode	guiexe
 type	win32
-
-import	user32.dll
-import	gdi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/libtest/hello2.spec b/libtest/hello2.spec
index 56568eec8fd..aaecc3ede37 100644
--- a/libtest/hello2.spec
+++ b/libtest/hello2.spec
@@ -1,7 +1,3 @@
 name	hello2
 mode	guiexe
 type	win32
-
-import	user32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/libtest/hello3.spec b/libtest/hello3.spec
index 38546b48f2c..272ba4f1093 100644
--- a/libtest/hello3.spec
+++ b/libtest/hello3.spec
@@ -2,9 +2,3 @@ name	hello3
 mode	guiexe
 type	win32
 rsrc	hello3res.res
-
-import	comdlg32.dll
-import	user32.dll
-import	gdi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/libtest/hello4.spec b/libtest/hello4.spec
index 9c34f003103..b19a9be117e 100644
--- a/libtest/hello4.spec
+++ b/libtest/hello4.spec
@@ -1,8 +1,3 @@
 name	hello4
 mode	guiexe
 type	win32
-
-import	user32.dll
-import	gdi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/libtest/hello5.spec b/libtest/hello5.spec
index 620b887f9e6..04c83790e90 100644
--- a/libtest/hello5.spec
+++ b/libtest/hello5.spec
@@ -1,7 +1,3 @@
 name	hello5
 mode	guiexe
 type	win32
-
-import	kernel32.dll
-import	ntdll.dll
-
diff --git a/libtest/new.spec b/libtest/new.spec
index caa2d2eb50d..36e492c7dd7 100644
--- a/libtest/new.spec
+++ b/libtest/new.spec
@@ -1,8 +1,3 @@
 name	new
 mode	guiexe
 type	win32
-
-import	user32.dll
-import	gdi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/libtest/rolex.spec b/libtest/rolex.spec
index 00d6fce61cc..85adaefc5ea 100644
--- a/libtest/rolex.spec
+++ b/libtest/rolex.spec
@@ -1,8 +1,3 @@
 name	rolex
 mode	guiexe
 type	win32
-
-import	user32.dll
-import	gdi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/libtest/volinfo.spec b/libtest/volinfo.spec
index eaba29d3a08..50c1d631e95 100644
--- a/libtest/volinfo.spec
+++ b/libtest/volinfo.spec
@@ -1,6 +1,3 @@
 name	volinfo
 mode	guiexe
 type	win32
-
-import	kernel32.dll
-import	ntdll.dll
diff --git a/miscemu/Makefile.in b/miscemu/Makefile.in
index 3096d41679d..0afb8f397bf 100644
--- a/miscemu/Makefile.in
+++ b/miscemu/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = miscemu
+IMPORTS   = ntdll.dll
 
 SPEC_SRCS = wine.spec
 
diff --git a/miscemu/wine.spec b/miscemu/wine.spec
index a6ded8576eb..52555b7ac85 100644
--- a/miscemu/wine.spec
+++ b/miscemu/wine.spec
@@ -2,5 +2,3 @@ name	wine
 mode	guiexe
 type	win32
 init	wine_initial_task
-
-import	ntdll.dll
diff --git a/programs/Makeprog.rules.in b/programs/Makeprog.rules.in
index 1dc0465dd19..c8f2651d2b7 100644
--- a/programs/Makeprog.rules.in
+++ b/programs/Makeprog.rules.in
@@ -8,11 +8,12 @@
 # plus all variables required by the global Make.rules.in
 #
 
-DEFS       = @DLLFLAGS@ -DSTRICT -DNONAMELESSUNION -DNONAMELESSSTRUCT $(EXTRADEFS)
-LDDLLFLAGS = @LDDLLFLAGS@
-ALL_OBJS   = $(MODULE).spec.o $(OBJS)
-ALL_LIBS   = $(LIBWINE) $(EXTRALIBS) $(LIBS)
-SYMBOLFILE = $(MODULE).tmp.o
+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)
 
@@ -29,7 +30,7 @@ $(MODULE): $(MODULE).so
 # Rules for checking that no imports are missing
 
 checklink:: $(MODULE).so
-	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c $(MODULE).so $(ALL_LIBS) && $(RM) checklink
+	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c $(MODULE).so && $(RM) checklink
 
 # Rules for testing
 
diff --git a/programs/avitools/Makefile.in b/programs/avitools/Makefile.in
index c96f24c9d5b..628b1fcf9de 100644
--- a/programs/avitools/Makefile.in
+++ b/programs/avitools/Makefile.in
@@ -18,13 +18,13 @@ all: $(PROGRAMS)
 @MAKE_RULES@
 
 aviinfo.spec.c: aviinfo.spec aviinfo.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L $(DLLDIR) -sym aviinfo.o -o aviinfo.spec.c -spec $(SRCDIR)/aviinfo.spec
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym aviinfo.o -o aviinfo.spec.c -spec $(SRCDIR)/aviinfo.spec -L$(DLLDIR) -lkernel32.dll -lntdll.dll
 
 aviplay.spec.c: aviplay.spec aviplay.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L $(DLLDIR) -sym aviplay.o -o aviplay.spec.c -spec $(SRCDIR)/aviplay.spec
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym aviplay.o -o aviplay.spec.c -spec $(SRCDIR)/aviplay.spec -L$(DLLDIR) -lddraw.dll -lkernel32.dll -lntdll.dll
 
 icinfo.spec.c: icinfo.spec icinfo.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L $(DLLDIR) -sym icinfo.o -o icinfo.spec.c -spec $(SRCDIR)/icinfo.spec
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym icinfo.o -o icinfo.spec.c -spec $(SRCDIR)/icinfo.spec -L$(DLLDIR) -lmsvfw32.dll -lkernel32.dll -lntdll.dll
 
 aviinfo.so: aviinfo.o aviinfo.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o aviinfo.so aviinfo.o aviinfo.spec.o $(ALL_LIBS)
@@ -56,8 +56,8 @@ uninstall::
 	$(RM) $(bindir)/aviinfo $(bindir)/aviplay $(bindir)/icinfo
 
 checklink:: $(PROGRAMS:%=%.so)
-	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c aviinfo.so $(ALL_LIBS) && $(RM) checklink
-	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c aviplay.so $(ALL_LIBS) && $(RM) checklink
-	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c icinfo.so $(ALL_LIBS) && $(RM) checklink
+	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c aviinfo.so && $(RM) checklink
+	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c aviplay.so && $(RM) checklink
+	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c icinfo.so && $(RM) checklink
 
 ### Dependencies:
diff --git a/programs/avitools/aviinfo.spec b/programs/avitools/aviinfo.spec
index 8ee93e6c514..1730af69fc9 100644
--- a/programs/avitools/aviinfo.spec
+++ b/programs/avitools/aviinfo.spec
@@ -1,6 +1,3 @@
 name	aviinfo
 mode	guiexe
 type	win32
-
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/avitools/aviplay.spec b/programs/avitools/aviplay.spec
index 6057a043846..9a1a3e1e59d 100644
--- a/programs/avitools/aviplay.spec
+++ b/programs/avitools/aviplay.spec
@@ -1,7 +1,3 @@
 name	aviplay
 mode	guiexe
 type	win32
-
-import	ddraw.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/avitools/icinfo.spec b/programs/avitools/icinfo.spec
index cfb2ae86d73..ffe307c99f5 100644
--- a/programs/avitools/icinfo.spec
+++ b/programs/avitools/icinfo.spec
@@ -1,7 +1,3 @@
 name	icinfo
 mode	guiexe
 type	win32
-
-import	msvfw32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/clock/Makefile.in b/programs/clock/Makefile.in
index 409c357fa71..915835e14d5 100644
--- a/programs/clock/Makefile.in
+++ b/programs/clock/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = clock
+IMPORTS   = comdlg32.dll shell32.dll user32.dll gdi32.dll kernel32.dll ntdll.dll
 
 LICENSELANG = En
 
diff --git a/programs/clock/clock.spec b/programs/clock/clock.spec
index 8212eeba915..f5e1a38ab79 100644
--- a/programs/clock/clock.spec
+++ b/programs/clock/clock.spec
@@ -3,9 +3,3 @@ mode	guiexe
 type	win32
 rsrc	rsrc.res
 
-import	comdlg32.dll
-import	shell32.dll
-import	user32.dll
-import	gdi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/cmdlgtst/Makefile.in b/programs/cmdlgtst/Makefile.in
index 4f362a8a1db..589771d1a51 100644
--- a/programs/cmdlgtst/Makefile.in
+++ b/programs/cmdlgtst/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = cmdlgtst
+IMPORTS   = comdlg32.dll user32.dll gdi32.dll kernel32.dll ntdll.dll
 
 C_SRCS = \
 	cmdlgtst.c
diff --git a/programs/cmdlgtst/cmdlgtst.spec b/programs/cmdlgtst/cmdlgtst.spec
index 7e948ed46a2..e100d40d4f8 100644
--- a/programs/cmdlgtst/cmdlgtst.spec
+++ b/programs/cmdlgtst/cmdlgtst.spec
@@ -3,8 +3,3 @@ mode	guiexe
 type	win32
 rsrc	cmdlgr.res
 
-import	comdlg32.dll
-import	user32.dll
-import	gdi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/control/Makefile.in b/programs/control/Makefile.in
index 8158e7d0e7f..68d78dcfde3 100644
--- a/programs/control/Makefile.in
+++ b/programs/control/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = control
+IMPORTS   = shell32.dll user32.dll kernel32.dll ntdll.dll
 
 C_SRCS = control.c
 
diff --git a/programs/control/control.spec b/programs/control/control.spec
index 4af82552976..c902d8ba43b 100644
--- a/programs/control/control.spec
+++ b/programs/control/control.spec
@@ -2,7 +2,3 @@ name	control
 mode	guiexe
 type	win32
 
-import	shell32.dll
-import	user32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/notepad/Makefile.in b/programs/notepad/Makefile.in
index e757de17a8f..2a31a44e15b 100644
--- a/programs/notepad/Makefile.in
+++ b/programs/notepad/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = notepad
+IMPORTS   = comdlg32.dll shell32.dll user32.dll gdi32.dll kernel32.dll ntdll.dll
 
 LICENSELANG = En
 
diff --git a/programs/notepad/notepad.spec b/programs/notepad/notepad.spec
index a655b12342d..1d647ba5608 100644
--- a/programs/notepad/notepad.spec
+++ b/programs/notepad/notepad.spec
@@ -3,9 +3,3 @@ mode	guiexe
 type	win32
 rsrc	rsrc.res
 
-import	comdlg32.dll
-import	shell32.dll
-import	user32.dll
-import	gdi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/osversioncheck/Makefile.in b/programs/osversioncheck/Makefile.in
index e725115a5f1..8016fc958ba 100644
--- a/programs/osversioncheck/Makefile.in
+++ b/programs/osversioncheck/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = osversioncheck
+IMPORTS   = kernel32.dll ntdll.dll
 
 C_SRCS = osversioncheck.c
 
diff --git a/programs/osversioncheck/osversioncheck.spec b/programs/osversioncheck/osversioncheck.spec
index c149f815a9a..a59ffeed222 100644
--- a/programs/osversioncheck/osversioncheck.spec
+++ b/programs/osversioncheck/osversioncheck.spec
@@ -3,5 +3,3 @@ mode    cuiexe
 type	win32
 init	main
 
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/progman/Makefile.in b/programs/progman/Makefile.in
index deb8c67ca50..ba09ea82c42 100644
--- a/programs/progman/Makefile.in
+++ b/programs/progman/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = progman
+IMPORTS   = shell32.dll comdlg32.dll user32.dll gdi32.dll kernel32.dll ntdll.dll
 
 LICENSELANG = En
 
diff --git a/programs/progman/progman.spec b/programs/progman/progman.spec
index be7940827e2..f33dfa88f52 100644
--- a/programs/progman/progman.spec
+++ b/programs/progman/progman.spec
@@ -3,9 +3,3 @@ mode	guiexe
 type	win32
 rsrc	rsrc.res
 
-import	shell32.dll
-import	comdlg32.dll
-import	user32.dll
-import	gdi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/regapi/Makefile.in b/programs/regapi/Makefile.in
index 7b122672e1f..3eb8a66784f 100644
--- a/programs/regapi/Makefile.in
+++ b/programs/regapi/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = regapi
+IMPORTS   = advapi32.dll kernel32.dll ntdll.dll
 
 C_SRCS = \
 	regapi.c
diff --git a/programs/regapi/regapi.spec b/programs/regapi/regapi.spec
index 86ef42d62b9..0d1754693b4 100644
--- a/programs/regapi/regapi.spec
+++ b/programs/regapi/regapi.spec
@@ -2,6 +2,3 @@ name	regapi
 mode	guiexe
 type	win32
 
-import	advapi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/regedit/Makefile.in b/programs/regedit/Makefile.in
index c4d9c4dda3a..c44a3386a38 100644
--- a/programs/regedit/Makefile.in
+++ b/programs/regedit/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = regedit
+IMPORTS   = msvcrt.dll advapi32.dll kernel32.dll ntdll.dll
 
 C_SRCS = \
 	regedit.c \
diff --git a/programs/regedit/regedit.spec b/programs/regedit/regedit.spec
index 09691ee8646..5b1fcc68110 100644
--- a/programs/regedit/regedit.spec
+++ b/programs/regedit/regedit.spec
@@ -3,7 +3,3 @@ type    win32
 mode    guiexe
 init    WinMain
 
-import msvcrt.dll
-import advapi32.dll
-import kernel32.dll
-import ntdll.dll
diff --git a/programs/regsvr32/Makefile.in b/programs/regsvr32/Makefile.in
index 21364d65325..f8792eb605e 100644
--- a/programs/regsvr32/Makefile.in
+++ b/programs/regsvr32/Makefile.in
@@ -4,6 +4,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = regsvr32
+IMPORTS   = msvcrt.dll kernel32.dll ntdll.dll
 
 C_SRCS = \
 	regsvr32.c
diff --git a/programs/regsvr32/regsvr32.spec b/programs/regsvr32/regsvr32.spec
index 4296e9fea8c..d0f75c17a86 100644
--- a/programs/regsvr32/regsvr32.spec
+++ b/programs/regsvr32/regsvr32.spec
@@ -3,6 +3,3 @@ type    win32
 mode    cuiexe
 init    main
 
-import msvcrt.dll
-import kernel32.dll
-import ntdll.dll
diff --git a/programs/regtest/Makefile.in b/programs/regtest/Makefile.in
index f296f5cea1e..5a739b9a435 100644
--- a/programs/regtest/Makefile.in
+++ b/programs/regtest/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = regtest
+IMPORTS   = advapi32.dll kernel32.dll ntdll.dll
 
 C_SRCS = regtest.c
 
diff --git a/programs/regtest/regtest.spec b/programs/regtest/regtest.spec
index ccf39f3d46f..13047360ff5 100644
--- a/programs/regtest/regtest.spec
+++ b/programs/regtest/regtest.spec
@@ -2,6 +2,3 @@ name	regtest
 mode	guiexe
 type	win32
 
-import	advapi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/uninstaller/Makefile.in b/programs/uninstaller/Makefile.in
index 7b6e08c7015..433cd268109 100644
--- a/programs/uninstaller/Makefile.in
+++ b/programs/uninstaller/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = uninstaller
+IMPORTS   = user32.dll gdi32.dll advapi32.dll kernel32.dll ntdll.dll
 
 C_SRCS = \
 	main.c
diff --git a/programs/uninstaller/uninstaller.spec b/programs/uninstaller/uninstaller.spec
index 0768707eb25..6496a262dfc 100644
--- a/programs/uninstaller/uninstaller.spec
+++ b/programs/uninstaller/uninstaller.spec
@@ -3,8 +3,3 @@ mode	guiexe
 type	win32
 rsrc	rsrc.res
 
-import	user32.dll
-import	gdi32.dll
-import	advapi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/view/Makefile.in b/programs/view/Makefile.in
index 393f0f3c35d..39db49a29d1 100644
--- a/programs/view/Makefile.in
+++ b/programs/view/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = view
+IMPORTS   = comdlg32.dll user32.dll gdi32.dll kernel32.dll ntdll.dll
 
 C_SRCS = \
 	init.c \
diff --git a/programs/view/view.spec b/programs/view/view.spec
index be0fde02cca..8c0b03ca10b 100644
--- a/programs/view/view.spec
+++ b/programs/view/view.spec
@@ -3,8 +3,3 @@ mode	guiexe
 type	win32
 rsrc	viewrc.res
 
-import	comdlg32.dll
-import	user32.dll
-import	gdi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/wcmd/Makefile.in b/programs/wcmd/Makefile.in
index 6f221e8c8c3..ae267f960ab 100644
--- a/programs/wcmd/Makefile.in
+++ b/programs/wcmd/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = wcmd
+IMPORTS   = shell32.dll user32.dll kernel32.dll ntdll.dll
 
 C_SRCS = \
 	batch.c \
diff --git a/programs/wcmd/wcmd.spec b/programs/wcmd/wcmd.spec
index 1b5731b5d4d..2b657c3746e 100644
--- a/programs/wcmd/wcmd.spec
+++ b/programs/wcmd/wcmd.spec
@@ -4,7 +4,3 @@ type	win32
 init	main
 rsrc	wcmdrc.res
 
-import	shell32.dll
-import	user32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/wineconsole/Makefile.in b/programs/wineconsole/Makefile.in
index 99a2d70cbcb..1fce2099348 100644
--- a/programs/wineconsole/Makefile.in
+++ b/programs/wineconsole/Makefile.in
@@ -4,6 +4,8 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = wineconsole
+IMPORTS   = gdi32.dll user32.dll advapi32.dll kernel32.dll ntdll.dll
+DELAYIMPORTS = comctl32
 
 C_SRCS = \
 	dialog.c \
diff --git a/programs/wineconsole/wineconsole.spec b/programs/wineconsole/wineconsole.spec
index 871d1479973..804fce9dfc0 100644
--- a/programs/wineconsole/wineconsole.spec
+++ b/programs/wineconsole/wineconsole.spec
@@ -4,9 +4,3 @@ type	win32
 init	WINECON_WinMain
 rsrc    wineconsole_res.res                                                                                                                                                                  
 
-import -delay comctl32
-import  gdi32.dll
-import  user32.dll
-import	advapi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/winemine/Makefile.in b/programs/winemine/Makefile.in
index 1eee283973c..5fe2854440f 100644
--- a/programs/winemine/Makefile.in
+++ b/programs/winemine/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = winemine
+IMPORTS   = user32.dll gdi32.dll advapi32.dll kernel32.dll ntdll.dll
 
 C_SRCS = \
         dialog.c \
diff --git a/programs/winemine/winemine.spec b/programs/winemine/winemine.spec
index 902bb7dbd3d..85c29061fda 100644
--- a/programs/winemine/winemine.spec
+++ b/programs/winemine/winemine.spec
@@ -3,8 +3,3 @@ mode	guiexe
 type	win32
 rsrc	rsrc.res
 
-import	user32.dll
-import	gdi32.dll
-import	advapi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/winepath/Makefile.in b/programs/winepath/Makefile.in
index f82442b6542..7d9d30d3b2f 100644
--- a/programs/winepath/Makefile.in
+++ b/programs/winepath/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = winepath
+IMPORTS   = kernel32.dll ntdll.dll
 
 C_SRCS = winepath.c
 
diff --git a/programs/winepath/winepath.spec b/programs/winepath/winepath.spec
index 8639561b2e7..b73bfd35e68 100644
--- a/programs/winepath/winepath.spec
+++ b/programs/winepath/winepath.spec
@@ -2,5 +2,3 @@ name	winepath
 mode	cuiexe
 type	win32
 
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/winetest/Makefile.in b/programs/winetest/Makefile.in
index 6b031e28705..19f458fd433 100644
--- a/programs/winetest/Makefile.in
+++ b/programs/winetest/Makefile.in
@@ -7,6 +7,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = winetest
+IMPORTS   = kernel32.dll ntdll.dll
 
 C_SRCS = winetest.c
 
diff --git a/programs/winetest/winetest.spec b/programs/winetest/winetest.spec
index 3b294b11d74..fa8f8e3e66b 100644
--- a/programs/winetest/winetest.spec
+++ b/programs/winetest/winetest.spec
@@ -2,5 +2,3 @@ name	winetest
 mode	cuiexe
 type	win32
 
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/winhelp/Makefile.in b/programs/winhelp/Makefile.in
index 391da0b520b..d7cf6c7880c 100644
--- a/programs/winhelp/Makefile.in
+++ b/programs/winhelp/Makefile.in
@@ -3,8 +3,8 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = winhelp
+IMPORTS   = comdlg32.dll shell32.dll user32.dll gdi32.dll kernel32.dll ntdll.dll
 PROGRAMS  = hlp2sgml
-IMPORTS   = advapi32 comctl32 shlwapi shell32 ole32 rpcrt4 comdlg32 winspool.drv user32 gdi32 kernel32 ntdll
 
 C_SRCS = \
 	winhelp.c \
diff --git a/programs/winhelp/winhelp.spec b/programs/winhelp/winhelp.spec
index 689bac9b6a3..2d819da5c24 100644
--- a/programs/winhelp/winhelp.spec
+++ b/programs/winhelp/winhelp.spec
@@ -4,9 +4,3 @@ type	win32
 init	WinMain
 rsrc	rsrc.res
 
-import	comdlg32.dll
-import	shell32.dll
-import	user32.dll
-import	gdi32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/programs/winver/Makefile.in b/programs/winver/Makefile.in
index bbedff70803..b8e18354ab3 100644
--- a/programs/winver/Makefile.in
+++ b/programs/winver/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = winver
+IMPORTS   = shell32.dll kernel32.dll ntdll.dll
 
 C_SRCS = winver.c
 
diff --git a/programs/winver/winver.spec b/programs/winver/winver.spec
index a8b0ca4f411..c7c18bd1294 100644
--- a/programs/winver/winver.spec
+++ b/programs/winver/winver.spec
@@ -2,6 +2,3 @@ name	winver
 mode	guiexe
 type	win32
 
-import	shell32.dll
-import	kernel32.dll
-import	ntdll.dll
diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c
index c16d6f2108e..686f93136f2 100644
--- a/tools/winebuild/import.c
+++ b/tools/winebuild/import.c
@@ -161,7 +161,14 @@ static void read_exported_symbols( const char *name, struct import *imp )
 /* add a dll to the list of imports */
 void add_import_dll( const char *name, int delay )
 {
-    struct import *imp = xmalloc( sizeof(*imp) );
+    struct import *imp;
+    int i;
+
+    /* check if we already imported it */
+    for (i = 0; i < nb_imports; i++)
+        if (!strcmp( dll_imports[i]->dll, name )) return;
+
+    imp = xmalloc( sizeof(*imp) );
     imp->dll        = xstrdup( name );
     imp->delay      = delay;
     imp->imports    = NULL;
diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c
index 01d63197517..13c27d92bb7 100644
--- a/tools/winebuild/main.c
+++ b/tools/winebuild/main.c
@@ -120,6 +120,8 @@ static void do_relay16(void);
 static void do_relay32(void);
 static void do_sym( const char *arg );
 static void do_lib( const char *arg );
+static void do_import( const char *arg );
+static void do_dimport( const char *arg );
 
 static const struct option_descr option_table[] =
 {
@@ -127,6 +129,8 @@ static const struct option_descr option_table[] =
     { "-h",       0, do_usage,   "-h               Display this help message" },
     { "-w",       0, do_warnings,"-w               Turn on warnings" },
     { "-L",       1, do_lib,     "-L directory     Look for imports libraries in 'directory'" },
+    { "-l",       1, do_import,  "-l lib.dll       Import the specified library" },
+    { "-dl",      1, do_dimport, "-dl lib.dll      Delay-import the specified library" },
     { "-o",       1, do_output,  "-o name          Set the output file name (default: stdout)" },
     { "-sym",     1, do_sym,     "-sym file.o      Read the list of undefined symbols from 'file.o'" },
     { "-spec",    1, do_spec,    "-spec file.spec  Build a .c file from a spec file" },
@@ -218,6 +222,16 @@ static void do_lib( const char *arg )
     lib_path[nb_lib_paths++] = xstrdup( arg );
 }
 
+static void do_import( const char *arg )
+{
+    add_import_dll( arg, 0 );
+}
+
+static void do_dimport( const char *arg )
+{
+    add_import_dll( arg, 1 );
+}
+
 /* parse options from the argv array and remove all the recognized ones */
 static void parse_options( char *argv[] )
 {
-- 
GitLab