Build Win32 resources as .res files and dump them into the .spec.c file.

diff --git a/Make.rules.in b/Make.rules.in
index 644811e..8ff5639 100644
--- a/Make.rules.in
+++ b/Make.rules.in
@@ -16,7 +16,6 @@
 # GLUE         : C sources for which glue code needs to be generated
 # EXTRA_SRCS   : extra source files for make depend
 # EXTRA_OBJS   : extra object files
-# WRCEXTRA     : extra wrc flags (e.g. '-p _SysRes')
 # SUBDIRS      : subdirectories that contain a Makefile
 # EXTRASUBDIRS : subdirectories that do not contain a Makefile
 
@@ -55,10 +54,9 @@
 LINTFLAGS = @LINTFLAGS@
 ALLLINTFLAGS = $(LINTFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL)
 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
-BUILD     = $(TOPOBJDIR)/tools/winebuild/winebuild
+WINEBUILD = $(TOPOBJDIR)/tools/winebuild/winebuild
 MAKEDEP   = $(TOPOBJDIR)/tools/makedep
 WRC       = $(TOPOBJDIR)/tools/wrc/wrc
-WRCFLAGS  = -c -s -p $*
 WMC       = $(TOPOBJDIR)/tools/wmc/wmc
 DLLDIR    = $(TOPOBJDIR)/dlls
 @SET_MAKE@
@@ -81,7 +79,7 @@
                   *.flc *.spec.c *.glue.c y.tab.c y.tab.h lex.yy.c core
 
 OBJS = $(SPEC_SRCS:.spec=.spec.o) $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) \
-       $(ASM_SRCS:.S=.o) $(RC_SRCS:.rc=.o) $(GLUE:.c=.glue.o) $(EXTRA_OBJS)
+       $(ASM_SRCS:.S=.o) $(RC16_SRCS:.rc16=.o) $(GLUE:.c=.glue.o) $(EXTRA_OBJS)
 
 LINTS = $(C_SRCS:.c=.ln)
 
@@ -156,7 +154,7 @@
 
 # Implicit rules
 
-.SUFFIXES: .mc .rc .res .spec .spec.c .spec.o .glue.c
+.SUFFIXES: .mc .rc .rc16 .res .spec .spec.c .spec.o .glue.c
 
 .c.o:
 	$(CC) -c $(ALLCFLAGS) -o $*.o $<
@@ -173,26 +171,17 @@
 .mc.rc:
 	LD_LIBRARY_PATH="$(TOPOBJDIR):$$LD_LIBRARY_PATH" $(WMC) -i -H /dev/null -o $@ $<
 
-.rc.s:
-	$(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) $<
-
-.rc.h:
-	$(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) -nh $<
+.rc16.s:
+	LD_LIBRARY_PATH="$(TOPOBJDIR):$$LD_LIBRARY_PATH" $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -w16 -m -c -p `basename $*` -s $<
 
 .rc.res:
-	$(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) -r $<
-
-.res.s:
-	$(WRC) $(WRCFLAGS) $(WRCEXTRA) -b $<
-
-.res.h:
-	$(WRC) $(WRCFLAGS) $(WRCEXTRA) -bnh $<
+	LD_LIBRARY_PATH="$(TOPOBJDIR):$$LD_LIBRARY_PATH" $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
 
 .spec.spec.c:
-	$(BUILD) @DLLFLAGS@ -o $@ -spec $<
+	LD_LIBRARY_PATH="$(TOPOBJDIR):$$LD_LIBRARY_PATH" $(WINEBUILD) @DLLFLAGS@ -o $@ -spec $<
 
 .c.glue.c:
-	$(BUILD) @DLLFLAGS@ -o $@ -glue $<
+	LD_LIBRARY_PATH="$(TOPOBJDIR):$$LD_LIBRARY_PATH" $(WINEBUILD) @DLLFLAGS@ -o $@ -glue $<
 
 .c.ln:
 	$(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
@@ -205,24 +194,28 @@
 
 # Rule to rebuild the resource compiler
 
-$(WRC) check_wrc:
+$(WRC):
 	cd $(TOPOBJDIR)/tools/wrc && $(MAKE) wrc
 
 # Rule to rebuild the message compiler
 
-$(WMC) check_wmc:
+$(WMC):
 	cd $(TOPOBJDIR)/tools/wmc && $(MAKE) wmc
 
 # Rule to rebuild the 'makedep' program
 
-$(MAKEDEP) check_makedep:
+$(MAKEDEP):
 	cd $(TOPOBJDIR)/tools && $(MAKE) makedep
 
 # Rule to rebuild the 'winebuild' program
 
-$(BUILD) check_winebuild:
+$(WINEBUILD):
 	cd $(TOPOBJDIR)/tools/winebuild && $(MAKE) winebuild
 
+# Rule for main module spec file
+
+$(MODULE).spec.c: $(RC_SRCS:.rc=.res)
+
 # Rules for makefile
 
 Makefile: Makefile.in $(TOPSRCDIR)/configure
@@ -260,8 +253,8 @@
 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
 	cd `dirname $@` && $(MAKE) depend
 
-depend: $(MAKEDEP) $(C_SRCS) $(RC_SRCS) $(EXTRA_SRCS) $(GEN_C_SRCS) $(SUBDIRS:%=%/__depend__)
-	$(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(EXTRA_SRCS) -C. $(GEN_C_SRCS)
+depend: $(MAKEDEP) $(C_SRCS) $(RC_SRCS) $(RC16_SRCS) $(EXTRA_SRCS) $(GEN_C_SRCS) $(SUBDIRS:%=%/__depend__)
+	$(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC16_SRCS) $(EXTRA_SRCS) -C. $(GEN_C_SRCS)
 
 # Rules for cleaning
 
@@ -272,7 +265,7 @@
 	-cd `dirname $@` && $(RM) $(CLEAN_FILES)
 
 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
-	$(RM) $(CLEAN_FILES) $(GEN_C_SRCS) $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.s) $(RC_SRCS:.rc=.h) $(MC_SRCS:.mc=.rc) $(PROGRAMS)
+	$(RM) $(CLEAN_FILES) $(GEN_C_SRCS) $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.res) $(RC16_SRCS:.rc16=.s) $(MC_SRCS:.mc=.rc) $(PROGRAMS)
 
 # Rules for installing
 
