4
# Copyright (C) 2007 MySQL AB
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; version 2 of the License.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
##############################################################################
21
# This script reports various configuration settings that may be needed
22
# when using the MySQL client library.
24
# This script try to match the shell script version as close as possible,
25
# but in addition being compatible with ActiveState Perl on Windows.
27
# All unrecognized arguments to this script are passed to mysqld.
29
# NOTE: This script will only be used on Windows until solved how to
30
# handle @LIBS@ and other strings inserted that might contain
31
# several arguments, possibly with spaces in them.
33
# NOTE: This script was deliberately written to be as close to the shell
34
# script as possible, to make the maintenance of both in parallel
37
##############################################################################
45
qw/DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX
46
DPEDANTIC_SAFEMALLOC DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS
47
DEXTRA_DEBUG DHAVE_purify O O[0-9] xO[0-9] W[-A-Za-z]*
48
Xa xstrconst xc99=none
49
unroll2 ip mp restrict/;
51
my @exclude_libs = qw/lmtmalloc static-libcxa i-static static-intel/;
56
my $socket = '@MYSQL_UNIX_ADDR@';
57
my $version = '@VERSION@';
63
my $IFS = $^O eq "MSWin32" ? ";" : ":";
65
foreach my $dir ( split($IFS, $ENV{PATH}) )
67
if ( -f "$dir/$file" or -f "$dir/$file.exe" )
72
print STDERR "which: no $file in ($ENV{PATH})\n";
76
# ----------------------------------------------------------------------
77
# If we can find the given directory relatively to where mysql_config is
78
# we should use this instead of the incompiled one.
79
# This is to ensure that this script also works with the binary MySQL
81
# ----------------------------------------------------------------------
88
foreach my $dirname ( @dirs )
90
my $path = "$basedir/$dirname";
103
# if the file is a symlink, try to resolve it
104
if ( $^O ne "MSWin32" and -l $file )
106
$file = readlink($file);
109
if ( $file =~ m,^/, )
111
# Do nothing, absolute path
113
elsif ( $file =~ m,/, )
115
# Make absolute, and remove "/./" in path
116
$file = "$cwd/$file";
122
$file = which($file);
128
##############################################################################
130
# Form a command line that can handle spaces in paths and arguments
132
##############################################################################
136
foreach my $opt ( @_ )
138
next unless $opt; # If undefined or empty, just skip
139
push(@cmd, "\"$opt\""); # Quote argument
141
return join(" ", @cmd);
144
##############################################################################
148
##############################################################################
150
my $me = get_full_path($0);
151
$basedir = dirname(dirname($me)); # Remove "/bin/mysql_config" part
153
my $ldata = '@localstatedir@';
154
my $execdir = '@libexecdir@';
155
my $bindir = '@bindir@';
157
# ----------------------------------------------------------------------
158
# If installed, search for the compiled in directory first (might be "lib64")
159
# ----------------------------------------------------------------------
161
my $pkglibdir = fix_path('@pkglibdir@',"libmysql/relwithdebinfo",
162
"libmysql/release","libmysql/debug","lib/mysql","lib");
164
my $pkgincludedir = fix_path('@pkgincludedir@', "include/mysql", "include");
166
# Assume no argument with space in it
167
my @ldflags = split(" ",'@LDFLAGS@');
170
if ( '@MYSQL_TCP_PORT_DEFAULT@' == 0 ) {
173
$port = '@MYSQL_TCP_PORT@';
176
# ----------------------------------------------------------------------
178
# We intentionally add a space to the beginning and end of lib strings, simplifies replace later
179
# ----------------------------------------------------------------------
181
my (@lib_opts,@lib_r_opts,@lib_e_opts);
182
if ( $^O eq "MSWin32" )
184
my $linkpath = "$pkglibdir";
185
# user32 is only needed for debug or embedded
186
my @winlibs = ("wsock32.lib","advapi32.lib","user32.lib");
187
@lib_opts = ("$linkpath/mysqlclient.lib",@winlibs);
188
@lib_r_opts = @lib_opts;
189
@lib_e_opts = ("$linkpath/mysqlserver.lib",@winlibs);
193
my $linkpath = "-L$pkglibdir";
194
@lib_opts = ($linkpath,"-lmysqlclient");
195
@lib_r_opts = ($linkpath,"-lmysqlclient_r");
196
@lib_e_opts = ($linkpath,"-lmysqld");
201
[@ldflags,@lib_opts,'@ZLIB_DEPS@','@NON_THREADED_LIBS@','@openssl_libs@','@STATIC_NSS_FLAGS@'];
203
[@ldflags,@lib_r_opts,'@ZLIB_DEPS@','@LIBS@','@openssl_libs@'];
204
$flags->{embedded_libs} =
205
[@ldflags,@lib_e_opts,'@ZLIB_DEPS@','@LIBS@','@WRAPLIBS@','@innodb_system_libs@','@openssl_libs@'];
207
$flags->{include} = ["-I$pkgincludedir"];
208
$flags->{cflags} = [@{$flags->{include}},split(" ",'@CFLAGS@')];
210
# ----------------------------------------------------------------------
211
# Remove some options that a client doesn't have to care about
212
# FIXME until we have a --cxxflags, we need to remove -Xa
213
# and -xstrconst to make --cflags usable for Sun Forte C++
214
# ----------------------------------------------------------------------
216
my $filter = join("|", @exclude_cflags);
217
my @tmp = @{$flags->{cflags}}; # Copy the flag list
218
$flags->{cflags} = []; # Clear it
219
foreach my $cflag ( @tmp )
221
push(@{$flags->{cflags}}, $cflag) unless $cflag =~ m/^($filter)$/o;
224
# Same for --libs(_r)
225
$filter = join("|", @exclude_libs);
226
foreach my $lib_type ( "libs","libs_r","embedded_libs" )
228
my @tmp = @{$flags->{$lib_type}}; # Copy the flag list
229
$flags->{$lib_type} = []; # Clear it
230
foreach my $lib ( @tmp )
232
push(@{$flags->{$lib_type}}, $lib) unless $lib =~ m/^($filter)$/o;
236
my $include = quote_options(@{$flags->{include}});
237
my $cflags = quote_options(@{$flags->{cflags}});
238
my $libs = quote_options(@{$flags->{libs}});
239
my $libs_r = quote_options(@{$flags->{libs_r}});
240
my $embedded_libs = quote_options(@{$flags->{embedded_libs}});
242
##############################################################################
244
# Usage information, output if no option is given
246
##############################################################################
260
--libmysqld-libs [$embedded_libs]
267
##############################################################################
269
# Get options and output the values
271
##############################################################################
274
"cflags" => sub { print "$cflags\n" },
275
"include" => sub { print "$include\n" },
276
"libs" => sub { print "$libs\n" },
277
"libs_r" => sub { print "$libs_r\n" },
278
"socket" => sub { print "$socket\n" },
279
"port" => sub { print "$port\n" },
280
"version" => sub { print "$version\n" },
281
"embedded-libs|embedded|libmysqld-libs" =>
282
sub { print "$embedded_libs\n" },