summaryrefslogtreecommitdiff
path: root/scripts/mysql_config.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/mysql_config.sh')
-rw-r--r--scripts/mysql_config.sh70
1 files changed, 50 insertions, 20 deletions
diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh
index aa7af1cb2c6..84ff518c381 100644
--- a/scripts/mysql_config.sh
+++ b/scripts/mysql_config.sh
@@ -60,11 +60,19 @@ fix_path ()
get_full_path ()
{
- case $1 in
- /*) echo "$1";;
- ./*) tmp=`pwd`/$1; echo $tmp | sed -e 's;/\./;/;' ;;
- *) which $1 ;;
- esac
+ file=$1
+
+ # if the file is a symlink, try to resolve it
+ if [ -h $file ];
+ then
+ file=`ls -l $file | awk '{ print $NF }'`
+ fi
+
+ case $file in
+ /*) echo "$file";;
+ */*) tmp=`pwd`/$file; echo $tmp | sed -e 's;/\./;/;' ;;
+ *) which $file ;;
+ esac
}
me=`get_full_path $0`
@@ -74,48 +82,70 @@ basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
ldata='@localstatedir@'
execdir='@libexecdir@'
bindir='@bindir@'
+
+# If installed, search for the compiled in directory first (might be "lib64")
pkglibdir='@pkglibdir@'
-fix_path pkglibdir lib/mysql lib
+pkglibdir_rel=`echo $pkglibdir | sed -e "s;^$basedir/;;"`
+fix_path pkglibdir $pkglibdir_rel lib/mysql lib
+
pkgincludedir='@pkgincludedir@'
fix_path pkgincludedir include/mysql include
+
version='@VERSION@'
socket='@MYSQL_UNIX_ADDR@'
port='@MYSQL_TCP_PORT@'
ldflags='@LDFLAGS@'
-client_libs='@CLIENT_LIBS@'
-# Create options
+# Create options
+# We intentionally add a space to the beginning of lib strings, simplifies replace later
+libs=" $ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@"
+libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@"
+libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r @ZLIB_DEPS@ @LIBS@ @openssl_libs@"
+embedded_libs=" $ldflags -L$pkglibdir -lmysqld @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @innodb_system_libs@"
-libs="$ldflags -L$pkglibdir -lmysqlclient $client_libs"
-libs=`echo "$libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
-libs_r="$ldflags -L$pkglibdir -lmysqlclient_r @LIBS@ @openssl_libs@"
-libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
cflags="-I$pkgincludedir @CFLAGS@ " #note: end space!
include="-I$pkgincludedir"
-embedded_libs="$ldflags -L$pkglibdir -lmysqld @LIBS@ @WRAPLIBS@ @innodb_system_libs@"
-embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
# Remove some options that a client doesn't have to care about
+# FIXME until we have a --cxxflags, we need to remove -Xa
+# and -xstrconst to make --cflags usable for Sun Forte C++
for remove in DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX \
DPEDANTIC_SAFEMALLOC DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \
- DEXTRA_DEBUG DHAVE_purify 'O[0-9]' 'W[-A-Za-z]*'
+ DEXTRA_DEBUG DHAVE_purify 'O[0-9]' 'W[-A-Za-z]*' \
+ Xa xstrconst "xc99=none"
do
- cflags=`echo "$cflags"|sed -e "s/-$remove *//g"`
+ # The first option we might strip will always have a space before it because
+ # we set -I$pkgincludedir as the first option
+ cflags=`echo "$cflags"|sed -e "s/ -$remove */ /g"`
done
cflags=`echo "$cflags"|sed -e 's/ *\$//'`
+# Same for --libs(_r)
+for remove in lmtmalloc
+do
+ # We know the strings starts with a space
+ libs=`echo "$libs"|sed -e "s/ -$remove */ /g"`
+ libs_r=`echo "$libs_r"|sed -e "s/ -$remove */ /g"`
+ embedded_libs=`echo "$embedded_libs"|sed -e "s/ -$remove */ /g"`
+done
+
+# Strip trailing and ending space if any, and '+' (FIXME why?)
+libs=`echo "$libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
+libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
+embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
+
usage () {
cat <<EOF
Usage: $0 [OPTIONS]
Options:
--cflags [$cflags]
- --include [$include]
+ --include [$include]
--libs [$libs]
--libs_r [$libs_r]
--socket [$socket]
--port [$port]
--version [$version]
- --libmysqld-libs [$embedded_libs]
+ --libmysqld-libs [$embedded_libs]
EOF
exit 1
}
@@ -125,13 +155,13 @@ if test $# -le 0; then usage; fi
while test $# -gt 0; do
case $1 in
--cflags) echo "$cflags" ;;
- --include) echo "$include" ;;
+ --include) echo "$include" ;;
--libs) echo "$libs" ;;
--libs_r) echo "$libs_r" ;;
--socket) echo "$socket" ;;
--port) echo "$port" ;;
--version) echo "$version" ;;
- --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;;
+ --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;;
*) usage ;;
esac