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.

182 lines
5.2 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
  1. #!/bin/sh
  2. # Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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; either version 2 of the License, or
  7. # (at your option) any later version.
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. pkgincludedir='@pkgincludedir@'
  80. fix_path pkgincludedir include/mysql include
  81. version='@VERSION@'
  82. socket='@MYSQL_UNIX_ADDR@'
  83. port='@MYSQL_TCP_PORT@'
  84. ldflags='@LDFLAGS@'
  85. # Create options
  86. # We intentionally add a space to the beginning of lib strings, simplifies replace later
  87. libs=" $ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@"
  88. libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@"
  89. libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r @ZLIB_DEPS@ @LIBS@ @openssl_libs@"
  90. embedded_libs=" $ldflags -L$pkglibdir -lmysqld @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @innodb_system_libs@ @openssl_libs@"
  91. cflags="-I$pkgincludedir @CFLAGS@ " #note: end space!
  92. include="-I$pkgincludedir"
  93. # Remove some options that a client doesn't have to care about
  94. # FIXME until we have a --cxxflags, we need to remove -Xa
  95. # and -xstrconst to make --cflags usable for Sun Forte C++
  96. for remove in DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX \
  97. DPEDANTIC_SAFEMALLOC DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \
  98. DEXTRA_DEBUG DHAVE_purify 'O[0-9]' 'W[-A-Za-z]*' \
  99. Xa xstrconst "xc99=none"
  100. do
  101. # The first option we might strip will always have a space before it because
  102. # we set -I$pkgincludedir as the first option
  103. cflags=`echo "$cflags"|sed -e "s/ -$remove */ /g"`
  104. done
  105. cflags=`echo "$cflags"|sed -e 's/ *\$//'`
  106. # Same for --libs(_r)
  107. for remove in lmtmalloc
  108. do
  109. # We know the strings starts with a space
  110. libs=`echo "$libs"|sed -e "s/ -$remove */ /g"`
  111. libs_r=`echo "$libs_r"|sed -e "s/ -$remove */ /g"`
  112. embedded_libs=`echo "$embedded_libs"|sed -e "s/ -$remove */ /g"`
  113. done
  114. # Strip trailing and ending space if any, and '+' (FIXME why?)
  115. libs=`echo "$libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  116. libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  117. embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  118. usage () {
  119. cat <<EOF
  120. Usage: $0 [OPTIONS]
  121. Options:
  122. --cflags [$cflags]
  123. --include [$include]
  124. --libs [$libs]
  125. --libs_r [$libs_r]
  126. --socket [$socket]
  127. --port [$port]
  128. --version [$version]
  129. --libmysqld-libs [$embedded_libs]
  130. EOF
  131. exit 1
  132. }
  133. if test $# -le 0; then usage; fi
  134. while test $# -gt 0; do
  135. case $1 in
  136. --cflags) echo "$cflags" ;;
  137. --include) echo "$include" ;;
  138. --libs) echo "$libs" ;;
  139. --libs_r) echo "$libs_r" ;;
  140. --socket) echo "$socket" ;;
  141. --port) echo "$port" ;;
  142. --version) echo "$version" ;;
  143. --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;;
  144. *) usage ;;
  145. esac
  146. shift
  147. done
  148. #echo "ldata: '"$ldata"'"
  149. #echo "execdir: '"$execdir"'"
  150. #echo "bindir: '"$bindir"'"
  151. #echo "pkglibdir: '"$pkglibdir"'"
  152. #echo "pkgincludedir: '"$pkgincludedir"'"
  153. #echo "version: '"$version"'"
  154. #echo "socket: '"$socket"'"
  155. #echo "port: '"$port"'"
  156. #echo "ldflags: '"$ldflags"'"
  157. #echo "client_libs: '"$client_libs"'"
  158. exit 0