home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 Autumn / INTERNET109.ISO / pc / software / windows / building / mysql / data1.cab / Development / scripts / mysql_config < prev    next >
Encoding:
Text File  |  2003-08-03  |  3.3 KB  |  134 lines

  1. #!/bin/sh
  2. # Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 2 of the License, or
  6. # (at your option) any later version.
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10. # GNU General Public License for more details.
  11. # You should have received a copy of the GNU General Public License
  12. # along with this program; if not, write to the Free Software
  13. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  14.  
  15. # This script reports various configuration settings that may be needed
  16. # when using the MySQL client library.
  17.  
  18. which ()
  19. {
  20.   IFS="${IFS=   }"; save_ifs="$IFS"; IFS=':'
  21.   for file
  22.   do
  23.     for dir in $PATH
  24.     do
  25.       if test -f $dir/$file
  26.       then
  27.         echo "$dir/$file"
  28.         continue 2
  29.       fi
  30.     done
  31.     echo "which: no $file in ($PATH)"
  32.     exit 1
  33.   done
  34.   IFS="$save_ifs"
  35. }
  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.  
  43. fix_path ()
  44. {
  45.   var=$1
  46.   shift
  47.   for filename
  48.   do
  49.     path=$basedir/$filename
  50.     if [ -d "$path" ] ;
  51.     then
  52.       eval "$var"=$path
  53.       return
  54.     fi
  55.   done
  56. }
  57.  
  58. get_full_path ()
  59. {
  60.   case $1 in
  61.     /*)    echo "$1";;
  62.     ./*) tmp=`pwd`/$1; echo $tmp | sed -e 's;/./;/;' ;;
  63.      *) which $1 ;;
  64.    esac
  65. }
  66.  
  67. me=`get_full_path $0`
  68.  
  69. basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
  70.  
  71. ldata='/usr/local/mysql/var'
  72. execdir='/usr/local/mysql/libexec'
  73. bindir='/usr/local/mysql/bin'
  74. pkglibdir='/usr/local/mysql/lib/mysql'
  75. fix_path pkglibdir lib/mysql lib
  76. pkgincludedir='/usr/local/mysql/include/mysql'
  77. fix_path pkgincludedir include/mysql include
  78. version='4.0.13'
  79. socket='/tmp/mysql.sock'
  80. port='3306'
  81. ldflags=''
  82. client_libs='-lz -lcrypt -lnsl -lm   '
  83.  
  84. libs="$ldflags -L'$pkglibdir' -lmysqlclient $client_libs"
  85. libs=`echo $libs | sed -e 's; +;;'`
  86. cflags="-I'$pkgincludedir'"
  87. embedded_libs="$ldflags -L'$pkglibdir' -lmysqld -lpthread -lz -lcrypt -lnsl -lm  -lpthread  -lrt"
  88.  
  89. usage () {
  90.         cat <<EOF
  91. Usage: $0 [OPTIONS]
  92. Options:
  93.         --cflags         [$cflags]
  94.         --libs           [$libs]
  95.         --socket         [$socket]
  96.         --port           [$port]
  97.         --version        [$version]
  98.     --libmysqld-libs [$embedded_libs]
  99. EOF
  100.         exit 1
  101. }
  102.  
  103. if test $# -le 0; then usage; fi
  104.  
  105. while test $# -gt 0; do
  106.         case $1 in
  107.         --cflags)  echo "$cflags" ;;
  108.         --libs)    echo "$libs" ;;
  109.         --socket)  echo "$socket" ;;
  110.         --port)    echo "$port" ;;
  111.         --version) echo "$version" ;;
  112.     --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;;
  113.         *)         usage ;;
  114.         esac
  115.  
  116.         shift
  117. done
  118.  
  119. #echo "ldata: '"$ldata"'"
  120. #echo "execdir: '"$execdir"'"
  121. #echo "bindir: '"$bindir"'"
  122. #echo "pkglibdir: '"$pkglibdir"'"
  123. #echo "pkgincludedir: '"$pkgincludedir"'"
  124. #echo "version: '"$version"'"
  125. #echo "socket: '"$socket"'"
  126. #echo "port: '"$port"'"
  127. #echo "ldflags: '"$ldflags"'"
  128. #echo "client_libs: '"$client_libs"'"
  129.  
  130. exit 0
  131.