@@ -284,11 +277,11 @@
 
 # Misc. rules
 
-$(SPEC_SRCS:.spec=.spec.c): $(BUILD) $(TOPSRCDIR)/include/builtin16.h
+$(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD) $(TOPSRCDIR)/include/builtin16.h
 
-$(GLUE:.c=.glue.c): $(BUILD) $(TOPSRCDIR)/include/builtin16.h
+$(GLUE:.c=.glue.c): $(WINEBUILD) $(TOPSRCDIR)/include/builtin16.h
 
-$(RC_SRCS:.rc=.s): $(WRC)
+$(RC_SRCS:.rc=.res) $(RC16_SRCS:.rc16=.s): $(WRC)
 
 $(MC_SRCS:.mc=.rc): $(WMC)
 
diff --git a/dlls/comctl32/.cvsignore b/dlls/comctl32/.cvsignore
index 5134e4c..6ae9a07 100644
--- a/dlls/comctl32/.cvsignore
+++ b/dlls/comctl32/.cvsignore
@@ -2,4 +2,4 @@
 *.spec.glue.s
 Makefile
 libcomctl32.so.1.0
-rsrc.s
+rsrc.res
diff --git a/dlls/comctl32/Makefile.in b/dlls/comctl32/Makefile.in
index 193ab09..19490e1 100644
--- a/dlls/comctl32/Makefile.in
+++ b/dlls/comctl32/Makefile.in
@@ -4,7 +4,6 @@
 VPATH     = @srcdir@
 MODULE    = comctl32
 SOVERSION = 1.0
-WRCEXTRA  = -s -p$(MODULE)
 IMPORTS   = user32 gdi32 advapi32 kernel32
 
 C_SRCS = \
@@ -40,6 +39,4 @@
 
 @MAKE_DLL_RULES@
 
-all: check_wrc
-
 ### Dependencies:
diff --git a/dlls/comctl32/comctl32.spec b/dlls/comctl32/comctl32.spec
index 6b20abc..2cd1bbe 100644
--- a/dlls/comctl32/comctl32.spec
+++ b/dlls/comctl32/comctl32.spec
@@ -1,7 +1,7 @@
 name	comctl32
 type	win32
 init	COMCTL32_LibMain
-rsrc	comctl32
+rsrc	rsrc.res
 
 import	user32.dll
 import	gdi32.dll
diff --git a/dlls/commdlg/.cvsignore b/dlls/commdlg/.cvsignore
index 1b95709..8231de2 100644
--- a/dlls/commdlg/.cvsignore
+++ b/dlls/commdlg/.cvsignore
@@ -2,4 +2,4 @@
 *.spec.glue.s
 Makefile
 libcomdlg32.so.1.0
-rsrc.s
+rsrc.res
diff --git a/dlls/commdlg/Makefile.in b/dlls/commdlg/Makefile.in
index dcf0854..029ecb9 100644
--- a/dlls/commdlg/Makefile.in
+++ b/dlls/commdlg/Makefile.in
@@ -6,7 +6,6 @@
 SOVERSION = 1.0
 ALTNAMES  = commdlg
 IMPORTS   = shell32 shlwapi comctl32 user32 winspool.drv gdi32 kernel32
-WRCEXTRA  = -s -pcomdlg32
 
 C_SRCS = \
 	cdlg32.c \
@@ -26,6 +25,4 @@
 
 @MAKE_DLL_RULES@
 
-all: check_wrc
-
 ### Dependencies:
diff --git a/dlls/commdlg/comdlg32.spec b/dlls/commdlg/comdlg32.spec
index b4cbeb5..e63af38 100644
--- a/dlls/commdlg/comdlg32.spec
+++ b/dlls/commdlg/comdlg32.spec
@@ -1,7 +1,7 @@
 name	comdlg32
 type	win32
 init	COMDLG32_DllEntryPoint
-rsrc	comdlg32
+rsrc	rsrc.res
 
 import shell32.dll
 import shlwapi.dll
diff --git a/dlls/kernel/.cvsignore b/dlls/kernel/.cvsignore
index 5c16c63..9873ff0 100644
--- a/dlls/kernel/.cvsignore
+++ b/dlls/kernel/.cvsignore
@@ -1,5 +1,5 @@
 *.spec.c
 Makefile
-kernel.s
+kernel.res
 libkernel32.so.1.0
 utthunk.glue.c
diff --git a/dlls/kernel/Makefile.in b/dlls/kernel/Makefile.in
index 7d0ec92..d4f3c42 100644
--- a/dlls/kernel/Makefile.in
+++ b/dlls/kernel/Makefile.in
@@ -34,6 +34,6 @@
 
 @MAKE_DLL_RULES@
 
-depend $(RC_SRCS:.rc=.s): $(MC_SRCS:.mc=.rc)
+depend $(RC_SRCS:.rc=.res): $(MC_SRCS:.mc=.rc)
 
 ### Dependencies:
