Added winebuild support for generating a .dbg.c file containing the
debug channels definitions.
Made win32 the default type for spec files.
Ignore C compiler in winebuild so we can simply pass it $(DEFS).
Removed type win32 and debug_channels from spec files.
Fixed winebuild to always generate correct C identifiers (reported by
Vincent Béron).

diff --git a/Make.rules.in b/Make.rules.in
index 7497a82..1e66fdf 100644
--- a/Make.rules.in
+++ b/Make.rules.in
@@ -107,7 +107,7 @@
 prog_manext     = 1
 conf_manext     = 5
 CLEAN_FILES     = *.o *.a *.so *.ln *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
-                  *.flc *.spec.c *.spec.def *.glue.c y.tab.c y.tab.h @LEX_OUTPUT_ROOT@.c core
+                  *.flc *.spec.c *.spec.def *.glue.c *.dbg.c y.tab.c y.tab.h @LEX_OUTPUT_ROOT@.c core
 
 OBJS = $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) \
        $(ASM_SRCS:.S=.o) $(GLUE:.c=.glue.o) $(EXTRA_OBJS)
@@ -137,13 +137,13 @@
 	$(WINDRES) -i $< -o $@
 
 .spec.spec.c:
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -o $@ -spec $<
+	$(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -spec $<
 
 .spec.spec.def:
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -o $@ -def $<
+	$(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -def $<
 
 .c.glue.c:
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -o $@ -glue $<
+	$(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -glue $<
 
 .c.ln:
 	$(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
@@ -169,6 +169,11 @@
 	$(LDCOMBINE) $(SPEC_SRCS:.spec=.spec.o) $(OBJS) -o $@
 	-$(STRIP) --strip-unneeded $@
 
+# Rule for main module debug channels
+
+$(MODULE).dbg.c: $(C_SRCS) $(WINEBUILD)
+	$(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -debug -C$(SRCDIR) $(C_SRCS)
+
 # Rule to rebuild the resource compiler
 
 $(WRC):
@@ -232,8 +237,8 @@
 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
 	cd `dirname $@` && $(MAKE) depend
 
-depend: $(MAKEDEP) $(GEN_C_SRCS) $(SUBDIRS:%=%/__depend__)
-	$(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(EXTRA_SRCS) $(CTESTS) -C. $(GEN_C_SRCS)
+depend: $(MAKEDEP) $(SUBDIRS:%=%/__depend__)
+	$(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(EXTRA_SRCS) $(CTESTS)
 
 # Rules for cleaning
 
@@ -290,7 +295,7 @@
 	-$(STRIP) --strip-unneeded $@
 
 $(TESTPROGRAM).spec.c: $(TESTPROGRAM).tmp.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym $(TESTPROGRAM).tmp.o -o $@ -exe $(TESTPROGRAM) -mcui -L$(DLLDIR) $(TESTIMPORTS:%=-l%)
+	$(LDPATH) $(WINEBUILD) $(DEFS) -sym $(TESTPROGRAM).tmp.o -o $@ -exe $(TESTPROGRAM) -mcui -L$(DLLDIR) $(TESTIMPORTS:%=-l%)
 
 $(TESTPROGRAM).exe: $(TESTOBJS)
 	$(CC) $(TESTOBJS) -o $@ $(TESTIMPORTS:%=-l%) $(LIBWINE) $(LIBS)
diff --git a/debugger/.cvsignore b/debugger/.cvsignore
index 7f47d23..b815434 100644
--- a/debugger/.cvsignore
+++ b/debugger/.cvsignore
@@ -1,6 +1,7 @@
 Makefile
 lex.yy.c
 winedbg
+winedbg.dbg.c
 winedbg.spec.c
 y.tab.c
 y.tab.h
diff --git a/dlls/Makedll.rules.in b/dlls/Makedll.rules.in
index a999792..8670246 100644
--- a/dlls/Makedll.rules.in
+++ b/dlls/Makedll.rules.in
@@ -14,7 +14,7 @@
 SPEC_SRCS   = $(ALTSPECS:%=%.spec)
 MAINSPEC    = $(MODULE:%.dll=%).spec
 SPEC_DEF    = $(MAINSPEC).def
-ALL_OBJS    = $(MAINSPEC).o $(SPEC_SRCS:.spec=.spec.o) $(OBJS)
+ALL_OBJS    = $(MAINSPEC).o $(SPEC_SRCS:.spec=.spec.o) $(OBJS) $(MODULE).dbg.o
 ALL_LIBS    = $(LIBWINE) $(EXTRALIBS) $(LIBS)
 TESTIMPORTS = $(MODULE) $(DELAYIMPORTS) $(IMPORTS)
 
@@ -25,7 +25,7 @@
 # Rule for main module spec file
 
 $(MAINSPEC).c: $(MAINSPEC) $(RC_SRCS:.rc=.res) $(SYMBOLFILE) $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ $(SYMBOLFILE:%=-sym %) -o $@ -spec $(SRCDIR)/$(MAINSPEC) $(RC_SRCS:%.rc=-res %.res) -L$(DLLDIR) $(DELAYIMPORTS:%=-dl%) $(IMPORTS:%=-l%)
+	$(LDPATH) $(WINEBUILD) $(DEFS) $(SYMBOLFILE:%=-sym %) -o $@ -spec $(SRCDIR)/$(MAINSPEC) $(RC_SRCS:%.rc=-res %.res) -L$(DLLDIR) $(DELAYIMPORTS:%=-dl%) $(IMPORTS:%=-l%)
 
 # Rules for .so files
 
@@ -34,8 +34,8 @@
 
 # Rules for .dll files
 
-$(MODULE): $(OBJS) $(SPEC_DEF) Makefile.in
-	$(DLLWRAP) $(DLLWRAPFLAGS) --def $(SPEC_DEF) --implib $(MODULE:.dll=.a) -o $(MODULE) $(OBJS) -L$(DLLDIR) $(IMPORTS:%=-l%) $(ALL_LIBS)
+$(MODULE): $(OBJS) $(MODULE).dbg.o $(SPEC_DEF) Makefile.in
+	$(DLLWRAP) $(DLLWRAPFLAGS) --def $(SPEC_DEF) --implib $(MODULE:.dll=.a) -o $(MODULE) $(OBJS) $(MODULE).dbg.o -L$(DLLDIR) $(IMPORTS:%=-l%) $(ALL_LIBS)
 
 $(SPEC_DEF): $(WINEBUILD)
 
@@ -48,11 +48,6 @@
 
 $(TESTRESULTS): $(MODULE)$(DLLEXT)
 
-# Rules for debug channels
-
-debug_channels: dummy
-	$(TOPSRCDIR)/tools/make_debug $(MAINSPEC) $(C_SRCS) $(SUBDIRS:%=%/*.c)
-
 # Sanity check
 
 Makedll.rules: $(TOPSRCDIR)/Makedll.rules.in $(TOPSRCDIR)/configure
diff --git a/dlls/advapi32/.cvsignore b/dlls/advapi32/.cvsignore
index c4669ab..1b89f21 100644
--- a/dlls/advapi32/.cvsignore
+++ b/dlls/advapi32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+advapi32.dll.dbg.c
 advapi32.spec.c
diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec
index f7327cfd..1c2c8fc 100644
--- a/dlls/advapi32/advapi32.spec
+++ b/dlls/advapi32/advapi32.spec
@@ -1,7 +1,4 @@
 name	advapi32
-type	win32
-
-debug_channels (advapi crypt reg)
 
 @ stdcall AbortSystemShutdownA(ptr) AbortSystemShutdownA
 @ stdcall AbortSystemShutdownW(ptr) AbortSystemShutdownW
diff --git a/dlls/avicap32/.cvsignore b/dlls/avicap32/.cvsignore
index 103d1dd..6d99ff3 100644
--- a/dlls/avicap32/.cvsignore
+++ b/dlls/avicap32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+avicap32.dll.dbg.c
 avicap32.spec.c
diff --git a/dlls/avicap32/avicap32.spec b/dlls/avicap32/avicap32.spec
index 7145dbb..64eebc8 100644
--- a/dlls/avicap32/avicap32.spec
+++ b/dlls/avicap32/avicap32.spec
@@ -1,4 +1,2 @@
 name avicap32
-type win32
 
-debug_channels ()
diff --git a/dlls/avifil32/.cvsignore b/dlls/avifil32/.cvsignore
index 614b820..fbab5a7 100644
--- a/dlls/avifil32/.cvsignore
+++ b/dlls/avifil32/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
+avifil32.dll.dbg.c
 avifil32.spec.c
 avifile.spec.c
diff --git a/dlls/avifil32/avifil32.spec b/dlls/avifil32/avifil32.spec
index 4d74ecf..abfd32e 100644
--- a/dlls/avifil32/avifil32.spec
+++ b/dlls/avifil32/avifil32.spec
@@ -1,7 +1,4 @@
 name	avifil32
-type	win32
-
-debug_channels (avifile)
 
 @ stub    AVIBuildFilter
 @ stub    AVIBuildFilterA
diff --git a/dlls/comctl32/.cvsignore b/dlls/comctl32/.cvsignore
index e75122b..03f439d 100644
--- a/dlls/comctl32/.cvsignore
+++ b/dlls/comctl32/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
+comctl32.dll.dbg.c
 comctl32.spec.c
 rsrc.res
diff --git a/dlls/comctl32/comctl32.spec b/dlls/comctl32/comctl32.spec
index 8921e74..68da71c 100644
--- a/dlls/comctl32/comctl32.spec
+++ b/dlls/comctl32/comctl32.spec
@@ -1,11 +1,6 @@
 name	comctl32
-type	win32
 init	COMCTL32_LibMain
 
-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)
-
 # Functions exported by the Win95 comctl32.dll 
 # (these need to have these exact ordinals, because some win95 dlls 
 #  import comctl32.dll by ordinal)
diff --git a/dlls/commdlg/.cvsignore b/dlls/commdlg/.cvsignore
index 7de11cc..58b0233 100644
--- a/dlls/commdlg/.cvsignore
+++ b/dlls/commdlg/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
+comdlg32.dll.dbg.c
 comdlg32.spec.c
 commdlg.spec.c
 rsrc.res
diff --git a/dlls/commdlg/comdlg32.spec b/dlls/commdlg/comdlg32.spec
index d5693a4..6d927e6 100644
--- a/dlls/commdlg/comdlg32.spec
+++ b/dlls/commdlg/comdlg32.spec
@@ -1,9 +1,6 @@
 name	comdlg32
-type	win32
 init	COMDLG32_DllEntryPoint
 
-debug_channels (commdlg)
-
 @ stdcall ChooseColorA(ptr) ChooseColorA
 @ stdcall ChooseColorW(ptr) ChooseColorW
 @ stdcall ChooseFontA(ptr) ChooseFontA
diff --git a/dlls/crtdll/.cvsignore b/dlls/crtdll/.cvsignore
index 2ca972c..214507d 100644
--- a/dlls/crtdll/.cvsignore
+++ b/dlls/crtdll/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+crtdll.dll.dbg.c
 crtdll.spec.c
diff --git a/dlls/crtdll/crtdll.spec b/dlls/crtdll/crtdll.spec
index ff5c6c2..590e61c 100644
--- a/dlls/crtdll/crtdll.spec
+++ b/dlls/crtdll/crtdll.spec
@@ -1,10 +1,7 @@
 # Old C runtime library. All functions provided by msvcrt
 name    crtdll
-type    win32
 init    CRTDLL_Init
 
-debug_channels (crtdll)
-
 @ forward ??2@YAPAXI@Z msvcrt.??2@YAPAXI@Z
 @ forward ??3@YAXPAX@Z msvcrt.??3@YAXPAX@Z
 @ forward ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z msvcrt.?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z
diff --git a/dlls/crypt32/.cvsignore b/dlls/crypt32/.cvsignore
index 8017333..ef778ed 100644
--- a/dlls/crypt32/.cvsignore
+++ b/dlls/crypt32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+crypt32.dll.dbg.c
 crypt32.spec.c
diff --git a/dlls/crypt32/crypt32.spec b/dlls/crypt32/crypt32.spec
index 469c121..5a54d68 100644
--- a/dlls/crypt32/crypt32.spec
+++ b/dlls/crypt32/crypt32.spec
@@ -1,7 +1,4 @@
 name crypt32
-type win32
-
-debug_channels ()
 
 @ stub CertAddCRLContextToStore
 @ stub CertAddCTLContextToStore
diff --git a/dlls/dciman32/.cvsignore b/dlls/dciman32/.cvsignore
index 6757d1d..a13bb42 100644
--- a/dlls/dciman32/.cvsignore
+++ b/dlls/dciman32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+dciman32.dll.dbg.c
 dciman32.spec.c
diff --git a/dlls/dciman32/dciman32.spec b/dlls/dciman32/dciman32.spec
index b19b902..762852d 100644
--- a/dlls/dciman32/dciman32.spec
+++ b/dlls/dciman32/dciman32.spec
@@ -1,5 +1,4 @@
 name	dciman32
-type	win32
 
 @ stub    DCIBeginAccess
 @ stdcall DCICloseProvider(long) DCICloseProvider
diff --git a/dlls/ddraw/.cvsignore b/dlls/ddraw/.cvsignore
index 568a5fa..ef8425d 100644
--- a/dlls/ddraw/.cvsignore
+++ b/dlls/ddraw/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
+ddraw.dll.dbg.c
 ddraw.spec.c
 version.res
diff --git a/dlls/ddraw/ddraw.spec b/dlls/ddraw/ddraw.spec
index a4c4f90..0f98a07 100644
--- a/dlls/ddraw/ddraw.spec
+++ b/dlls/ddraw/ddraw.spec
@@ -1,9 +1,6 @@
 name ddraw
-type win32
 init DDRAW_DllMain
 
-debug_channels (ddraw)
-
 @ stub DDHAL32_VidMemAlloc
 @ stub DDHAL32_VidMemFree
 @ stub DDInternalLock
diff --git a/dlls/devenum/.cvsignore b/dlls/devenum/.cvsignore
index 1c6fa20..aed793e 100644
--- a/dlls/devenum/.cvsignore
+++ b/dlls/devenum/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+devenum.dll.dbg.c
 devenum.spec.c
diff --git a/dlls/devenum/devenum.spec b/dlls/devenum/devenum.spec
index d0b3e7d..1e92635 100644
--- a/dlls/devenum/devenum.spec
+++ b/dlls/devenum/devenum.spec
@@ -1,7 +1,4 @@
 name devenum
-type win32
-
-debug_channels()
 
 @ stub DllCanUnloadNow
 @ stub DllGetClassObject
diff --git a/dlls/dinput/.cvsignore b/dlls/dinput/.cvsignore
index f6b621f..8c7d70a 100644
--- a/dlls/dinput/.cvsignore
+++ b/dlls/dinput/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+dinput.dll.dbg.c
 dinput.spec.c
diff --git a/dlls/dinput/dinput.spec b/dlls/dinput/dinput.spec
index 74288c6..d0478a1 100644
--- a/dlls/dinput/dinput.spec
+++ b/dlls/dinput/dinput.spec
@@ -1,7 +1,4 @@
 name dinput
-type win32
-
-debug_channels (dinput)
 
 @ stdcall DirectInputCreateA(long long ptr ptr) DirectInputCreateA
 @ stub DirectInputCreateW
diff --git a/dlls/dplay/.cvsignore b/dlls/dplay/.cvsignore
index fe92581..1aac9b3 100644
--- a/dlls/dplay/.cvsignore
+++ b/dlls/dplay/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+dplay.dll.dbg.c
 dplay.spec.c
diff --git a/dlls/dplay/dplay.spec b/dlls/dplay/dplay.spec
index 1979d4c..4a00bb6 100644
--- a/dlls/dplay/dplay.spec
+++ b/dlls/dplay/dplay.spec
@@ -1,6 +1,5 @@
 # First DirectPlay dll. Replaced by dplayx.dll.
 name dplay
-type win32
 
 @ forward DirectPlayCreate dplayx.DirectPlayCreate
 @ forward DirectPlayEnumerate dplayx.DirectPlayEnumerate
diff --git a/dlls/dplayx/.cvsignore b/dlls/dplayx/.cvsignore
index dbf7360..297580e 100644
--- a/dlls/dplayx/.cvsignore
+++ b/dlls/dplayx/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
+dplayx.dll.dbg.c
 dplayx.spec.c
 version.res
diff --git a/dlls/dplayx/dplayx.spec b/dlls/dplayx/dplayx.spec
index 7391aae..674f00a 100644
--- a/dlls/dplayx/dplayx.spec
+++ b/dlls/dplayx/dplayx.spec
@@ -1,9 +1,6 @@
 name dplayx
-type win32
 init DPLAYX_LibMain
 
-debug_channels (dplay)
-
   1 stdcall DirectPlayCreate(ptr ptr ptr) DirectPlayCreate
   2 stdcall DirectPlayEnumerateA(ptr ptr) DirectPlayEnumerateA
   3 stdcall DirectPlayEnumerateW(ptr ptr) DirectPlayEnumerateW
diff --git a/dlls/dsound/.cvsignore b/dlls/dsound/.cvsignore
index c88b549..ec79935 100644
--- a/dlls/dsound/.cvsignore
+++ b/dlls/dsound/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+dsound.dll.dbg.c
 dsound.spec.c
diff --git a/dlls/dsound/dsound.spec b/dlls/dsound/dsound.spec
index 8cb2f9c..34534f5 100644
--- a/dlls/dsound/dsound.spec
+++ b/dlls/dsound/dsound.spec
@@ -1,7 +1,4 @@
 name dsound
-type win32
-
-debug_channels (dsound)
 
 0 stub DirectSoundUnknown
 1 stdcall DirectSoundCreate(ptr ptr ptr) DirectSoundCreate
diff --git a/dlls/gdi/.cvsignore b/dlls/gdi/.cvsignore
index 557fa03..39e0a71 100644
--- a/dlls/gdi/.cvsignore
+++ b/dlls/gdi/.cvsignore
@@ -1,6 +1,7 @@
 Makefile
 dispdib.spec.c
 gdi.exe.spec.c
+gdi32.dll.dbg.c
 gdi32.spec.c
 printdrv.glue.c
 version.res
diff --git a/dlls/gdi/gdi32.spec b/dlls/gdi/gdi32.spec
index 31b90ed..6741a47 100644
--- a/dlls/gdi/gdi32.spec
+++ b/dlls/gdi/gdi32.spec
@@ -1,10 +1,6 @@
 name    gdi32
-type    win32
 init    MAIN_GdiInit
 
-debug_channels (bitblt bitmap clipping dc ddraw driver enhmetafile font gdi
-                metafile palette print region text win16drv wing)
-
 # ordinal exports
 100 stdcall @(long long str str str) GDI_CallDevInstall16
 101 stdcall @(long str str ptr) GDI_CallExtDeviceModePropSheet16
diff --git a/dlls/glu32/.cvsignore b/dlls/glu32/.cvsignore
index 5aa5a5f..5125d00 100644
--- a/dlls/glu32/.cvsignore
+++ b/dlls/glu32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+glu32.dll.dbg.c
 glu32.spec.c
diff --git a/dlls/glu32/glu32.spec b/dlls/glu32/glu32.spec
index 772e11d..fd50546 100644
--- a/dlls/glu32/glu32.spec
+++ b/dlls/glu32/glu32.spec
@@ -1,5 +1,4 @@
 name glu32
-type win32
 
 @ stdcall gluLookAt(double double double double double double double double double) wine_gluLookAt
 @ stdcall gluOrtho2D(double double double double) wine_gluOrtho2D
diff --git a/dlls/icmp/.cvsignore b/dlls/icmp/.cvsignore
index f540160..d046dd8 100644
--- a/dlls/icmp/.cvsignore
+++ b/dlls/icmp/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+icmp.dll.dbg.c
 icmp.spec.c
diff --git a/dlls/icmp/icmp.spec b/dlls/icmp/icmp.spec
index 731c1fc..9cb088e 100644
--- a/dlls/icmp/icmp.spec
+++ b/dlls/icmp/icmp.spec
@@ -1,7 +1,4 @@
 name icmp
-type win32
-
-debug_channels (icmp)
 
 @ stdcall IcmpCloseHandle(ptr) IcmpCloseHandle
 @ stdcall IcmpCreateFile() IcmpCreateFile
diff --git a/dlls/imagehlp/.cvsignore b/dlls/imagehlp/.cvsignore
index 6eaf6d0..0a109cb 100644
--- a/dlls/imagehlp/.cvsignore
+++ b/dlls/imagehlp/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+imagehlp.dll.dbg.c
 imagehlp.spec.c
diff --git a/dlls/imagehlp/imagehlp.spec b/dlls/imagehlp/imagehlp.spec
index b9531d2..af5bd8d 100644
--- a/dlls/imagehlp/imagehlp.spec
+++ b/dlls/imagehlp/imagehlp.spec
@@ -1,9 +1,6 @@
 name	imagehlp
-type	win32
 init	IMAGEHLP_LibMain
 
-debug_channels (imagehlp)
-
 @ stdcall BindImage(str str str) BindImage
 @ stdcall BindImageEx(long str str str ptr) BindImageEx
 @ stdcall CheckSumMappedFile(ptr long ptr ptr) CheckSumMappedFile
diff --git a/dlls/imm32/.cvsignore b/dlls/imm32/.cvsignore
index 423ab3c..e093305 100644
--- a/dlls/imm32/.cvsignore
+++ b/dlls/imm32/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
 imm.spec.c
+imm32.dll.dbg.c
 imm32.spec.c
diff --git a/dlls/imm32/imm32.spec b/dlls/imm32/imm32.spec
index 3347812..94a1d99 100644
--- a/dlls/imm32/imm32.spec
+++ b/dlls/imm32/imm32.spec
@@ -1,7 +1,4 @@
 name	imm32
-type	win32
-
-debug_channels (imm)
 
 @ stdcall ImmAssociateContext(long long) ImmAssociateContext
 @ stdcall ImmConfigureIMEA(long long long ptr) ImmConfigureIMEA
diff --git a/dlls/kernel/.cvsignore b/dlls/kernel/.cvsignore
index 8be1c15..67ea13a 100644
--- a/dlls/kernel/.cvsignore
+++ b/dlls/kernel/.cvsignore
@@ -1,6 +1,7 @@
 Makefile
 comm.spec.c
 kernel.res
+kernel32.dll.dbg.c
 kernel32.spec.c
 krnl386.exe.spec.c
 stress.spec.c
diff --git a/dlls/kernel/kernel32.spec b/dlls/kernel/kernel32.spec
index 3e99c79..0d7b406 100644
--- a/dlls/kernel/kernel32.spec
+++ b/dlls/kernel/kernel32.spec
@@ -1,10 +1,6 @@
 name	kernel32
-type	win32
 init	MAIN_KernelInit
 
-debug_channels (comm console debugstr dll int resource stress thunk toolhelp
-                win32)
-
 # Functions exported by the Win95 kernel32.dll 
 # (these need to have these exact ordinals, for some win95 dlls 
 #  import kernel32.dll by ordinal)
diff --git a/dlls/lzexpand/.cvsignore b/dlls/lzexpand/.cvsignore
index 2bfb03c..62d8563 100644
--- a/dlls/lzexpand/.cvsignore
+++ b/dlls/lzexpand/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
+lz32.dll.dbg.c
 lz32.spec.c
 lzexpand.spec.c
diff --git a/dlls/lzexpand/lz32.spec b/dlls/lzexpand/lz32.spec
index 7b158b2..503dce1 100644
--- a/dlls/lzexpand/lz32.spec
+++ b/dlls/lzexpand/lz32.spec
@@ -1,7 +1,4 @@
 name	lz32
-type	win32
-
-debug_channels (file)
 
 @ stdcall CopyLZFile(long long) CopyLZFile
 @ stdcall GetExpandedNameA(str ptr) GetExpandedNameA
diff --git a/dlls/mapi32/.cvsignore b/dlls/mapi32/.cvsignore
index aac7145..261a6c2 100644
--- a/dlls/mapi32/.cvsignore
+++ b/dlls/mapi32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+mapi32.dll.dbg.c
 mapi32.spec.c
diff --git a/dlls/mapi32/mapi32.spec b/dlls/mapi32/mapi32.spec
index d682641..be82299 100644
--- a/dlls/mapi32/mapi32.spec
+++ b/dlls/mapi32/mapi32.spec
@@ -1,7 +1,4 @@
 name mapi32
-type win32
-
-debug_channels (mapi)
 
 @ stub BMAPIAddress
 @ stub BMAPIDetails
diff --git a/dlls/mpr/.cvsignore b/dlls/mpr/.cvsignore
index 7d7523f..e30b9ef 100644
--- a/dlls/mpr/.cvsignore
+++ b/dlls/mpr/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+mpr.dll.dbg.c
 mpr.spec.c
diff --git a/dlls/mpr/mpr.spec b/dlls/mpr/mpr.spec
index e20e614..5f9068f 100644
--- a/dlls/mpr/mpr.spec
+++ b/dlls/mpr/mpr.spec
@@ -1,7 +1,4 @@
 name mpr
-type win32
-
-debug_channels (mpr)
 
 # ordinal exports
  1 stub @
diff --git a/dlls/msacm/.cvsignore b/dlls/msacm/.cvsignore
index 3a11a6f..bf49807 100644
--- a/dlls/msacm/.cvsignore
+++ b/dlls/msacm/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
 msacm.res
 msacm.spec.c
+msacm32.dll.dbg.c
 msacm32.spec.c
diff --git a/dlls/msacm/imaadp32/.cvsignore b/dlls/msacm/imaadp32/.cvsignore
index 7901fe2..525c7a4 100644
--- a/dlls/msacm/imaadp32/.cvsignore
+++ b/dlls/msacm/imaadp32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+imaadp32.acm.dbg.c
 imaadp32.acm.spec.c
diff --git a/dlls/msacm/imaadp32/imaadp32.acm.spec b/dlls/msacm/imaadp32/imaadp32.acm.spec
index 64cf04a..53b1f79 100644
--- a/dlls/msacm/imaadp32/imaadp32.acm.spec
+++ b/dlls/msacm/imaadp32/imaadp32.acm.spec
@@ -1,7 +1,4 @@
 name imaadp32
 file imaadp32.acm
-type win32
-
-debug_channels (adpcm)
 
 @ stdcall DriverProc (long long long long long) ADPCM_DriverProc
diff --git a/dlls/msacm/msacm32.spec b/dlls/msacm/msacm32.spec
index b8900fb..07f9281 100644
--- a/dlls/msacm/msacm32.spec
+++ b/dlls/msacm/msacm32.spec
@@ -1,9 +1,6 @@
 name msacm32
-type win32
 init MSACM32_LibMain
 
-debug_channels (msacm)
-
 @ stdcall acmDriverAddA(ptr long long long long) acmDriverAddA
 @ stdcall acmDriverAddW(ptr long long long long) acmDriverAddW
 @ stdcall acmDriverClose(long long) acmDriverClose
diff --git a/dlls/msacm/msg711/.cvsignore b/dlls/msacm/msg711/.cvsignore
index 9152208..b75bb72 100644
--- a/dlls/msacm/msg711/.cvsignore
+++ b/dlls/msacm/msg711/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+msg711.drv.dbg.c
 msg711.drv.spec.c
diff --git a/dlls/msacm/msg711/msg711.drv.spec b/dlls/msacm/msg711/msg711.drv.spec
index 3df1a28..d03bb63 100644
--- a/dlls/msacm/msg711/msg711.drv.spec
+++ b/dlls/msacm/msg711/msg711.drv.spec
@@ -1,7 +1,4 @@
 name msg711
 file msg711.drv
-type win32
-
-debug_channels ()
 
 @ stub DriverProc #(long long long long long)
diff --git a/dlls/msdmo/.cvsignore b/dlls/msdmo/.cvsignore
index 06694f4..6fb9add 100644
--- a/dlls/msdmo/.cvsignore
+++ b/dlls/msdmo/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+msdmo.dll.dbg.c
 msdmo.spec.c
diff --git a/dlls/msdmo/msdmo.spec b/dlls/msdmo/msdmo.spec
index 9e962d3..0915fa5 100644
--- a/dlls/msdmo/msdmo.spec
+++ b/dlls/msdmo/msdmo.spec
@@ -1,7 +1,4 @@
 name msdmo
-type win32
-
-debug_channels ()
 
 @ stub DMOEnum
 @ stub DMOGetName
diff --git a/dlls/msimg32/.cvsignore b/dlls/msimg32/.cvsignore
index 7ef3314..274f1f4 100644
--- a/dlls/msimg32/.cvsignore
+++ b/dlls/msimg32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+msimg32.dll.dbg.c
 msimg32.spec.c
diff --git a/dlls/msimg32/msimg32.spec b/dlls/msimg32/msimg32.spec
index 748c8c9..dd4af75 100644
--- a/dlls/msimg32/msimg32.spec
+++ b/dlls/msimg32/msimg32.spec
@@ -1,7 +1,4 @@
 name msimg32
-type win32
-
-debug_channels (msimg32)
 
 @ stdcall AlphaBlend(long long long long long long long long long long long) AlphaBlend
 @ stub DllInitialize
diff --git a/dlls/msisys/.cvsignore b/dlls/msisys/.cvsignore
index 2cbfe04..9c0c080 100644
--- a/dlls/msisys/.cvsignore
+++ b/dlls/msisys/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+msisys.ocx.dbg.c
 msisys.ocx.spec.c
diff --git a/dlls/msisys/msisys.ocx.spec b/dlls/msisys/msisys.ocx.spec
index 6c6ae61..904ea07 100644
--- a/dlls/msisys/msisys.ocx.spec
+++ b/dlls/msisys/msisys.ocx.spec
@@ -1,10 +1,7 @@
 name	msisys
 file	msisys.ocx
-type	win32
 init	MSISYS_DllMain
 
-debug_channels (msisys)
-
 @ stdcall DllCanUnloadNow() MSISYS_DllCanUnloadNow
 @ stdcall DllGetClassObject(ptr ptr ptr) MSISYS_DllGetClassObject
 @ stdcall DllRegisterServer() MSISYS_DllRegisterServer
diff --git a/dlls/msnet32/.cvsignore b/dlls/msnet32/.cvsignore
index a5862c1..2eb8e46 100644
--- a/dlls/msnet32/.cvsignore
+++ b/dlls/msnet32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+msnet32.dll.dbg.c
 msnet32.spec.c
diff --git a/dlls/msnet32/msnet32.spec b/dlls/msnet32/msnet32.spec
index 07dbe95..0400353 100644
--- a/dlls/msnet32/msnet32.spec
+++ b/dlls/msnet32/msnet32.spec
@@ -1,5 +1,4 @@
 name msnet32
-type win32
 
   1 stub @
   2 stub @
diff --git a/dlls/msrle32/.cvsignore b/dlls/msrle32/.cvsignore
index 2a842f8..7ee5ee5 100644
--- a/dlls/msrle32/.cvsignore
+++ b/dlls/msrle32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+msrle32.dll.dbg.c
 msrle32.spec.c
diff --git a/dlls/msrle32/msrle32.spec b/dlls/msrle32/msrle32.spec
index f64d3df..62e3ca8 100644
--- a/dlls/msrle32/msrle32.spec
+++ b/dlls/msrle32/msrle32.spec
@@ -1,7 +1,4 @@
 name msrle32
-type win32
-
-debug_channels()
 
 @ stub DriverProc #(long long long long long)
 
diff --git a/dlls/msvcrt/.cvsignore b/dlls/msvcrt/.cvsignore
index ac6bca3..97af32c 100644
--- a/dlls/msvcrt/.cvsignore
+++ b/dlls/msvcrt/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+msvcrt.dll.dbg.c
 msvcrt.spec.c
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index 2f3475d..70145ed 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -1,10 +1,7 @@
 # msvcrt.dll - MS VC++ Run Time Library
 name    msvcrt
-type    win32
 init    MSVCRT_Init
 
-debug_channels (msvcrt)
-
 @ cdecl $I10_OUTPUT() MSVCRT_I10_OUTPUT
 @ cdecl ??0__non_rtti_object@@QAE@ABV0@@Z(ptr ptr) MSVCRT___non_rtti_object_copy_ctor
 @ cdecl ??0__non_rtti_object@@QAE@PBD@Z(ptr ptr) MSVCRT___non_rtti_object_ctor
diff --git a/dlls/msvcrt20/.cvsignore b/dlls/msvcrt20/.cvsignore
index 32f19cb..87d9213 100644
--- a/dlls/msvcrt20/.cvsignore
+++ b/dlls/msvcrt20/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+msvcrt20.dll.dbg.c
 msvcrt20.spec.c
diff --git a/dlls/msvcrt20/msvcrt20.spec b/dlls/msvcrt20/msvcrt20.spec
index f22911c..7e88159 100644
--- a/dlls/msvcrt20/msvcrt20.spec
+++ b/dlls/msvcrt20/msvcrt20.spec
@@ -1,8 +1,5 @@
 # msvcrt20.dll - MS VC++ Run Time Library
 name    msvcrt20
-type    win32
-
-debug_channels (msvcrt) 
 
 @ stub ??0Iostream_init@@QAE@AAVios@@H@Z  #
 @ stub ??0Iostream_init@@QAE@XZ #
diff --git a/dlls/msvideo/.cvsignore b/dlls/msvideo/.cvsignore
index 27896d4..369c692 100644
--- a/dlls/msvideo/.cvsignore
+++ b/dlls/msvideo/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
+msvfw32.dll.dbg.c
 msvfw32.spec.c
 msvideo.spec.c
 msvideo_main.glue.c
diff --git a/dlls/msvideo/msvfw32.spec b/dlls/msvideo/msvfw32.spec
index 501c064..3892934 100644
--- a/dlls/msvideo/msvfw32.spec
+++ b/dlls/msvideo/msvfw32.spec
@@ -1,7 +1,4 @@
 name	msvfw32
-type	win32
-
-debug_channels (mci msvideo)
 
 # Yes, ICCompress,ICDecompress,MCIWnd* and ICDraw* are cdecl (VFWAPIV).
 # The rest is stdcall (VFWAPI) however. -Marcus Meissner, 990124
diff --git a/dlls/netapi32/.cvsignore b/dlls/netapi32/.cvsignore
index 199fc7c..7e2a48f 100644
--- a/dlls/netapi32/.cvsignore
+++ b/dlls/netapi32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+netapi32.dll.dbg.c
 netapi32.spec.c
diff --git a/dlls/netapi32/netapi32.spec b/dlls/netapi32/netapi32.spec
index a321c85..b476aa4 100644
--- a/dlls/netapi32/netapi32.spec
+++ b/dlls/netapi32/netapi32.spec
@@ -1,8 +1,5 @@
 name	netapi32
-type    win32
 init	NETAPI32_LibMain
 
-debug_channels (netbios)
-
 1 stdcall Netbios(ptr) Netbios
 
diff --git a/dlls/ntdll/.cvsignore b/dlls/ntdll/.cvsignore
index 628b5f6..8573fd7 100644
--- a/dlls/ntdll/.cvsignore
+++ b/dlls/ntdll/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
+ntdll.dll.dbg.c
 ntdll.spec.c
 relay16.s
 relay32.s
diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in
index f5bc369..4abbfdb 100644
--- a/dlls/ntdll/Makefile.in
+++ b/dlls/ntdll/Makefile.in
@@ -142,10 +142,10 @@
 @MAKE_DLL_RULES@
 
 relay16.s: $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -o $@ -relay16
+	$(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -relay16
 
 relay32.s: $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -o $@ -relay32
+	$(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -relay32
 
 install:: install_libdir
 uninstall:: uninstall_libdir
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 77b509f..687d1ef 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -1,11 +1,4 @@
 name	ntdll
-type	win32
-
-debug_channels (atom cdrom console debug delayhlp dll dosfs dosmem file fixup
-                global heap int int21 int31 io loaddll local module ntdll process
-                profile reg relay resource segment seh selector server snoop
-                string system tape task thread tid timer toolhelp ver virtual
-                vxd win32)
 
 #note that the Zw... functions are alternate names for the 
 #Nt... functions.  (see www.sysinternals.com for details)
diff --git a/dlls/odbc32/.cvsignore b/dlls/odbc32/.cvsignore
index 4d7688f..3462f11 100644
--- a/dlls/odbc32/.cvsignore
+++ b/dlls/odbc32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+odbc32.dll.dbg.c
 odbc32.spec.c
diff --git a/dlls/odbc32/odbc32.spec b/dlls/odbc32/odbc32.spec
index bfa1c9c..1d46d8c 100644
--- a/dlls/odbc32/odbc32.spec
+++ b/dlls/odbc32/odbc32.spec
@@ -1,9 +1,6 @@
 name	odbc32
-type	win32
 init    MAIN_OdbcInit
 
-debug_channels (odbc)
-
 001 stdcall SQLAllocConnect(long ptr) SQLAllocConnect
 002 stdcall SQLAllocEnv(ptr)  SQLAllocEnv
 003 stdcall SQLAllocStmt(long ptr) SQLAllocStmt
diff --git a/dlls/ole32/.cvsignore b/dlls/ole32/.cvsignore
index 01418cb..596bc23 100644
--- a/dlls/ole32/.cvsignore
+++ b/dlls/ole32/.cvsignore
@@ -5,6 +5,7 @@
 ole2nls.spec.c
 ole2prox.spec.c
 ole2thk.spec.c
+ole32.dll.dbg.c
 ole32.spec.c
 ole32res.res
 storage.spec.c
diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec
index 8cfb6f8..4639af7 100644
--- a/dlls/ole32/ole32.spec
+++ b/dlls/ole32/ole32.spec
@@ -1,9 +1,6 @@
 name	ole32
-type	win32
 init	OLE32_DllEntryPoint
 
-debug_channels (accel ole relay storage)
-
   1 stub BindMoniker                # stdcall (ptr long ptr ptr) return 0,ERR_NOTIMPLEMENTED
   2 stdcall CLSIDFromProgID(wstr ptr) CLSIDFromProgID
   3 stdcall CLSIDFromString(wstr ptr) CLSIDFromString
diff --git a/dlls/oleaut32/.cvsignore b/dlls/oleaut32/.cvsignore
index cf245a0..eca8239 100644
--- a/dlls/oleaut32/.cvsignore
+++ b/dlls/oleaut32/.cvsignore
@@ -1,5 +1,6 @@
 Makefile
 ole2disp.spec.c
+oleaut32.dll.dbg.c
 oleaut32.spec.c
 typelib.spec.c
 version.res
diff --git a/dlls/oleaut32/oleaut32.spec b/dlls/oleaut32/oleaut32.spec
index 3e62b9e..369722d 100644
--- a/dlls/oleaut32/oleaut32.spec
+++ b/dlls/oleaut32/oleaut32.spec
@@ -1,7 +1,4 @@
 name oleaut32
-type win32
-
-debug_channels (ole olerelay typelib)
 
 1 stdcall DllGetClassObject(ptr ptr ptr) OLEAUT32_DllGetClassObject
 2 stdcall SysAllocString(wstr) SysAllocString
diff --git a/dlls/olecli/.cvsignore b/dlls/olecli/.cvsignore
index f45948f..f4ef9df 100644
--- a/dlls/olecli/.cvsignore
+++ b/dlls/olecli/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
 olecli.spec.c
+olecli32.dll.dbg.c
 olecli32.spec.c
diff --git a/dlls/olecli/olecli32.spec b/dlls/olecli/olecli32.spec
index e50bcf5..a26d101 100644
--- a/dlls/olecli/olecli32.spec
+++ b/dlls/olecli/olecli32.spec
@@ -1,7 +1,4 @@
 name olecli32
-type win32
-
-debug_channels (ole)
 
    1 stub WEP
    2 stub OleDelete
diff --git a/dlls/oledlg/.cvsignore b/dlls/oledlg/.cvsignore
index 704ceaa..75b7154 100644
--- a/dlls/oledlg/.cvsignore
+++ b/dlls/oledlg/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+oledlg.dll.dbg.c
 oledlg.spec.c
diff --git a/dlls/oledlg/oledlg.spec b/dlls/oledlg/oledlg.spec
index 207bf0a..722bf5b 100644
--- a/dlls/oledlg/oledlg.spec
+++ b/dlls/oledlg/oledlg.spec
@@ -1,7 +1,4 @@
 name	oledlg
-type	win32
-
-debug_channels (ole)
 
   1 stdcall OleUIAddVerbMenuA(ptr str long long long long long long ptr) OleUIAddVerbMenuA
   2 stdcall OleUICanConvertOrActivateAs(ptr long long) OleUICanConvertOrActivateAs
diff --git a/dlls/olepro32/.cvsignore b/dlls/olepro32/.cvsignore
index f59f056..9f8beb9 100644
--- a/dlls/olepro32/.cvsignore
+++ b/dlls/olepro32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+olepro32.dll.dbg.c
 olepro32.spec.c
diff --git a/dlls/olepro32/olepro32.spec b/dlls/olepro32/olepro32.spec
index fd434dd..3987806 100644
--- a/dlls/olepro32/olepro32.spec
+++ b/dlls/olepro32/olepro32.spec
@@ -1,7 +1,4 @@
 name olepro32
-type win32
-
-debug_channels (ole)
 
 248 forward OleIconToCursor OLEAUT32.OleIconToCursor
 249 forward OleCreatePropertyFrameIndirect OLEAUT32.OleCreatePropertyFrameIndirect
diff --git a/dlls/olesvr/.cvsignore b/dlls/olesvr/.cvsignore
index 7bfe5af..e313602 100644
--- a/dlls/olesvr/.cvsignore
+++ b/dlls/olesvr/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
 olesvr.spec.c
+olesvr32.dll.dbg.c
 olesvr32.spec.c
diff --git a/dlls/olesvr/olesvr32.spec b/dlls/olesvr/olesvr32.spec
index bfce0af..371b523 100644
--- a/dlls/olesvr/olesvr32.spec
+++ b/dlls/olesvr/olesvr32.spec
@@ -1,7 +1,4 @@
 name	olesvr32
-type	win32
-
-debug_channels (ole)
 
  1 stub WEP
  2 stdcall OleRegisterServer(str ptr ptr long long) OleRegisterServer
diff --git a/dlls/opengl32/.cvsignore b/dlls/opengl32/.cvsignore
index a064ed4..65eb828 100644
--- a/dlls/opengl32/.cvsignore
+++ b/dlls/opengl32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+opengl32.dll.dbg.c
 opengl32.spec.c
diff --git a/dlls/opengl32/opengl32.spec b/dlls/opengl32/opengl32.spec
index 35c03bf..3c06c97 100644
--- a/dlls/opengl32/opengl32.spec
+++ b/dlls/opengl32/opengl32.spec
@@ -1,9 +1,6 @@
 name opengl32
-type win32
 init OpenGL32_Init
 
-debug_channels (opengl)
-
 @  stdcall wglCreateContext(long) wglCreateContext
 @  stdcall wglCreateLayerContext(long long) wglCreateLayerContext
 @  stdcall wglCopyContext(long long long) wglCopyContext
diff --git a/dlls/psapi/.cvsignore b/dlls/psapi/.cvsignore
index dfa5000..955eba3 100644
--- a/dlls/psapi/.cvsignore
+++ b/dlls/psapi/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+psapi.dll.dbg.c
 psapi.spec.c
diff --git a/dlls/psapi/psapi.spec b/dlls/psapi/psapi.spec
index d0acd04..d6f0275 100644
--- a/dlls/psapi/psapi.spec
+++ b/dlls/psapi/psapi.spec
@@ -1,7 +1,4 @@
 name    psapi
-type    win32
-
-debug_channels (psapi)
 
 @ stdcall EmptyWorkingSet(long) EmptyWorkingSet
 @ stdcall EnumDeviceDrivers(ptr long ptr) EnumDeviceDrivers
diff --git a/dlls/qcap/.cvsignore b/dlls/qcap/.cvsignore
index 4baa8b6..aefad9f 100644
--- a/dlls/qcap/.cvsignore
+++ b/dlls/qcap/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+qcap.dll.dbg.c
 qcap.spec.c
diff --git a/dlls/qcap/qcap.spec b/dlls/qcap/qcap.spec
index 2ef3d9f..18321af 100644
--- a/dlls/qcap/qcap.spec
+++ b/dlls/qcap/qcap.spec
@@ -1,7 +1,4 @@
 name qcap
-type win32
-
-debug_channels()
 
 @ stub DllCanUnloadNow
 @ stub DllGetClassObject
diff --git a/dlls/quartz/.cvsignore b/dlls/quartz/.cvsignore
index 70e5165..85e9242 100644
--- a/dlls/quartz/.cvsignore
+++ b/dlls/quartz/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+quartz.dll.dbg.c
 quartz.spec.c
diff --git a/dlls/quartz/quartz.spec b/dlls/quartz/quartz.spec
index 375ea8d..1b363ec 100644
--- a/dlls/quartz/quartz.spec
+++ b/dlls/quartz/quartz.spec
@@ -1,7 +1,4 @@
 name	quartz
-type	win32
-
-debug_channels (quartz)
 
 @ stub AMGetErrorTextA
 @ stub AMGetErrorTextW
diff --git a/dlls/rasapi32/.cvsignore b/dlls/rasapi32/.cvsignore
index ecf5e14..7176938 100644
--- a/dlls/rasapi32/.cvsignore
+++ b/dlls/rasapi32/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
 rasapi16.spec.c
+rasapi32.dll.dbg.c
 rasapi32.spec.c
diff --git a/dlls/rasapi32/rasapi32.spec b/dlls/rasapi32/rasapi32.spec
index fb8501c..94507e5 100644
--- a/dlls/rasapi32/rasapi32.spec
+++ b/dlls/rasapi32/rasapi32.spec
@@ -1,7 +1,4 @@
 name	rasapi32
-type	win32
-
-debug_channels (ras)
 
  1  stub RasAutodialAddressToNetwork
  2  stub RasAutodialEntryToNetwork
diff --git a/dlls/richedit/.cvsignore b/dlls/richedit/.cvsignore
index c5dbbfe..27323c9 100644
--- a/dlls/richedit/.cvsignore
+++ b/dlls/richedit/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+riched32.dll.dbg.c
 riched32.spec.c
diff --git a/dlls/richedit/riched32.spec b/dlls/richedit/riched32.spec
index 8010c66..1f0e28b 100644
--- a/dlls/richedit/riched32.spec
+++ b/dlls/richedit/riched32.spec
@@ -1,7 +1,4 @@
 name	riched32
-type	win32
 init	RICHED32_LibMain
 
-debug_channels (richedit)
-
 2 stdcall DllGetVersion (ptr) RICHED32_DllGetVersion
diff --git a/dlls/rpcrt4/.cvsignore b/dlls/rpcrt4/.cvsignore
index dba83f6..fe5dc76 100644
--- a/dlls/rpcrt4/.cvsignore
+++ b/dlls/rpcrt4/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+rpcrt4.dll.dbg.c
 rpcrt4.spec.c
diff --git a/dlls/rpcrt4/rpcrt4.spec b/dlls/rpcrt4/rpcrt4.spec
index 8f3857c..305bf5d 100644
--- a/dlls/rpcrt4/rpcrt4.spec
+++ b/dlls/rpcrt4/rpcrt4.spec
@@ -1,9 +1,6 @@
 name	rpcrt4
-type	win32
 init	RPCRT4_LibMain
 
-debug_channels (ole)
-
 @ stub DceErrorInqTextA
 @ stub DceErrorInqTextW
 
diff --git a/dlls/serialui/.cvsignore b/dlls/serialui/.cvsignore
index 9d1d466..a926717 100644
--- a/dlls/serialui/.cvsignore
+++ b/dlls/serialui/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
+serialui.dll.dbg.c
 serialui.spec.c
 serialui_rc.res
diff --git a/dlls/serialui/serialui.spec b/dlls/serialui/serialui.spec
index 665d553..7b28686 100644
--- a/dlls/serialui/serialui.spec
+++ b/dlls/serialui/serialui.spec
@@ -1,9 +1,6 @@
 name	serialui
-type	win32
 init	SERIALUI_LibMain
 
-debug_channels (comm)
-
 2 stdcall EnumPropPages(ptr ptr ptr) SERIALUI_EnumPropPages
 3 stdcall drvCommConfigDialog(ptr long ptr) SERIALUI_CommConfigDialog
 4 stdcall drvSetDefaultCommConfig(str ptr long) SERIALUI_SetDefaultCommConfig
diff --git a/dlls/setupapi/.cvsignore b/dlls/setupapi/.cvsignore
index 8df8ae4..72b2f69 100644
--- a/dlls/setupapi/.cvsignore
+++ b/dlls/setupapi/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
+setupapi.dll.dbg.c
 setupapi.res
 setupapi.spec.c
 setupx.spec.c
diff --git a/dlls/setupapi/setupapi.spec b/dlls/setupapi/setupapi.spec
index e6af34d..f332050 100644
--- a/dlls/setupapi/setupapi.spec
+++ b/dlls/setupapi/setupapi.spec
@@ -1,7 +1,4 @@
 name setupapi
-type win32
-
-debug_channels (setupapi)
 
 @ stub AddMiniIconToList
 @ stub AddTagToGroupOrderListEntry
diff --git a/dlls/shdocvw/.cvsignore b/dlls/shdocvw/.cvsignore
index d74a544..d7d3303 100644
--- a/dlls/shdocvw/.cvsignore
+++ b/dlls/shdocvw/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+shdocvw.dll.dbg.c
 shdocvw.spec.c
diff --git a/dlls/shdocvw/shdocvw.spec b/dlls/shdocvw/shdocvw.spec
index 47eb9f4..c0f683c 100644
--- a/dlls/shdocvw/shdocvw.spec
+++ b/dlls/shdocvw/shdocvw.spec
@@ -1,7 +1,4 @@
 name	shdocvw
-type	win32
-
-debug_channels (comimpl shdocvw)
 
 # ordinal exports
 101 stub @
diff --git a/dlls/shell32/.cvsignore b/dlls/shell32/.cvsignore
index ce0caa6..6c848d4 100644
--- a/dlls/shell32/.cvsignore
+++ b/dlls/shell32/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
 shell.spec.c
+shell32.dll.dbg.c
 shell32.spec.c
 shres.res
diff --git a/dlls/shell32/shell32.spec b/dlls/shell32/shell32.spec
index bf35874..d22eec4 100644
--- a/dlls/shell32/shell32.spec
+++ b/dlls/shell32/shell32.spec
@@ -1,9 +1,6 @@
 name	shell32
-type	win32
 init	Shell32LibMain
 
-debug_channels (exec pidl shell shlctrl)
-
 # Functions exported by the Win95 shell32.dll 
 # (these need to have these exact ordinals, for some 
 #  win95 and winNT dlls import shell32.dll by ordinal)
diff --git a/dlls/shfolder/.cvsignore b/dlls/shfolder/.cvsignore
index 36465b5..9a9af27 100644
--- a/dlls/shfolder/.cvsignore
+++ b/dlls/shfolder/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+shfolder.dll.dbg.c
 shfolder.spec.c
diff --git a/dlls/shfolder/shfolder.spec b/dlls/shfolder/shfolder.spec
index 0d97004..65ca40d 100644
--- a/dlls/shfolder/shfolder.spec
+++ b/dlls/shfolder/shfolder.spec
@@ -1,5 +1,4 @@
 name shfolder
-type win32
 
 @ forward SHGetFolderPathA shell32.SHGetFolderPathA
 @ forward SHGetFolderPathW shell32.SHGetFolderPathW
diff --git a/dlls/shlwapi/.cvsignore b/dlls/shlwapi/.cvsignore
index 1fd3a31..9568f96 100644
--- a/dlls/shlwapi/.cvsignore
+++ b/dlls/shlwapi/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+shlwapi.dll.dbg.c
 shlwapi.spec.c
diff --git a/dlls/shlwapi/shlwapi.spec b/dlls/shlwapi/shlwapi.spec
index f933f66..30a3659 100644
--- a/dlls/shlwapi/shlwapi.spec
+++ b/dlls/shlwapi/shlwapi.spec
@@ -1,9 +1,6 @@
 name shlwapi
-type win32
 init SHLWAPI_LibMain
 
-debug_channels (shell)
-
 1   stdcall @(str ptr) SHLWAPI_1
 2   stdcall @(wstr ptr) SHLWAPI_2
 3   stdcall @(str long) SHLWAPI_3
diff --git a/dlls/snmpapi/.cvsignore b/dlls/snmpapi/.cvsignore
index 779a181..c2f5b71 100644
--- a/dlls/snmpapi/.cvsignore
+++ b/dlls/snmpapi/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+snmpapi.dll.dbg.c
 snmpapi.spec.c
diff --git a/dlls/snmpapi/snmpapi.spec b/dlls/snmpapi/snmpapi.spec
index 6c86eb4..a1d8a9a 100644
--- a/dlls/snmpapi/snmpapi.spec
+++ b/dlls/snmpapi/snmpapi.spec
@@ -1,9 +1,6 @@
 name    snmpapi
-type    win32
 init    SNMPAPI_DllMain
 
-debug_channels (snmpapi)
-
 @ stub SnmpSvcAddrIsIpx
 @ stub SnmpSvcAddrToSocket
 @ stub SnmpSvcBufRevAndCpy
diff --git a/dlls/sti/.cvsignore b/dlls/sti/.cvsignore
index b194d26..c93235f 100644
--- a/dlls/sti/.cvsignore
+++ b/dlls/sti/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+sti.dll.dbg.c
 sti.spec.c
diff --git a/dlls/sti/sti.spec b/dlls/sti/sti.spec
index f4716d4..4848784 100644
--- a/dlls/sti/sti.spec
+++ b/dlls/sti/sti.spec
@@ -1,7 +1,4 @@
 name sti
-type win32
-
-debug_channels()
 
 @ stub DllCanUnloadNow
 @ stub DllGetClassObject
diff --git a/dlls/tapi32/.cvsignore b/dlls/tapi32/.cvsignore
index f1566da..65d7929 100644
--- a/dlls/tapi32/.cvsignore
+++ b/dlls/tapi32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+tapi32.dll.dbg.c
 tapi32.spec.c
diff --git a/dlls/tapi32/tapi32.spec b/dlls/tapi32/tapi32.spec
index 32402ee..d4afab2 100644
--- a/dlls/tapi32/tapi32.spec
+++ b/dlls/tapi32/tapi32.spec
@@ -1,7 +1,4 @@
 name	tapi32
-type	win32
-
-debug_channels (tapi)
 
 @ stdcall lineAccept(long str long) lineAccept
 @ stdcall lineAddProvider(str long ptr) lineAddProvider
diff --git a/dlls/ttydrv/.cvsignore b/dlls/ttydrv/.cvsignore
index 2736f1f..e177b59 100644
--- a/dlls/ttydrv/.cvsignore
+++ b/dlls/ttydrv/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+ttydrv.dll.dbg.c
 ttydrv.spec.c
diff --git a/dlls/ttydrv/ttydrv.spec b/dlls/ttydrv/ttydrv.spec
index b8d5aa3..5d379cb 100644
--- a/dlls/ttydrv/ttydrv.spec
+++ b/dlls/ttydrv/ttydrv.spec
@@ -1,9 +1,6 @@
 name	ttydrv
-type	win32
 init	TTYDRV_Init
 
-debug_channels (ttydrv)
-
 # GDI driver
 
 @ cdecl Arc(ptr long long long long long long long long) TTYDRV_DC_Arc
diff --git a/dlls/twain/.cvsignore b/dlls/twain/.cvsignore
index 6fbf05b..f93dc00 100644
--- a/dlls/twain/.cvsignore
+++ b/dlls/twain/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+twain_32.dll.dbg.c
 twain_32.spec.c
diff --git a/dlls/twain/twain_32.spec b/dlls/twain/twain_32.spec
index d337782..cde68f2 100644
--- a/dlls/twain/twain_32.spec
+++ b/dlls/twain/twain_32.spec
@@ -1,7 +1,4 @@
 name	twain_32
-type	win32
 init	TWAIN_LibMain
 
-debug_channels (twain)
-
 @ stdcall DSM_Entry(ptr ptr long long long ptr) DSM_Entry
diff --git a/dlls/url/.cvsignore b/dlls/url/.cvsignore
index 9b4dc6b..af36c61 100644
--- a/dlls/url/.cvsignore
+++ b/dlls/url/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+url.dll.dbg.c
 url.spec.c
diff --git a/dlls/url/url.spec b/dlls/url/url.spec
index d9805c0..91a444c 100644
--- a/dlls/url/url.spec
+++ b/dlls/url/url.spec
@@ -1,7 +1,4 @@
 name url
-type win32
-
-debug_channels()
 
 @ stub AddMIMEFileTypesPS
 @ stub AutodialHookCallback
diff --git a/dlls/urlmon/.cvsignore b/dlls/urlmon/.cvsignore
index 16ad900..4364e74 100644
--- a/dlls/urlmon/.cvsignore
+++ b/dlls/urlmon/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+urlmon.dll.dbg.c
 urlmon.spec.c
diff --git a/dlls/urlmon/urlmon.spec b/dlls/urlmon/urlmon.spec
index 9f05a76..24034bc 100644
--- a/dlls/urlmon/urlmon.spec
+++ b/dlls/urlmon/urlmon.spec
@@ -1,7 +1,4 @@
 name    urlmon
-type    win32
-
-debug_channels (urlmon win32)
 
 1 stub CDLGetLongPathNameA
 2 stub CDLGetLongPathNameW
diff --git a/dlls/user/.cvsignore b/dlls/user/.cvsignore
index 49c2c5b..05b1095 100644
--- a/dlls/user/.cvsignore
+++ b/dlls/user/.cvsignore
@@ -6,5 +6,6 @@
 property.glue.c
 text.glue.c
 user.exe.spec.c
+user32.dll.dbg.c
 user32.spec.c
 wnd16.glue.c
diff --git a/dlls/user/user32.spec b/dlls/user/user32.spec
index 8cc1fa2..c941cfc 100644
--- a/dlls/user/user32.spec
+++ b/dlls/user/user32.spec
@@ -1,12 +1,6 @@
 name	user32
-type	win32
 init	UserClientDllInitialize
 
-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
-                string syscolor system text timer win win32 wnet)
-
 @ stdcall ActivateKeyboardLayout(long long) ActivateKeyboardLayout
 @ stdcall AdjustWindowRect(ptr long long) AdjustWindowRect
 @ stdcall AdjustWindowRectEx(ptr long long long) AdjustWindowRectEx
diff --git a/dlls/version/.cvsignore b/dlls/version/.cvsignore
index 0b26930..e377992 100644
--- a/dlls/version/.cvsignore
+++ b/dlls/version/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
 ver.spec.c
+version.dll.dbg.c
 version.spec.c
diff --git a/dlls/version/version.spec b/dlls/version/version.spec
index 0853d9c..82ed1cd 100644
--- a/dlls/version/version.spec
+++ b/dlls/version/version.spec
@@ -1,7 +1,4 @@
 name version
-type win32
-
-debug_channels (ver)
 
 @ stdcall GetFileVersionInfoA(str long long ptr) GetFileVersionInfoA
 @ stdcall GetFileVersionInfoSizeA(str ptr) GetFileVersionInfoSizeA
diff --git a/dlls/win32s/.cvsignore b/dlls/win32s/.cvsignore
index e76201f..8ccefa3 100644
--- a/dlls/win32s/.cvsignore
+++ b/dlls/win32s/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
+w32skrnl.dll.dbg.c
 w32skrnl.spec.c
 w32sys.spec.c
 win32s16.spec.c
diff --git a/dlls/win32s/w32skrnl.spec b/dlls/win32s/w32skrnl.spec
index 7fa7897..fd97de8 100644
--- a/dlls/win32s/w32skrnl.spec
+++ b/dlls/win32s/w32skrnl.spec
@@ -1,7 +1,4 @@
 name	w32skrnl
-type	win32
-
-debug_channels (dll)
 
 1 stub _kSetEnvironmentVariable@8
 2 stub _SzFromImte@4
diff --git a/dlls/winaspi/.cvsignore b/dlls/winaspi/.cvsignore
index 1df4934..003be60 100644
--- a/dlls/winaspi/.cvsignore
+++ b/dlls/winaspi/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
 winaspi.spec.c
 winaspi16.glue.c
+wnaspi32.dll.dbg.c
 wnaspi32.spec.c
diff --git a/dlls/winaspi/wnaspi32.spec b/dlls/winaspi/wnaspi32.spec
index 8c9303b..a0c4998 100644
--- a/dlls/winaspi/wnaspi32.spec
+++ b/dlls/winaspi/wnaspi32.spec
@@ -1,9 +1,6 @@
 name	wnaspi32
-type	win32
 init	WNASPI32_LibMain
 
-debug_channels (aspi)
-
 # we have several ordinal clashes here, it seems...
 
 1 cdecl GetASPI32SupportInfo() GetASPI32SupportInfo
diff --git a/dlls/winedos/.cvsignore b/dlls/winedos/.cvsignore
index 3670d73..88f6c2d 100644
--- a/dlls/winedos/.cvsignore
+++ b/dlls/winedos/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+winedos.dll.dbg.c
 winedos.spec.c
diff --git a/dlls/winedos/winedos.spec b/dlls/winedos/winedos.spec
index 10dd266..1e50d4f 100644
--- a/dlls/winedos/winedos.spec
+++ b/dlls/winedos/winedos.spec
@@ -1,9 +1,6 @@
 name winedos
-type win32
 init DOSVM_Init
 
-debug_channels (aspi console ddraw int int21 int31 module relay)
-
 @ stdcall LoadDosExe(str long) MZ_LoadImage
 
 # DPMI functions
diff --git a/dlls/wineps/.cvsignore b/dlls/wineps/.cvsignore
index 9b34e2b..7daf02a 100644
--- a/dlls/wineps/.cvsignore
+++ b/dlls/wineps/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
 rsrc.res
+wineps.dll.dbg.c
 wineps.spec.c
 wineps16.spec.c
diff --git a/dlls/wineps/wineps.spec b/dlls/wineps/wineps.spec
index c11f7ef..4b2fbfe 100644
--- a/dlls/wineps/wineps.spec
+++ b/dlls/wineps/wineps.spec
@@ -1,9 +1,6 @@
 name	wineps
-type	win32
 init	PSDRV_Init
 
-debug_channels (psdrv)
-
 # GDI driver
 
 @ cdecl Arc(ptr long long long long long long long long) PSDRV_Arc
diff --git a/dlls/wininet/.cvsignore b/dlls/wininet/.cvsignore
index 02f7ace..aaa584e 100644
--- a/dlls/wininet/.cvsignore
+++ b/dlls/wininet/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+wininet.dll.dbg.c
 wininet.spec.c
diff --git a/dlls/wininet/wininet.spec b/dlls/wininet/wininet.spec
index 87faaac..96b138f 100644
--- a/dlls/wininet/wininet.spec
+++ b/dlls/wininet/wininet.spec
@@ -1,9 +1,6 @@
 name    wininet
-type    win32
 init    WININET_LibMain
 
-debug_channels (wininet)
-
 @ stub InternetInitializeAutoProxyDll
 @ stub ShowCertificate
 @ stdcall CommitUrlCacheEntryA(str str long long long str long str str) CommitUrlCacheEntryA
diff --git a/dlls/winmm/.cvsignore b/dlls/winmm/.cvsignore
index 0811ae9..49b85c0 100644
--- a/dlls/winmm/.cvsignore
+++ b/dlls/winmm/.cvsignore
@@ -4,5 +4,6 @@
 mmsystem.spec.c
 sound.spec.c
 time.glue.c
+winmm.dll.dbg.c
 winmm.spec.c
 winmm_res.res
diff --git a/dlls/winmm/joystick/.cvsignore b/dlls/winmm/joystick/.cvsignore
index 3e41704..aa7a0b1 100644
--- a/dlls/winmm/joystick/.cvsignore
+++ b/dlls/winmm/joystick/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+joystick.drv.dbg.c
 joystick.drv.spec.c
diff --git a/dlls/winmm/joystick/joystick.drv.spec b/dlls/winmm/joystick/joystick.drv.spec
index 655886a..54e9c34 100644
--- a/dlls/winmm/joystick/joystick.drv.spec
+++ b/dlls/winmm/joystick/joystick.drv.spec
@@ -1,7 +1,4 @@
 name joystick
 file joystick.drv
-type win32
-
-debug_channels (joystick)
 
 @ stdcall DriverProc(long long long long long) JSTCK_DriverProc
diff --git a/dlls/winmm/mcianim/.cvsignore b/dlls/winmm/mcianim/.cvsignore
index 66b554d..2f9b1b1 100644
--- a/dlls/winmm/mcianim/.cvsignore
+++ b/dlls/winmm/mcianim/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+mcianim.drv.dbg.c
 mcianim.drv.spec.c
diff --git a/dlls/winmm/mcianim/mcianim.drv.spec b/dlls/winmm/mcianim/mcianim.drv.spec
index 9d28dab..2e34ad0 100644
--- a/dlls/winmm/mcianim/mcianim.drv.spec
+++ b/dlls/winmm/mcianim/mcianim.drv.spec
@@ -1,7 +1,4 @@
 name mcianim
 file mcianim.drv
-type win32
-
-debug_channels (mcianim)
 
 @ stdcall DriverProc(long long long long long) MCIANIM_DriverProc
diff --git a/dlls/winmm/mciavi/.cvsignore b/dlls/winmm/mciavi/.cvsignore
index 9e25e5c..ec8f910 100644
--- a/dlls/winmm/mciavi/.cvsignore
+++ b/dlls/winmm/mciavi/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
+mciavi.drv.dbg.c
 mciavi.drv.spec.c
 mciavi_res.res
diff --git a/dlls/winmm/mciavi/mciavi.drv.spec b/dlls/winmm/mciavi/mciavi.drv.spec
index 8e40607..bba843c 100644
--- a/dlls/winmm/mciavi/mciavi.drv.spec
+++ b/dlls/winmm/mciavi/mciavi.drv.spec
@@ -1,8 +1,5 @@
 name mciavi
 file mciavi.drv
-type win32
 init MCIAVI_LibMain
 
-debug_channels (mciavi)
-
 @ stdcall DriverProc(long long long long long) MCIAVI_DriverProc
diff --git a/dlls/winmm/mcicda/.cvsignore b/dlls/winmm/mcicda/.cvsignore
index 31a6d4b..698fb76 100644
--- a/dlls/winmm/mcicda/.cvsignore
+++ b/dlls/winmm/mcicda/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+mcicda.drv.dbg.c
 mcicda.drv.spec.c
diff --git a/dlls/winmm/mcicda/mcicda.drv.spec b/dlls/winmm/mcicda/mcicda.drv.spec
index 5294537..c6d6716 100644
--- a/dlls/winmm/mcicda/mcicda.drv.spec
+++ b/dlls/winmm/mcicda/mcicda.drv.spec
@@ -1,7 +1,4 @@
 name mcicda
 file mcicda.drv
-type win32
-
-debug_channels (mcicda)
 
 @ stdcall DriverProc(long long long long long) MCICDA_DriverProc
diff --git a/dlls/winmm/mciseq/.cvsignore b/dlls/winmm/mciseq/.cvsignore
index 4b25329..6903122 100644
--- a/dlls/winmm/mciseq/.cvsignore
+++ b/dlls/winmm/mciseq/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+mciseq.drv.dbg.c
 mciseq.drv.spec.c
diff --git a/dlls/winmm/mciseq/mciseq.drv.spec b/dlls/winmm/mciseq/mciseq.drv.spec
index 3377010..46ae86b 100644
--- a/dlls/winmm/mciseq/mciseq.drv.spec
+++ b/dlls/winmm/mciseq/mciseq.drv.spec
@@ -1,7 +1,4 @@
 name mciseq
 file mciseq.drv
-type win32
-
-debug_channels (mcimidi)
 
 @ stdcall DriverProc(long long long long long) MCIMIDI_DriverProc
diff --git a/dlls/winmm/mciwave/.cvsignore b/dlls/winmm/mciwave/.cvsignore
index 670a6ab..df05586 100644
--- a/dlls/winmm/mciwave/.cvsignore
+++ b/dlls/winmm/mciwave/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+mciwave.drv.dbg.c
 mciwave.drv.spec.c
diff --git a/dlls/winmm/mciwave/mciwave.drv.spec b/dlls/winmm/mciwave/mciwave.drv.spec
index 7b3147d..23e6f73 100644
--- a/dlls/winmm/mciwave/mciwave.drv.spec
+++ b/dlls/winmm/mciwave/mciwave.drv.spec
@@ -1,7 +1,4 @@
 name mciwave
 file mciwave.drv
-type win32
-
-debug_channels (mciwave)
 
 @ stdcall DriverProc(long long long long long) MCIWAVE_DriverProc
diff --git a/dlls/winmm/midimap/.cvsignore b/dlls/winmm/midimap/.cvsignore
index 9ae44ca..bdf88dd 100644
--- a/dlls/winmm/midimap/.cvsignore
+++ b/dlls/winmm/midimap/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+midimap.drv.dbg.c
 midimap.drv.spec.c
diff --git a/dlls/winmm/midimap/midimap.drv.spec b/dlls/winmm/midimap/midimap.drv.spec
index 454e032..6c1d246 100644
--- a/dlls/winmm/midimap/midimap.drv.spec
+++ b/dlls/winmm/midimap/midimap.drv.spec
@@ -1,8 +1,5 @@
 name midimap
 file midimap.drv
-type win32
-
-debug_channels (msacm)
 
 @ stdcall DriverProc(long long long long long) MIDIMAP_DriverProc
 @ stdcall modMessage(long long long long long) MIDIMAP_modMessage
diff --git a/dlls/winmm/wavemap/.cvsignore b/dlls/winmm/wavemap/.cvsignore
index ea6af38..77f7009 100644
--- a/dlls/winmm/wavemap/.cvsignore
+++ b/dlls/winmm/wavemap/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+msacm.drv.dbg.c
 msacm.drv.spec.c
diff --git a/dlls/winmm/wavemap/msacm.drv.spec b/dlls/winmm/wavemap/msacm.drv.spec
index c573e40..892c379 100644
--- a/dlls/winmm/wavemap/msacm.drv.spec
+++ b/dlls/winmm/wavemap/msacm.drv.spec
@@ -1,8 +1,5 @@
 name msacmmap
 file msacm.drv
-type win32
-
-debug_channels (msacm)
 
 @ stdcall DriverProc(long long long long long) WAVEMAP_DriverProc
 @ stdcall widMessage(long long long long long) WAVEMAP_widMessage
diff --git a/dlls/winmm/winearts/.cvsignore b/dlls/winmm/winearts/.cvsignore
index 3a5385a..cfeff58 100644
--- a/dlls/winmm/winearts/.cvsignore
+++ b/dlls/winmm/winearts/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+winearts.drv.dbg.c
 winearts.drv.spec.c
diff --git a/dlls/winmm/winearts/Makefile.in b/dlls/winmm/winearts/Makefile.in
index 61c5d58..577bea7 100644
--- a/dlls/winmm/winearts/Makefile.in
+++ b/dlls/winmm/winearts/Makefile.in
@@ -4,7 +4,7 @@
 VPATH     = @srcdir@
 MODULE    = winearts.drv
 IMPORTS   = winmm user32 kernel32 ntdll
-EXTRADEFS = @ARTSINCL@
+EXTRAINCL = @ARTSINCL@
 EXTRALIBS = @ARTSLIBS@
 
 LDDLLFLAGS = @LDDLLFLAGS@
diff --git a/dlls/winmm/winearts/winearts.drv.spec b/dlls/winmm/winearts/winearts.drv.spec
index b89c8fa..c410623 100644
--- a/dlls/winmm/winearts/winearts.drv.spec
+++ b/dlls/winmm/winearts/winearts.drv.spec
@@ -1,8 +1,5 @@
 name winearts
 file winearts.drv
-type win32
-
-debug_channels (wave)
 
 @ stdcall DriverProc(long long long long long) ARTS_DriverProc
 @ stdcall wodMessage(long long long long long) ARTS_wodMessage
diff --git a/dlls/winmm/wineoss/.cvsignore b/dlls/winmm/wineoss/.cvsignore
index b480bb3..186250c 100644
--- a/dlls/winmm/wineoss/.cvsignore
+++ b/dlls/winmm/wineoss/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+wineoss.drv.dbg.c
 wineoss.drv.spec.c
diff --git a/dlls/winmm/wineoss/wineoss.drv.spec b/dlls/winmm/wineoss/wineoss.drv.spec
index 2171e02..7b259a9 100644
--- a/dlls/winmm/wineoss/wineoss.drv.spec
+++ b/dlls/winmm/wineoss/wineoss.drv.spec
@@ -1,8 +1,5 @@
 name wineoss
 file wineoss.drv
-type win32
-
-debug_channels (midi mmaux wave)
 
   1 stdcall DriverProc(long long long long long) OSS_DriverProc
   2 stdcall auxMessage(long long long long long) OSS_auxMessage
diff --git a/dlls/winmm/winmm.spec b/dlls/winmm/winmm.spec
index 4c494c5..e706854 100644
--- a/dlls/winmm/winmm.spec
+++ b/dlls/winmm/winmm.spec
@@ -1,9 +1,6 @@
 name winmm
-type win32
 init WINMM_LibMain
 
-debug_channels (driver mci mmio mmsys mmtime sound)
-
 # ordinal exports
 1 stdcall @(ptr long long) PlaySoundA
 3 stub @
diff --git a/dlls/winnls/.cvsignore b/dlls/winnls/.cvsignore
index 5459b37..3ea5b4c 100644
--- a/dlls/winnls/.cvsignore
+++ b/dlls/winnls/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
 winnls.spec.c
+winnls32.dll.dbg.c
 winnls32.spec.c
diff --git a/dlls/winnls/winnls32.spec b/dlls/winnls/winnls32.spec
index b452a05..ea4353d 100644
--- a/dlls/winnls/winnls32.spec
+++ b/dlls/winnls/winnls32.spec
@@ -1,5 +1,4 @@
 name	winnls32
-type	win32
 
 1  stub WINNLS32EnableIME
 2  stub WINNLS32GetEnableStatus
diff --git a/dlls/winsock/.cvsignore b/dlls/winsock/.cvsignore
index f51c975..cf6c740 100644
--- a/dlls/winsock/.cvsignore
+++ b/dlls/winsock/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
 winsock.spec.c
+ws2_32.dll.dbg.c
 ws2_32.spec.c
diff --git a/dlls/winsock/ws2_32.spec b/dlls/winsock/ws2_32.spec
index ca27137..ec45f3f 100644
--- a/dlls/winsock/ws2_32.spec
+++ b/dlls/winsock/ws2_32.spec
@@ -3,11 +3,8 @@
 #  Export table information obtained from Windows 2000 ws2_32.dll
 
 name ws2_32
-type win32
 init WS_LibMain
 
-debug_channels (winsock)
-
 #  EXPORTS ***********
 1   stdcall  accept(long ptr ptr) WS_accept
 2   stdcall  bind(long ptr long) WS_bind
diff --git a/dlls/winspool/.cvsignore b/dlls/winspool/.cvsignore
index af5cd83..5f979ba 100644
--- a/dlls/winspool/.cvsignore
+++ b/dlls/winspool/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+winspool.drv.dbg.c
 winspool.drv.spec.c
diff --git a/dlls/winspool/winspool.drv.spec b/dlls/winspool/winspool.drv.spec
index e20f8b9..0932b0b 100644
--- a/dlls/winspool/winspool.drv.spec
+++ b/dlls/winspool/winspool.drv.spec
@@ -1,10 +1,7 @@
 name	winspool
-type	win32
 file	winspool.drv
 init	WINSPOOL_EntryPoint
 
-debug_channels (winspool)
-
 100 stub @
 @ stub ADVANCEDSETUPDIALOG
 @ stub AbortPrinter
diff --git a/dlls/wintrust/.cvsignore b/dlls/wintrust/.cvsignore
index 8a9f7bb..da89a78 100644
--- a/dlls/wintrust/.cvsignore
+++ b/dlls/wintrust/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+wintrust.dll.dbg.c
 wintrust.spec.c
diff --git a/dlls/wintrust/wintrust.spec b/dlls/wintrust/wintrust.spec
index cdf11e0..b793167 100644
--- a/dlls/wintrust/wintrust.spec
+++ b/dlls/wintrust/wintrust.spec
@@ -1,6 +1,3 @@
 name	wintrust
-type	win32
-
-debug_channels (win32)
 
 @ stdcall WinVerifyTrust(long ptr ptr) WinVerifyTrust
diff --git a/dlls/wow32/.cvsignore b/dlls/wow32/.cvsignore
index 71fe447..a115ddc 100644
--- a/dlls/wow32/.cvsignore
+++ b/dlls/wow32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+wow32.dll.dbg.c
 wow32.spec.c
diff --git a/dlls/wow32/wow32.spec b/dlls/wow32/wow32.spec
index e301266..032bbbb 100644
--- a/dlls/wow32/wow32.spec
+++ b/dlls/wow32/wow32.spec
@@ -1,5 +1,4 @@
 name	wow32
-type	win32
 
 # ordinal exports
 1 forward WOWGetDescriptor kernel32.K32WOWGetDescriptor
diff --git a/dlls/wsock32/.cvsignore b/dlls/wsock32/.cvsignore
index 5e34f92..251bbc9 100644
--- a/dlls/wsock32/.cvsignore
+++ b/dlls/wsock32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+wsock32.dll.dbg.c
 wsock32.spec.c
diff --git a/dlls/wsock32/wsock32.spec b/dlls/wsock32/wsock32.spec
index 308c7df..7d33f9c 100644
--- a/dlls/wsock32/wsock32.spec
+++ b/dlls/wsock32/wsock32.spec
@@ -1,7 +1,4 @@
 name	wsock32
-type	win32
-
-debug_channels (winsock)
 
   1 forward accept ws2_32.accept
   2 forward bind ws2_32.bind
diff --git a/dlls/x11drv/.cvsignore b/dlls/x11drv/.cvsignore
index 75471af..85a8026 100644
--- a/dlls/x11drv/.cvsignore
+++ b/dlls/x11drv/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
 wineclipsrv
+x11drv.dll.dbg.c
 x11drv.spec.c
diff --git a/dlls/x11drv/x11drv.spec b/dlls/x11drv/x11drv.spec
index 34a2433..c45306c 100644
--- a/dlls/x11drv/x11drv.spec
+++ b/dlls/x11drv/x11drv.spec
@@ -1,10 +1,6 @@
 name	x11drv
-type	win32
 init	X11DRV_Init
 
-debug_channels (bitblt bitmap clipboard cursor dinput event font gdi graphics
-                key keyboard opengl palette text win x11drv xrender)
-
 # GDI driver
 
 @ cdecl Arc(ptr long long long long long long long long) X11DRV_Arc
diff --git a/libtest/Makefile.in b/libtest/Makefile.in
index 7917eee..2376b9a 100644
--- a/libtest/Makefile.in
+++ b/libtest/Makefile.in
@@ -1,4 +1,4 @@
-DEFS       = @DLLFLAGS@ -DSTRICT -DNONAMELESSUNION -DNONAMELESSSTRUCT
+DEFS       = @DLLFLAGS@ -DSTRICT -DNONAMELESSUNION -DNONAMELESSSTRUCT $(EXTRADEFS)
 LDDLLFLAGS = @LDDLLFLAGS@
 TOPSRCDIR  = @top_srcdir@
 TOPOBJDIR  = ..
@@ -38,47 +38,47 @@
 @MAKE_RULES@
 
 expand.spec.c: expand.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym expand.o -o expand.spec.c -exe expand -mgui -L$(DLLDIR) -llz32 -lkernel32 -lntdll
+	$(LDPATH) $(WINEBUILD) $(DEFS) -sym expand.o -o expand.spec.c -exe expand -mgui -L$(DLLDIR) -llz32 -lkernel32 -lntdll
 expand.so: expand.o expand.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o expand.so $+ $(ALL_LIBS)
 
 hello.spec.c: hello.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym hello.o -o hello.spec.c -exe hello -mgui -L$(DLLDIR) -luser32 -lgdi32 -lkernel32 -lntdll
+	$(LDPATH) $(WINEBUILD) $(DEFS) -sym hello.o -o hello.spec.c -exe hello -mgui -L$(DLLDIR) -luser32 -lgdi32 -lkernel32 -lntdll
 hello.so: hello.o hello.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o hello.so $+ $(ALL_LIBS)
 
 hello2.spec.c: hello2.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym hello2.o -o hello2.spec.c -exe hello2 -mgui -L$(DLLDIR) -luser32 -lkernel32 -lntdll
+	$(LDPATH) $(WINEBUILD) $(DEFS) -sym hello2.o -o hello2.spec.c -exe hello2 -mgui -L$(DLLDIR) -luser32 -lkernel32 -lntdll
 hello2.so: hello2.o hello2.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o hello2.so $+ $(ALL_LIBS)
 
 hello3.spec.c: hello3.o hello3res.res $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym hello3.o -res hello3res.res -o hello3.spec.c -exe hello3 -mgui -L$(DLLDIR) -lcomdlg32 -luser32 -lgdi32 -lkernel32 -lntdll
+	$(LDPATH) $(WINEBUILD) $(DEFS) -sym hello3.o -res hello3res.res -o hello3.spec.c -exe hello3 -mgui -L$(DLLDIR) -lcomdlg32 -luser32 -lgdi32 -lkernel32 -lntdll
 hello3.so: hello3.o hello3.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o hello3.so $+ $(ALL_LIBS)
 
 hello4.spec.c: hello4.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym hello4.o -o hello4.spec.c -exe hello4 -mgui -L$(DLLDIR) -luser32 -lgdi32 -lkernel32 -lntdll
+	$(LDPATH) $(WINEBUILD) $(DEFS) -sym hello4.o -o hello4.spec.c -exe hello4 -mgui -L$(DLLDIR) -luser32 -lgdi32 -lkernel32 -lntdll
 hello4.so: hello4.o hello4.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o hello4.so $+ $(ALL_LIBS)
 
 hello5.spec.c: hello5.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym hello5.o -o hello5.spec.c -exe hello5 -mgui -L$(DLLDIR) -lkernel32 -lntdll
+	$(LDPATH) $(WINEBUILD) $(DEFS) -sym hello5.o -o hello5.spec.c -exe hello5 -mgui -L$(DLLDIR) -lkernel32 -lntdll
 hello5.so: hello5.o hello5.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o hello5.so $+ $(ALL_LIBS)
 
 new.spec.c: new.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym new.o -o new.spec.c -exe new -mgui -L$(DLLDIR) -luser32 -lgdi32 -lkernel32 -lntdll
+	$(LDPATH) $(WINEBUILD) $(DEFS) -sym new.o -o new.spec.c -exe new -mgui -L$(DLLDIR) -luser32 -lgdi32 -lkernel32 -lntdll
 new.so: new.o new.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o new.so $+ $(ALL_LIBS)
 
 rolex.spec.c: rolex.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym rolex.o -o rolex.spec.c -exe rolex -mgui -L$(DLLDIR) -luser32 -lgdi32 -lkernel32 -lntdll
+	$(LDPATH) $(WINEBUILD) $(DEFS) -sym rolex.o -o rolex.spec.c -exe rolex -mgui -L$(DLLDIR) -luser32 -lgdi32 -lkernel32 -lntdll
 rolex.so: rolex.o rolex.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o rolex.so $+ $(ALL_LIBS)
 
 volinfo.spec.c: volinfo.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym volinfo.o -o volinfo.spec.c -exe volinfo -mgui -L$(DLLDIR) -lkernel32 -lntdll
+	$(LDPATH) $(WINEBUILD) $(DEFS) -sym volinfo.o -o volinfo.spec.c -exe volinfo -mgui -L$(DLLDIR) -lkernel32 -lntdll
 volinfo.so: volinfo.o volinfo.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o volinfo.so $+ $(ALL_LIBS)
 
diff --git a/miscemu/wine.spec b/miscemu/wine.spec
index 52555b7..2923380 100644
--- a/miscemu/wine.spec
+++ b/miscemu/wine.spec
@@ -1,4 +1,3 @@
 name	wine
 mode	guiexe
-type	win32
 init	wine_initial_task
diff --git a/programs/Makeprog.rules.in b/programs/Makeprog.rules.in
index 3c1b3ee..c4a9d90 100644
--- a/programs/Makeprog.rules.in
+++ b/programs/Makeprog.rules.in
@@ -11,6 +11,7 @@
 
 DEFS        = @DLLFLAGS@ -DSTRICT -DNONAMELESSUNION -DNONAMELESSSTRUCT $(EXTRADEFS)
 LDDLLFLAGS  = @LDDLLFLAGS@
+ALL_OBJS    = $(OBJS) $(MODULE).dbg.o
 ALL_LIBS    = $(LIBWINE) $(EXTRALIBS) $(LIBS)
 SYMBOLFILE  = $(MODULE).tmp.o
 TESTIMPORTS = $(DELAYIMPORTS) $(IMPORTS)
@@ -23,20 +24,20 @@
 # Rule for main module spec file
 
 $(MODULE).spec.c: $(RC_SRCS:.rc=.res) $(SYMBOLFILE) $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ $(SYMBOLFILE:%=-sym %) -o $@ -exe $(MODULE) $(APPMODE:%=-m%) $(RC_SRCS:%.rc=-res %.res) -L$(DLLDIR) $(DELAYIMPORTS:%=-dl%) $(IMPORTS:%=-l%)
+	$(LDPATH) $(WINEBUILD) $(DEFS) $(SYMBOLFILE:%=-sym %) -o $@ -exe $(MODULE) $(APPMODE:%=-m%) $(RC_SRCS:%.rc=-res %.res) -L$(DLLDIR) $(DELAYIMPORTS:%=-dl%) $(IMPORTS:%=-l%)
 
 # Rules for .so main module
 
-$(MODULE).so: $(MODULE).spec.o $(OBJS) Makefile.in
-	$(LDSHARED) $(LDDLLFLAGS) $(MODULE).spec.o $(OBJS) -o $@ $(ALL_LIBS)
+$(MODULE).so: $(MODULE).spec.o $(ALL_OBJS) Makefile.in
+	$(LDSHARED) $(LDDLLFLAGS) $(MODULE).spec.o $(ALL_OBJS) -o $@ $(ALL_LIBS)
 
 $(MODULE): $(MODULE).so
 	$(RM) $(MODULE) && $(LN_S) $(TOPOBJDIR)/wine $(MODULE)
 
 # Rules for .exe main module
 
-$(MODULE).exe: $(OBJS) $(RCOBJS) Makefile.in
-	$(CC) $(OBJS) $(RCOBJS) -o $@ $(DELAYIMPORTS:%=-l%) $(IMPORTS:%=-l%) $(ALL_LIBS)
+$(MODULE).exe: $(ALL_OBJS) $(RCOBJS) Makefile.in
+	$(CC) $(ALL_OBJS) $(RCOBJS) -o $@ $(DELAYIMPORTS:%=-l%) $(IMPORTS:%=-l%) $(ALL_LIBS)
 
 # Rules for checking that no imports are missing
 
@@ -47,11 +48,6 @@
 
 $(TESTRESULTS): $(MODULE).so
 
-# Rules for debug channels
-
-debug_channels: dummy
-	$(TOPSRCDIR)/tools/make_debug $(MODULE).spec $(C_SRCS)
-
 # Rules for installation
 
 .PHONY: install_prog$(EXEEXT)
diff --git a/programs/avitools/Makefile.in b/programs/avitools/Makefile.in
index 00886f6..e4e5e53 100644
--- a/programs/avitools/Makefile.in
+++ b/programs/avitools/Makefile.in
@@ -1,4 +1,4 @@
-DEFS       = @DLLFLAGS@ -DSTRICT -DNONAMELESSUNION -DNONAMELESSSTRUCT
+DEFS       = @DLLFLAGS@ -DSTRICT -DNONAMELESSUNION -DNONAMELESSSTRUCT $(EXTRADEFS)
 LDDLLFLAGS = @LDDLLFLAGS@
 TOPSRCDIR  = @top_srcdir@
 TOPOBJDIR  = ../..
@@ -13,13 +13,13 @@
 @MAKE_RULES@
 
 aviinfo.spec.c: aviinfo.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym aviinfo.o -o aviinfo.spec.c -exe aviinfo -mgui -L$(DLLDIR) -lkernel32 -lntdll
+	$(LDPATH) $(WINEBUILD) $(DEFS) -sym aviinfo.o -o aviinfo.spec.c -exe aviinfo -mgui -L$(DLLDIR) -lkernel32 -lntdll
 
 aviplay.spec.c: aviplay.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym aviplay.o -o aviplay.spec.c -exe aviplay -mgui -L$(DLLDIR) -lddraw -lkernel32 -lntdll
+	$(LDPATH) $(WINEBUILD) $(DEFS) -sym aviplay.o -o aviplay.spec.c -exe aviplay -mgui -L$(DLLDIR) -lddraw -lkernel32 -lntdll
 
 icinfo.spec.c: icinfo.o $(WINEBUILD)
-	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -sym icinfo.o -o icinfo.spec.c -exe icinfo -mgui -L$(DLLDIR) -lmsvfw32 -lkernel32 -lntdll
+	$(LDPATH) $(WINEBUILD) $(DEFS) -sym icinfo.o -o icinfo.spec.c -exe icinfo -mgui -L$(DLLDIR) -lmsvfw32 -lkernel32 -lntdll
 
 aviinfo.so: aviinfo.o aviinfo.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o aviinfo.so aviinfo.o aviinfo.spec.o $(ALL_LIBS)
diff --git a/programs/clock/.cvsignore b/programs/clock/.cvsignore
index d535364..2f2e0a9 100644
--- a/programs/clock/.cvsignore
+++ b/programs/clock/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
 clock
+clock.dbg.c
 clock.spec.c
 rsrc.res
diff --git a/programs/cmdlgtst/.cvsignore b/programs/cmdlgtst/.cvsignore
index 29bc66a..684099c 100644
--- a/programs/cmdlgtst/.cvsignore
+++ b/programs/cmdlgtst/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
 cmdlgr.res
 cmdlgtst
+cmdlgtst.dbg.c
 cmdlgtst.spec.c
diff --git a/programs/control/.cvsignore b/programs/control/.cvsignore
index dafb694..9f10f66 100644
--- a/programs/control/.cvsignore
+++ b/programs/control/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
 control
+control.dbg.c
 control.spec.c
diff --git a/programs/notepad/.cvsignore b/programs/notepad/.cvsignore
index 46fda4a..127bbbf 100644
--- a/programs/notepad/.cvsignore
+++ b/programs/notepad/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
 notepad
+notepad.dbg.c
 notepad.spec.c
 rsrc.res
diff --git a/programs/osversioncheck/.cvsignore b/programs/osversioncheck/.cvsignore
index 769454b..4da03d5 100644
--- a/programs/osversioncheck/.cvsignore
+++ b/programs/osversioncheck/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
 osversioncheck
+osversioncheck.dbg.c
 osversioncheck.spec.c
diff --git a/programs/progman/.cvsignore b/programs/progman/.cvsignore
index 8716df3..73bdce5 100644
--- a/programs/progman/.cvsignore
+++ b/programs/progman/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
 progman
+progman.dbg.c
 progman.spec.c
 rsrc.res
diff --git a/programs/regapi/.cvsignore b/programs/regapi/.cvsignore
index bb58883..bfb8096 100644
--- a/programs/regapi/.cvsignore
+++ b/programs/regapi/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
 regapi
+regapi.dbg.c
 regapi.spec.c
diff --git a/programs/regedit/.cvsignore b/programs/regedit/.cvsignore
index 463823f..dd85b97 100644
--- a/programs/regedit/.cvsignore
+++ b/programs/regedit/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+regedit.dbg.c
 regedit.spec.c
diff --git a/programs/regsvr32/.cvsignore b/programs/regsvr32/.cvsignore
index 07ce01a..8e4e068 100644
--- a/programs/regsvr32/.cvsignore
+++ b/programs/regsvr32/.cvsignore
@@ -1,2 +1,3 @@
 Makefile
+regsvr32.dbg.c
 regsvr32.spec.c
diff --git a/programs/regtest/.cvsignore b/programs/regtest/.cvsignore
index 2d18c33..b8a6b35 100644
--- a/programs/regtest/.cvsignore
+++ b/programs/regtest/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
 regtest
+regtest.dbg.c
 regtest.spec.c
diff --git a/programs/uninstaller/.cvsignore b/programs/uninstaller/.cvsignore
index 43799b4..bd46993 100644
--- a/programs/uninstaller/.cvsignore
+++ b/programs/uninstaller/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
 rsrc.res
 uninstaller
+uninstaller.dbg.c
 uninstaller.spec.c
diff --git a/programs/view/.cvsignore b/programs/view/.cvsignore
index 7deec69..4543de0 100644
--- a/programs/view/.cvsignore
+++ b/programs/view/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
 view
+view.dbg.c
 view.spec.c
 viewrc.res
diff --git a/programs/wcmd/.cvsignore b/programs/wcmd/.cvsignore
index 06b6766..997f434 100644
--- a/programs/wcmd/.cvsignore
+++ b/programs/wcmd/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
 wcmd
+wcmd.dbg.c
 wcmd.spec.c
 wcmdrc.res
diff --git a/programs/wineconsole/.cvsignore b/programs/wineconsole/.cvsignore
index 84bd2b5..d20ecf1 100644
--- a/programs/wineconsole/.cvsignore
+++ b/programs/wineconsole/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
 wineconsole
+wineconsole.dbg.c
 wineconsole.spec.c
 wineconsole_res.res
diff --git a/programs/winemine/.cvsignore b/programs/winemine/.cvsignore
index f16473e..2e6b092 100644
--- a/programs/winemine/.cvsignore
+++ b/programs/winemine/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
 rsrc.res
 winemine
+winemine.dbg.c
 winemine.spec.c
diff --git a/programs/winepath/.cvsignore b/programs/winepath/.cvsignore
index 0966b84..24c02ce 100644
--- a/programs/winepath/.cvsignore
+++ b/programs/winepath/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
 winepath
+winepath.dbg.c
 winepath.spec.c
diff --git a/programs/winetest/.cvsignore b/programs/winetest/.cvsignore
index b6780d9..3ebb0b7 100644
--- a/programs/winetest/.cvsignore
+++ b/programs/winetest/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
 wine.c
+winetest.dbg.c
 winetest.spec.c
diff --git a/programs/winhelp/.cvsignore b/programs/winhelp/.cvsignore
index 35d2256..5984385 100644
--- a/programs/winhelp/.cvsignore
+++ b/programs/winhelp/.cvsignore
@@ -3,6 +3,7 @@
 lex.yy.c
 rsrc.res
 winhelp
+winhelp.dbg.c
 winhelp.spec.c
 y.tab.c
 y.tab.h
diff --git a/programs/winver/.cvsignore b/programs/winver/.cvsignore
index e4bc633..72f1115 100644
--- a/programs/winver/.cvsignore
+++ b/programs/winver/.cvsignore
@@ -1,3 +1,4 @@
 Makefile
 winver
+winver.dbg.c
 winver.spec.c
diff --git a/tools/winebuild/README b/tools/winebuild/README
index cc49bf3..29e94ef 100644
--- a/tools/winebuild/README
+++ b/tools/winebuild/README
@@ -8,9 +8,7 @@
 [heap   SIZE]
 [stack  SIZE]
 [init	FUNCTION]
-[import [IMP_FLAGS] DLL]
 [rsrc	RESFILE]
-[debug_channels ([CHANNEL [CHANNEL...]])]
 [ignore ([SYMBOL [SYMBOL...]])]
 
 ORDINAL FUNCTYPE [FLAGS] EXPORTNAME([ARGTYPE [ARGTYPE [...]]]) HANDLERNAME
@@ -51,20 +49,8 @@
 "init" specifies a function which will be called when this dll
 is loaded. This is only valid for Win32 modules.
 
-"import" names a module that this one depends on (only for Win32
-modules at the present). The import declaration can be present several
-times.
-
-"IMP_FLAGS" is a series of optional flags, preceded by a '-'
-character. The supported flags are:
-"-delay":       the module this module depends upon will be loaded
-	 	when the first API will be called (and not while this
-		module is loaded)
-
 "rsrc" specifies the path of the compiled resource file.
 
-"debug_channels" specifies the list of debug channels used by the dll.
-
 "ignore" specifies a list of symbols that should be ignored when
 resolving undefined symbols against the imported libraries.
 
diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h
index 5cce3c9..232157d 100644
--- a/tools/winebuild/build.h
+++ b/tools/winebuild/build.h
@@ -60,7 +60,6 @@
 
 typedef enum
 {
-    SPEC_INVALID,
     SPEC_WIN16,
     SPEC_WIN32
 } SPEC_TYPE;
@@ -146,6 +145,7 @@
 extern void output_standard_file_header( FILE *outfile );
 extern void dump_bytes( FILE *outfile, const unsigned char *data, int len,
                         const char *label, int constant );
+extern const char *make_c_identifier( const char *str );
 extern int get_alignment(int alignBoundary);
 
 extern void add_import_dll( const char *name, int delay );
@@ -157,6 +157,7 @@
 extern void load_res16_file( const char *name );
 extern int output_res16_data( FILE *outfile );
 extern int output_res16_directory( unsigned char *buffer );
+extern void parse_debug_channels( const char *srcdir, const char *filename );
 
 extern void BuildGlue( FILE *outfile, FILE *infile );
 extern void BuildRelays16( FILE *outfile );
@@ -164,6 +165,7 @@
 extern void BuildSpec16File( FILE *outfile );
 extern void BuildSpec32File( FILE *outfile );
 extern void BuildDef32File( FILE *outfile );
+extern void BuildDebugFile( FILE *outfile );
 extern SPEC_TYPE ParseTopLevel( FILE *file, int def_only );
 
 /* global variables */
diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c
index 81a78e9..802af1f 100644
--- a/tools/winebuild/main.c
+++ b/tools/winebuild/main.c
@@ -67,6 +67,7 @@
 
 static FILE *input_file;
 static FILE *output_file;
+static const char *current_src_dir;
 
 /* execution mode */
 static enum
@@ -76,6 +77,7 @@
     MODE_EXE,
     MODE_GLUE,
     MODE_DEF,
+    MODE_DEBUG,
     MODE_RELAY16,
     MODE_RELAY32
 } exec_mode = MODE_NONE;
@@ -110,10 +112,12 @@
     const char *usage;
 };
 
-static void do_pic(void);
 static void do_output( const char *arg );
 static void do_usage(void);
 static void do_warnings(void);
+static void do_f_flags( const char *arg );
+static void do_define( const char *arg );
+static void do_include( const char *arg );
 static void do_exe_mode( const char *arg );
 static void do_spec( const char *arg );
 static void do_def( const char *arg );
@@ -121,7 +125,9 @@
 static void do_glue( const char *arg );
 static void do_relay16(void);
 static void do_relay32(void);
+static void do_debug(void);
 static void do_sym( const char *arg );
+static void do_chdir( const char *arg );
 static void do_lib( const char *arg );
 static void do_import( const char *arg );
 static void do_dimport( const char *arg );
@@ -129,30 +135,29 @@
 
 static const struct option_descr option_table[] =
 {
-    { "-fPIC",    0, do_pic,     "-fPIC            Generate PIC code" },
     { "-h",       0, do_usage,   "-h               Display this help message" },
     { "-w",       0, do_warnings,"-w               Turn on warnings" },
+    { "-C",       1, do_chdir,   "-C dir           Change directory to <dir> before opening source files" },
+    { "-f",       1, do_f_flags, "-f flags         Compiler flags (only -fPIC is supported)" },
+    { "-D",       1, do_define,  "-D sym           Ignored for C flags compatibility" },
+    { "-I",       1, do_include, "-I dir           Ignored for C flags compatibility" },
     { "-m",       1, do_exe_mode,"-m mode          Set the executable mode (cui|gui|cuiw|guiw)" },
     { "-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" },
     { "-res",     1, do_rsrc,    "-res rsrc.res    Load resources from rsrc.res" },
     { "-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'" },
+    { "-sym",     1, do_sym,     "-sym file.o      Read the list of undefined symbols from 'file.o'\n" },
     { "-spec",    1, do_spec,    "-spec file.spec  Build a .c file from a spec file" },
     { "-def",     1, do_def,     "-def file.spec   Build a .def file from a spec file" },
     { "-exe",     1, do_exe,     "-exe name        Build a .c file from the named executable" },
+    { "-debug",   0, do_debug,   "-debug [files]   Build a .c file containing debug channels declarations" },
     { "-glue",    1, do_glue,    "-glue file.c     Build the 16-bit glue for a .c file" },
     { "-relay16", 0, do_relay16, "-relay16         Build the 16-bit relay assembly routines" },
     { "-relay32", 0, do_relay32, "-relay32         Build the 32-bit relay assembly routines" },
     { NULL,       0, NULL,      NULL }
 };
 
-static void do_pic(void)
-{
-    UsePIC = 1;
-}
-
 static void do_output( const char *arg )
 {
     if ( ( unlink ( arg ) ) == -1 && ( errno != ENOENT ) ) 
@@ -175,7 +180,7 @@
     fprintf( stderr, "Usage: winebuild [options]\n\n" );
     fprintf( stderr, "Options:\n" );
     for (opt = option_table; opt->name; opt++) fprintf( stderr, "   %s\n", opt->usage );
-    fprintf( stderr, "\nExactly one of -spec, -glue or -relay must be specified.\n\n" );
+    fprintf( stderr, "\nExactly one of -spec, -def, -exe, -debug, -glue, -relay16 or -relay32 must be specified.\n\n" );
     exit(1);
 }
 
@@ -184,6 +189,22 @@
     display_warnings = 1;
 }
 
+static void do_f_flags( const char *arg )
+{
+    if (!strcmp( arg, "PIC" )) UsePIC = 1;
+    /* ignore all other flags */
+}
+
+static void do_define( const char *arg )
+{
+    /* nothing */
+}
+
+static void do_include( const char *arg )
+{
+    /* nothing */
+}
+
 static void do_spec( const char *arg )
 {
     if (exec_mode != MODE_NONE || !arg[0]) do_usage();
@@ -228,6 +249,17 @@
     open_input( arg );
 }
 
+static void do_debug(void)
+{
+    if (exec_mode != MODE_NONE) do_usage();
+    exec_mode = MODE_DEBUG;
+}
+
+static void do_chdir( const char *arg )
+{
+    current_src_dir = arg;
+}
+
 static void do_relay16(void)
 {
     if (exec_mode != MODE_NONE) do_usage();
@@ -274,8 +306,7 @@
     char * const * ptr;
     const char* arg=NULL;
 
-    ptr=argv+1;
-    while (*ptr != NULL)
+    for (ptr = argv + 1; *ptr; ptr++)
     {
         for (opt = option_table; opt->name; opt++)
         {
@@ -298,13 +329,18 @@
 
         if (!opt->name)
         {
+            if (exec_mode == MODE_DEBUG && **ptr != '-')
+            {
+                /* this a file name to parse for debug channels */
+                parse_debug_channels( current_src_dir, *ptr );
+                continue;
+            }
             fprintf( stderr, "Unrecognized option '%s'\n", *ptr );
             do_usage();
         }
 
         if (opt->has_arg && arg!=NULL) opt->func( arg );
         else opt->func( "" );
-        ptr++;
     }
 }
 
@@ -346,6 +382,9 @@
             default: assert(0);
         }
         break;
+    case MODE_DEBUG:
+        BuildDebugFile( output_file );
+        break;
     case MODE_GLUE:
         BuildGlue( output_file, input_file );
         break;
diff --git a/tools/winebuild/parser.c b/tools/winebuild/parser.c
index 784106b..af91c3d 100644
--- a/tools/winebuild/parser.c
+++ b/tools/winebuild/parser.c
@@ -36,7 +36,7 @@
 
 int current_line = 0;
 
-static SPEC_TYPE SpecType = SPEC_INVALID;
+static SPEC_TYPE SpecType = SPEC_WIN32;
 
 static char ParseBuffer[512];
 static char TokenBuffer[512];
@@ -128,26 +128,6 @@
 
 
 /*******************************************************************
- *         ParseDebug
- *
- * Parse a debug channel definition.
- */
-static void ParseDebug(void)
-{
-    const char *token = GetToken(0);
-    if (*token != '(') fatal_error( "Expected '(' got '%s'\n", token );
-    for (;;)
-    {
-        token = GetToken(0);
-        if (*token == ')') break;
-        debug_channels = xrealloc( debug_channels,
-                                   (nb_debug_channels + 1) * sizeof(*debug_channels));
-        debug_channels[nb_debug_channels++] = xstrdup(token);
-    }
-}
-
-
-/*******************************************************************
  *         ParseIgnore
  *
  * Parse an 'ignore' definition.
@@ -575,12 +555,6 @@
                 fatal_error( "Owner only supported for Win16 spec files\n" );
             strcpy( owner_name, GetToken(0) );
         }
-        else if (strcmp(token, "debug_channels") == 0)
-        {
-            if (SpecType != SPEC_WIN32)
-                fatal_error( "debug channels only supported for Win32 spec files\n" );
-            ParseDebug();
-        }
         else if (strcmp(token, "ignore") == 0)
         {
             if (SpecType != SPEC_WIN32)
@@ -614,7 +588,6 @@
             sprintf( DLLFileName, "%s.exe", DLLName );
     }
 
-    if (SpecType == SPEC_INVALID) fatal_error( "Missing 'type' declaration\n" );
     if (SpecType == SPEC_WIN16 && !owner_name[0])
         fatal_error( "'owner' not specified for Win16 dll\n" );
 
@@ -622,3 +595,84 @@
     sort_names();
     return SpecType;
 }
+
+
+/*******************************************************************
+ *         add_debug_channel
+ */
+static void add_debug_channel( const char *name )
+{
+    int i;
+
+    for (i = 0; i < nb_debug_channels; i++)
+        if (!strcmp( debug_channels[i], name )) return;
+
+    debug_channels = xrealloc( debug_channels, (nb_debug_channels + 1) * sizeof(*debug_channels));
+    debug_channels[nb_debug_channels++] = xstrdup(name);
+}
+
+
+/*******************************************************************
+ *         parse_debug_channels
+ *
+ * Parse a source file and extract the debug channel definitions.
+ */
+void parse_debug_channels( const char *srcdir, const char *filename )
+{
+    FILE *file;
+    int eol_seen = 1;
+    char *fullname = NULL;
+
+    if (srcdir)
+    {
+        fullname = xmalloc( strlen(srcdir) + strlen(filename) + 2 );
+        strcpy( fullname, srcdir );
+        strcat( fullname, "/" );
+        strcat( fullname, filename );
+    }
+    else fullname = xstrdup( filename );
+
+    if (!(file = fopen( fullname, "r" ))) fatal_error( "Cannot open file '%s'\n", fullname );
+    input_file_name = fullname;
+    current_line = 1;
+    while (fgets( ParseBuffer, sizeof(ParseBuffer), file ))
+    {
+        char *channel, *end, *p = ParseBuffer;
+
+        p = ParseBuffer + strlen(ParseBuffer) - 1;
+        if (!eol_seen)  /* continuation line */
+        {
+            eol_seen = (*p == '\n');
+            continue;
+        }
+        if ((eol_seen = (*p == '\n'))) *p = 0;
+
+        p = ParseBuffer;
+        while (isspace(*p)) p++;
+        if (!memcmp( p, "WINE_DECLARE_DEBUG_CHANNEL", 26 ) ||
+            !memcmp( p, "WINE_DEFAULT_DEBUG_CHANNEL", 26 ))
+        {
+            p += 26;
+            while (isspace(*p)) p++;
+            if (*p != '(')
+                fatal_error( "invalid debug channel specification '%s'\n", ParseBuffer );
+            p++;
+            while (isspace(*p)) p++;
+            if (!isalpha(*p))
+                fatal_error( "invalid debug channel specification '%s'\n", ParseBuffer );
+            channel = p;
+            while (isalnum(*p) || *p == '_') p++;
+            end = p;
+            while (isspace(*p)) p++;
+            if (*p != ')')
+                fatal_error( "invalid debug channel specification '%s'\n", ParseBuffer );
+            *end = 0;
+            add_debug_channel( channel );
+        }
+        current_line++;
+    }
+    fclose( file );
+    input_file_name = NULL;
+    current_line = 0;
+    free( fullname );
+}
diff --git a/tools/winebuild/spec16.c b/tools/winebuild/spec16.c
index b30723e..f12de6e 100644
--- a/tools/winebuild/spec16.c
+++ b/tools/winebuild/spec16.c
@@ -786,7 +786,7 @@
 
 #ifdef __i386__
         fprintf( outfile, "    { 0x68, %s_CallFrom16_%s, 0x9a, __wine_call_from_16_%s,\n",
-                 DLLName, profile, 
+                 make_c_identifier(DLLName), profile,
                  (typelist[i]->flags & (FLAG_REGISTER|FLAG_INTERRUPT)) ? "regs":
                  typelist[i]->type == TYPE_PASCAL_16? "word" : "long" );
         if (argsize)
@@ -890,16 +890,19 @@
 
 #if defined(__i386__)
     fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" );
-    fprintf( outfile, "    \"\\tcall " PREFIX "__wine_spec_%s_init\\n\"\n", DLLName );
+    fprintf( outfile, "    \"\\tcall " PREFIX "__wine_spec_%s_init\\n\"\n",
+             make_c_identifier(DLLName) );
     fprintf( outfile, "    \"\\t.previous\\n\");\n" );
 #elif defined(__sparc__)
     fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" );
-    fprintf( outfile, "    \"\\tcall " PREFIX "__wine_spec_%s_init\\n\"\n", DLLName );
+    fprintf( outfile, "    \"\\tcall " PREFIX "__wine_spec_%s_init\\n\"\n",
+             make_c_identifier(DLLName) );
     fprintf( outfile, "    \"\\tnop\\n\"\n" );
     fprintf( outfile, "    \"\\t.previous\\n\");\n" );
 #elif defined(__PPC__)
     fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" );
-    fprintf( outfile, "    \"\\tbl " PREFIX "__wine_spec_%s_init\\n\"\n", DLLName );
+    fprintf( outfile, "    \"\\tbl " PREFIX "__wine_spec_%s_init\\n\"\n",
+             make_c_identifier(DLLName) );
     fprintf( outfile, "    \"\\t.previous\\n\");\n" );
 #else
 #error You need to define the DLL constructor for your architecture
@@ -914,7 +917,7 @@
              "{\n"
              "    extern void __wine_register_dll_16( const struct dll_descriptor *descr );\n"
              "    __wine_register_dll_16( &descriptor );\n"
-             "}\n", DLLName );
+             "}\n", make_c_identifier(DLLName) );
 }
 
 
diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c
index 7bfd39d..1e33c05 100644
--- a/tools/winebuild/spec32.c
+++ b/tools/winebuild/spec32.c
@@ -58,7 +58,7 @@
         for (p = buffer; *p; p++) if (!isalnum(*p) && *p != '_') break;
         if (!*p) return buffer;
     }
-    sprintf( buffer, "__wine_%s_%s_%d", prefix, DLLName, odp->ordinal );
+    sprintf( buffer, "__wine_%s_%s_%d", prefix, make_c_identifier(DLLName), odp->ordinal );
     return buffer;
 }
 
