########################################################################
# HOW TO BUILD WX WIDGETS LIBRARIES
########################################################################

This file is supposed to live in

    sanity@lamarc.gs.washington.edu:wx-libs/wx-notes.txt


#########################################
Note: if you want to build a wxWidgets library for use with the mingw
cross compiler (for running executables on MS Windows boxen), see
sanity@lamarc.gs.washington.edu:cross-tools/cross-notes.txt
first to make sure you have the mingw cross compiler set up

#########################################
# Where to put it

I installed stuff in the "sanity" user account on lamarc. You should be
able to read and use stuff there just by following the path

    /net/gs/vol1/home/sanity

If you want to make changes, you'll need the IT folks to give you sudo
access. Once that is done, you can log in this way:

    sudo -H -s -u sanity


#########################################
# Getting the packages

Packages are available from the wxWidgets web site:

    http://www.wxwidgets.org/

Follow links to the "downloads" section and choose an appropriate
version of the wxALL source archive. Note that a wxWidgets "Stable
Release" is usually more stable than we want -- for this build I
chose the "Development Release" 2.9.4 because it was better for 
building for the Mac.


#########################################
# Building Linux wxWidgets libraries

Here are the steps I used to build and install the release and debug
64-bit Linux wxWidgets libraries in the sanity account. I build debug
first because wx-config assumes the most recently installed library
is the default installation, so we want the 'release' one done last

    # Step 0:
    # These are some values I used, but which you might want or need
    # to do differently
    export WX_VERSION=2.9.4
    export WX_INSTALL_LOC=$HOME/wx-libs/wxLinux

    # Step 1:
    # untar your new distribution -- version number will be different for you
    # the 'j' option to tar tells it this is a .bz2 file; use 'z' if you have .gz
    cd $HOME/wx-libs/builds
    tar xfvj ./../tars/wxWidgets-${WX_VERSION}.tar.bz2

    # Step 2:
    # invoke modules to get a more modern default g++ compiler and
    # library.
    . /etc/profile.d/modules.sh
    module load modules modules-init modules-gs
    module load gmp mpfr/2.4.1 gcc

    # Step 3:
    # build and install the debug wxWidgets library
    #
    # we use '--disable-shared' on all installations because
    # that allows us to munge the library into the executable
    # we give to users. It makes it big but most users cannot
    # competently do installations with shared libraries
    #
    # '--with-libtiff=builtin' works around some unpleasantness
    # in must Linux distributions
    #
    # getting rid of '--disable-unicode' would require unpleasant
    # but do-able work in our code base. It has been easy to 
    # put off
    cd $HOME/wx-libs/builds/wxWidgets-${WX_VERSION}
    mkdir debug
    cd debug
    ../configure --disable-shared --with-libtiff=builtin \
        --disable-unicode \
        --prefix=$WX_INSTALL_LOC --enable-debug
    make
    make install

    # Step 4:
    # build and install the release wxWidgets library
    cd $HOME/wx-libs/builds/wxWidgets-${WX_VERSION}
    mkdir release
    cd release
    ../configure --disable-shared --with-libtiff=builtin \
        --disable-unicode \
        --prefix=$WX_INSTALL_LOC
    make
    make install

#########################################
# Building cross-compiling wxWidgets libraries

Here are the steps I used to build and install the 32-bit and 64-bit
releases of the wxWidgets libraries. I assume you have done the
above already, so I didn't repeat steps to unpack archives, etc.,
but I did repeat environment variable settings and modules commands
since those are the trickiest things. Note that I installed these
into a different directory than the Linux libraries. Theoretically,
it should be possible to do it all in one place, but I have had
trouble with that in the past.

    # Step 0:
    # These are some values I used, but which you might want or need
    # to do differently
    export WX_VERSION=2.9.4
    export WX_INSTALL_LOC=$HOME/wx-libs/wxMSW

    # Step 1:
    # invoke modules to get a more modern default g++ compiler and
    # library.
    . /etc/profile.d/modules.sh
    module load modules modules-init modules-gs
    module load gmp mpfr/2.4.1 gcc

    # Step 2:
    # unfortunately, in order to make the modules
    # command make everything
    # 'just work' for the typical user,
    # several environment variables
    # are set which hose the
    # cross-compiling process. these steps
    # undo that
    unset CC
    unset CPP
    unset CXX
    unset CPPFLAGS
    unset LDFLAGS

    # Step 3a:
    # get the desired 32-bit cross-compiler on our $PATH
    export CROSS_HOME=/net/gs/vol1/home/sanity/cross-tools/cross_win32
    export HOST_TYPE=i686-w64-mingw32
    export PATH=$CROSS_HOME/bin:$CROSS_HOME/$HOST_TYPE/bin/:$PATH

    # Step 3b:
    # build and install the release wxWidgets library
    cd $HOME/wx-libs/builds/wxWidgets-${WX_VERSION}
    mkdir msw-32
    cd msw-32
    ../configure --disable-shared --with-libtiff=builtin \
        --host=$HOST_TYPE \
        --prefix=$WX_INSTALL_LOC
    make
    make install


    # Step 4a:
    # get the desired 64-bit cross-compiler on our $PATH
    export CROSS_HOME=/net/gs/vol1/home/sanity/cross-tools/cross_win64
    export HOST_TYPE=x86_64-w64-mingw32
    export PATH=$CROSS_HOME/bin:$CROSS_HOME/$HOST_TYPE/bin/:$PATH

    # Step 4b:
    # build and install the release wxWidgets library
    cd $HOME/wx-libs/builds/wxWidgets-${WX_VERSION}
    mkdir msw-64
    cd msw-64
    ../configure --disable-shared --with-libtiff=builtin \
        --host=$HOST_TYPE \
        --prefix=$WX_INSTALL_LOC
    make
    make install


#########################################
# Building 64-bit Mac OS X libraries

Here's what I did to build a wxWidgets library that works for 10.6 and 10.7


    cd path/to/wxWidgetsDistribution
    mkdir osx
    cd osx
    ../configure --disable-unicode --disable-shared \
      --with-osx_cocoa \
      --with-macosx-version-min=10.6 \
      --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk \
      --with-libjpeg=builtin --with-libpng=builtin \
      --with-regex=builtin --without-libtiff \
      --with-zlib=builtin --with-expat=builtin \
      --prefix=$HOME/my-wx-lib
    make
    make install

# note -- you will need to use the following flags when configuring lamarc

    ../configure --disable-unicode --disable-shared \
      --with-osx_cocoa \
      --with-macosx-version-min=10.6 \
      --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk \
      --with-wx-config=$HOME/my-wx-lib/bin/wx-config