diff --git a/dlls/kernel/kernel32.spec b/dlls/kernel/kernel32.spec
index 8c01816..9ec0476 100644
--- a/dlls/kernel/kernel32.spec
+++ b/dlls/kernel/kernel32.spec
@@ -1,7 +1,7 @@
 name	kernel32
 type	win32
 init	MAIN_KernelInit
-rsrc	kernel
+rsrc	kernel.res
 
 import  ntdll.dll
 
diff --git a/dlls/msacm/.cvsignore b/dlls/msacm/.cvsignore
index 4be7f8b..4a5bd72 100644
--- a/dlls/msacm/.cvsignore
+++ b/dlls/msacm/.cvsignore
@@ -3,4 +3,4 @@
 Makefile
 libmsacm.so.1.0
 libmsacm32.so.1.0
-msacm.s
+msacm.res
diff --git a/dlls/msacm/msacm32.spec b/dlls/msacm/msacm32.spec
index 13e297c..6c2b782 100644
--- a/dlls/msacm/msacm32.spec
+++ b/dlls/msacm/msacm32.spec
@@ -1,7 +1,7 @@
 name msacm32
 type win32
 init MSACM32_LibMain
-rsrc msacm
+rsrc msacm.res
 
 import winmm.dll
 import user32.dll
diff --git a/dlls/serialui/.cvsignore b/dlls/serialui/.cvsignore
index ce9997d..2492d95 100644
--- a/dlls/serialui/.cvsignore
+++ b/dlls/serialui/.cvsignore
@@ -1,4 +1,4 @@
 Makefile
 libserialui.so.1.0
 serialui.spec.c
-serialui_rc.s
+serialui_rc.res
diff --git a/dlls/serialui/serialui.spec b/dlls/serialui/serialui.spec
index c6d3d06..65014da 100644
--- a/dlls/serialui/serialui.spec
+++ b/dlls/serialui/serialui.spec
@@ -1,7 +1,7 @@
 name	serialui
 type	win32
 init	SERIALUI_LibMain
-rsrc	serialui_rc
+rsrc	serialui_rc.res
 
 import	user32.dll
 import	advapi32.dll
diff --git a/dlls/shell32/.cvsignore b/dlls/shell32/.cvsignore
index a904018..52d8c78 100644
--- a/dlls/shell32/.cvsignore
+++ b/dlls/shell32/.cvsignore
@@ -2,4 +2,4 @@
 *.spec.glue.s
 Makefile
 libshell32.so.1.0
-shres.s
+shres.res
diff --git a/dlls/shell32/Makefile.in b/dlls/shell32/Makefile.in
index 2cdb32e..abe9128 100644
--- a/dlls/shell32/Makefile.in
+++ b/dlls/shell32/Makefile.in
@@ -42,7 +42,5 @@
 
 @MAKE_DLL_RULES@
 
-all: check_wrc
-
 ### Dependencies:
 
diff --git a/dlls/shell32/shell32.spec b/dlls/shell32/shell32.spec
index b508da6..76ed322 100644
--- a/dlls/shell32/shell32.spec
+++ b/dlls/shell32/shell32.spec
@@ -1,7 +1,7 @@
 name	shell32
 type	win32
 init	Shell32LibMain
-rsrc	shres
+rsrc	shres.res
 
 # fixme: avoid this import
 import ole32.dll
diff --git a/dlls/user/Makefile.in b/dlls/user/Makefile.in
index cb7d104..3f51237 100644
--- a/dlls/user/Makefile.in
+++ b/dlls/user/Makefile.in
@@ -4,7 +4,6 @@
 VPATH     = @srcdir@
 MODULE    = user32
 SOVERSION = 1.0
-WRCEXTRA  = -w16 -m
 ALTNAMES  = user keyboard ddeml display mouse
 IMPORTS   = gdi32 advapi32 kernel32
 
@@ -23,26 +22,28 @@
 	thunk.c \
 	user_main.c
 
-RC_SRCS = \
-	disp.rc \
-	mouserc.rc
+RC16_SRCS = \
+	resources/display.rc16 \
+	resources/mouse.rc16
+
+RC_SRCS = resources/user32.rc
 
 GLUE = thunk.c
 
 EXTRA_OBJS = \
 	$(TOPOBJDIR)/controls/controls.o \
-	$(TOPOBJDIR)/resources/resources.o \
 	$(TOPOBJDIR)/windows/windows.o
 
 SUBDIRS = \
 	$(TOPOBJDIR)/controls \
-	$(TOPOBJDIR)/resources \
 	$(TOPOBJDIR)/windows
 
+EXTRASUBDIRS = \
+	resources
+
 @MAKE_DLL_RULES@
 
 $(EXTRA_OBJS): $(TOOLSUBDIRS) dummy
 	@cd `dirname $@` && $(MAKE) `basename $@`
 
 ### Dependencies:
-
diff --git a/dlls/user/display.spec b/dlls/user/display.spec
index d1f0eca..fa03cf1 100644
--- a/dlls/user/display.spec
+++ b/dlls/user/display.spec
@@ -1,7 +1,7 @@
 name	display
 type	win16
 owner	user32
-rsrc	disp
+rsrc	display
 
 1   stub BitBlt
 2   stub ColorInfo
diff --git a/dlls/user/mouse.spec b/dlls/user/mouse.spec
index 06e31f9..132e27e 100644
--- a/dlls/user/mouse.spec
+++ b/dlls/user/mouse.spec
@@ -1,7 +1,7 @@
 name	mouse
 type	win16
 owner	user32