@@ -310,9 +310,9 @@
             if (!isalnum(*p) && *p != '_' && *p != '.') break;
         if (*p) continue;
         fprintf( outfile, "    \"\\t.globl " PREFIX "__wine_dllexport_%s_%s\\n\"\n",
-                 DLLName, Names[i]->name );
+                 make_c_identifier(DLLName), Names[i]->name );
         fprintf( outfile, "    \"" PREFIX "__wine_dllexport_%s_%s:\\n\"\n",
-                 DLLName, Names[i]->name );
+                 make_c_identifier(DLLName), Names[i]->name );
     }
     fprintf( outfile, "    \"\\t.long 0xffffffff\\n\"\n" );
 
@@ -433,7 +433,7 @@
 void BuildSpec32File( FILE *outfile )
 {
     int exports_size = 0;
-    int nr_exports, nr_imports, nr_resources, nr_debug;
+    int nr_exports, nr_imports, nr_resources;
     int characteristics, subsystem;
     DWORD page_size;
 
@@ -504,10 +504,6 @@
 
     nr_resources = output_resources( outfile );
 
-    /* Output the debug channels */
-
-    nr_debug = output_debug( outfile );
-
     /* Output LibMain function */
 
     characteristics = subsystem = 0;
@@ -714,38 +710,20 @@
 
 #if defined(__i386__)
     fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" );
-    fprintf( outfile, "    \"\\tcall " PREFIX "__wine_spec_%s_init\\n\"\n", DLLName );
+    fprintf( outfile, "    \"\\tcall " PREFIX "__wine_spec_%s_init\\n\"\n",
+             make_c_identifier(DLLName) );
     fprintf( outfile, "    \"\\t.previous\\n\");\n" );
-    if (nr_debug)
-    {
-        fprintf( outfile, "asm(\"\\t.section\t.fini ,\\\"ax\\\"\\n\"\n" );
-        fprintf( outfile, "    \"\\tcall " PREFIX "__wine_spec_%s_fini\\n\"\n", DLLName );
-        fprintf( outfile, "    \"\\t.previous\\n\");\n" );
-    }
 #elif defined(__sparc__)
     fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" );
-    fprintf( outfile, "    \"\\tcall " PREFIX "__wine_spec_%s_init\\n\"\n", DLLName );
+    fprintf( outfile, "    \"\\tcall " PREFIX "__wine_spec_%s_init\\n\"\n",
+             make_c_identifier(DLLName) );
     fprintf( outfile, "    \"\\tnop\\n\"\n" );
     fprintf( outfile, "    \"\\t.previous\\n\");\n" );
-    if (nr_debug)
-    {
-        fprintf( outfile, "asm(\"\\t.section\t.fini ,\\\"ax\\\"\\n\"\n" );
-        fprintf( outfile, "    \"\\tcall " PREFIX "__wine_spec_%s_fini\\n\"\n", DLLName );
-        fprintf( outfile, "    \"\\tnop\\n\"\n" );
-        fprintf( outfile, "    \"\\t.previous\\n\");\n" );
-    }
 #elif defined(__PPC__)
     fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" );
     fprintf( outfile, "    \"\\tbl " PREFIX "__wine_spec_%s_init\\n\"\n",
-             DLLName );
+             make_c_identifier(DLLName) );
     fprintf( outfile, "    \"\\t.previous\\n\");\n" );
