--- a/unix/vncserver	2017-03-11 02:25:51.655811658 +0000
+++ b/unix/vncserver	2017-03-11 02:33:43.344291034 +0000
@@ -76,6 +76,15 @@
        "if [ -f /etc/X11/xinit/xinitrc ]; then\n".
        "  exec sh /etc/X11/xinit/xinitrc\n".
        "fi\n".
+       "if [ -x /etc/gdm/Xsession ] && [ -x /usr/bin/dtstart ] ; then\n".
+       "  exec /etc/gdm/Xsession /usr/bin/dtstart jds\n".
+       "fi\n".
+       "if [ -x /etc/X11/gdm/Xsession ] && [ -x /usr/bin/dtstart ] ; then\n".
+       "  exec /etc/X11/gdm/Xsession /usr/bin/dtstart jds\n".
+       "fi\n".
+       "if [ -x /usr/dt/config/Xsession.jds ]; then\n".
+       "  exec /usr/dt/config/Xsession.jds\n".
+       "fi\n".
        "[ -r \$HOME/.Xresources ] && xrdb \$HOME/.Xresources\n".
        "xsetroot -solid grey\n".
        "xterm -geometry 80x24+10+10 -ls -title \"\$VNCDESKTOP Desktop\" &\n".
--- a/unix/xserver/hw/vnc/Makefile.am	2017-03-11 08:13:43.250650526 +0000
+++ b/unix/xserver/hw/vnc/Makefile.am	2017-03-11 08:14:11.089457087 +0000
@@ -20,7 +20,7 @@
 
 libvnccommon_la_CPPFLAGS = -DVENDOR_RELEASE="$(VENDOR_RELEASE)" \
 	-DVENDOR_STRING="\"$(VENDOR_STRING)\"" -I$(TIGERVNC_SRCDIR)/common -UHAVE_CONFIG_H \
-	-I$(TIGERVNC_SRCDIR)/unix/vncconfig $(XVNC_CPPFLAGS) ${XSERVERLIBS_CFLAGS} -I$(includedir) \
+	-I$(TIGERVNC_SRCDIR)/unix/vncconfig $(XVNC_CPPFLAGS) ${XSERVERLIBS_CFLAGS} -I$(includedir) -I/usr/include/xorg \
 	-I$(top_srcdir)/include
 
 bin_PROGRAMS = Xvnc
@@ -40,7 +40,8 @@
 	-UHAVE_CONFIG_H \
 	-DXFree86Server -DVENDOR_RELEASE="$(VENDOR_RELEASE)" \
 	-DVENDOR_STRING="\"$(VENDOR_STRING)\"" -I$(TIGERVNC_SRCDIR)/common \
-	-I$(top_srcdir)/include ${XSERVERLIBS_CFLAGS} -I$(includedir)
+	-I$(top_srcdir)/include ${XSERVERLIBS_CFLAGS} -I$(includedir) \
+	-I/usr/include/xorg
 
 Xvnc_LDADD = $(XVNC_LIBS) libvnccommon.la $(COMMON_LIBS) \
 	$(XSERVER_LIBS) $(XSERVER_SYS_LIBS) $(XVNC_SYS_LIBS) -lX11
@@ -60,7 +61,8 @@
 	-I$(top_srcdir)/hw/xfree86/os-support \
 	-I$(top_srcdir)/hw/xfree86/os-support/bus \
 	-I$(top_srcdir)/include \
-	${XSERVERLIBS_CFLAGS} -I$(includedir)
+	${XSERVERLIBS_CFLAGS} -I$(includedir) \
+	-I/usr/include/xorg
 
 libvnc_la_LDFLAGS = -module -avoid-version -Wl,-z,now
 
--- a/unix/xserver/hw/vnc/Makefile.am	2017-03-11 15:32:58.976784002 +0000
+++ b/unix/xserver/hw/vnc/Makefile.am	2017-03-11 15:35:57.896191911 +0000
@@ -44,10 +44,13 @@
 	-I/usr/include/xorg
 
 Xvnc_LDADD = $(XVNC_LIBS) libvnccommon.la $(COMMON_LIBS) \