-rsrc	mouserc
+rsrc	mouse
 
 1 pascal16 Inquire(ptr) MOUSE_Inquire
 2 pascal16 Enable(segptr) WIN16_MOUSE_Enable
diff --git a/dlls/user/resources/.cvsignore b/dlls/user/resources/.cvsignore
new file mode 100644
index 0000000..55589a2
--- /dev/null
+++ b/dlls/user/resources/.cvsignore
@@ -0,0 +1,3 @@
+display.s
+mouse.s
+user32.res
diff --git a/dlls/user/user32.spec b/dlls/user/user32.spec
index 4868019..f7461d6 100644
--- a/dlls/user/user32.spec
+++ b/dlls/user/user32.spec
@@ -1,7 +1,7 @@
 name	user32
 type	win32
 init	USER_Init
-rsrc	user32
+rsrc	resources/user32.res
 
 import	gdi32.dll
 import	advapi32.dll
diff --git a/dlls/wineps/.cvsignore b/dlls/wineps/.cvsignore
index 0ebc2b7..20564a9 100644
--- a/dlls/wineps/.cvsignore
+++ b/dlls/wineps/.cvsignore
@@ -1,5 +1,5 @@
 Makefile
 libwineps.so.1.0
-rsrc.s
+rsrc.res
 wineps.spec.c
 wineps16.spec.c
diff --git a/dlls/wineps/Makefile.in b/dlls/wineps/Makefile.in
index 6baacb4..3437aeb 100644
--- a/dlls/wineps/Makefile.in
+++ b/dlls/wineps/Makefile.in
@@ -5,7 +5,6 @@
 MODULE    = wineps
 SOVERSION = 1.0
 ALTNAMES  = wineps16
-WRCEXTRA = -s -pwineps
 IMPORTS   = user32 gdi32 kernel32
 
 C_SRCS = \
diff --git a/dlls/wineps/wineps.spec b/dlls/wineps/wineps.spec
index 6b0ab5c..17053e3 100644
--- a/dlls/wineps/wineps.spec
+++ b/dlls/wineps/wineps.spec
@@ -1,7 +1,7 @@
 name	wineps
 type	win32
 init	PSDRV_Init
-rsrc	wineps
+rsrc	rsrc.res
 
 import	user32.dll
 import	gdi32.dll
diff --git a/dlls/winmm/.cvsignore b/dlls/winmm/.cvsignore
index 9231b6a..f1a6064 100644
--- a/dlls/winmm/.cvsignore
+++ b/dlls/winmm/.cvsignore
@@ -3,4 +3,4 @@
 *.spec.glue.s
 Makefile
 libwinmm.so.1.0
-winmm_res.s
+winmm_res.res
diff --git a/dlls/winmm/Makefile.in b/dlls/winmm/Makefile.in
index e9907b5..5448f63 100644
--- a/dlls/winmm/Makefile.in
+++ b/dlls/winmm/Makefile.in
@@ -36,6 +36,4 @@
 
 @MAKE_DLL_RULES@
 
-all: check_wrc
-
 ### Dependencies:
diff --git a/dlls/winmm/winmm.spec b/dlls/winmm/winmm.spec
index 6844651..08bf866 100644
--- a/dlls/winmm/winmm.spec
+++ b/dlls/winmm/winmm.spec
@@ -1,7 +1,7 @@
 name winmm
 type win32
 init WINMM_LibMain
-rsrc winmm_res
+rsrc winmm_res.res
 
 import user32.dll
 import kernel32.dll
diff --git a/if1632/Makefile.in b/if1632/Makefile.in
index 7e2b875..cb78c74 100644
--- a/if1632/Makefile.in
+++ b/if1632/Makefile.in
@@ -23,7 +23,7 @@
 $(MODULE).o: $(OBJS) Makefile.in $(TOPSRCDIR)/Make.rules.in
 	$(LDCOMBINE) $(OBJS) -o $@
 
-asmrelay.s: $(BUILD)
-	$(BUILD) @DLLFLAGS@ -o $@ -relay
+asmrelay.s: $(WINEBUILD)
+	LD_LIBRARY_PATH="$(TOPOBJDIR):$$LD_LIBRARY_PATH" $(WINEBUILD) @DLLFLAGS@ -o $@ -relay
 
 ### Dependencies:
diff --git a/libtest/.cvsignore b/libtest/.cvsignore
index efb2d9a..e4e523f 100644
--- a/libtest/.cvsignore
+++ b/libtest/.cvsignore
@@ -7,7 +7,7 @@
 hello2.spec.c
 hello3
 hello3.spec.c
-hello3res.s
+hello3res.res
 hello4
 hello4.spec.c
 hello5
diff --git a/libtest/Makefile.in b/libtest/Makefile.in
index 14e38f6..90e8714 100644
--- a/libtest/Makefile.in
+++ b/libtest/Makefile.in
@@ -21,7 +21,7 @@
 RC_SRCS = \
 	hello3res.rc
 
-all: check_wrc $(PROGRAMS)
+all: $(PROGRAMS)
 
 @MAKE_RULES@
 
@@ -34,9 +34,11 @@
 hello2: hello2.o hello2.spec.o
 	$(CC) -o hello2 $+ -L$(DLLDIR) -lgdi32 -lkernel32 -luser32 $(DLL_LINK) $(LIBS)
 
-hello3: hello3.o hello3.spec.o hello3res.o
+hello3: hello3.o hello3.spec.o
 	$(CC) -o hello3 $+  -L$(DLLDIR) -ladvapi32 -lcomctl32 -lcomdlg32 -lgdi32 -lkernel32 -lole32 -lrpcrt4 -lshell32 -lshlwapi -luser32 -lwinspool.drv $(DLL_LINK) $(LIBS)
 