-    if (nr_debug)
-    {
-        fprintf( outfile, "asm(\"\\t.section\t.fini ,\\\"ax\\\"\\n\"\n" );
-        fprintf( outfile, "    \"\\tbl " PREFIX "__wine_spec_%s_fini\\n\"\n",
-                 DLLName );
-        fprintf( outfile, "    \"\\t.previous\\n\");\n" );
-    }
 #else
 #error You need to define the DLL constructor for your architecture
 #endif
@@ -760,20 +738,8 @@
              "    extern void __wine_dll_register( const struct image_nt_headers *, const char * );\n"
              "    extern void *__wine_dbg_register( char * const *, int );\n"
              "    __wine_dll_register( &nt_header, \"%s\" );\n",
-             DLLName, DLLFileName );
-    if (nr_debug)
-        fprintf( outfile, "    debug_registration = __wine_dbg_register( debug_channels, %d );\n",
-                 nr_debug );
+             make_c_identifier(DLLName), DLLFileName );
     fprintf( outfile, "}\n" );
-    if (nr_debug)
-    {
-        fprintf( outfile,
-                 "\nvoid __wine_spec_%s_fini(void)\n"
-                 "{\n"
-                 "    extern void __wine_dbg_unregister( void* );\n"
-                 "    __wine_dbg_unregister( debug_registration );\n"
-                 "}\n", DLLName );
-    }
 }
 
 