-	$(XSERVER_LIBS) $(XSERVER_SYS_LIBS) $(XVNC_SYS_LIBS) -lX11
+	-ljpeg -lz ../../IA/libIA.la \
+	$(XSERVER_LIBS) $(XSERVER_SYS_LIBS) $(XVNC_SYS_LIBS)
 
 Xvnc_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xvnc_LDFLAGS += $(GNUTLS_LDFLAGS)
 
+if XORG
 libvnc_la_LTLIBRARIES = libvnc.la
 libvnc_ladir = $(moduledir)/extensions
 
@@ -62,10 +64,11 @@
 	-I$(top_srcdir)/hw/xfree86/os-support/bus \
 	-I$(top_srcdir)/include \
 	${XSERVERLIBS_CFLAGS} -I$(includedir) \
-	-I/usr/include/xorg
+	-I/usr/include/xorg $(PIXMAN_CFLAGS)
 
 libvnc_la_LDFLAGS = -module -avoid-version -Wl,-z,now
 
 libvnc_la_LIBADD = libvnccommon.la $(COMMON_LIBS)
+endif
 
 EXTRA_DIST = Xvnc.man
--- a/cmake/StaticBuild.cmake	2017-02-15 18:15:12.881885498 +0000
+++ b/cmake/StaticBuild.cmake	2017-02-15 18:20:07.054136785 +0000
@@ -7,6 +7,11 @@
 # a lot of details change with each different build environment.
 #
 
+SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> <LINK_FLAGS> crS <TARGET> <OBJECTS>")
+SET(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> <LINK_FLAGS> r <TARGET> <OBJECTS>")
+SET(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> <LINK_FLAGS> crS <TARGET> <OBJECTS>")
+SET(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> <LINK_FLAGS> r <TARGET> <OBJECTS>")
+
 option(BUILD_STATIC
     "Link statically against most libraries, if possible" OFF)
 
--- a/java/CMakeLists.txt	2017-03-13 20:34:32.537260248 +0000
+++ b/java/CMakeLists.txt	2017-03-13 20:34:46.649466591 +0000
@@ -7,7 +7,7 @@
 
 find_package(Java)
 
-set(DEFAULT_JAVACFLAGS "-source 1.6 -target 1.6 -Xlint:all,-serial,-cast,-unchecked,-fallthrough,-dep-ann,-deprecation,-rawtypes")
+set(DEFAULT_JAVACFLAGS "-source 1.8 -target 1.8 -Xlint:all,-serial,-cast,-unchecked,-fallthrough,-dep-ann,-deprecation,-rawtypes")
 set(JAVACFLAGS ${DEFAULT_JAVACFLAGS} CACHE STRING
   "Java compiler flags (Default: ${DEFAULT_JAVACFLAGS})")
 message(STATUS "Java compiler flags = ${JAVACFLAGS}")
--- tigervnc-1.8.0/unix/vncserver.~3~	2018-05-19 10:12:57.878402758 +0000
+++ tigervnc-1.8.0/unix/vncserver	2018-05-19 10:15:10.651993596 +0000
@@ -303,7 +303,7 @@
 
 # Make an X server cookie and set up the Xauthority file
 # mcookie is a part of util-linux, usually only GNU/Linux systems have it.
-$cookie = `mcookie`;
+my $cookie = "";
 # Fallback for non GNU/Linux OS - use /dev/urandom on systems that have it,
 # otherwise use perl's random number generator, seeded with the sum
 # of the current time, our PID and part of the encrypted form of the password.
--- a/vncviewer/vncviewer.cxx	2017-03-16 12:33:53.666780502 -0700
+++ b/vncviewer/vncviewer.cxx	2017-03-16 12:34:37.502948883 -0700
@@ -481,7 +481,7 @@
 
   init_fltk();
 
-#if !defined(WIN32) && !defined(__APPLE__)
+#if !defined(WIN32) && !defined(__APPLE__) && !defined(sun)
   fl_open_display();
   XkbSetDetectableAutoRepeat(fl_display, True, NULL);
 #endif