+hello3.spec.c: hello3res.res
+
 hello4: hello4.o hello4.spec.o
 	$(CC) -o hello4 $+ -L$(DLLDIR) -lgdi32 -lkernel32 -luser32 $(DLL_LINK) $(LIBS)
 
diff --git a/libtest/hello3.spec b/libtest/hello3.spec
index 8dd4e4a..67b1097 100644
--- a/libtest/hello3.spec
+++ b/libtest/hello3.spec
@@ -2,4 +2,4 @@
 mode	guiexe
 type	win32
 init	WinMain
-rsrc	hello3res
+rsrc	hello3res.res
diff --git a/programs/avitools/Makefile.in b/programs/avitools/Makefile.in
index e9884a2..2f7e97f 100644
--- a/programs/avitools/Makefile.in
+++ b/programs/avitools/Makefile.in
@@ -12,7 +12,7 @@
 	aviinfo.spec \
 	aviplay.spec
 
-all: check_wrc $(PROGRAMS)
+all: $(PROGRAMS)
 
 @MAKE_RULES@
 
diff --git a/programs/clock/.cvsignore b/programs/clock/.cvsignore
index a315e8e..d535364 100644
--- a/programs/clock/.cvsignore
+++ b/programs/clock/.cvsignore
@@ -1,4 +1,4 @@
 Makefile
 clock
 clock.spec.c
-rsrc.s
+rsrc.res
diff --git a/programs/clock/Makefile.in b/programs/clock/Makefile.in
index 09246de..b2453d5 100644
--- a/programs/clock/Makefile.in
+++ b/programs/clock/Makefile.in
@@ -6,7 +6,6 @@
 MODULE    = none
 PROGRAMS  = clock
 IMPORTS   = advapi32 comctl32 shlwapi shell32 comdlg32 ole32 rpcrt4 winspool.drv user32 gdi32 kernel32
-WRCEXTRA  = -s -p clock
 
 LICENSELANG = En
 
@@ -21,14 +20,15 @@
 
 RC_SRCS = rsrc.rc
 
-all: check_wrc $(PROGRAMS)
+all: $(PROGRAMS)
 
 @MAKE_RULES@
 
-
 clock: $(OBJS)
 	$(CC) -o clock $(OBJS) $(DLL_LINK) $(LIBS)
 
+$(SPEC_SRCS:.spec=.spec.c): $(RC_SRCS:.rc=.res)
+
 install::
 	$(INSTALL_PROGRAM) clock $(bindir)/clock
 
diff --git a/programs/clock/clock.spec b/programs/clock/clock.spec
index 2e9df98..394fd04 100644
--- a/programs/clock/clock.spec
+++ b/programs/clock/clock.spec
@@ -2,4 +2,4 @@
 mode	guiexe
 type	win32
 init	WinMain
-rsrc	clock
+rsrc	rsrc.res
diff --git a/programs/cmdlgtst/.cvsignore b/programs/cmdlgtst/.cvsignore
index 90d8e1b..29bc66a 100644
--- a/programs/cmdlgtst/.cvsignore
+++ b/programs/cmdlgtst/.cvsignore
@@ -1,4 +1,4 @@
 Makefile
-cmdlgr.s
+cmdlgr.res
 cmdlgtst
 cmdlgtst.spec.c
diff --git a/programs/cmdlgtst/Makefile.in b/programs/cmdlgtst/Makefile.in
index 7964d13..1e023b2 100644
--- a/programs/cmdlgtst/Makefile.in
+++ b/programs/cmdlgtst/Makefile.in
@@ -6,7 +6,6 @@
 MODULE    = none
 PROGRAMS  = cmdlgtst
 IMPORTS   = advapi32 comctl32 comdlg32 shell32 shlwapi ole32 rpcrt4 winspool.drv user32 gdi32 kernel32
-WRCEXTRA  = -s -p cmdlgtst
 
 C_SRCS = \
 	cmdlgtst.c
@@ -17,13 +16,15 @@
 RC_SRCS = \
 	cmdlgr.rc
 
-all: check_wrc $(PROGRAMS)
+all: $(PROGRAMS)
 
 @MAKE_RULES@
 
 cmdlgtst: $(OBJS)
 	$(CC) -o cmdlgtst $(OBJS) $(DLL_LINK) $(LIBS)
 
+$(SPEC_SRCS:.spec=.spec.c): $(RC_SRCS:.rc=.res)
+
 install::
 	$(INSTALL_PROGRAM) cmdlgtst $(bindir)/cmdlgtst
 
diff --git a/programs/cmdlgtst/cmdlgtst.spec b/programs/cmdlgtst/cmdlgtst.spec
index 6f37900..eb79a65 100644
--- a/programs/cmdlgtst/cmdlgtst.spec
+++ b/programs/cmdlgtst/cmdlgtst.spec
@@ -2,5 +2,5 @@
 mode	guiexe
 type	win32
 init	WinMain
-rsrc	cmdlgtst
+rsrc	cmdlgr.res
 import	comdlg32.dll
diff --git a/programs/notepad/.cvsignore b/programs/notepad/.cvsignore
index 576cdea..46fda4a 100644
--- a/programs/notepad/.cvsignore
+++ b/programs/notepad/.cvsignore
@@ -1,4 +1,4 @@
 Makefile
 notepad
 notepad.spec.c
