Installation Instructions
*************************

Copyright (C) 2007 MySQL AB

Installing from SVN
===================

Get the SVN source from:

  $ svn co http://svn.mysql.com/svnpublic/mysql-proxy/ mysql-proxy

Later you can update the tree by running

  $ cd mysql-proxy/
  $ svn up

As you built from SVN none of the configure scripts is prepared. You need:

- autoconf 2.56 or higher
- automake 1.9 or higher
- flex 

to generate the configure script. Use the provided autogen.sh to rebuild 
the config-scripts:

  $ sh ./autogen.sh

You should have a configure script, ready to build.

MacOS X
-------

In case you are using fink some packages are in different locations and need to be adjusted.

pkg-config installs its pkg.m4 into the fink locations while automake looks in 
/usr/local/share/aclocal. Setting ACLOCAL_FLAGS to get a include directory makes aclocal
aware of the new location.

  $ ACLOCAL_FLAGS="-I /sw/share/aclocal/"
  $ export ACLOCAL_FLAGS
  $ sh ./autogen.sh

Installing from Source 
======================

  $ gzip -cd mysql-proxy-<version>.tar.gz | tar xf -
  $ cd mysql-proxy-<version>

Preparing the Build
===================

As you have the source in the right place and the configure script exists, you have 
to make sure that the dependencies are in place;

- libevent 1.x or higher (1.3b or later is prefered)
- lua 5.1.x or higher
- glib2 2.6.0 or higher
- pkg-config 
- mysql 5.0.x or higher developer files
- Ensure $MYSQL_HOME/bin is in the PATH  (mysql_config required)

CentOS release 4.3 (Final)
--------------------------

CentOS 4.3 does not have lua 5.1 (it is on 5.0) and it has a version of
glib-2.0 that is too old to build.

If you can afford to upgrade lua and glib-2, just obtain newer versions of
LUA and Glib-2 source rpms and run "rpmbuild --rebuild <source rpm name>",
for example out of Fedora Core 7, and install the resulting newer packages.

libevent and libevent-devel have been gathered from Dag Wieers
<dag@wieers.com> repository.

$ yum install \
    lua \
    lua-devel \
    libevent \
    libevent-devel \
    glib2 \
    glib2-devel \
    pkg-config \
    mysqlclient14-devel

If you cannot upgrade the glib2 to the required minimum version, you'll have
to hack up the glib2 package to install to /usr/local and compile the proxy with

----
  %build
  export PKG_CONFIG_PATH="/usr/local/lib64/pkgconfig"
  export GLIB_CFLAGS="-I/usr/local/include/glib-2.0 -I/usr/local/lib64/glib-2.0/include"
  export GLIB_LIBS="-L/usr/local/lib64 -Wl,-rpath /usr/local/lib64 -lglib-2.0"
  %configure \
    --datadir=%{_datadir}/%{name} \
  %if 0%{?with_lua}
    --with-lua
  %else
    --without-lua
  %endif
  %{__make}
----


Ubuntu/Debian
-------------

  $ apt-get install \
      pkg-config \
      liblua5.1-0 \
      liblua5.1-dev \
      libevent-dev \
      libevent1  \
      libglib2.0-0 \
      libglib2.0-dev \
      libmysqlclient-dev

On Debian and Ubuntu you need to tell the configure script that it has to use 
"pkg-config lua5.1" to detect the lua-libriaries instead of the default 
"pkg-config lua".

  $ ./configure --with-lua=lua5.1


MacOSX
------

If you are using darwin-ports pkg-config might not be able to see the glib-2.0.pc in 
/opt/local/lib/pkgconfig.

  $ PKG_CONFIG_PATH="/opt/local/lib/pkgconfig" \
      ./configure

openSUSE
--------

Make sure that the following RPM packages (and their dependencies) are
installed (use YaST or any other package management tool to install these):

- glib2-devel
- mysql-devel
- lua-devel
- libevent

You can convert the source tarball into an installable binary RPM by running
the following command:

  $ rpmbuild -ta --clean mysql-proxy-<version>.tar.gz

The binary will be installed in /usr/sbin/mysql-proxy, the example lua scripts
are placed into /usr/share/doc/packages/mysql-proxy


All other Platforms
-------------------

On most platforms a simple configure run works nicely:

  $ ./configure 


If lua isn't shipped with a lua.pc file for pkg-config we need to override the 
pkg-config checks:

  $ ./configure \
    LUA_CFLAGS="-I/directory/of/lua.h" \
    LUA_LDFLAGS="-L/directory/of/liblua.so -llua"

In case libevent is not detected correctly, you should set LDFLAGS and CPPFLAGS:

  $ ./configure \
    LDFLAGS="-L/directory/of/libevent.so -levent" \
    CPPFLAGS="-I/directory/of/event.h"

Building
========

  $ make
  $ make install

You should have a /usr/local/sbin/mysql-proxy now.


