home *** CD-ROM | disk | FTP | other *** search
/ CD BIT 75 / CD BIT 75.iso / Software / mysql-4.0.22-win / data1.cab / Development / scripts / mysql_config < prev    next >
Encoding:
Text File  |  2004-10-28  |  4.6 KB  |  153 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.22'
  79. socket='/tmp/mysql.sock'
  80. port='3306'
  81. ldflags=''
  82. client_libs='-lz -lcrypt -lnsl -lm  -L/usr/lib -lssl -lcrypto -lc -lnss_files -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv'
  83.  
  84. # Create options
  85.  
  86. libs="$ldflags -L$pkglibdir -lmysqlclient $client_libs"
  87. libs=`echo "$libs" | sed -e 's;  \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  88. libs_r="$ldflags -L$pkglibdir -lmysqlclient_r -lpthread -lz -lcrypt -lnsl -lm  -lpthread -lc -lnss_files -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv -L/usr/lib -lssl -lcrypto"
  89. libs_r=`echo "$libs_r" | sed -e 's;  \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  90. cflags="-I$pkgincludedir -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Wunused -mcpu=pentiumpro -O3 -fno-omit-frame-pointer " #note: end space!
  91. include="-I$pkgincludedir"
  92. embedded_libs="$ldflags -L$pkglibdir -lmysqld -lpthread -lz -lcrypt -lnsl -lm  -lpthread -lc -lnss_files -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv  -lrt"
  93. embedded_libs=`echo "$embedded_libs" | sed -e 's;  \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  94.  
  95. # Remove some options that a client doesn't have to care about
  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. do
  100.   cflags=`echo "$cflags"|sed -e "s/-$remove  *//g"` 
  101. done
  102. cflags=`echo "$cflags"|sed -e 's/ *\$//'` 
  103.  
  104. usage () {
  105.         cat <<EOF
  106. Usage: $0 [OPTIONS]
  107. Options:
  108.         --cflags         [$cflags]
  109.     --include     [$include]
  110.         --libs           [$libs]
  111.         --libs_r         [$libs_r]
  112.         --socket         [$socket]
  113.         --port           [$port]
  114.         --version        [$version]
  115.     --libmysqld-libs [$embedded_libs]
  116. EOF
  117.         exit 1
  118. }
  119.  
  120. if test $# -le 0; then usage; fi
  121.  
  122. while test $# -gt 0; do
  123.         case $1 in
  124.         --cflags)  echo "$cflags" ;;
  125.     --include) echo "$include" ;;
  126.         --libs)    echo "$libs" ;;
  127.         --libs_r)  echo "$libs_r" ;;
  128.         --socket)  echo "$socket" ;;
  129.         --port)    echo "$port" ;;
  130.         --version) echo "$version" ;;
  131.     --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;;
  132.         *)         usage ;;
  133.         esac
  134.  
  135.         shift
  136. done
  137.  
  138. #echo "ldata: '"$ldata"'"
  139. #echo "execdir: '"$execdir"'"
  140. #echo "bindir: '"$bindir"'"
  141. #echo "pkglibdir: '"$pkglibdir"'"
  142. #echo "pkgincludedir: '"$pkgincludedir"'"
  143. #echo "version: '"$version"'"
  144. #echo "socket: '"$socket"'"
  145. #echo "port: '"$port"'"
  146. #echo "ldflags: '"$ldflags"'"
  147. #echo "client_libs: '"$client_libs"'"
  148.  
  149. exit 0
  150.