-rsrc.s
+rsrc.res
diff --git a/programs/notepad/Makefile.in b/programs/notepad/Makefile.in
index 9766259..d7cda1e 100644
--- a/programs/notepad/Makefile.in
+++ b/programs/notepad/Makefile.in
@@ -6,7 +6,6 @@
 MODULE    = none
 PROGRAMS  = notepad
 IMPORTS   = advapi32 comctl32 shlwapi shell32 ole32 rpcrt4 comdlg32 winspool.drv user32 gdi32 kernel32
-WRCEXTRA  = -s -p notepad
 
 LICENSELANG = En
 
@@ -22,13 +21,15 @@
 
 RC_SRCS = rsrc.rc
 
-all: check_wrc $(PROGRAMS)
+all: $(PROGRAMS)
 
 @MAKE_RULES@
 
 notepad: $(OBJS)
 	$(CC) -o notepad $(OBJS) $(DLL_LINK) $(LIBS)
 
+$(SPEC_SRCS:.spec=.spec.c): $(RC_SRCS:.rc=.res)
+
 install::
 	$(INSTALL_PROGRAM) notepad $(bindir)/notepad
 
diff --git a/programs/notepad/notepad.spec b/programs/notepad/notepad.spec
index a5ee592..c200259 100644
--- a/programs/notepad/notepad.spec
+++ b/programs/notepad/notepad.spec
@@ -2,5 +2,5 @@
 mode	guiexe
 type	win32
 init	WinMain
-rsrc	notepad
+rsrc	rsrc.res
 import	comdlg32.dll
diff --git a/programs/progman/.cvsignore b/programs/progman/.cvsignore
index 447481c..8716df3 100644
--- a/programs/progman/.cvsignore
+++ b/programs/progman/.cvsignore
@@ -1,4 +1,4 @@
 Makefile
 progman
 progman.spec.c
-rsrc.s
+rsrc.res
diff --git a/programs/progman/Makefile.in b/programs/progman/Makefile.in
index 6d12e9b..98b4264 100644
--- a/programs/progman/Makefile.in
+++ b/programs/progman/Makefile.in
@@ -6,7 +6,6 @@
 MODULE    = none
 PROGRAMS  = progman
 IMPORTS   = shlwapi shell32 comdlg32 ole32 rpcrt4 winspool.drv user32 gdi32 kernel32
-WRCEXTRA  = -s -p progman
 
 LICENSELANG = En
 
@@ -24,13 +23,15 @@
 
 RC_SRCS = rsrc.rc
 
-all: check_wrc $(PROGRAMS)
+all: $(PROGRAMS)
 
 @MAKE_RULES@
 
 progman: $(OBJS)
 	$(CC) -o progman $(OBJS) $(DLL_LINK) $(LIBS)
 
+$(SPEC_SRCS:.spec=.spec.c): $(RC_SRCS:.rc=.res)
+
 install::
 	$(INSTALL_PROGRAM) progman $(bindir)/progman
 
diff --git a/programs/progman/progman.spec b/programs/progman/progman.spec
index 5e4c692..a85ede3 100644
--- a/programs/progman/progman.spec
+++ b/programs/progman/progman.spec
@@ -2,5 +2,5 @@
 mode	guiexe
 type	win32
 init	WinMain
-rsrc	progman
+rsrc	rsrc.res
 import	comdlg32.dll
diff --git a/programs/uninstaller/.cvsignore b/programs/uninstaller/.cvsignore
index 664cfff..43799b4 100644
--- a/programs/uninstaller/.cvsignore
+++ b/programs/uninstaller/.cvsignore
@@ -1,4 +1,4 @@
 Makefile
-rsrc.s
+rsrc.res
 uninstaller
 uninstaller.spec.c
diff --git a/programs/uninstaller/Makefile.in b/programs/uninstaller/Makefile.in
index 99b1564..62e0083 100644
--- a/programs/uninstaller/Makefile.in
+++ b/programs/uninstaller/Makefile.in
@@ -5,7 +5,6 @@
 VPATH     = @srcdir@
 MODULE    = none
 PROGRAMS  = uninstaller
-WRCEXTRA  = -s -p uninstaller
 IMPORTS   = user32 gdi32 kernel32
 
 LICENSELANG = En
@@ -17,13 +16,15 @@
 
 RC_SRCS = rsrc.rc
 
-all: check_wrc $(PROGRAMS)
+all: $(PROGRAMS)
 
 @MAKE_RULES@
 
 uninstaller: $(OBJS)
 	$(CC) -o uninstaller $(OBJS) $(DLL_LINK) $(LIBS)
 
+$(SPEC_SRCS:.spec=.spec.c): $(RC_SRCS:.rc=.res)
+
 install::
 	$(INSTALL_PROGRAM) uninstaller $(bindir)/uninstaller
 
diff --git a/programs/uninstaller/uninstaller.spec b/programs/uninstaller/uninstaller.spec
index 4763ae8..7473669 100644
--- a/programs/uninstaller/uninstaller.spec
+++ b/programs/uninstaller/uninstaller.spec
@@ -2,4 +2,4 @@
 mode	guiexe
 type	win32
 init	WinMain
-rsrc	uninstaller
+rsrc	rsrc.res
diff --git a/programs/view/.cvsignore b/programs/view/.cvsignore
index e7bc3b6..7deec69 100644
--- a/programs/view/.cvsignore
+++ b/programs/view/.cvsignore
@@ -1,4 +1,4 @@
 Makefile
 view
 view.spec.c
