~vlad-lesin/percona-server/mysql-5.0.33-original

« back to all changes in this revision

Viewing changes to scripts/mysql_config.sh

  • Committer: Vlad Lesin
  • Date: 2012-07-31 09:21:34 UTC
  • Revision ID: vladislav.lesin@percona.com-20120731092134-zfodx022b7992wsi
VirginĀ 5.0.33

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 
3
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; either version 2 of the License, or
 
7
# (at your option) any later version.
 
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.
 
13
 
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 
 
18
# This script reports various configuration settings that may be needed
 
19
# when using the MySQL client library.
 
20
 
 
21
which ()
 
22
{
 
23
  IFS="${IFS=   }"; save_ifs="$IFS"; IFS=':'
 
24
  for file
 
25
  do
 
26
    for dir in $PATH
 
27
    do
 
28
      if test -f $dir/$file
 
29
      then
 
30
        echo "$dir/$file"
 
31
        continue 2
 
32
      fi
 
33
    done
 
34
    echo "which: no $file in ($PATH)"
 
35
    exit 1
 
36
  done
 
37
  IFS="$save_ifs"
 
38
}
 
39
 
 
40
#
 
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
 
45
 
 
46
fix_path ()
 
47
{
 
48
  var=$1
 
49
  shift
 
50
  for filename
 
51
  do
 
52
    path=$basedir/$filename
 
53
    if [ -d "$path" ] ;
 
54
    then
 
55
      eval "$var"=$path
 
56
      return
 
57
    fi
 
58
  done
 
59
}
 
60
 
 
61
get_full_path ()
 
62
{
 
63
  file=$1
 
64
 
 
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 }'`
 
69
  fi
 
70
 
 
71
  case $file in
 
72
    /*) echo "$file";;
 
73
    */*) tmp=`pwd`/$file; echo $tmp | sed -e 's;/\./;/;' ;;
 
74
    *) which $file ;;
 
75
  esac
 
76
}
 
77
 
 
78
me=`get_full_path $0`
 
79
 
 
80
basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
 
81
 
 
82
ldata='@localstatedir@'
 
83
execdir='@libexecdir@'
 
84
bindir='@bindir@'
 
85
 
 
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
 
90
 
 
91
pkgincludedir='@pkgincludedir@'
 
92
fix_path pkgincludedir include/mysql include
 
93
 
 
94
version='@VERSION@'
 
95
socket='@MYSQL_UNIX_ADDR@'
 
96
port='@MYSQL_TCP_PORT@'
 
97
ldflags='@LDFLAGS@'
 
98
 
 
99
# Create options 
 
100
# We intentionally add a space to the beginning and end of lib strings, simplifies replace later
 
101
libs=" $ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@"
 
102
libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@ "
 
103
libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r @ZLIB_DEPS@ @LIBS@ @openssl_libs@ "
 
104
embedded_libs=" $ldflags -L$pkglibdir -lmysqld @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @innodb_system_libs@ @openssl_libs@ "
 
105
 
 
106
cflags="-I$pkgincludedir @CFLAGS@ " #note: end space!
 
107
include="-I$pkgincludedir"
 
108
 
 
109
# Remove some options that a client doesn't have to care about
 
110
# FIXME until we have a --cxxflags, we need to remove -Xa
 
111
#       and -xstrconst to make --cflags usable for Sun Forte C++
 
112
for remove in DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX \
 
113
              DPEDANTIC_SAFEMALLOC DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \
 
114
              DEXTRA_DEBUG DHAVE_purify O 'O[0-9]' 'xO[0-9]' 'W[-A-Za-z]*' \
 
115
              Xa xstrconst "xc99=none" \
 
116
              unroll2 ip mp restrict
 
117
do
 
118
  # The first option we might strip will always have a space before it because
 
119
  # we set -I$pkgincludedir as the first option
 
120
  cflags=`echo "$cflags"|sed -e "s/ -$remove  */ /g"` 
 
121
done
 
122
cflags=`echo "$cflags"|sed -e 's/ *\$//'` 
 
123
 
 
124
# Same for --libs(_r)
 
125
for remove in lmtmalloc static-libcxa i-static
 
126
do
 
127
  # We know the strings starts with a space
 
128
  libs=`echo "$libs"|sed -e "s/ -$remove  */ /g"` 
 
129
  libs_r=`echo "$libs_r"|sed -e "s/ -$remove  */ /g"` 
 
130
  embedded_libs=`echo "$embedded_libs"|sed -e "s/ -$remove  */ /g"` 
 
131
done
 
132
 
 
133
# Strip trailing and ending space if any, and '+' (FIXME why?)
 
134
libs=`echo "$libs" | sed -e 's;  \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
 
135
libs_r=`echo "$libs_r" | sed -e 's;  \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
 
136
embedded_libs=`echo "$embedded_libs" | sed -e 's;  \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
 
137
 
 
138
usage () {
 
139
        cat <<EOF
 
140
Usage: $0 [OPTIONS]
 
141
Options:
 
142
        --cflags         [$cflags]
 
143
        --include        [$include]
 
144
        --libs           [$libs]
 
145
        --libs_r         [$libs_r]
 
146
        --socket         [$socket]
 
147
        --port           [$port]
 
148
        --version        [$version]
 
149
        --libmysqld-libs [$embedded_libs]
 
150
EOF
 
151
        exit 1
 
152
}
 
153
 
 
154
if test $# -le 0; then usage; fi
 
155
 
 
156
while test $# -gt 0; do
 
157
        case $1 in
 
158
        --cflags)  echo "$cflags" ;;
 
159
        --include) echo "$include" ;;
 
160
        --libs)    echo "$libs" ;;
 
161
        --libs_r)  echo "$libs_r" ;;
 
162
        --socket)  echo "$socket" ;;
 
163
        --port)    echo "$port" ;;
 
164
        --version) echo "$version" ;;
 
165
        --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;;
 
166
        *)         usage ;;
 
167
        esac
 
168
 
 
169
        shift
 
170
done
 
171
 
 
172
#echo "ldata: '"$ldata"'"
 
173
#echo "execdir: '"$execdir"'"
 
174
#echo "bindir: '"$bindir"'"
 
175
#echo "pkglibdir: '"$pkglibdir"'"
 
176
#echo "pkgincludedir: '"$pkgincludedir"'"
 
177
#echo "version: '"$version"'"
 
178
#echo "socket: '"$socket"'"
 
179
#echo "port: '"$port"'"
 
180
#echo "ldflags: '"$ldflags"'"
 
181
#echo "client_libs: '"$client_libs"'"
 
182
 
 
183
exit 0