Make unicode.o into a separate ELF library so that we can use it from
the wineserver too.

diff --git a/Make.rules.in b/Make.rules.in
index 19e9e49..6a27957 100644
--- a/Make.rules.in
+++ b/Make.rules.in
@@ -173,7 +173,7 @@
 	$(CC) -c -o $*.o $<  
 
 .mc.rc:
-	$(WMC) -i -H /dev/null -o $@ $<
+	LD_LIBRARY_PATH="$(TOPOBJDIR):$$LD_LIBRARY_PATH" $(WMC) -i -H /dev/null -o $@ $<
 
 .rc.s:
 	$(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) $<
diff --git a/Makefile.in b/Makefile.in
index 58d57e0..1f529eb 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -32,6 +32,10 @@
 LIBPROGRAMS = \
 	debugger/winedbg
 
+# Libraries (not dlls) to build
+LIBRARIES = \
+	unicode/libwine_unicode.$(LIBEXT)
+
 # Sub-directories to run make depend/clean into
 SUBDIRS = \
 	console \
@@ -75,7 +79,8 @@
 	documentation \
 	include \
 	server \
-	tools
+	tools \
+	unicode
 
 LIBOBJS = \
 	controls/controls.o \
@@ -98,7 +103,6 @@
 	relay32/relay32.o \
 	resources/resources.o \
 	scheduler/scheduler.o \
-	unicode/unicode.o \
 	win32/win32.o \
 	windows/windows.o
 
@@ -126,20 +130,20 @@
 	@echo $? is newer than 'Make.rules', please rerun ./configure!
 	@exit 1
 
-wine: lib$(MODULE).$(LIBEXT) $(DLLDIR) $(EMUOBJS)
+wine: libwine.$(LIBEXT) libwine_unicode.$(LIBEXT) dlls $(EMUOBJS)
 	$(CC) -o wine $(EMUOBJS) $(DLL_LINK) $(LIBS)
 
 llib-lwine.ln : $(LIBLINTS)
 	$(LINT) $(ALLLINTFLAGS) -owine $(LIBLINTS)
 
-install_so: lib$(MODULE).so.$(SOVERSION)
+install_so: libwine.so.$(SOVERSION)
 	[ -d $(libdir) ] || $(MKDIR) $(libdir)
-	$(INSTALL_PROGRAM) lib$(MODULE).so.$(SOVERSION) $(libdir)/lib$(MODULE).so.$(SOVERSION)
-	cd $(libdir) && $(RM) lib$(MODULE).so && $(LN_S) lib$(MODULE).so.$(SOVERSION) lib$(MODULE).so
+	$(INSTALL_PROGRAM) libwine.so.$(SOVERSION) $(libdir)/libwine.so.$(SOVERSION)
+	cd $(libdir) && $(RM) libwine.so && $(LN_S) libwine.so.$(SOVERSION) libwine.so
 
-install_a: lib$(MODULE).a
+install_a: libwine.a
 	[ -d $(libdir) ] || $(MKDIR) $(libdir)
-	$(INSTALL_DATA) lib$(MODULE).a $(libdir)/lib$(MODULE).a
+	$(INSTALL_DATA) libwine.a $(libdir)/libwine.a
 
 install:: all $(LIBEXT:%=install_%) $(INSTALLSUBDIRS:%=%/__install__)
 	[ -d $(bindir) ] || $(MKDIR) $(bindir)
@@ -151,29 +155,36 @@
 	cd $(libdir) && $(RM) libwine.a libwine.so libwine.so.$(SOVERSION)
 	cd $(bindir) && $(RM) wine dosmod
 
-lib$(MODULE).so.$(SOVERSION): $(OBJS) Makefile.in Make.rules.in
+libwine.so.$(SOVERSION): $(OBJS) Makefile.in Make.rules.in
 	$(LDSHARED) $(OBJS) -o $@
 
-lib$(MODULE).so: lib$(MODULE).so.$(SOVERSION)
-	$(RM) $@ && $(LN_S) lib$(MODULE).so.$(SOVERSION) $@
+libwine.so: libwine.so.$(SOVERSION)
+	$(RM) $@ && $(LN_S) libwine.so.$(SOVERSION) $@
 
-lib$(MODULE).a: $(OBJS) Makefile.in Make.rules.in
+libwine.a: $(OBJS) Makefile.in Make.rules.in
 	$(RM) $@
 	$(AR) $@ $(OBJS)
 	$(RANLIB) $@
 
