You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
6.0 KiB

26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
  1. #!/bin/sh
  2. # Copyright (c) 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
  3. # Use is subject to license terms.
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; version 2 of the License.
  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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. # This script reports various configuration settings that may be needed
  18. # when using the MySQL client library.
  19. which ()
  20. {
  21. IFS="${IFS= }"; save_ifs="$IFS"; IFS=':'
  22. for file
  23. do
  24. for dir in $PATH
  25. do
  26. if test -f $dir/$file
  27. then
  28. echo "$dir/$file"
  29. continue 2
  30. fi
  31. done
  32. echo "which: no $file in ($PATH)"
  33. exit 1
  34. done
  35. IFS="$save_ifs"
  36. }
  37. #
  38. # If we can find the given directory relatively to where mysql_config is
  39. # we should use this instead of the incompiled one.
  40. # This is to ensure that this script also works with the binary MySQL
  41. # version
  42. fix_path ()
  43. {
  44. var=$1
  45. shift
  46. for filename
  47. do
  48. path=$basedir/$filename
  49. if [ -d "$path" ] ;
  50. then
  51. eval "$var"=$path
  52. return
  53. fi
  54. done
  55. }
  56. get_full_path ()
  57. {
  58. file=$1
  59. # if the file is a symlink, try to resolve it
  60. if [ -h $file ];
  61. then
  62. file=`ls -l $file | awk '{ print $NF }'`
  63. fi
  64. case $file in
  65. /*) echo "$file";;
  66. */*) tmp=`pwd`/$file; echo $tmp | sed -e 's;/\./;/;' ;;
  67. *) which $file ;;
  68. esac
  69. }
  70. me=`get_full_path $0`
  71. basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
  72. ldata='@localstatedir@'
  73. execdir='@libexecdir@'
  74. bindir='@bindir@'
  75. # If installed, search for the compiled in directory first (might be "lib64")
  76. pkglibdir='@pkglibdir@'
  77. pkglibdir_rel=`echo $pkglibdir | sed -e "s;^$basedir/;;"`
  78. fix_path pkglibdir $pkglibdir_rel lib/mysql lib
  79. plugindir='@pkgplugindir@'
  80. pkgincludedir='@pkgincludedir@'
  81. fix_path pkgincludedir include/mysql include
  82. version='@VERSION@'
  83. socket='@MYSQL_UNIX_ADDR@'
  84. ldflags='@LDFLAGS@'
  85. if [ @MYSQL_TCP_PORT_DEFAULT@ -eq 0 ]; then
  86. port=0
  87. else
  88. port=@MYSQL_TCP_PORT@
  89. fi
  90. # Create options
  91. # We intentionally add a space to the beginning and end of lib strings, simplifies replace later
  92. libs=" $ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@"
  93. libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@ "
  94. libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r @ZLIB_DEPS@ @LIBS@ @openssl_libs@ "
  95. embedded_libs=" $ldflags -L$pkglibdir -lmysqld @LIBDL@ @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @innodb_system_libs@ @openssl_libs@ "
  96. if [ -r "$pkglibdir/libmygcc.a" ]; then
  97. # When linking against the static library with a different version of GCC
  98. # from what was used to compile the library, some symbols may not be defined
  99. # automatically. We package the libmygcc.a from the build host, to provide
  100. # definitions for those. Bugs 4921, 19561, 19817, 21158, etc.
  101. libs="$libs -lmygcc "
  102. libs_r="$libs_r -lmygcc "
  103. embedded_libs="$embedded_libs -lmygcc "
  104. fi
  105. cflags="-I$pkgincludedir @CFLAGS@ " #note: end space!
  106. include="-I$pkgincludedir"
  107. # Remove some options that a client doesn't have to care about
  108. # FIXME until we have a --cxxflags, we need to remove -Xa
  109. # and -xstrconst to make --cflags usable for Sun Forte C++
  110. # FIXME until we have a --cxxflags, we need to remove -AC99
  111. # to make --cflags usable for HP C++ (aCC)
  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. 'mtune=[-A-Za-z0-9]*' 'mcpu=[-A-Za-z0-9]*' 'march=[-A-Za-z0-9]*' \
  116. Xa xstrconst "xc99=none" AC99 \
  117. unroll2 ip mp restrict
  118. do
  119. # The first option we might strip will always have a space before it because
  120. # we set -I$pkgincludedir as the first option
  121. cflags=`echo "$cflags"|sed -e "s/ -$remove */ /g"`
  122. done
  123. cflags=`echo "$cflags"|sed -e 's/ *\$//'`
  124. # Same for --libs(_r)
  125. for remove in lmtmalloc static-libcxa i-static static-intel
  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. # Strip trailing and ending space if any, and '+' (FIXME why?)
  133. libs=`echo "$libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  134. libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  135. embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  136. usage () {
  137. cat <<EOF
  138. Usage: $0 [OPTIONS]
  139. Options:
  140. --cflags [$cflags]
  141. --include [$include]
  142. --libs [$libs]
  143. --libs_r [$libs_r]
  144. --plugindir [$plugindir]
  145. --socket [$socket]
  146. --port [$port]
  147. --version [$version]
  148. --libmysqld-libs [$embedded_libs]
  149. EOF
  150. exit 1
  151. }
  152. if test $# -le 0; then usage; fi
  153. while test $# -gt 0; do
  154. case $1 in
  155. --cflags) echo "$cflags" ;;
  156. --include) echo "$include" ;;
  157. --libs) echo "$libs" ;;
  158. --libs_r) echo "$libs_r" ;;
  159. --plugindir) echo "$plugindir" ;;
  160. --socket) echo "$socket" ;;
  161. --port) echo "$port" ;;
  162. --version) echo "$version" ;;
  163. --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;;
  164. *) usage ;;
  165. esac
  166. shift
  167. done
  168. #echo "ldata: '"$ldata"'"
  169. #echo "execdir: '"$execdir"'"
  170. #echo "bindir: '"$bindir"'"
  171. #echo "pkglibdir: '"$pkglibdir"'"
  172. #echo "pkgincludedir: '"$pkgincludedir"'"
  173. #echo "version: '"$version"'"
  174. #echo "socket: '"$socket"'"
  175. #echo "port: '"$port"'"
  176. #echo "ldflags: '"$ldflags"'"
  177. #echo "client_libs: '"$client_libs"'"
  178. exit 0