-viewrc.s
+viewrc.res
diff --git a/programs/view/Makefile.in b/programs/view/Makefile.in
index ddba930..4f4c4fc 100644
--- a/programs/view/Makefile.in
+++ b/programs/view/Makefile.in
@@ -6,7 +6,6 @@
 MODULE    = none
 PROGRAMS  = view
 IMPORTS   = advapi32 comctl32 comdlg32 shell32 shlwapi ole32 rpcrt4 winspool.drv user32 gdi32 kernel32
-WRCEXTRA  = -s -p view
 
 C_SRCS = \
 	init.c \
@@ -19,13 +18,15 @@
 RC_SRCS = \
 	viewrc.rc
 
-all: check_wrc $(PROGRAMS)
+all: $(PROGRAMS)
 
 @MAKE_RULES@
 
 view: $(OBJS)
 	$(CC) -o view $(OBJS) $(DLL_LINK) $(LIBS)
 
+$(SPEC_SRCS:.spec=.spec.c): $(RC_SRCS:.rc=.res)
+
 install::
 	$(INSTALL_PROGRAM) view $(bindir)/view
 
diff --git a/programs/view/view.spec b/programs/view/view.spec
index 34d2915..8ffc6ec 100644
--- a/programs/view/view.spec
+++ b/programs/view/view.spec
@@ -2,4 +2,4 @@
 mode	guiexe
 type	win32
 init	WinMain
-rsrc	view
+rsrc	viewrc.res
diff --git a/programs/wcmd/.cvsignore b/programs/wcmd/.cvsignore
index d588e37..06b6766 100644
--- a/programs/wcmd/.cvsignore
+++ b/programs/wcmd/.cvsignore
@@ -1,4 +1,4 @@
 Makefile
 wcmd
 wcmd.spec.c
-wcmdrc.s
+wcmdrc.res
diff --git a/programs/wcmd/Makefile.in b/programs/wcmd/Makefile.in
index 87812b2..2b960e0 100644
--- a/programs/wcmd/Makefile.in
+++ b/programs/wcmd/Makefile.in
@@ -6,7 +6,6 @@
 MODULE    = none
 PROGRAMS  = wcmd
 IMPORTS   = user32 gdi32 kernel32
-WRCEXTRA  = -s -p wcmd
 
 C_SRCS = \
 	batch.c \
@@ -20,10 +19,12 @@
 RC_SRCS = \
 	wcmdrc.rc
 
-all: check_wrc $(PROGRAMS)
+all: $(PROGRAMS)
 
 @MAKE_RULES@
 
+$(SPEC_SRCS:.spec=.spec.c): $(RC_SRCS:.rc=.res)
+
 wcmd: $(OBJS)
 	$(CC) -o wcmd $(OBJS) $(DLL_LINK) $(LIBS)
 
diff --git a/programs/wcmd/wcmd.spec b/programs/wcmd/wcmd.spec
index 3cffcff..60cb6bb 100644
--- a/programs/wcmd/wcmd.spec
+++ b/programs/wcmd/wcmd.spec
@@ -1,5 +1,5 @@
 name	wcmd
 mode    cuiexe
 type	win32
-rsrc	wcmd
 init	wine_main
+rsrc	wcmdrc.res
diff --git a/programs/winemine/.cvsignore b/programs/winemine/.cvsignore
index 5315ee1..f16473e 100644
--- a/programs/winemine/.cvsignore
+++ b/programs/winemine/.cvsignore
@@ -1,4 +1,4 @@
 Makefile
-rsrc.s
+rsrc.res
 winemine
 winemine.spec.c
diff --git a/programs/winemine/Makefile.in b/programs/winemine/Makefile.in
index 5934a75..c9bc2d1 100644
--- a/programs/winemine/Makefile.in
+++ b/programs/winemine/Makefile.in
@@ -5,7 +5,6 @@
 VPATH     = @srcdir@
 MODULE    = none
 PROGRAMS  = winemine
-WRCEXTRA  = -s -p winemine
 IMPORTS   = user32 gdi32 kernel32
 
 LICENSELANG = En
@@ -14,18 +13,19 @@
 	main.c \
         dialog.c
 
-
 SPEC_SRCS = winemine.spec
 
 RC_SRCS = rsrc.rc
 
-all: check_wrc $(PROGRAMS)
+all: $(PROGRAMS)
 
 @MAKE_RULES@
 
 winemine: $(OBJS)
 	$(CC) -o winemine $(OBJS) $(DLL_LINK) $(LIBS)
 
+$(SPEC_SRCS:.spec=.spec.c): $(RC_SRCS:.rc=.res)
+
 install::
 	$(INSTALL_PROGRAM) winemine $(bindir)/winemine
 
diff --git a/programs/winemine/winemine.spec b/programs/winemine/winemine.spec
index 6425621..0f75699 100644
--- a/programs/winemine/winemine.spec
+++ b/programs/winemine/winemine.spec
@@ -2,4 +2,4 @@
 mode	guiexe
 type	win32
 init	WinMain
-rsrc	winemine
+rsrc	rsrc.res
diff --git a/programs/winhelp/.cvsignore b/programs/winhelp/.cvsignore
index 3954058..35d2256 100644
--- a/programs/winhelp/.cvsignore
+++ b/programs/winhelp/.cvsignore
@@ -1,7 +1,7 @@
 Makefile
 hlp2sgml
 lex.yy.c
-rsrc.s
+rsrc.res
 winhelp
 winhelp.spec.c
 y.tab.c
diff --git a/programs/winhelp/Makefile.in b/programs/winhelp/Makefile.in
index d7ebbbf..831c7d7 100644
--- a/programs/winhelp/Makefile.in
+++ b/programs/winhelp/Makefile.in
@@ -6,7 +6,6 @@
 MODULE    = none
 PROGRAMS  = winhelp hlp2sgml
 IMPORTS   = advapi32 comctl32 shlwapi shell32 ole32 rpcrt4 comdlg32 winspool.drv user32 gdi32 kernel32
