*******************************************************************************
**     Building TurboVNC for Unix
*******************************************************************************


==================
Build Requirements
==================

-- autoconf 2.56 or later
-- automake 1.7 or later
   * On Solaris, these are available from BlastWave (http://www.blastwave.org)
     or OpenCSW (http://www.opencsw.org)
   * Needed only when building TurboVNC from CVS, or if you wish to modify the
     build scripts and Makefiles

-- make

-- rsync (if building the TurboVNC Server using an out-of-tree build)

-- GCC
   * On OS X, this is available in the X Code Tools, which are located on the
     install discs or at:
     http://developer.apple.com/tools/xcode

... OR ...

-- SOLARIS ONLY:  Oracle Solaris Studio 12 or later
   * See http://www.oracle.com/technetwork/server-storage/solarisstudio/ for a
     free download.

-- X Intrinsics/Athena Widgets development kit
   * libXaw, libXt, and all dependencies thereof
   * On OS X, this is available in the "X11 SDK" package, which is part of the
     X Code Tools.

-- x86 ONLY:  libjpeg-turbo SDK v1.0.0 or later
   * The libjpeg-turbo SDK packages for various platforms can be obtained from
     the "Files" area of:
     http://sourceforge.net/projects/libjpeg-turbo/


==================
Out-of-Tree Builds
==================

Binary objects, libraries, and executables are generated in the same directory
from which configure was executed (the "binary directory"), and this directory
need not necessarily be the same as the TurboVNC source directory.  You can
create multiple independent binary directories, in which different versions of
TurboVNC can be built from the same source tree using different compilers or
settings.  In the sections below, {build_directory} refers to the binary
directory, whereas {source_directory} refers to the TurboVNC source directory.
For in-tree builds, these directories are the same.


=================
Building TurboVNC
=================

The following procedure will build the TurboVNC Viewer on Linux, FreeBSD,
32-bit OS X, and Solaris/x86 systems (on Solaris, this generates a 32-bit
binary.  See below for 64-bit build instructions.)

  cd {source_directory}
  autoreconf -fiv
  cd {build_directory}
  sh {source_directory}/configure [additional configure flags]
  make

NOTE: Running autoreconf is only necessary if building TurboVNC from the CVS
repository or if configure.ac has been modified.

On supported platforms (Linux, Solaris, and FreeBSD, at the moment), the
TurboVNC Server (Xvnc) can then be built by executing:

  make xserver

You can also run:

  make xserver-clean

to clean the Xvnc build, or

  make xserver-rebuild

to do a minimal rebuild of Xvnc without re-configuring it.


==========
Installing
==========

  make install

will install the TurboVNC Viewer into /opt/TurboVNC.

  make xserver-install

will do likewise for the TurboVNC Server.  'make uninstall' and
'make xserver-uninstall' will correspondingly uninstall the viewer and server.

You can change the directory into which TurboVNC will install by passing an
argument of

  --prefix={directory}

on the configure command line.  Run configure --help for more details.


==================================
Build Recipes for Specific Systems
==================================

32-bit Build on 64-bit Linux
----------------------------

Add

  --host i686-pc-linux-gnu CFLAGS='-O3 -m32' LDFLAGS=-m32

to the configure command line.  You may need to also add

  --x-libraries=/usr/X11R6/lib

to the configure command line if you are running an older distribution that
uses XFree86 (this is known to be necessary on RedHat Enterprise Linux 3, for
instance.)  On newer systems that store the X11 libraries in /usr/lib, the
build should work, but it will probably generate a bunch of warnings when
linking vncviewer.  You can add

  --x-libraries=/usr/lib

to the configure command line to get rid of these warnings.


64-bit Build on 64-bit OS X
---------------------------

Add

  --host x86_64-apple-darwin

to the configure command line.


32-bit Build on 64-bit OS X
---------------------------

Add

  CFLAGS='-O3 -m32' LDFLAGS=-m32

to the configure command line.


64-bit Backward-Compatible Build on 64-bit OS X
-----------------------------------------------

Add

  --host x86_64-apple-darwin \
  CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \
    -mmacosx-version-min=10.5 -O3' \
    LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \
    -mmacosx-version-min=10.5'

to the configure command line.  The OS X 10.5 SDK must be installed.


32-bit Backward-Compatible Build on OS X
----------------------------------------

Add

  CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
    -mmacosx-version-min=10.4 -O3 -m32' \
    LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
    -mmacosx-version-min=10.4 -m32'

to the configure command line.  The OS X 10.4 SDK must be installed.


64-bit Build on 64-bit Solaris
------------------------------

Add

  --host x86_64-pc-solaris CFLAGS='-O3 -m64' LDFLAGS=-m64

to the configure command line.


Oracle Solaris Studio
---------------------

Add

  CC=cc

to the configure command line.  TurboVNC will automatically be built with
the maximum optimization level (-xO5) unless you override CFLAGS.

To build a 64-bit version of TurboVNC using Oracle Solaris Studio, add

  --host x86_64-pc-solaris CC=cc CFLAGS='-xO5 -m64' LDFLAGS=-m64

to the configure command line.


=========================
Creating Release Packages
=========================

The following commands can be used to create various types of release packages:

make rpm

  Create RedHat-style binary RPM package.  Requires RPM v4 or later.

make deb

  Create Debian-style binary package.  Requires dpkg.

make dmg

  Create Macintosh package/disk image.  This requires the PackageMaker
  application, which must be installed in /Developer/Applications/Utilities.

make udmg [BUILDDIR32={32-bit build directory}]

  On 64-bit OS X systems, this creates a version of the Macintosh package and
  disk image which contains universal i386/x86-64 binaries.  You should first
  configure a 32-bit out-of-tree build of TurboVNC, then configure a 64-bit
  out-of-tree build, then run 'make udmg' from the 64-bit build directory.  The
  build system will look for the 32-bit build under {source_directory}/osxx86
  by default, but you can override this by setting the BUILDDIR32 variable on
  the make command line as shown above.


=============
Other Options
=============

Custom builds of libjpeg-turbo
------------------------------

The TurboVNC build will look for libjpeg-turbo in its usual place
(/opt/libjpeg-turbo).  If you have built a custom version of libjpeg-turbo and
installed it into a different directory, then set the JPEG_CFLAGS and
JPEG_LDFLAGS variables on the configure command line to specify how to build
and link against your custom version.  For instance,

  configure JPEG_CFLAGS='-I/usr/local/include' \
    JPEG_LDFLAGS='-L/usr/local/lib -Wl,-Bstatic -lturbojpeg -Wl,-Bdynamic'

The default build of TurboVNC tries to use the TurboJPEG/OSS static library
(libturbojpeg.a), so you can override JPEG_LDFLAGS to build TurboVNC against
the TurboJPEG/OSS dynamic library if you wish.
