~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to scripts/mysql_config.sh

  • Committer: Stewart Smith
  • Date: 2008-07-09 01:40:54 UTC
  • mfrom: (105 drizzle)
  • mto: This revision was merged to the branch mainline in revision 111.
  • Revision ID: stewart@flamingspork.com-20080709014054-xfgfzirbhqzrzkkj
mergeĀ fromĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
# Copyright (C) 2000-2006 MySQL 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; version 2 of the License.
7
 
8
 
# This program is distributed in the hope that it will be useful,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU General Public License for more details.
12
 
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 
 
17
 
# This script reports various configuration settings that may be needed
18
 
# when using the MySQL client library.
19
 
 
20
 
which ()
21
 
{
22
 
  IFS="${IFS=   }"; save_ifs="$IFS"; IFS=':'
23
 
  for file
24
 
  do
25
 
    for dir in $PATH
26
 
    do
27
 
      if test -f $dir/$file
28
 
      then
29
 
        echo "$dir/$file"
30
 
        continue 2
31
 
      fi
32
 
    done
33
 
    echo "which: no $file in ($PATH)"
34
 
    exit 1
35
 
  done
36
 
  IFS="$save_ifs"
37
 
}
38
 
 
39
 
#
40
 
# If we can find the given directory relatively to where mysql_config is
41
 
# we should use this instead of the incompiled one.
42
 
# This is to ensure that this script also works with the binary MySQL
43
 
# version
44
 
 
45
 
fix_path ()
46
 
{
47
 
  var=$1
48
 
  shift
49
 
  for filename
50
 
  do
51
 
    path=$basedir/$filename
52
 
    if [ -d "$path" ] ;
53
 
    then
54
 
      eval "$var"=$path
55
 
      return
56
 
    fi
57
 
  done
58
 
}
59
 
 
60
 
get_full_path ()
61
 
{
62
 
  file=$1
63
 
 
64
 
  # if the file is a symlink, try to resolve it
65
 
  if [ -h $file ];
66
 
  then
67
 
    file=`ls -l $file | awk '{ print $NF }'`
68
 
  fi
69
 
 
70
 
  case $file in
71
 
    /*) echo "$file";;
72
 
    */*) tmp=`pwd`/$file; echo $tmp | sed -e 's;/\./;/;' ;;
73
 
    *) which $file ;;
74
 
  esac
75
 
}
76
 
 
77
 
me=`get_full_path $0`
78
 
 
79
 
basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
80
 
 
81
 
ldata='@localstatedir@'
82
 
execdir='@libexecdir@'
83
 
bindir='@bindir@'
84
 
 
85
 
# If installed, search for the compiled in directory first (might be "lib64")
86
 
pkglibdir='@pkglibdir@'
87
 
pkglibdir_rel=`echo $pkglibdir | sed -e "s;^$basedir/;;"`
88
 
fix_path pkglibdir $pkglibdir_rel lib/mysql lib
89
 
 
90
 
plugindir='@pkgplugindir@'
91
 
 
92
 
pkgincludedir='@pkgincludedir@'
93
 
fix_path pkgincludedir include/mysql include
94
 
 
95
 
version='@VERSION@'
96
 
socket='@MYSQL_UNIX_ADDR@'
97
 
ldflags='@LDFLAGS@'
98
 
 
99
 
if [ @MYSQL_TCP_PORT_DEFAULT@ -eq 0 ]; then
100
 
  port=0
101
 
else
102
 
  port=@MYSQL_TCP_PORT@
103
 
fi
104
 
 
105
 
# Create options 
106
 
# We intentionally add a space to the beginning and end of lib strings, simplifies replace later
107
 
libs=" $ldflags -L$pkglibdir -lmysqlclient "
108
 
libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@ "
109
 
libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r @LIBS@ @openssl_libs@ "
110
 
libdir="-L$pkglibdir"
111
 
embedded_libs=" $ldflags -L$pkglibdir -lmysqld @LIBS@ @WRAPLIBS@ @innodb_system_libs@ @openssl_libs@ "
112
 
 
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 "
121
 
fi
122
 
 
123
 
cflags="-I$pkgincludedir @CFLAGS@ " #note: end space!
124
 
include="-I$pkgincludedir"
125
 
 
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
137
 
do
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/ *\$//'` 
143
 
 
144
 
# Same for --libs(_r)
145
 
for remove in lmtmalloc static-libcxa i-static static-intel
146
 
do
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
152
 
 
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; *\$;;'`
157
 
 
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
 
        --libdir         [$libdir]
167
 
        --plugindir      [$plugindir]
168
 
        --socket         [$socket]
169
 
        --port           [$port]
170
 
        --version        [$version]
171
 
        --libmysqld-libs [$embedded_libs]
172
 
EOF
173
 
        exit 1
174
 
}
175
 
 
176
 
if test $# -le 0; then usage; fi
177
 
 
178
 
while test $# -gt 0; do
179
 
        case $1 in
180
 
        --cflags)  echo "$cflags" ;;
181
 
        --include) echo "$include" ;;
182
 
        --libs)    echo "$libs" ;;
183
 
        --libs_r)  echo "$libs_r" ;;
184
 
        --libdir)  echo "$libdir" ;;
185
 
        --plugindir) echo "$plugindir" ;;
186
 
        --socket)  echo "$socket" ;;
187
 
        --port)    echo "$port" ;;
188
 
        --version) echo "$version" ;;
189
 
        --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;;
190
 
        *)         usage ;;
191
 
        esac
192
 
 
193
 
        shift
194
 
done
195
 
 
196
 
#echo "ldata: '"$ldata"'"
197
 
#echo "execdir: '"$execdir"'"
198
 
#echo "bindir: '"$bindir"'"
199
 
#echo "pkglibdir: '"$pkglibdir"'"
200
 
#echo "pkgincludedir: '"$pkgincludedir"'"
201
 
#echo "version: '"$version"'"
202
 
#echo "socket: '"$socket"'"
203
 
#echo "port: '"$port"'"
204
 
#echo "ldflags: '"$ldflags"'"
205
 
#echo "client_libs: '"$client_libs"'"
206
 
 
207
 
exit 0