-$(EMUOBJS) $(LIBOBJS) $(DLLOBJS) $(PROGRAMS) $(LIBPROGRAMS): dummy
+$(EMUOBJS) $(LIBOBJS) $(DLLOBJS) $(PROGRAMS) $(LIBPROGRAMS) $(LIBRARIES): dummy
 	@cd `dirname $@` && $(MAKE) `basename $@`
 
-$(EMUOBJS) $(LIBOBJS) $(DLLOBJS) $(PROGRAMS) $(DLLDIR): tools
+# Dependencies between directories
 
-$(LIBPROGRAMS): tools dlls lib$(MODULE).$(LIBEXT)
+$(EMUOBJS) $(LIBOBJS) $(DLLOBJS) $(PROGRAMS) dlls: tools
+
+$(LIBPROGRAMS): tools dlls libwine.$(LIBEXT) libwine_unicode.$(LIBEXT)
+
+server tools dlls: libwine_unicode.$(LIBEXT)
+
+libwine_unicode.$(LIBEXT): unicode/libwine_unicode.$(LIBEXT)
+	$(RM) $@ && $(LN_S) unicode/libwine_unicode.$(LIBEXT) $@
 
 $(LIBLINTS) $(EMULINTS): dummy
 	@cd `dirname $@` && $(MAKE) lint
 
 checklink::
-	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c -L. -lwine $(LIBS) && $(RM) checklink
+	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c -L. -lwine -lwine_unicode $(LIBS) && $(RM) checklink
 
 install_programs: dummy
 	@cd programs && $(MAKE) install
@@ -196,7 +207,7 @@
 	for i in $(SUBDIRS); do (cd $$i && $(MAKE) html); done
 
 clean::
-	$(RM) wine libwine.so.1.0 TAGS
+	$(RM) wine libwine.so.$(SOVERSION) TAGS
 
 distclean: clean
 	$(RM) config.* Make.rules dlls/Makedll.rules include/config.h documentation/wine.man documentation/wine.conf.man
diff --git a/configure b/configure
index 293d067..c182e46 100755
--- a/configure
+++ b/configure
@@ -4553,9 +4553,9 @@
 
 if test "$LIBEXT" = "so"; then
     DLLFLAGS="-fPIC"
-    DLL_LINK="-L\$(DLLDIR) \$(IMPORTS:%=-l%) -L\$(TOPOBJDIR) -lwine"
+    DLL_LINK="-L\$(DLLDIR) \$(IMPORTS:%=-l%) -L\$(TOPOBJDIR) -lwine -lwine_unicode"
 else
-    DLL_LINK="-L\$(DLLDIR) \$(DLLS:%=-l%) -L\$(TOPOBJDIR) -lwine \$(X_LIBS) \$(XLIB)"
+    DLL_LINK="-L\$(DLLDIR) \$(DLLS:%=-l%) -L\$(TOPOBJDIR) -lwine -lwine_unicode \$(X_LIBS) \$(XLIB)"
     echo $ac_n "checking whether the linker supports --[no]-whole-archive (Linux)""... $ac_c" 1>&6
 echo "configure:4561: checking whether the linker supports --[no]-whole-archive (Linux)" >&5
 if eval "test \"`echo '$''{'ac_cv_c_whole_archive'+set}'`\" = set"; then
diff --git a/configure.in b/configure.in
index 0b0a53e..57113e4 100644
--- a/configure.in
+++ b/configure.in
@@ -507,9 +507,9 @@
 
 if test "$LIBEXT" = "so"; then
     DLLFLAGS="-fPIC"
-    DLL_LINK="-L\$(DLLDIR) \$(IMPORTS:%=-l%) -L\$(TOPOBJDIR) -lwine"
+    DLL_LINK="-L\$(DLLDIR) \$(IMPORTS:%=-l%) -L\$(TOPOBJDIR) -lwine -lwine_unicode"
 else
