home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / mysql / scripts / mysql_config < prev    next >
Encoding:
Text File  |  2008-04-17  |  5.2 KB  |  183 lines

  1. #!/bin/sh
  2. # Copyright (C) 2000-2006 MySQL 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; version 2 of the License.
  6. # This program is distributed in the hope that it will be useful,
  7. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9. # GNU General Public License for more details.
  10. # You should have received a copy of the GNU General Public License
  11. # along with this program; if not, write to the Free Software
  12. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  13.  
  14. # This script reports various configuration settings that may be needed
  15. # when using the MySQL client library.
  16.  
  17. which ()
  18. {
  19.   IFS="${IFS=   }"; save_ifs="$IFS"; IFS=':'
  20.   for file
  21.   do
  22.     for dir in $PATH
  23.     do
  24.       if test -f $dir/$file
  25.       then
  26.         echo "$dir/$file"
  27.         continue 2
  28.       fi
  29.     done
  30.     echo "which: no $file in ($PATH)"
  31.     exit 1
  32.   done
  33.   IFS="$save_ifs"
  34. }
  35.  
  36. #
  37. # If we can find the given directory relatively to where mysql_config is
  38. # we should use this instead of the incompiled one.
  39. # This is to ensure that this script also works with the binary MySQL
  40. # version
  41.  
  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.  
  57. get_full_path ()
  58. {
  59.   file=$1
  60.  
  61.   # if the file is a symlink, try to resolve it
  62.   if [ -h $file ];
  63.   then
  64.     file=`ls -l $file | awk '{ print $NF }'`
  65.   fi
  66.  
  67.   case $file in
  68.     /*) echo "$file";;
  69.     */*) tmp=`pwd`/$file; echo $tmp | sed -e 's;/\./;/;' ;;
  70.     *) which $file ;;
  71.   esac
  72. }
  73.  
  74. me=`get_full_path $0`
  75.  
  76. basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
  77.  
  78. ldata='@localstatedir@'
  79. execdir='@libexecdir@'
  80. bindir='@bindir@'
  81.  
  82. # If installed, search for the compiled in directory first (might be "lib64")
  83. pkglibdir='@pkglibdir@'
  84. pkglibdir_rel=`echo $pkglibdir | sed -e "s;^$basedir/;;"`
  85. fix_path pkglibdir $pkglibdir_rel lib/mysql lib
  86.  
  87. pkgincludedir='@pkgincludedir@'
  88. fix_path pkgincludedir include/mysql include
  89.  
  90. version='@VERSION@'
  91. socket='@MYSQL_UNIX_ADDR@'
  92. port='@MYSQL_TCP_PORT@'
  93. ldflags='@LDFLAGS@'
  94.  
  95. # Create options 
  96. # We intentionally add a space to the beginning and end of lib strings, simplifies replace later
  97. libs=" $ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@"
  98. libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@ "
  99. libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r @ZLIB_DEPS@ @LIBS@ @openssl_libs@ "
  100. embedded_libs=" $ldflags -L$pkglibdir -lmysqld @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @innodb_system_libs@ @openssl_libs@ "
  101.  
  102. cflags="-I$pkgincludedir @CFLAGS@ " #note: end space!
  103. include="-I$pkgincludedir"
  104.  
  105. # Remove some options that a client doesn't have to care about
  106. # FIXME until we have a --cxxflags, we need to remove -Xa
  107. #       and -xstrconst to make --cflags usable for Sun Forte C++
  108. for remove in DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX \
  109.               DPEDANTIC_SAFEMALLOC DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \
  110.               DEXTRA_DEBUG DHAVE_purify O 'O[0-9]' 'xO[0-9]' 'W[-A-Za-z]*' \
  111.               Xa xstrconst "xc99=none" \
  112.               unroll2 ip mp restrict
  113. do
  114.   # The first option we might strip will always have a space before it because
  115.   # we set -I$pkgincludedir as the first option
  116.   cflags=`echo "$cflags"|sed -e "s/ -$remove  */ /g"` 
  117. done
  118. cflags=`echo "$cflags"|sed -e 's/ *\$//'` 
  119.  
  120. # Same for --libs(_r)
  121. for remove in lmtmalloc static-libcxa i-static static-intel
  122. do
  123.   # We know the strings starts with a space
  124.   libs=`echo "$libs"|sed -e "s/ -$remove  */ /g"` 
  125.   libs_r=`echo "$libs_r"|sed -e "s/ -$remove  */ /g"` 
  126.   embedded_libs=`echo "$embedded_libs"|sed -e "s/ -$remove  */ /g"` 
  127. done
  128.  
  129. # Strip trailing and ending space if any, and '+' (FIXME why?)
  130. libs=`echo "$libs" | sed -e 's;  \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  131. libs_r=`echo "$libs_r" | sed -e 's;  \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  132. embedded_libs=`echo "$embedded_libs" | sed -e 's;  \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  133.  
  134. usage () {
  135.         cat <<EOF
  136. Usage: $0 [OPTIONS]
  137. Options:
  138.         --cflags         [$cflags]
  139.         --include        [$include]
  140.         --libs           [$libs]
  141.         --libs_r         [$libs_r]
  142.         --socket         [$socket]
  143.         --port           [$port]
  144.         --version        [$version]
  145.         --libmysqld-libs [$embedded_libs]
  146. EOF
  147.         exit 1
  148. }
  149.  
  150. if test $# -le 0; then usage; fi
  151.  
  152. while test $# -gt 0; do
  153.         case $1 in
  154.         --cflags)  echo "$cflags" ;;
  155.         --include) echo "$include" ;;
  156.         --libs)    echo "$libs" ;;
  157.         --libs_r)  echo "$libs_r" ;;
  158.         --socket)  echo "$socket" ;;
  159.         --port)    echo "$port" ;;
  160.         --version) echo "$version" ;;
  161.         --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;;
  162.         *)         usage ;;
  163.         esac
  164.  
  165.         shift
  166. done
  167.  
  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.  
  179. exit 0
  180.