1#!/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, version 2.0,
6# as published by the Free Software Foundation.
7#
8# This program is also distributed with certain software (including
9# but not limited to OpenSSL) that is licensed under separate terms,
10# as designated in a particular file or component or in included license
11# documentation.  The authors of MySQL hereby grant you an additional
12# permission to link the program and your derivative works with the
13# separately licensed software that they have included with MySQL.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU General Public License, version 2.0, for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23
24# This script reports various configuration settings that may be needed
25# when using the MySQL client library.
26
27which ()
28{
29  IFS="${IFS=   }"; save_ifs="$IFS"; IFS=':'
30  for file
31  do
32    for dir in $PATH
33    do
34      if test -f $dir/$file
35      then
36        echo "$dir/$file"
37        continue 2
38      fi
39    done
40    echo "which: no $file in ($PATH)"
41    exit 1
42  done
43  IFS="$save_ifs"
44}
45
46#
47# If we can find the given directory relatively to where mysql_config is
48# we should use this instead of the incompiled one.
49# This is to ensure that this script also works with the binary MySQL
50# version
51
52fix_path ()
53{
54  var=$1
55  shift
56  for filename
57  do
58    path=$basedir/$filename
59    if [ -d "$path" ] ;
60    then
61      eval "$var"=$path
62      return
63    fi
64  done
65}
66
67get_full_path ()
68{
69  file=$1
70
71  # if the file is a symlink, try to resolve it
72  if [ -h $file ];
73  then
74    file=`ls -l $file | awk '{ print $NF }'`
75  fi
76
77  case $file in
78    /*) echo "$file";;
79    */*) tmp=`pwd`/$file; echo $tmp | sed -e 's;/\./;/;' ;;
80    *) which $file ;;
81  esac
82}
83
84me=`get_full_path $0`
85
86# Script might have been renamed but assume mysql_<something>config<something>
87basedir=`echo $me | sed -e 's;/bin/mysql_.*config.*;;'`
88
89ldata='@localstatedir@'
90execdir='@libexecdir@'
91bindir='@bindir@'
92
93# If installed, search for the compiled in directory first (might be "lib64")
94pkglibdir='@pkglibdir@'
95pkglibdir_rel=`echo $pkglibdir | sed -e "s;^$basedir/;;"`
96fix_path pkglibdir $pkglibdir_rel @libsubdir@/mysql @libsubdir@
97
98plugindir='@pkgplugindir@'
99plugindir_rel=`echo $plugindir | sed -e "s;^$basedir/;;"`
100fix_path plugindir $plugindir_rel @libsubdir@/mysql/plugin @libsubdir@/plugin
101
102pkgincludedir='@pkgincludedir@'
103if [ -f "$basedir/include/mysql/mysql.h" ]; then
104  pkgincludedir="$basedir/include/mysql"
105elif [ -f "$basedir/include/mysql.h" ]; then
106  pkgincludedir="$basedir/include"
107fi
108
109version='@VERSION@'
110socket='@MYSQL_UNIX_ADDR@'
111ldflags='@LDFLAGS@'
112
113if [ @MYSQL_TCP_PORT_DEFAULT@ -eq 0 ]; then
114  port=0
115else
116  port=@MYSQL_TCP_PORT@
117fi
118
119# Create options
120libs="@QUOTED_CMAKE_CXX_LINK_FLAGS@-L$pkglibdir@RPATH_OPTION@"
121libs="$libs -l@LIBMYSQL_OS_OUTPUT_NAME@ @CONFIG_CLIENT_LIBS@"
122embedded_libs="@QUOTED_CMAKE_CXX_LINK_FLAGS@-L$pkglibdir@RPATH_OPTION@"
123embedded_libs="$embedded_libs -l@LIBEMBED_OS_OUTPUT_NAME@ @CONFIG_EMBEDD_LIBS@"
124
125cflags="-I$pkgincludedir @CFLAGS@"
126cxxflags="-I$pkgincludedir @CXXFLAGS@"
127include="-I$pkgincludedir"
128
129
130usage () {
131        cat <<EOF
132Usage: $0 [OPTIONS]
133Compiler: @COMPILER_ID_AND_VERSION@
134Options:
135        --cflags         [$cflags]
136        --cxxflags       [$cxxflags]
137        --include        [$include]
138        --libs           [$libs]
139        --libs_r         [$libs]
140        --plugindir      [$plugindir]
141        --socket         [$socket]
142        --port           [$port]
143        --version        [$version]@LIBMYSQLD_LIBS_USAGE@
144        --variable=VAR   VAR is one of:
145                pkgincludedir [$pkgincludedir]
146                pkglibdir     [$pkglibdir]
147                plugindir     [$plugindir]
148EOF
149        exit 1
150}
151
152if test $# -le 0; then usage; fi
153
154while test $# -gt 0; do
155        case $1 in
156        --cflags)  echo "$cflags" ;;
157        --cxxflags)echo "$cxxflags";;
158        --include) echo "$include" ;;
159        --libs)    echo "$libs" ;;
160        --libs_r)  echo "$libs" ;;
161        --plugindir) echo "$plugindir" ;;
162        --socket)  echo "$socket" ;;
163        --port)    echo "$port" ;;
164        --version) echo "$version" ;;
165        --embedded-libs | --embedded | --libmysqld-libs) @DISABLE_EMBEDDED_SH@ echo "$embedded_libs" ;;
166        --variable=*)
167          var=`echo "$1" | sed 's,^[^=]*=,,'`
168          case "$var" in
169            pkgincludedir) echo "$pkgincludedir" ;;
170            pkglibdir) echo "$pkglibdir" ;;
171            plugindir) echo "$plugindir" ;;
172            *) usage ;;
173          esac
174          ;;
175        *)         usage ;;
176        esac
177
178        shift
179done
180
181#echo "ldata: '"$ldata"'"
182#echo "execdir: '"$execdir"'"
183#echo "bindir: '"$bindir"'"
184#echo "pkglibdir: '"$pkglibdir"'"
185#echo "pkgincludedir: '"$pkgincludedir"'"
186#echo "version: '"$version"'"
187#echo "socket: '"$socket"'"
188#echo "port: '"$port"'"
189#echo "ldflags: '"$ldflags"'"
190#echo "client_libs: '"$client_libs"'"
191
192exit 0
193