~diego-fmpwizard/mysql-proxy/bug-43424

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
Installation Instructions
*************************



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

Windows
-------

To be written...

C:\work\mysql-lb-win32\trunk>cmake -G "Visual Studio 8 2005" -DFLEX_EXECUTABLE="c:\Program Files\GnuWin32\bin\flex.exe" -DMYSQL_INCLUDE_DIRS="c:\Program Files\MySQL\MySQL Server 5.0\include" -DMYSQL_LIBRARY_DIRS="c:\Program Files\MySQL\MySQL Server 5.0\lib" -DGLIB_INCLUDE_DIRS="c:\Program Files\GTK2-Runtime\include\glib-2.0";"c:\Program Files\GTK2-Runtime\lib\glib-2.0\include" -DGLIB_LIBRARY_DIRS="c:\Program Files\GTK2-Runtime\lib" -DCMAKE_INSTALL_PREFIX=c:\work\install .

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.