-    DLL_LINK="-L\$(DLLDIR) \$(DLLS:%=-l%) -L\$(TOPOBJDIR) -lwine \$(X_LIBS) \$(XLIB)"
+    DLL_LINK="-L\$(DLLDIR) \$(DLLS:%=-l%) -L\$(TOPOBJDIR) -lwine -lwine_unicode \$(X_LIBS) \$(XLIB)"
     AC_CACHE_CHECK([whether the linker supports --[[no]]-whole-archive (Linux)],
  	           ac_cv_c_whole_archive,
             [saved_cflags=$CFLAGS
diff --git a/dlls/Makedll.rules.in b/dlls/Makedll.rules.in
index ce99535..0f45318 100644
--- a/dlls/Makedll.rules.in
+++ b/dlls/Makedll.rules.in
@@ -45,7 +45,7 @@
 IMPORTLIBS = $(IMPORTS:%=$(DLLDIR)/lib%.$(LIBEXT))
 
 checklink:: lib$(MODULE).$(LIBEXT) $(IMPORTLIBS)
-	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c -L. -l$(MODULE) -L$(TOPOBJDIR) -lwine $(EXTRALIBS) $(LIBS) && $(RM) checklink
+	$(CC) -o checklink $(TOPSRCDIR)/library/checklink.c -L. -l$(MODULE) -L$(TOPOBJDIR) -lwine -lwine_unicode $(EXTRALIBS) $(LIBS) && $(RM) checklink
 
 $(IMPORTLIBS): dummy
 	@cd $(DLLDIR) && $(MAKE) `basename $@`
diff --git a/server/Makefile.in b/server/Makefile.in
index 472e8f1..12fd8de 100644
--- a/server/Makefile.in
+++ b/server/Makefile.in
@@ -42,7 +42,7 @@
 @MAKE_RULES@
 
 wineserver: $(OBJS)
-	$(CC) -o $(PROGRAMS) $(OBJS) $(LIBS)
+	$(CC) -o $(PROGRAMS) $(OBJS) -L$(TOPOBJDIR) -lwine_unicode $(LIBS)
 
 install:: $(PROGRAMS)
 	[ -d $(bindir) ] || $(MKDIR) $(bindir)
diff --git a/server/atom.c b/server/atom.c
index 8dd6f67..1e4652c 100644
--- a/server/atom.c
+++ b/server/atom.c
@@ -144,7 +144,7 @@
 {
     int i;
     WCHAR hash = 0;
-    for (i = 0; str[i]; i++) hash ^= towupper(str[i]) + i;
+    for (i = 0; str[i]; i++) hash ^= toupperW(str[i]) + i;
     return hash % table->entries_count;
 }
 
diff --git a/server/registry.c b/server/registry.c
index f22ab3c..bd12532 100644
--- a/server/registry.c
+++ b/server/registry.c
@@ -11,6 +11,7 @@
  */
 
 #include <assert.h>
+#include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <limits.h>
diff --git a/server/unicode.c b/server/unicode.c
index 3ba4e03..8928077 100644
--- a/server/unicode.c
+++ b/server/unicode.c
@@ -4,6 +4,7 @@
  * Copyright (C) 1999 Alexandre Julliard
  */
 
+#include <ctype.h>
 #include <stdio.h>
 
 #include "unicode.h"
diff --git a/server/unicode.h b/server/unicode.h
index 6479761..2ef1bae 100644
--- a/server/unicode.h
+++ b/server/unicode.h
@@ -11,47 +11,10 @@
 #error This file can only be used in the Wine server
 #endif
 
-#include "config.h"
-
-#include <ctype.h>
-#ifdef HAVE_WCTYPE_H
-#include <wctype.h>
-#endif
-
 #include "windef.h"
+#include "wine/unicode.h"
 #include "object.h"
 
-static inline size_t strlenW( const WCHAR *str )
-{
-    const WCHAR *s = str;
-    while (*s) s++;
-    return s - str;
-}
-
-static inline int strcmpW( const WCHAR *str1, const WCHAR *str2 ) 
-{
-    while (*str1 && (*str1 == *str2)) { str1++; str2++; }
-    return *str1 - *str2;
-}
-
-#ifndef HAVE_WCTYPE_H
-/* FIXME */
-#define towupper(ch) (HIBYTE(ch) ? ch : (WCHAR)toupper(LOBYTE(ch)))
-#endif
-
-static inline int strcmpiW( const WCHAR *str1, const WCHAR *str2 ) 
-{
-    while (*str1 && (towupper(*str1) == towupper(*str2))) { str1++; str2++; }
-    return towupper(*str1) - towupper(*str2);
-}
-
-static inline WCHAR *strcpyW( WCHAR *dst, const WCHAR *src ) 
-{
-    const WCHAR *ret = dst;
-    while ((*dst++ = *src++));
-    return (WCHAR *)ret;
-}
-
 static inline WCHAR *strdupW( const WCHAR *str )
 {
     size_t len = (strlenW(str) + 1) * sizeof(WCHAR);
diff --git a/tools/wmc/Makefile.in b/tools/wmc/Makefile.in
index bd75cb8..9b122b2 100644
--- a/tools/wmc/Makefile.in
+++ b/tools/wmc/Makefile.in
@@ -4,6 +4,7 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 YACCOPT   = #-v
+LIBEXT    = @LIBEXT@
 
 PROGRAMS = wmc
 MODULE   = none
@@ -18,17 +19,17 @@
 EXTRA_SRCS = mcy.y
 EXTRA_OBJS = y.tab.o
 
-all: check_unicode $(PROGRAMS)
+all: $(PROGRAMS)
 
 depend mcl.o: y.tab.h
 
 @MAKE_RULES@
 
-wmc: $(OBJS) $(TOPOBJDIR)/unicode/unicode.o
-	$(CC) $(CFLAGS) -o wmc $(OBJS) $(TOPOBJDIR)/unicode/unicode.o $(LEXLIB)
+wmc: $(OBJS) $(TOPOBJDIR)/libwine_unicode.$(LIBEXT)
+	$(CC) $(CFLAGS) -o wmc $(OBJS) -L$(TOPOBJDIR) -lwine_unicode $(LEXLIB)
 
-$(TOPOBJDIR)/unicode/unicode.o check_unicode:
-	cd $(TOPOBJDIR)/unicode && $(MAKE)
+$(TOPOBJDIR)/libwine_unicode.$(LIBEXT):
+	cd $(TOPOBJDIR) && $(MAKE) libwine_unicode.$(LIBEXT)
 
 y.tab.c y.tab.h: mcy.y
 	$(YACC) $(YACCOPT) -d -t $(SRCDIR)/mcy.y
diff --git a/unicode/.cvsignore b/unicode/.cvsignore
index f3c7a7c..da633d4 100644
--- a/unicode/.cvsignore
+++ b/unicode/.cvsignore
@@ -1 +1,2 @@
 Makefile
+libwine_unicode.so.1.0
diff --git a/unicode/Makefile.in b/unicode/Makefile.in
index ca840f7..10be462 100644
--- a/unicode/Makefile.in
+++ b/unicode/Makefile.in
@@ -3,7 +3,11 @@
 TOPOBJDIR = ..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
-MODULE    = unicode
+LIBEXT    = @LIBEXT@
+LDSHARED  = @LDSHARED@
+MODULE    = none
+SOVERSION = 1.0
+SONAME    = libwine_unicode.so
 
 CODEPAGES = \
 	037 \
@@ -69,8 +73,36 @@
 	wctomb.c \
 	$(CODEPAGES:%=c_%.c)
 
-all: $(MODULE).o
+all: libwine_unicode.$(LIBEXT)
 
 @MAKE_RULES@
 
+libwine_unicode.so.$(SOVERSION): $(OBJS)
+	$(LDSHARED) $(OBJS) -o $@
+
+libwine_unicode.so: libwine_unicode.so.$(SOVERSION)
+	$(RM) $@ && $(LN_S) libwine_unicode.so.$(SOVERSION) $@
+
+libwine_unicode.a: $(OBJS)
+	$(RM) $@
+	$(AR) $@ $(OBJS)
+	$(RANLIB) $@
+
+install_so: libwine_unicode.so.$(SOVERSION)
+	[ -d $(libdir) ] || $(MKDIR) $(libdir)
+	$(INSTALL_PROGRAM) libwine_unicode.so.$(SOVERSION) $(libdir)/libwine_unicode.so.$(SOVERSION)
+	cd $(libdir) && $(RM) libwine_unicode.so && $(LN_S) libwine_unicode.so.$(SOVERSION) libwine_unicode.so
+
+install_a: libwine_unicode.a
+	[ -d $(libdir) ] || $(MKDIR) $(libdir)
+	$(INSTALL_DATA) libwine_unicode.a $(libdir)/libwine_unicode.a
+
+install:: all $(LIBEXT:%=install_%)
+
+uninstall::
+	cd $(libdir) && $(RM) libwine_unicode.a libwine_unicode.so libwine_unicode.so.$(SOVERSION)
+
+clean::
+	$(RM) libwine_unicode.so.$(SOVERSION)
+
 ### Dependencies: