Merge unified_buildsys branch to trunk (r3892 - r3898)


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3899 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..0cd3384
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,9 @@
+SUBDIRS = common po
+
+if BUILD_WIN
+SUBDIRS += win
+else
+SUBDIRS += unix
+endif
+
+ACLOCAL_AMFLAGS = -I m4
diff --git a/common/common-config.win.h b/common/common-config.win.h
deleted file mode 100644
index 2f84e9c..0000000
--- a/common/common-config.win.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* common-config.win.h - Platform-specific definitions for Windows */
-
-#define HAVE_VSNPRINTF 1
-#ifdef _MSC_VER
-/* Older versions of MSVC lacks vsnprintf. MinGW has it, and if this
-   macro is defined before stdio.h is included, things will break. */
-#define vsnprintf _vsnprintf
-#endif
-
-#define HAVE_SNPRINTF 1
-#define snprintf _snprintf
diff --git a/common/configure.ac b/common/configure.ac
deleted file mode 100644
index 54e2f3d..0000000
--- a/common/configure.ac
+++ /dev/null
@@ -1,89 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_PREREQ([2.57])
-AC_INIT([librfb], [0.0.91], [http://www.tigervnc.org])
-
-AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
-
-dnl Checks for programs.
-AC_PROG_CC
-AC_PROG_CXX
-AC_PROG_LIBTOOL
-AC_LANG([C++])
-
-AC_CONFIG_HEADERS([common-config.h])
-CPPFLAGS="-DHAVE_COMMON_CONFIG_H $CPPFLAGS"
-
-case "`(uname -sr) 2>/dev/null`" in
-"SunOS 5"*)
-  SOLARIS=yes
-  ;;
-"IRIX 6"*)
-  LDFLAGS="-L/usr/lib32 $LDFLAGS"
-  ;;
-"LynxOS 2"*)
-  SJLJ_EXCEPTIONS=yes
-  ;;
-esac
-
-case "$host_os" in
-    mingw*)
-        CPPFLAGS="$CPPFLAGS -DWINVER=0x0500 -D_WIN32_IE=0x0500"
-        CXXFLAGS="$CXXFLAGS -mthreads"
-        ;;
-esac
-
-dnl FIXME: Remove duplication between this script and ../unix/configure.in
-if test "$GCC" = yes; then
-  CFLAGS="$CFLAGS -Wall"
-  if test "$SOLARIS" = yes; then
-    CFLAGS="$CFLAGS -Wno-unknown-pragmas -Wno-implicit-int"
-  fi
-fi
-if test "$GXX" = yes; then
-  CXXFLAGS="$CXXFLAGS -Wall"
-  if test "$SOLARIS" = yes; then
-    CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas -fpermissive"
-  fi
-  if test "$SJLJ_EXCEPTIONS" = yes; then
-    CXXFLAGS="$CXXFLAGS -fsjlj-exceptions"
-  fi
-fi
-
-dnl Check for zlib library
-INCLUDED_ZLIB=no
-AC_ARG_WITH([included-zlib],
-	AS_HELP_STRING([--with-included-zlib],
-		       [use libz which is distributed with VNC]),
-	[INCLUDED_ZLIB=yes],
-	[AC_SEARCH_LIBS([inflateEnd], [z], [], [INCLUDED_ZLIB=yes])])
-
-AM_CONDITIONAL([INCLUDED_ZLIB], [ test "x$INCLUDED_ZLIB" = xyes ])
-AC_CONFIG_SUBDIRS([zlib])
-
-dnl Check for libjpeg library
-INCLUDED_JPEG=yes
-AC_ARG_WITH([system-jpeg],
-	AS_HELP_STRING([--with-system-jpeg], 
-		       [use libjpeg which is distributed with the O/S]),
-	[AC_SEARCH_LIBS([jpeg_destroy_compress], [jpeg],
-			[INCLUDED_JPEG=no], [])],
-	[])
-
-AM_CONDITIONAL([INCLUDED_JPEG], [ test "x$INCLUDED_JPEG" = xyes ])
-AC_CONFIG_SUBDIRS([jpeg])
-
-AC_CHECK_FUNCS([vsnprintf snprintf strcasecmp strncasecmp])
-
-# IPv6 related functions
-AC_CHECK_FUNCS([inet_ntop getaddrinfo])
-
-AC_CHECK_TYPES([socklen_t], [], [], [[#include <sys/socket.h>]])
-
-AC_CHECK_HEADERS([sys/select.h])
-
-AC_OUTPUT([Makefile
-	   os/Makefile
-	   rdr/Makefile
-	   network/Makefile
-	   Xregion/Makefile
-	   rfb/Makefile])
diff --git a/common/jpeg/simd/Makefile.am b/common/jpeg/simd/Makefile.am
index 92a095e..0f1d125 100644
--- a/common/jpeg/simd/Makefile.am
+++ b/common/jpeg/simd/Makefile.am
@@ -2,7 +2,9 @@
 
 BUILT_SOURCES = jsimdcfg.inc
 
-EXTRA_DIST = nasm_lt.sh
+EXTRA_DIST = nasm_lt.sh jcclrmmx.asm jcclrss2.asm jdclrmmx.asm jdclrss2.asm \
+	jdmrgmmx.asm jdmrgss2.asm jcclrss2-64.asm jdclrss2-64.asm \
+	jdmrgss2-64.asm
 
 if SIMD_X86_64
 
@@ -19,9 +21,6 @@
 jccolss2-64.lo: jcclrss2-64.asm
 jdcolss2-64.lo: jdclrss2-64.asm
 jdmerss2-64.lo: jdmrgss2-64.asm
-
-EXTRA_DIST += jcclrss2-64.asm jdclrss2-64.asm jdmrgss2-64.asm
-
 endif
 
 if SIMD_I386
@@ -48,12 +47,6 @@
 jdcolss2.lo: jdclrss2.asm
 jdmermmx.lo: jdmrgmmx.asm
 jdmerss2.lo: jdmrgss2.asm
-
-EXTRA_DIST += \
-	jcclrmmx.asm jcclrss2.asm \
-	jdclrmmx.asm jdclrss2.asm \
-	jdmrgmmx.asm jdmrgss2.asm
-
 endif
 
 .asm.lo:
diff --git a/common/network/Makefile.am b/common/network/Makefile.am
index c4bad93..3db5536 100644
--- a/common/network/Makefile.am
+++ b/common/network/Makefile.am
@@ -4,5 +4,5 @@
 
 libnetwork_la_SOURCES = $(HDRS) TcpSocket.cxx
 
-libnetwork_la_CPPFLAGS = -I$(top_srcdir)
+libnetwork_la_CPPFLAGS = -I$(top_srcdir)/common
 
diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx
index 7ceff0b..c95dfcf 100644
--- a/common/network/TcpSocket.cxx
+++ b/common/network/TcpSocket.cxx
@@ -16,8 +16,8 @@
  * USA.
  */
 
-#ifdef HAVE_COMMON_CONFIG_H
-#include <common-config.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
 #endif
 
 #ifdef WIN32
diff --git a/common/os/Makefile.am b/common/os/Makefile.am
index 3d89260..5e37290 100644
--- a/common/os/Makefile.am
+++ b/common/os/Makefile.am
@@ -3,3 +3,6 @@
 HDRS = net.h print.h
 
 libos_la_SOURCES = $(HDRS) print.c net.c
+
+libos_la_CPPFLAGS = -I$(top_srcdir)/common
+
diff --git a/common/os/net.c b/common/os/net.c
index 50ce868..5c0ac2d 100644
--- a/common/os/net.c
+++ b/common/os/net.c
@@ -16,8 +16,8 @@
  * USA.
  */
 
-#ifdef HAVE_COMMON_CONFIG_H
-#include <common-config.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
 #endif
 
 #include <stdlib.h>
diff --git a/common/os/net.h b/common/os/net.h
index acaf50f..bd8b21c 100644
--- a/common/os/net.h
+++ b/common/os/net.h
@@ -19,12 +19,8 @@
 #ifndef OS_NET_H
 #define OS_NET_H
 
-#ifdef HAVE_COMMON_CONFIG_H
-#include <common-config.h>
-#endif
-
-#ifdef WIN32
-#include <common-config.win.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
 #endif
 
 #ifdef __cplusplus
diff --git a/common/os/print.c b/common/os/print.c
index 0f26de3..4be2203 100644
--- a/common/os/print.c
+++ b/common/os/print.c
@@ -16,8 +16,8 @@
  * USA.
  */
 
-#ifdef HAVE_COMMON_CONFIG_H
-#include <common-config.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
 #endif
 
 #include <os/print.h>
diff --git a/common/os/print.h b/common/os/print.h
index 523f3a1..442dd64 100644
--- a/common/os/print.h
+++ b/common/os/print.h
@@ -19,12 +19,8 @@
 #ifndef OS_PRINT_H
 #define OS_PRINT_H
 
-#ifdef HAVE_COMMON_CONFIG_H
-#include <common-config.h>
-#endif
-
-#ifdef WIN32
-#include <common-config.win.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
 #endif
 
 #include <stdarg.h>
diff --git a/common/rdr/FdInStream.cxx b/common/rdr/FdInStream.cxx
index e2281b4..adb14c5 100644
--- a/common/rdr/FdInStream.cxx
+++ b/common/rdr/FdInStream.cxx
@@ -16,8 +16,8 @@
  * USA.
  */
 
-#ifdef HAVE_COMMON_CONFIG_H
-#include <common-config.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
 #endif
 
 #include <stdio.h>
diff --git a/common/rdr/FdOutStream.cxx b/common/rdr/FdOutStream.cxx
index c771166..c84c946 100644
--- a/common/rdr/FdOutStream.cxx
+++ b/common/rdr/FdOutStream.cxx
@@ -16,8 +16,8 @@
  * USA.
  */
 
-#ifdef HAVE_COMMON_CONFIG_H
-#include <common-config.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
 #endif
 
 #include <stdio.h>
diff --git a/common/rdr/Makefile.am b/common/rdr/Makefile.am
index e9a01c1..589ad80 100644
--- a/common/rdr/Makefile.am
+++ b/common/rdr/Makefile.am
@@ -9,10 +9,10 @@
 	InStream.cxx RandomStream.cxx ZlibInStream.cxx ZlibOutStream.cxx \
 	HexInStream.cxx HexOutStream.cxx
 
-librdr_la_CPPFLAGS = -I$(top_srcdir)
+librdr_la_CPPFLAGS = -I$(top_srcdir)/common
 librdr_la_LIBADD =
 
 if INCLUDED_ZLIB
-librdr_la_CPPFLAGS += -I$(top_srcdir)/zlib
-librdr_la_LIBADD += $(top_srcdir)/zlib/libz.la
+librdr_la_CPPFLAGS += -I$(top_srcdir)/common/zlib
+librdr_la_LIBADD += $(top_srcdir)/common/zlib/libz.la
 endif
diff --git a/common/rfb/Makefile.am b/common/rfb/Makefile.am
index fdb119d..eec0076 100644
--- a/common/rfb/Makefile.am
+++ b/common/rfb/Makefile.am
@@ -41,10 +41,10 @@
 	VNCServerST.cxx ZRLEEncoder.cxx ZRLEDecoder.cxx encodings.cxx \
 	secTypes.cxx util.cxx
 
-librfb_la_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/../win
+librfb_la_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/win
 librfb_la_LIBADD =
 
 if INCLUDED_JPEG
-librfb_la_CPPFLAGS += -I$(top_srcdir)/jpeg
-librfb_la_LIBADD += $(top_srcdir)/jpeg/libjpeg.la
+librfb_la_CPPFLAGS += -I$(top_srcdir)/common/jpeg
+librfb_la_LIBADD += $(top_srcdir)/common/jpeg/libjpeg.la
 endif
diff --git a/common/rfb/util.cxx b/common/rfb/util.cxx
index a50ea58..265114f 100644
--- a/common/rfb/util.cxx
+++ b/common/rfb/util.cxx
@@ -30,8 +30,8 @@
  * is provided ``as is'' without express or implied warranty.
  */
 
-#ifdef HAVE_COMMON_CONFIG_H
-#include <common-config.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
 #endif
 
 #include <rfb/util.h>
diff --git a/common/rfb/util.h b/common/rfb/util.h
index 933df52..4124769 100644
--- a/common/rfb/util.h
+++ b/common/rfb/util.h
@@ -23,8 +23,8 @@
 #ifndef __RFB_UTIL_H__
 #define __RFB_UTIL_H__
 
-#ifdef HAVE_COMMON_CONFIG_H
-#include <common-config.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
 #endif
 
 #include <limits.h>
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..47091b4
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,164 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_PREREQ([2.57])
+AC_INIT([tigervnc], [0.0.91], [http://www.tigervnc.org])
+AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
+
+AC_CONFIG_SUBDIRS([common/jpeg common/zlib])
+
+AC_CONFIG_HEADERS([config.h])
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_LIBTOOL
+AC_LANG([C++])
+AM_GNU_GETTEXT([external])
+AM_GNU_GETTEXT_VERSION([0.14.1])
+
+case "`(uname -sr) 2>/dev/null`" in
+"SunOS 5"*)
+	SOLARIS=yes
+	USE_MITSHM=yes
+	USE_SUN_OVL=yes
+	;;
+"IRIX 6"*)
+	LDFLAGS="-L/usr/lib32 $LDFLAGS"
+	USE_MITSHM=yes
+	USE_READDISPLAY=yes
+	;;
+"LynxOS 2"*)
+	SJLJ_EXCEPTIONS=yes
+	;;
+esac
+
+BUILD_WIN=
+case "$host_os" in
+mingw*)
+	CPPFLAGS="$CPPFLAGS -DWINVER=0x0500 -D_WIN32_IE=0x0500"
+	CXXFLAGS="$CXXFLAGS -mthreads"
+	BUILD_WIN=yes
+	AC_CHECK_TOOL([WINDRES], windres, [AC_MSG_ERROR(windres not found)])
+	;;
+esac
+AM_CONDITIONAL([BUILD_WIN], [test "x$BUILD_WIN" = xyes])
+
+dnl FIXME: Check for MIT-SHM properly, add a corresponding --with option.
+if test "$USE_MITSHM" = yes; then
+	MITSHM_DEFINE="-DHAVE_MITSHM"
+fi
+AC_SUBST(MITSHM_DEFINE)
+
+if test "$GCC" = yes; then
+	CFLAGS="$CFLAGS -Wall"
+	if test "$SOLARIS" = yes; then
+		CFLAGS="$CFLAGS -Wno-unknown-pragmas -Wno-implicit-int"
+	fi
+fi
+if test "$GXX" = yes; then
+	CXXFLAGS="$CXXFLAGS -Wall"
+	if test "$SOLARIS" = yes; then
+		CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas -fpermissive"
+	fi
+	if test "$SJLJ_EXCEPTIONS" = yes; then
+		CXXFLAGS="$CXXFLAGS -fsjlj-exceptions"
+	fi
+fi
+
+AC_PATH_XTRA
+
+VNCCONFIG_DIR='vncconfig'
+AC_ARG_ENABLE([vncconfig],
+	AS_HELP_STRING([--enable-vncconfig],
+		       [build the vncconfig utility (default yes)]),
+	[if test "$enableval" = no; then VNCCONFIG_DIR=; fi ], [])
+AC_SUBST(VNCCONFIG_DIR)
+
+dnl Check for the XTest X11 extension library.
+AC_CHECK_LIB(Xtst,XTestGrabControl,USE_XTEST=yes,USE_XTEST=,
+	     ["$X_LIBS" -lXext -lX11])
+if test "$USE_XTEST" = yes; then
+	XTEST_DEFINE='-DHAVE_XTEST'
+	XTEST_LIB=-lXtst
+else
+	echo Warning: No XTest extension, building x0vncserver view-only
+	XTEST_DEFINE=
+	XTEST_LIB=
+fi
+AC_SUBST(XTEST_DEFINE)
+AC_SUBST(XTEST_LIB)
+
+dnl Support for READDISPLAY (Irix) and SUN_OVL (Solaris) extensions
+dnl FIXME: Implement corresponding --with options.
+if test "$USE_READDISPLAY" = yes; then
+	READDISPLAY_DEFINE='-DHAVE_READDISPLAY'
+elif test "$USE_SUN_OVL" = yes; then
+	READDISPLAY_DEFINE='-DHAVE_SUN_OVL'
+else
+	READDISPLAY_DEFINE=
+fi
+AC_SUBST(READDISPLAY_DEFINE)
+
+dnl Under Lynx/OS 2.3, we have to link with -lbsd to resolve
+dnl gethostbyname, inet_addr, htons etc. Check if it's necessary.
+dnl NOTE: Did not want to use AC_SEARCH_LIBS which would add
+dnl   -lbsd to LIBS. We set INET_LIB instead.
+AC_LANG_SAVE
+AC_LANG_C
+AC_CHECK_FUNC(gethostbyname,INET_LIB_REQ=,INET_LIB_REQ=yes)
+if test "$INET_LIB_REQ" = yes; then
+	AC_CHECK_LIB(bsd,gethostbyname,INET_LIB=-lbsd,INET_LIB=)
+fi
+AC_LANG_RESTORE
+AC_SUBST(INET_LIB)
+
+dnl Check for zlib library
+INCLUDED_ZLIB=no
+AC_ARG_WITH([included-zlib],
+	AS_HELP_STRING([--with-included-zlib],
+		       [use libz which is distributed with VNC]),
+	[INCLUDED_ZLIB=yes],
+	[AC_SEARCH_LIBS([inflateEnd], [z], [], [INCLUDED_ZLIB=yes])])
+
+AM_CONDITIONAL([INCLUDED_ZLIB], [ test "x$INCLUDED_ZLIB" = xyes ])
+AC_CONFIG_SUBDIRS([zlib])
+
+dnl Check for libjpeg library
+INCLUDED_JPEG=yes
+AC_ARG_WITH([system-jpeg],
+	AS_HELP_STRING([--with-system-jpeg], 
+		       [use libjpeg which is distributed with the O/S]),
+	[AC_SEARCH_LIBS([jpeg_destroy_compress], [jpeg],
+			[INCLUDED_JPEG=no], [])],
+	[])
+
+AM_CONDITIONAL([INCLUDED_JPEG], [ test "x$INCLUDED_JPEG" = xyes ])
+AC_CONFIG_SUBDIRS([jpeg])
+
+AC_CHECK_FUNCS([vsnprintf snprintf strcasecmp strncasecmp])
+
+# IPv6 related functions
+AC_CHECK_FUNCS([inet_ntop getaddrinfo])
+
+AC_CHECK_TYPES([socklen_t], [], [], [[#include <sys/socket.h>]])
+
+AC_CHECK_HEADERS([sys/select.h])
+
+AC_OUTPUT([
+Makefile
+common/Makefile
+common/os/Makefile
+common/rdr/Makefile
+common/network/Makefile
+common/Xregion/Makefile
+common/rfb/Makefile
+unix/Makefile
+unix/tx/Makefile
+unix/x0vncserver/Makefile
+unix/vncviewer/Makefile
+unix/vncconfig/Makefile
+unix/vncpasswd/Makefile
+win/Makefile
+win/vncviewer/Makefile
+win/rfb_win32/Makefile
+po/Makefile.in
+])
diff --git a/unix/po/LINGUAS b/po/LINGUAS
similarity index 100%
rename from unix/po/LINGUAS
rename to po/LINGUAS
diff --git a/unix/po/Makevars b/po/Makevars
similarity index 100%
rename from unix/po/Makevars
rename to po/Makevars
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644
index 0000000..0704ba7
--- /dev/null
+++ b/po/POTFILES.in
@@ -0,0 +1,12 @@
+# vncviewer_unix
+unix/vncviewer/AboutDialog.h
+unix/vncviewer/CConn.cxx
+unix/vncviewer/CConn.h
+unix/vncviewer/DesktopWindow.cxx
+unix/vncviewer/DesktopWindow.h
+unix/vncviewer/InfoDialog.h
+unix/vncviewer/OptionsDialog.h
+unix/vncviewer/parameters.h
+unix/vncviewer/PasswdDialog.h
+unix/vncviewer/ServerDialog.h
+unix/vncviewer/vncviewer.cxx
diff --git a/unix/po/Rules-quot b/po/Rules-quot
similarity index 100%
rename from unix/po/Rules-quot
rename to po/Rules-quot
diff --git a/unix/po/boldquot.sed b/po/boldquot.sed
similarity index 100%
rename from unix/po/boldquot.sed
rename to po/boldquot.sed
diff --git a/unix/po/de.po b/po/de.po
similarity index 100%
rename from unix/po/de.po
rename to po/de.po
diff --git a/unix/po/en@boldquot.header b/po/en@boldquot.header
similarity index 100%
rename from unix/po/en@boldquot.header
rename to po/en@boldquot.header
diff --git a/unix/po/en@quot.header b/po/en@quot.header
similarity index 100%
rename from unix/po/en@quot.header
rename to po/en@quot.header
diff --git a/unix/po/insert-header.sin b/po/insert-header.sin
similarity index 100%
rename from unix/po/insert-header.sin
rename to po/insert-header.sin
diff --git a/unix/po/pl.po b/po/pl.po
similarity index 100%
rename from unix/po/pl.po
rename to po/pl.po
diff --git a/unix/po/quot.sed b/po/quot.sed
similarity index 100%
rename from unix/po/quot.sed
rename to po/quot.sed
diff --git a/unix/po/remove-potcdate.sin b/po/remove-potcdate.sin
similarity index 100%
rename from unix/po/remove-potcdate.sin
rename to po/remove-potcdate.sin
diff --git a/unix/po/ru.po b/po/ru.po
similarity index 100%
rename from unix/po/ru.po
rename to po/ru.po
diff --git a/unix/po/sk.po b/po/sk.po
similarity index 100%
rename from unix/po/sk.po
rename to po/sk.po
diff --git a/unix/po/sv.po b/po/sv.po
similarity index 100%
rename from unix/po/sv.po
rename to po/sv.po
diff --git a/unix/po/tigervnc.pot b/po/tigervnc.pot
similarity index 100%
rename from unix/po/tigervnc.pot
rename to po/tigervnc.pot
diff --git a/unix/Makefile.am b/unix/Makefile.am
index 84e47c8..854956b 100644
--- a/unix/Makefile.am
+++ b/unix/Makefile.am
@@ -1,9 +1,15 @@
-SUBDIRS = ../common tx x0vncserver vncviewer vncpasswd po @VNCCONFIG_DIR@
+SUBDIRS = ../common tx x0vncserver vncviewer vncpasswd @VNCCONFIG_DIR@
 
 dist_bin_SCRIPTS = vncserver
 
 man1_MANS = vncserver.man
 
-ACLOCAL_AMFLAGS = -I m4
+XVNCDIR = xserver/hw/vnc
 
-EXTRA_DIST = vncserver.man
+EXTRA_DIST = vncserver.man $(XVNCDIR)/RegionHelper.h $(XVNCDIR)/vncExtInit.cc \
+	$(XVNCDIR)/buildtime.c $(XVNCDIR)/XserverDesktop.h $(XVNCDIR)/xvnc.cc \
+	$(XVNCDIR)/Xvnc.man $(XVNCDIR)/Input.cc $(XVNCDIR)/xf86vncModule.cc \
+	$(XVNCDIR)/XserverDesktop.cc $(XVNCDIR)/Input.h \
+	$(XVNCDIR)/xorg-version.h $(XVNCDIR)/vncHooks.h \
+	$(XVNCDIR)/Makefile.am $(XVNCDIR)/vncHooks.cc $(XVNCDIR)/vncExtInit.h \
+	xserver15.patch xserver16.patch
diff --git a/unix/configure.ac b/unix/configure.ac
deleted file mode 100644
index f903dfc..0000000
--- a/unix/configure.ac
+++ /dev/null
@@ -1,114 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_PREREQ([2.57])
-AC_INIT([tigervnc], [0.0.91], [http://www.tigervnc.org])
-AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
-
-AC_SUBST([COMMON_DIR], ['$(top_srcdir)/../common'])
-
-AC_CONFIG_SUBDIRS([../common])
-
-dnl Checks for programs.
-AC_PROG_CC
-AC_PROG_CXX
-AC_PROG_LIBTOOL
-AC_LANG([C++])
-AM_GNU_GETTEXT([external])
-AM_GNU_GETTEXT_VERSION([0.14.1])
-
-case "`(uname -sr) 2>/dev/null`" in
-"SunOS 5"*)
-  SOLARIS=yes
-  USE_MITSHM=yes
-  USE_SUN_OVL=yes
-  ;;
-"IRIX 6"*)
-  LDFLAGS="-L/usr/lib32 $LDFLAGS"
-  USE_MITSHM=yes
-  USE_READDISPLAY=yes
-  ;;
-"LynxOS 2"*)
-  SJLJ_EXCEPTIONS=yes
-  ;;
-esac
-
-dnl FIXME: Check for MIT-SHM properly, add a corresponding --with option.
-if test "$USE_MITSHM" = yes; then
-  MITSHM_DEFINE="-DHAVE_MITSHM"
-fi
-AC_SUBST(MITSHM_DEFINE)
-
-if test "$GCC" = yes; then
-  CFLAGS="$CFLAGS -Wall"
-  if test "$SOLARIS" = yes; then
-    CFLAGS="$CFLAGS -Wno-unknown-pragmas -Wno-implicit-int"
-  fi
-fi
-if test "$GXX" = yes; then
-  CXXFLAGS="$CXXFLAGS -Wall"
-  if test "$SOLARIS" = yes; then
-    CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas -fpermissive"
-  fi
-  if test "$SJLJ_EXCEPTIONS" = yes; then
-    CXXFLAGS="$CXXFLAGS -fsjlj-exceptions"
-  fi
-fi
-
-AC_PATH_XTRA
-
-AC_ARG_ENABLE(vncconfig,
-[  --enable-vncconfig      build the vncconfig utility (assumed by default),
-                          use --disable-vncconfig to skip building vncconfig])
-if test "$enable_vncconfig" = no; then
-  echo "vncconfig utility will not be built"
-  VNCCONFIG_DIR=
-else
-  VNCCONFIG_DIR='vncconfig'
-fi
-AC_SUBST(VNCCONFIG_DIR)
-
-dnl Check for the XTest X11 extension library.
-AC_CHECK_LIB(Xtst,XTestGrabControl,USE_XTEST=yes,USE_XTEST=,
-["$X_LIBS" -lXext -lX11])
-if test "$USE_XTEST" = yes; then
-  XTEST_DEFINE='-DHAVE_XTEST'
-  XTEST_LIB=-lXtst
-else
-  echo Warning: No XTest extension, building x0vncserver view-only
-  XTEST_DEFINE=
-  XTEST_LIB=
-fi
-AC_SUBST(XTEST_DEFINE)
-AC_SUBST(XTEST_LIB)
-
-dnl Support for READDISPLAY (Irix) and SUN_OVL (Solaris) extensions
-dnl FIXME: Implement corresponding --with options.
-if test "$USE_READDISPLAY" = yes; then
-  READDISPLAY_DEFINE='-DHAVE_READDISPLAY'
-elif test "$USE_SUN_OVL" = yes; then
-  READDISPLAY_DEFINE='-DHAVE_SUN_OVL'
-else
-  READDISPLAY_DEFINE=
-fi
-AC_SUBST(READDISPLAY_DEFINE)
-
-dnl Under Lynx/OS 2.3, we have to link with -lbsd to resolve
-dnl gethostbyname, inet_addr, htons etc. Check if it's necessary.
-dnl NOTE: Did not want to use AC_SEARCH_LIBS which would add
-dnl   -lbsd to LIBS. We set INET_LIB instead.
-AC_LANG_SAVE
-AC_LANG_C
-AC_CHECK_FUNC(gethostbyname,INET_LIB_REQ=,INET_LIB_REQ=yes)
-if test "$INET_LIB_REQ" = yes; then
-  AC_CHECK_LIB(bsd,gethostbyname,INET_LIB=-lbsd,INET_LIB=)
-fi
-AC_LANG_RESTORE
-AC_SUBST(INET_LIB)
-
-AC_OUTPUT(Makefile
-         tx/Makefile
-         x0vncserver/Makefile
-         vncviewer/Makefile
-         vncconfig/Makefile
-         vncpasswd/Makefile
-         po/Makefile.in
-)
diff --git a/unix/po/POTFILES.in b/unix/po/POTFILES.in
deleted file mode 100644
index bfe70a4..0000000
--- a/unix/po/POTFILES.in
+++ /dev/null
@@ -1,12 +0,0 @@
-# vncviewer_unix
-vncviewer/AboutDialog.h
-vncviewer/CConn.cxx
-vncviewer/CConn.h
-vncviewer/DesktopWindow.cxx
-vncviewer/DesktopWindow.h
-vncviewer/InfoDialog.h
-vncviewer/OptionsDialog.h
-vncviewer/parameters.h
-vncviewer/PasswdDialog.h
-vncviewer/ServerDialog.h
-vncviewer/vncviewer.cxx
diff --git a/unix/tx/Makefile.am b/unix/tx/Makefile.am
index ec42dbf..5766313 100644
--- a/unix/tx/Makefile.am
+++ b/unix/tx/Makefile.am
@@ -6,4 +6,5 @@
 libtx_la_SOURCES = $(HDRS) TXWindow.cxx TXScrollbar.cxx TXViewport.cxx \
 	TXImage.cxx TXMenu.cxx
 
-libtx_la_CPPFLAGS = -I$(COMMON_DIR) @X_CFLAGS@ # X_CFLAGS are really CPPFLAGS
+libtx_la_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/common/rfb \
+	@X_CFLAGS@ # X_CFLAGS are really CPPFLAGS
diff --git a/unix/vncconfig/Makefile.am b/unix/vncconfig/Makefile.am
index db9f657..fc1c095 100644
--- a/unix/vncconfig/Makefile.am
+++ b/unix/vncconfig/Makefile.am
@@ -7,10 +7,13 @@
 vncconfig_SOURCES = $(HDRS) vncExt.c vncconfig.cxx QueryConnectDialog.cxx \
 	buildtime.c
 
-vncconfig_CPPFLAGS = -I$(COMMON_DIR) -I$(top_srcdir)/tx @X_CFLAGS@ # X_CFLAGS are really CPPFLAGS
+# X_CFLAGS are really CPPFLAGS
+vncconfig_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/unix/tx @X_CFLAGS@
 
-vncconfig_LDADD = $(top_srcdir)/tx/libtx.la $(COMMON_DIR)/rfb/librfb.la \
-	$(COMMON_DIR)/network/libnetwork.la $(COMMON_DIR)/rdr/librdr.la \
-	@X_PRE_LIBS@ @X_LIBS@ -lX11 -lXext @X_EXTRA_LIBS@
+vncconfig_LDADD = $(top_srcdir)/unix/tx/libtx.la \
+	$(top_srcdir)/common/rfb/librfb.la \
+	$(top_srcdir)/common/network/libnetwork.la \
+	$(top_srcdir)/common/rdr/librdr.la @X_PRE_LIBS@ @X_LIBS@ -lX11 -lXext \
+	@X_EXTRA_LIBS@
 
 EXTRA_DIST = vncconfig.man
diff --git a/unix/vncpasswd/Makefile.am b/unix/vncpasswd/Makefile.am
index c6b9e97..cad2859 100644
--- a/unix/vncpasswd/Makefile.am
+++ b/unix/vncpasswd/Makefile.am
@@ -4,8 +4,9 @@
 
 vncpasswd_SOURCES = vncpasswd.cxx
 
-vncpasswd_CPPFLAGS = -I$(COMMON_DIR)
+vncpasswd_CPPFLAGS = -I$(top_srcdir)/common
 
-vncpasswd_LDADD = $(COMMON_DIR)/rfb/librfb.la $(COMMON_DIR)/rdr/librdr.la
+vncpasswd_LDADD = $(top_srcdir)/common/rfb/librfb.la \
+	$(top_srcdir)/common/rdr/librdr.la
 
 EXTRA_DIST = vncpasswd.man
diff --git a/unix/vncviewer/Makefile.am b/unix/vncviewer/Makefile.am
index 6b81ec3..e5e0190 100644
--- a/unix/vncviewer/Makefile.am
+++ b/unix/vncviewer/Makefile.am
@@ -7,12 +7,15 @@
 
 vncviewer_SOURCES = $(HDRS) DesktopWindow.cxx CConn.cxx vncviewer.cxx \
 	buildtime.c
+# X_CFLAGS are really CPPFLAGS
+vncviewer_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/unix \
+	-I$(top_srcdir)/unix/tx -I$(top_srcdir)/intl \
+	-DLOCALEDIR=\"$(localedir)\" @X_CFLAGS@
 
-vncviewer_CPPFLAGS = -I$(COMMON_DIR) -I$(top_srcdir) -I$(top_srcdir)/tx \
-	-I$(top_srcdir)/intl -DLOCALEDIR=\"$(localedir)\" @X_CFLAGS@ # X_CFLAGS are really CPPFLAGS
-
-vncviewer_LDADD = $(top_srcdir)/tx/libtx.la $(COMMON_DIR)/rfb/librfb.la \
-	$(COMMON_DIR)/network/libnetwork.la $(COMMON_DIR)/rdr/librdr.la \
+vncviewer_LDADD = $(top_srcdir)/unix/tx/libtx.la \
+	$(top_srcdir)/common/rfb/librfb.la \
+	$(top_srcdir)/common/network/libnetwork.la \
+	$(top_srcdir)/common/rdr/librdr.la \
 	@X_PRE_LIBS@ @X_LIBS@ -lXext -lX11 @X_EXTRA_LIBS@ # @LIBINTL@
 
 EXTRA_DIST = vncviewer.man
diff --git a/unix/x0vncserver/Makefile.am b/unix/x0vncserver/Makefile.am
index f237074..7959304 100644
--- a/unix/x0vncserver/Makefile.am
+++ b/unix/x0vncserver/Makefile.am
@@ -10,13 +10,15 @@
 	../vncconfig/QueryConnectDialog.cxx buildtime.c
 
 # X_CFLAGS are really CPPFLAGS
-x0vncserver_CPPFLAGS = -I$(COMMON_DIR) -I$(top_srcdir) -I$(top_srcdir)/tx \
-	-I$(top_srcdir)/vncconfig @XTEST_DEFINE@ @READDISPLAY_DEFINE@ \
+x0vncserver_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/common/rfb \
+	-I$(top_srcdir)/unix/tx -I$(top_srcdir)/unix/vncconfig \
+	-I$(top_srcdir)/unix @XTEST_DEFINE@ @READDISPLAY_DEFINE@ \
 	@MITSHM_DEFINE@ @X_CFLAGS@
 
-x0vncserver_LDADD = $(COMMON_DIR)/rfb/librfb.la \
-	$(COMMON_DIR)/network/libnetwork.la $(COMMON_DIR)/rdr/librdr.la \
-	$(top_srcdir)/tx/libtx.la @INET_LIB@ @X_PRE_LIBS@ @X_LIBS@ \
+x0vncserver_LDADD = $(top_srcdir)/common/rfb/librfb.la \
+	$(top_srcdir)/common/network/libnetwork.la \
+	$(top_srcdir)/common/rdr/librdr.la \
+	$(top_srcdir)/unix/tx/libtx.la @INET_LIB@ @X_PRE_LIBS@ @X_LIBS@ \
 	@XTEST_LIB@ -lXext -lX11 @X_EXTRA_LIBS@
 
 EXTRA_DIST = x0vncserver.man
diff --git a/unix/xserver/hw/vnc/Makefile.am b/unix/xserver/hw/vnc/Makefile.am
index c2e78df..223fe53 100644
--- a/unix/xserver/hw/vnc/Makefile.am
+++ b/unix/xserver/hw/vnc/Makefile.am
@@ -16,7 +16,7 @@
 	Input.cc
 
 libvnccommon_la_CPPFLAGS = -DVENDOR_RELEASE="$(VENDOR_RELEASE)" \
-	-DVENDOR_STRING="\"$(VENDOR_STRING)\"" -I$(LIB_DIR) \
+	-DVENDOR_STRING="\"$(VENDOR_STRING)\"" -I$(LIB_DIR) -UHAVE_CONFIG_H \
 	-I$(BIN_DIR)/vncconfig $(XVNC_CPPFLAGS) -I$(includedir)/pixman-1 -I$(includedir)
 
 bin_PROGRAMS = Xvnc
@@ -29,7 +29,7 @@
 
 nodist_Xvnc_SOURCES = fbrop.h fb.h pixman.h
 
-Xvnc_CPPFLAGS = $(XVNC_CPPFLAGS) -DNO_HW_ONLY_EXTS -DNO_MODULE_EXTS \
+Xvnc_CPPFLAGS = $(XVNC_CPPFLAGS) -DNO_HW_ONLY_EXTS -DNO_MODULE_EXTS -UHAVE_CONFIG_H \
 	-DXFree86Server -DVENDOR_RELEASE="$(VENDOR_RELEASE)" \
 	-DVENDOR_STRING="\"$(VENDOR_STRING)\"" -I$(LIB_DIR) \
 	-I$(top_srcdir)/include -I$(includedir)/pixman-1 -I$(includedir)
@@ -44,7 +44,7 @@
 
 libvnc_la_SOURCES = xf86vncModule.cc
 
-libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I$(LIB_DIR) \
+libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I$(LIB_DIR) -UHAVE_CONFIG_H \
 	-I$(top_srcdir)/hw/xfree86/common \
 	-I$(top_srcdir)/hw/xfree86/os-support \
 	-I$(top_srcdir)/hw/xfree86/os-support/bus \
diff --git a/win/Makefile.am b/win/Makefile.am
index d81086d..945e4e8 100644
--- a/win/Makefile.am
+++ b/win/Makefile.am
@@ -1,2 +1,2 @@
-SUBDIRS = ../common rfb_win32 vncviewer
+SUBDIRS = rfb_win32 vncviewer
 
diff --git a/win/configure.ac b/win/configure.ac
deleted file mode 100644
index e9e0c40..0000000
--- a/win/configure.ac
+++ /dev/null
@@ -1,32 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_PREREQ([2.57])
-AC_INIT([tigervnc], [0.0.91], [http://www.tigervnc.org])
-AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
-
-AC_SUBST([COMMON_DIR], ['$(top_srcdir)/../common'])
-
-AC_CONFIG_SUBDIRS([../common])
-
-dnl Checks for programs.
-AC_PROG_CC
-AC_PROG_CXX
-AC_PROG_LIBTOOL
-AC_CHECK_TOOL([WINDRES], windres, [AC_MSG_ERROR(windres not found)])
-AC_LANG([C++])
-
-if test "$GCC" = yes; then
-  CFLAGS="$CFLAGS -Wall"
-fi
-if test "$GXX" = yes; then
-  CXXFLAGS="$CXXFLAGS -Wall"
-fi
-
-CPPFLAGS="$CPPFLAGS -DWINVER=0x0500 -D_WIN32_IE=0x0500"
-CXXFLAGS="$CXXFLAGS -mthreads"
-
-AC_PATH_XTRA
-
-AC_OUTPUT(Makefile
-         vncviewer/Makefile
-	 rfb_win32/Makefile
-)
diff --git a/win/rfb_win32/Makefile.am b/win/rfb_win32/Makefile.am
index e1e9c7c..7c5d1c5 100644
--- a/win/rfb_win32/Makefile.am
+++ b/win/rfb_win32/Makefile.am
@@ -99,5 +99,5 @@
   WMShatter.cxx \
   WMWindowCopyRect.cxx
 
-librfb_win32_la_CPPFLAGS = -I$(top_srcdir) -I$(COMMON_DIR)
+librfb_win32_la_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/win
 librfb_win32_la_LIBADD =
diff --git a/win/vncviewer/Makefile.am b/win/vncviewer/Makefile.am
index dddef27..201f1e1 100644
--- a/win/vncviewer/Makefile.am
+++ b/win/vncviewer/Makefile.am
@@ -30,13 +30,13 @@
   ViewerToolBar.cxx \
   vncviewer.cxx
 
-vncviewer_CPPFLAGS = -I$(COMMON_DIR) -I$(top_srcdir)
+vncviewer_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/win
 
-vncviewer_LDADD = $(COMMON_DIR)/rfb/librfb.la \
-    $(top_srcdir)/rfb_win32/librfb_win32.la \
-    $(COMMON_DIR)/Xregion/libXregion.la \
-    $(COMMON_DIR)/network/libnetwork.la \
-    $(COMMON_DIR)/rdr/librdr.la \
+vncviewer_LDADD = $(top_srcdir)/common/rfb/librfb.la \
+    $(top_srcdir)/win/rfb_win32/librfb_win32.la \
+    $(top_srcdir)/common/Xregion/libXregion.la \
+    $(top_srcdir)/common/network/libnetwork.la \
+    $(top_srcdir)/common/rdr/librdr.la \
     resources.o -lws2_32 -lgdi32 -luser32 -lcomctl32 -lversion -lcomdlg32
 
 vncviewer_LDFLAGS = -I$(top_srcdir)/win -mwindows