-WRCEXTRA  = -s -p winhelp
 
 C_SRCS = \
 	winhelp.c \
@@ -21,12 +20,14 @@
 
 RC_SRCS = rsrc.rc
 
-all: check_wrc $(PROGRAMS)
+all: $(PROGRAMS)
 
 depend: y.tab.h
 
 @MAKE_RULES@
 
+$(SPEC_SRCS:.spec=.spec.c): $(RC_SRCS:.rc=.res)
+
 winhelp: $(OBJS)
 	$(CC) -o winhelp $(OBJS) $(DLL_LINK) $(LIBS)
 
diff --git a/programs/winhelp/winhelp.spec b/programs/winhelp/winhelp.spec
index 81efffa..23b5798 100644
--- a/programs/winhelp/winhelp.spec
+++ b/programs/winhelp/winhelp.spec
@@ -2,5 +2,5 @@
 mode	guiexe
 type	win32
 init	WinMain
-rsrc	winhelp
+rsrc	rsrc.res
 import	comdlg32.dll
diff --git a/relay32/builtin32.c b/relay32/builtin32.c
index 233eafd..cda826d 100644
--- a/relay32/builtin32.c
+++ b/relay32/builtin32.c
@@ -116,6 +116,28 @@
 
 
 /***********************************************************************
+ *           fixup_resources
+ */
+static void fixup_resources( IMAGE_RESOURCE_DIRECTORY *dir, char *root, void *base )
+{
+    IMAGE_RESOURCE_DIRECTORY_ENTRY *entry;
+    int i;
+
+    entry = (IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
+    for (i = 0; i < dir->NumberOfNamedEntries + dir->NumberOfIdEntries; i++, entry++)
+    {
+        void *ptr = root + entry->u2.s.OffsetToDirectory;
+        if (entry->u2.s.DataIsDirectory) fixup_resources( ptr, root, base );
+        else
+        {
+            IMAGE_RESOURCE_DATA_ENTRY *data = ptr;
+            fixup_rva_ptrs( &data->OffsetToData, base, 1 );
+        }
+    }
+}
+
+
+/***********************************************************************
  *           BUILTIN32_DoLoadImage
  *
  * Load a built-in Win32 module. Helper function for BUILTIN32_LoadImage.
@@ -126,7 +148,7 @@
     IMAGE_DOS_HEADER *dos;
     IMAGE_NT_HEADERS *nt;
     IMAGE_SECTION_HEADER *sec;
-    INT i, size, nb_sections;
+    INT size, nb_sections;
     BYTE *addr, *code_start, *data_start;
     int page_size = VIRTUAL_GetPageSize();
 
@@ -213,13 +235,11 @@
     /* Build the resource directory */
 
     dir = &nt->OptionalHeader.DataDirectory[IMAGE_FILE_RESOURCE_DIRECTORY];
-    if (dir->VirtualAddress)
+    if (dir->Size)
     {
-        BUILTIN32_RESOURCE *rsrc = (BUILTIN32_RESOURCE *)dir->VirtualAddress;
-        IMAGE_RESOURCE_DATA_ENTRY *rdep = rsrc->entries;
-        dir->VirtualAddress = (BYTE *)rsrc->restab - addr;
-        dir->Size = rsrc->restabsize;
-        for (i = 0; i < rsrc->nresources; i++) rdep[i].OffsetToData += dir->VirtualAddress;
+        void *ptr = (void *)dir->VirtualAddress;
+        fixup_rva_ptrs( &dir->VirtualAddress, addr, 1 );
+        fixup_resources( ptr, ptr, addr );
     }
 
     /* Build the export directory */
diff --git a/tools/makedep.c b/tools/makedep.c
index 11cbc8d..4c253e2 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -265,27 +265,26 @@
     char *ext = strrchr( obj, '.' );
     if (ext)
     {
-        if (!strcmp( ext, ".y" ))  /* yacc file */
+        *ext++ = 0;
+        if (!strcmp( ext, "y" ))  /* yacc file */
         {
-            fprintf( file, "y.tab.o: y.tab.c" );
-            *column += 16;
+            *column += fprintf( file, "y.tab.o: y.tab.c" );
         }
-        else if (!strcmp( ext, ".l" ))  /* lex file */
+        else if (!strcmp( ext, "l" ))  /* lex file */
         {
-            fprintf( file, "lex.yy.o: lex.yy.c" );
-            *column += 18;
+            *column += fprintf( file, "lex.yy.o: lex.yy.c" );
         }
-        else if (!strcmp( ext, ".rc" ))  /* resource file */
+        else if (!strcmp( ext, "rc" ))  /* resource file */
         {
-            strcpy( ext, ".s" );
-            fprintf( file, "%s: %s", obj, pFile->filename );
-            *column += strlen(obj) + strlen(pFile->filename);
+            *column += fprintf( file, "%s.res: %s", obj, pFile->filename );
+        }
+        else if (!strcmp( ext, "rc16" ))  /* Win16 resource file */
+        {
+            *column += fprintf( file, "%s.s: %s", obj, pFile->filename );
         }
         else
         {
-            strcpy( ext, ".o" );
-            fprintf( file, "%s: %s", obj, pFile->filename );
-            *column += strlen(obj) + strlen(pFile->filename) + 2;
+            *column += fprintf( file, "%s.o: %s", obj, pFile->filename );
         }
     }
     free( obj );