mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / scripts / mysql_config.sh
blob7dc9beb3b9041d5d0e3fe6e7daed931845b6c671
1 #!/bin/sh
2 # Copyright (c) 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
3 # Use is subject to license terms.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 # This script reports various configuration settings that may be needed
19 # when using the MySQL client library.
21 which ()
23 IFS="${IFS= }"; save_ifs="$IFS"; IFS=':'
24 for file
26 for dir in $PATH
28 if test -f $dir/$file
29 then
30 echo "$dir/$file"
31 continue 2
33 done
34 echo "which: no $file in ($PATH)"
35 exit 1
36 done
37 IFS="$save_ifs"
41 # If we can find the given directory relatively to where mysql_config is
42 # we should use this instead of the incompiled one.
43 # This is to ensure that this script also works with the binary MySQL
44 # version
46 fix_path ()
48 var=$1
49 shift
50 for filename
52 path=$basedir/$filename
53 if [ -d "$path" ] ;
54 then
55 eval "$var"=$path
56 return
58 done
61 get_full_path ()
63 file=$1
65 # if the file is a symlink, try to resolve it
66 if [ -h $file ];
67 then
68 file=`ls -l $file | awk '{ print $NF }'`
71 case $file in
72 /*) echo "$file";;
73 */*) tmp=`pwd`/$file; echo $tmp | sed -e 's;/\./;/;' ;;
74 *) which $file ;;
75 esac
78 me=`get_full_path $0`
80 basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
82 ldata='@localstatedir@'
83 execdir='@libexecdir@'
84 bindir='@bindir@'
86 # If installed, search for the compiled in directory first (might be "lib64")
87 pkglibdir='@pkglibdir@'
88 pkglibdir_rel=`echo $pkglibdir | sed -e "s;^$basedir/;;"`
89 fix_path pkglibdir $pkglibdir_rel lib/mysql lib
91 plugindir='@pkgplugindir@'
93 pkgincludedir='@pkgincludedir@'
94 fix_path pkgincludedir include/mysql include
96 version='@VERSION@'
97 socket='@MYSQL_UNIX_ADDR@'
98 ldflags='@LDFLAGS@'
100 if [ @MYSQL_TCP_PORT_DEFAULT@ -eq 0 ]; then
101 port=0
102 else
103 port=@MYSQL_TCP_PORT@
106 # Create options
107 # We intentionally add a space to the beginning and end of lib strings, simplifies replace later
108 libs=" $ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@"
109 libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@ "
110 libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r @ZLIB_DEPS@ @LIBS@ @openssl_libs@ "
111 embedded_libs=" $ldflags -L$pkglibdir -lmysqld @LIBDL@ @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @innodb_system_libs@ @openssl_libs@ "
113 if [ -r "$pkglibdir/libmygcc.a" ]; then
114 # When linking against the static library with a different version of GCC
115 # from what was used to compile the library, some symbols may not be defined
116 # automatically. We package the libmygcc.a from the build host, to provide
117 # definitions for those. Bugs 4921, 19561, 19817, 21158, etc.
118 libs="$libs -lmygcc "
119 libs_r="$libs_r -lmygcc "
120 embedded_libs="$embedded_libs -lmygcc "
123 cflags="-I$pkgincludedir @CFLAGS@ " #note: end space!
124 include="-I$pkgincludedir"
126 # Remove some options that a client doesn't have to care about
127 # FIXME until we have a --cxxflags, we need to remove -Xa
128 # and -xstrconst to make --cflags usable for Sun Forte C++
129 # FIXME until we have a --cxxflags, we need to remove -AC99
130 # to make --cflags usable for HP C++ (aCC)
131 for remove in DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX \
132 DPEDANTIC_SAFEMALLOC DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \
133 DEXTRA_DEBUG DHAVE_purify O 'O[0-9]' 'xO[0-9]' 'W[-A-Za-z]*' \
134 'mtune=[-A-Za-z0-9]*' 'mcpu=[-A-Za-z0-9]*' 'march=[-A-Za-z0-9]*' \
135 Xa xstrconst "xc99=none" AC99 \
136 unroll2 ip mp restrict
138 # The first option we might strip will always have a space before it because
139 # we set -I$pkgincludedir as the first option
140 cflags=`echo "$cflags"|sed -e "s/ -$remove */ /g"`
141 done
142 cflags=`echo "$cflags"|sed -e 's/ *\$//'`
144 # Same for --libs(_r)
145 for remove in lmtmalloc static-libcxa i-static static-intel
147 # We know the strings starts with a space
148 libs=`echo "$libs"|sed -e "s/ -$remove */ /g"`
149 libs_r=`echo "$libs_r"|sed -e "s/ -$remove */ /g"`
150 embedded_libs=`echo "$embedded_libs"|sed -e "s/ -$remove */ /g"`
151 done
153 # Strip trailing and ending space if any, and '+' (FIXME why?)
154 libs=`echo "$libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
155 libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
156 embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
158 usage () {
159 cat <<EOF
160 Usage: $0 [OPTIONS]
161 Options:
162 --cflags [$cflags]
163 --include [$include]
164 --libs [$libs]
165 --libs_r [$libs_r]
166 --plugindir [$plugindir]
167 --socket [$socket]
168 --port [$port]
169 --version [$version]
170 --libmysqld-libs [$embedded_libs]
172 exit 1
175 if test $# -le 0; then usage; fi
177 while test $# -gt 0; do
178 case $1 in
179 --cflags) echo "$cflags" ;;
180 --include) echo "$include" ;;
181 --libs) echo "$libs" ;;
182 --libs_r) echo "$libs_r" ;;
183 --plugindir) echo "$plugindir" ;;
184 --socket) echo "$socket" ;;
185 --port) echo "$port" ;;
186 --version) echo "$version" ;;
187 --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;;
188 *) usage ;;
189 esac
191 shift
192 done
194 #echo "ldata: '"$ldata"'"
195 #echo "execdir: '"$execdir"'"
196 #echo "bindir: '"$bindir"'"
197 #echo "pkglibdir: '"$pkglibdir"'"
198 #echo "pkgincludedir: '"$pkgincludedir"'"
199 #echo "version: '"$version"'"
200 #echo "socket: '"$socket"'"
201 #echo "port: '"$port"'"
202 #echo "ldflags: '"$ldflags"'"
203 #echo "client_libs: '"$client_libs"'"
205 exit 0