home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2004 July / INTERNET119.ISO / pc / software / windows / building / mysql / data1.cab / Development / scripts / mysql_config.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2004-02-11  |  4.0 KB  |  148 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='@localstatedir@'
  72. execdir='@libexecdir@'
  73. bindir='@bindir@'
  74. pkglibdir='@pkglibdir@'
  75. fix_path pkglibdir lib/mysql lib
  76. pkgincludedir='@pkgincludedir@'
  77. fix_path pkgincludedir include/mysql include
  78. version='@VERSION@'
  79. socket='@MYSQL_UNIX_ADDR@'
  80. port='@MYSQL_TCP_PORT@'
  81. ldflags='@LDFLAGS@'
  82. client_libs='@CLIENT_LIBS@'
  83.  
  84. # Create options, without end space
  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 @LIBS@ @openssl_libs@"
  89. libs_r=`echo "$libs_r" | sed -e 's;  \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  90. cflags="-I$pkgincludedir @CFLAGS@"
  91. include="-I$pkgincludedir"
  92. embedded_libs="$ldflags -L$pkglibdir -lmysqld @LIBS@ @WRAPLIBS@ @innodb_system_libs@"
  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.  
  97. cflags=`echo "$cflags " | sed -e 's;\(-DDBUG_OFF\|-DSAFEMALLOC\|-USAFEMALLOC\|-DSAFE_MUTEX\|-DPEDANTIC_SAFEMALLOC\|-DUNIV_MUST_NOT_INLINE\|-DFORCE_INIT_OF_VARS\|-DEXTRA_DEBUG\|-DHAVE_purify\|-O[0-9]\|-W[-A-Za-z]*\) *;;g' | sed -e 's; *\$;;'` 
  98.  
  99. usage () {
  100.         cat <<EOF
  101. Usage: $0 [OPTIONS]
  102. Options:
  103.         --cflags         [$cflags]
  104.     --include     [$include]
  105.         --libs           [$libs]
  106.         --libs_r         [$libs_r]
  107.         --socket         [$socket]
  108.         --port           [$port]
  109.         --version        [$version]
  110.     --libmysqld-libs [$embedded_libs]
  111. EOF
  112.         exit 1
  113. }
  114.  
  115. if test $# -le 0; then usage; fi
  116.  
  117. while test $# -gt 0; do
  118.         case $1 in
  119.         --cflags)  echo "$cflags" ;;
  120.     --include) echo "$include" ;;
  121.         --libs)    echo "$libs" ;;
  122.         --libs_r)  echo "$libs_r" ;;
  123.         --socket)  echo "$socket" ;;
  124.         --port)    echo "$port" ;;
  125.         --version) echo "$version" ;;
  126.     --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;;
  127.         *)         usage ;;
  128.         esac
  129.  
  130.         shift
  131. done
  132.  
  133. #echo "ldata: '"$ldata"'"
  134. #echo "execdir: '"$execdir"'"
  135. #echo "bindir: '"$bindir"'"
  136. #echo "pkglibdir: '"$pkglibdir"'"
  137. #echo "pkgincludedir: '"$pkgincludedir"'"
  138. #echo "version: '"$version"'"
  139. #echo "socket: '"$socket"'"
  140. #echo "port: '"$port"'"
  141. #echo "ldflags: '"$ldflags"'"
  142. #echo "client_libs: '"$client_libs"'"
  143.  
  144. exit 0
  145.