| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. |
| 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 16 | |
| 17 | # This script reports various configuration settings that may be needed |
| 18 | # when using the MySQL client library. |
| 19 | |
| 20 | whichscip-shell shell shell-project 0.0.0 which(). () |
| 21 | { |
| 22 | IFS="${IFS= }"; save_ifs="$IFS"; IFS=':' |
| 23 | for file |
| 24 | do |
| 25 | for dir in $PATH |
| 26 | do |
| 27 | if testscip-shell system . . test. -f $dir/$file |
| 28 | then |
| 29 | echoscip-shell system . . echo. "$dir/$file" |
| 30 | continue 2 |
| 31 | fi |
| 32 | done |
| 33 | echoscip-shell system . . 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_pathscip-shell shell shell-project 0.0.0 fix_path(). () |
| 46 | { |
| 47 | var=$1 |
| 48 | shift |
| 49 | for filename |
| 50 | do |
| 51 | path=$basedir/$filename |
| 52 | if [scip-shell system . . `[`. -d "$path" ] ; |
| 53 | then |
| 54 | eval "$var"=$path |
| 55 | return |
| 56 | fi |
| 57 | done |
| 58 | } |
| 59 | |
| 60 | get_full_pathscip-shell shell shell-project 0.0.0 get_full_path(). () |
| 61 | { |
| 62 | file=$1 |
| 63 | |
| 64 | # if the file is a symlink, try to resolve it |
| 65 | if [scip-shell system . . `[`. -h $file ]; |
| 66 | then |
| 67 | file=`lsscip-shell system . . ls. -l $file | awkscip-shell system . . awk. '{ print $NF }'` |
| 68 | fi |
| 69 | |
| 70 | case $file in |
| 71 | /*) echoscip-shell system . . echo. "$file";; |
| 72 | */*) tmp=`pwdscip-shell system . . pwd.`/$file; echoscip-shell system . . echo. $tmp | sedscip-shell system . . sed. -e 's;/\./;/;' ;; |
| 73 | *) whichscip-shell shell shell-project 0.0.0 which(). $file ;; |
| 74 | esac |
| 75 | } |
| 76 | |
| 77 | me=`get_full_pathscip-shell shell shell-project 0.0.0 get_full_path(). $0` |
| 78 | |
| 79 | # Script might have been renamed but assume mysql_<something>config<something> |
| 80 | basedir=`echoscip-shell system . . echo. $me | sedscip-shell system . . sed. -e 's;/bin/mysql_.*config.*;;'` |
| 81 | |
| 82 | ldata='/var/lib/mysqlscip-shell filesystem . . `/var/lib/mysql`.' |
| 83 | execdir='/usr/sbinscip-shell filesystem . . `/usr/sbin`.' |
| 84 | bindir='/usr/binscip-shell filesystem . . `/usr/bin`.' |
| 85 | |
| 86 | # If installed, search for the compiled in directory first (might be "lib64") |
| 87 | pkglibdir='/usr/lib/x86_64-linux-gnuscip-shell filesystem . . `/usr/lib/x86_64-linux-gnu`.' |
| 88 | pkglibdir_rel=`echoscip-shell system . . echo. $pkglibdir | sedscip-shell system . . sed. -e "s;^$basedir/;;"` |
| 89 | fix_pathscip-shell shell shell-project 0.0.0 fix_path(). pkglibdir $pkglibdir_rel lib/x86_64-linux-gnu/mysql lib/x86_64-linux-gnu |
| 90 | |
| 91 | plugindir='/usr/lib/mysql/pluginscip-shell filesystem . . `/usr/lib/mysql/plugin`.' |
| 92 | plugindir_rel=`echoscip-shell system . . echo. $plugindir | sedscip-shell system . . sed. -e "s;^$basedir/;;"` |
| 93 | fix_pathscip-shell shell shell-project 0.0.0 fix_path(). plugindir $plugindir_rel lib/x86_64-linux-gnu/mysql/plugin lib/x86_64-linux-gnu/plugin |
| 94 | |
| 95 | pkgincludedir='/usr/include/mysqlscip-shell filesystem . . `/usr/include/mysql`.' |
| 96 | if [scip-shell system . . `[`. -f "$basedir/include/mysql/mysql.h" ]; then |
| 97 | pkgincludedir="$basedir/include/mysql" |
| 98 | elif [scip-shell system . . `[`. -f "$basedir/include/mysql.h" ]; then |
| 99 | pkgincludedir="$basedir/include" |
| 100 | fi |
| 101 | |
| 102 | version='5.6.30' |
| 103 | socket='/var/run/mysqld/mysqld.sockscip-shell filesystem . . `/var/run/mysqld/mysqld.sock`.' |
| 104 | ldflags='' |
| 105 | |
| 106 | if [scip-shell system . . `[`. 0 -eq 0 ]; then |
| 107 | port=0 |
| 108 | else |
| 109 | port=3306 |
| 110 | fi |
| 111 | |
| 112 | # Create options |
| 113 | # We intentionally add a space to the beginning and end of lib strings, simplifies replace later |
| 114 | libs=" $ldflags -L$pkglibdir -lmysqlclient -lpthread -lz -lm -ldl " |
| 115 | libs="$libs " |
| 116 | libs="$libs " |
| 117 | libs_r=" $ldflags -L$pkglibdir -lmysqlclient -lpthread -lz -lm -ldl " |
| 118 | libs_r="$libs_r " |
| 119 | embedded_libs=" $ldflags -L$pkglibdir -lmysqld -lpthread -lz -lm -lwrap -lcrypt -ldl -laio " |
| 120 | embedded_libs="$embedded_libs " |
| 121 | |
| 122 | cflags="-I$pkgincludedir -g -O2 -Wformat -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF " #note: end space! |
| 123 | cxxflags="-I$pkgincludedir -g -O2 -Wformat -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF " #note: end space! |
| 124 | include="-I$pkgincludedir" |
| 125 | |
| 126 | # Remove some options that a client doesn't have to care about |
| 127 | for remove in DDBUG_OFF DSAFE_MUTEX DFORCE_INIT_OF_VARS \ |
| 128 | DEXTRA_DEBUG DHAVE_purify O 'O[0-9]' 'xO[0-9]' 'W[-A-Za-z]*' \ |
| 129 | 'mtune=[-A-Za-z0-9]*' 'mcpu=[-A-Za-z0-9]*' 'march=[-A-Za-z0-9]*' \ |
| 130 | unroll2 ip mp restrict |
| 131 | do |
| 132 | # The first option we might strip will always have a space before it because |
| 133 | # we set -I$pkgincludedir as the first option |
| 134 | cflags=`echoscip-shell system . . echo. "$cflags"|sedscip-shell system . . sed. -e "s/ -$remove */ /g"` |
| 135 | cxxflags=`echoscip-shell system . . echo. "$cxxflags"|sedscip-shell system . . sed. -e "s/ -$remove */ /g"` |
| 136 | done |
| 137 | cflags=`echoscip-shell system . . echo. "$cflags"|sedscip-shell system . . sed. -e 's/ *\$//'` |
| 138 | cxxflags=`echoscip-shell system . . echo. "$cxxflags"|sedscip-shell system . . sed. -e 's/ *\$//'` |
| 139 | |
| 140 | # Same for --libs(_r) |
| 141 | for remove in lmtmalloc static-libcxa i-static static-intel |
| 142 | do |
| 143 | # We know the strings starts with a space |
| 144 | libs=`echoscip-shell system . . echo. "$libs"|sedscip-shell system . . sed. -e "s/ -$remove */ /g"` |
| 145 | libs_r=`echoscip-shell system . . echo. "$libs_r"|sedscip-shell system . . sed. -e "s/ -$remove */ /g"` |
| 146 | embedded_libs=`echoscip-shell system . . echo. "$embedded_libs"|sedscip-shell system . . sed. -e "s/ -$remove */ /g"` |
| 147 | done |
| 148 | |
| 149 | # Strip trailing and ending space if any, and '+' (FIXME why?) |
| 150 | libs=`echoscip-shell system . . echo. "$libs" | sedscip-shell system . . sed. -e 's; \+; ;g' | sedscip-shell system . . sed. -e 's;^ *;;' | sedscip-shell system . . sed. -e 's; *\$;;'` |
| 151 | libs_r=`echoscip-shell system . . echo. "$libs_r" | sedscip-shell system . . sed. -e 's; \+; ;g' | sedscip-shell system . . sed. -e 's;^ *;;' | sedscip-shell system . . sed. -e 's; *\$;;'` |
| 152 | embedded_libs=`echoscip-shell system . . echo. "$embedded_libs" | sedscip-shell system . . sed. -e 's; \+; ;g' | sedscip-shell system . . sed. -e 's;^ *;;' | sedscip-shell system . . sed. -e 's; *\$;;'` |
| 153 | |
| 154 | usagescip-shell shell shell-project 0.0.0 usage(). () { |
| 155 | catscip-shell system . . cat. <<EOF |
| 156 | Usage: $0 [OPTIONS] |
| 157 | Options: |
| 158 | --cflags [$cflags] |
| 159 | --cxxflags [$cxxflags] |
| 160 | --include [$include] |
| 161 | --libs [$libs] |
| 162 | --libs_r [$libs_r] |
| 163 | --plugindir [$plugindir] |
| 164 | --socket [$socket] |
| 165 | --port [$port] |
| 166 | --version [$version] |
| 167 | --libmysqld-libs [$embedded_libs] |
| 168 | --variable=VAR VAR is one of: |
| 169 | pkgincludedir [$pkgincludedir] |
| 170 | pkglibdir [$pkglibdir] |
| 171 | plugindir [$plugindir] |
| 172 | EOF |
| 173 | exit 1 |
| 174 | } |
| 175 | |
| 176 | if testscip-shell system . . test. $# -le 0; then usagescip-shell shell shell-project 0.0.0 usage().; fi |
| 177 | |
| 178 | while testscip-shell system . . test. $# -gt 0; do |
| 179 | case $1 in |
| 180 | --cflags) echoscip-shell system . . echo. "$cflags" ;; |
| 181 | --cxxflags)echoscip-shell system . . echo. "$cxxflags";; |
| 182 | --include) echoscip-shell system . . echo. "$include" ;; |
| 183 | --libs) echoscip-shell system . . echo. "$libs" ;; |
| 184 | --libs_r) echoscip-shell system . . echo. "$libs_r" ;; |
| 185 | --plugindir) echoscip-shell system . . echo. "$plugindir" ;; |
| 186 | --socket) echoscip-shell system . . echo. "$socket" ;; |
| 187 | --port) echoscip-shell system . . echo. "$port" ;; |
| 188 | --version) echoscip-shell system . . echo. "$version" ;; |
| 189 | --embedded-libs | --embedded | --libmysqld-libs) echoscip-shell system . . echo. "$embedded_libs" ;; |
| 190 | --variable=*) |
| 191 | var=`echoscip-shell system . . echo. "$1" | sedscip-shell system . . sed. 's,^[^=]*=,,'` |
| 192 | case "$var" in |
| 193 | pkgincludedir) echoscip-shell system . . echo. "$pkgincludedir" ;; |
| 194 | pkglibdir) echoscip-shell system . . echo. "$pkglibdir" ;; |
| 195 | plugindir) echoscip-shell system . . echo. "$plugindir" ;; |
| 196 | *) usagescip-shell shell shell-project 0.0.0 usage(). ;; |
| 197 | esac |
| 198 | ;; |
| 199 | *) usagescip-shell shell shell-project 0.0.0 usage(). ;; |
| 200 | esac |
| 201 | |
| 202 | shift |
| 203 | done |
| 204 | |
| 205 | #echo "ldata: '"$ldata"'" |
| 206 | #echo "execdir: '"$execdir"'" |
| 207 | #echo "bindir: '"$bindir"'" |
| 208 | #echo "pkglibdir: '"$pkglibdir"'" |
| 209 | #echo "pkgincludedir: '"$pkgincludedir"'" |
| 210 | #echo "version: '"$version"'" |
| 211 | #echo "socket: '"$socket"'" |
| 212 | #echo "port: '"$port"'" |
| 213 | #echo "ldflags: '"$ldflags"'" |
| 214 | #echo "client_libs: '"$client_libs"'" |
| 215 | |
| 216 | exit 0 |