@@ -842,3 +808,91 @@
         fprintf(outfile, " @%d\n", odp->ordinal);
     }
 }
+
+
+/*******************************************************************
+ *         BuildDebugFile
+ *
+ * Build the debugging channels source file.
+ */
+void BuildDebugFile( FILE *outfile )
+{
+    int nr_debug;
+    char *prefix, *p;
+
+    output_standard_file_header( outfile );
+    nr_debug = output_debug( outfile );
+    if (!nr_debug)
+    {
+        fprintf( outfile, "/* no debug channels found for this module */\n" );
+        return;
+    }
+
+    if (output_file_name)
+    {
+        if ((p = strrchr( output_file_name, '/' ))) p++;
+        prefix = xstrdup( p ? p : output_file_name );
+        if ((p = strchr( prefix, '.' ))) *p = 0;
+        strcpy( p, make_c_identifier(p) );
+    }
+    else prefix = xstrdup( "_" );
+
+    /* Output the DLL constructor */
+
+    fprintf( outfile,
+             "#ifdef __GNUC__\n"
+             "static void __wine_dbg_%s_init(void) __attribute__((constructor));\n"
+             "static void __wine_dbg_%s_fini(void) __attribute__((destructor));\n"
+             "#else\n"
+             "static void __asm__dummy_dll_init(void) {\n",
+             prefix, prefix );
+
+#if defined(__i386__)
+    fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" );
+    fprintf( outfile, "    \"\\tcall " PREFIX "__wine_dbg_%s_init\\n\"\n", prefix );
+    fprintf( outfile, "    \"\\t.previous\\n\");\n" );
+    fprintf( outfile, "asm(\"\\t.section\t.fini ,\\\"ax\\\"\\n\"\n" );
+    fprintf( outfile, "    \"\\tcall " PREFIX "__wine_dbg_%s_fini\\n\"\n", prefix );
+    fprintf( outfile, "    \"\\t.previous\\n\");\n" );
+#elif defined(__sparc__)
+    fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" );
+    fprintf( outfile, "    \"\\tcall " PREFIX "__wine_dbg_%s_init\\n\"\n", prefix );
+    fprintf( outfile, "    \"\\tnop\\n\"\n" );
+    fprintf( outfile, "    \"\\t.previous\\n\");\n" );
+    fprintf( outfile, "asm(\"\\t.section\t.fini ,\\\"ax\\\"\\n\"\n" );
+    fprintf( outfile, "    \"\\tcall " PREFIX "__wine_dbg_%s_fini\\n\"\n", prefix );
+    fprintf( outfile, "    \"\\tnop\\n\"\n" );
+    fprintf( outfile, "    \"\\t.previous\\n\");\n" );
+#elif defined(__PPC__)
+    fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" );
+    fprintf( outfile, "    \"\\tbl " PREFIX "__wine_dbg_%s_init\\n\"\n", prefix );
+    fprintf( outfile, "    \"\\t.previous\\n\");\n" );
+    fprintf( outfile, "asm(\"\\t.section\t.fini ,\\\"ax\\\"\\n\"\n" );
+    fprintf( outfile, "    \"\\tbl " PREFIX "__wine_dbg_%s_fini\\n\"\n", prefix );
+    fprintf( outfile, "    \"\\t.previous\\n\");\n" );
+#else
+#error You need to define the DLL constructor for your architecture
+#endif
+    fprintf( outfile, "}\n#endif /* defined(__GNUC__) */\n" );
+
+    fprintf( outfile,
+             "\n#ifdef __GNUC__\n"
+             "static\n"
+             "#endif\n"
+             "void __wine_dbg_%s_init(void)\n"
+             "{\n"
+             "    extern void *__wine_dbg_register( char * const *, int );\n"
+             "    debug_registration = __wine_dbg_register( debug_channels, %d );\n"
+             "}\n", prefix, nr_debug );
+    fprintf( outfile,
+             "\n#ifdef __GNUC__\n"
+             "static\n"
+             "#endif\n"
+             "void __wine_dbg_%s_fini(void)\n"
+             "{\n"
+             "    extern void __wine_dbg_unregister( void* );\n"
+             "    __wine_dbg_unregister( debug_registration );\n"
+             "}\n", prefix );
+
+    free( prefix );
+}
diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c
index 0bba03c..7e4bb4f 100644
--- a/tools/winebuild/utils.c
+++ b/tools/winebuild/utils.c
@@ -151,6 +151,27 @@
     fprintf( outfile, "\n};\n" );
 }
 
+
+/*******************************************************************
+ *         make_c_identifier
+ *
+ * Map a string to a valid C identifier.
+ */
+const char *make_c_identifier( const char *str )
+{
+    static char buffer[256];
+    char *p;
+
+    for (p = buffer; *str && p < buffer+sizeof(buffer)-1; p++, str++)
+    {
+        if (isalnum(*str)) *p = *str;
+        else *p = '_';
+    }
+    *p = 0;
+    return buffer;
+}
+
+
 /*****************************************************************
  *  Function:    get_alignment
  *