mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / configure.in
blob94a9d5b4e995ec5cffef01b32c31f3f294074f23
1 dnl -*- ksh -*-
2 dnl Process this file with autoconf to produce a configure script.
4 # Minimum Autoconf version required.
5 AC_PREREQ(2.59)
7 dnl Various people throughout the community may parse configure.in to
8 dnl get the MySQL version from the source branch.  If the formatting
9 dnl of this line is going to be changed, please announce the change to
10 dnl internals@lists.mysql.com in advance of pushing the change.
11 dnl
12 dnl When changing the major version number please also check the switch
13 dnl statement in mysqlbinlog::check_master_version().  You may also need
14 dnl to update version.c in ndb.
15 AC_INIT([MySQL Server], [5.1.73], [], [mysql])
17 AC_CONFIG_SRCDIR([sql/mysqld.cc])
18 AC_CANONICAL_SYSTEM
19 # USTAR format gives us the possibility to store longer path names in
20 # TAR files, the path name is split into two parts, a 155 chacater
21 # first part and a 100 character second part.
22 AM_INIT_AUTOMAKE([1.9 tar-ustar])
23 AC_PROG_LIBTOOL
25 AC_CONFIG_HEADERS([include/config.h])
27 # Request support for automake silent-rules if available.
28 # Default to verbose output. One can use the configure-time
29 # option --enable-silent-rules or make V=0 to activate
30 # silent rules.
31 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
33 PROTOCOL_VERSION=10
34 DOT_FRM_VERSION=6
35 # See the libtool docs for information on how to do shared lib versions.
36 SHARED_LIB_MAJOR_VERSION=16
37 SHARED_LIB_VERSION=$SHARED_LIB_MAJOR_VERSION:0:0
38 NDB_SHARED_LIB_MAJOR_VERSION=3
39 NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0
41 # Set all version vars based on $VERSION. How do we do this more elegant ?
42 # Remember that regexps needs to quote [ and ] since this is run through m4
43 # We take some made up examples
45 #  VERSION                  5.1.40sp1-alpha     5.0.34a  5.5.1-m2
46 #  MYSQL_U_SCORE_VERSION    5.1.40sp1_alpha     5.0.34a  5.5.1_m2
47 #  MYSQL_NO_DASH_VERSION    5.1.40sp1           5.0.34a  5.5.1
48 #  MYSQL_NUMERIC_VERSION    5.1.40              5.0.34   5.5.1
49 #  MYSQL_BASE_VERSION       5.1                 5.0      5.5
50 #  MYSQL_VERSION_ID         50140               50034    50501
52 MYSQL_U_SCORE_VERSION=`echo $VERSION | sed -e "s|-|_|"`
53 MYSQL_NO_DASH_VERSION=`echo $VERSION | sed -e "s|-.*$||"`
54 MYSQL_NUMERIC_VERSION=`echo $MYSQL_NO_DASH_VERSION | sed -e "s|[[a-z]][[a-z0-9]]*$||"`
55 MYSQL_BASE_VERSION=`echo $MYSQL_NUMERIC_VERSION | sed -e "s|\.[[^.]]*$||"`
56 MYSQL_VERSION_ID=`echo $MYSQL_NUMERIC_VERSION | \
57     awk -F. '{printf "%d%0.2d%0.2d", $1, $2, $3}'`
58 MYSQL_COPYRIGHT_YEAR=`date '+%Y'`
60 # Add previous major version for debian package upgrade path
61 MYSQL_PREVIOUS_BASE_VERSION=5.0
63 # The port should be constant for a LONG time
64 MYSQL_TCP_PORT_DEFAULT=3306
65 MYSQL_UNIX_ADDR_DEFAULT="/tmp/mysql.sock"
67 dnl Include m4 
68 sinclude(config/ac-macros/maintainer.m4)
69 sinclude(config/ac-macros/alloca.m4)
70 sinclude(config/ac-macros/check_cpu.m4)
71 sinclude(config/ac-macros/character_sets.m4)
72 sinclude(config/ac-macros/compiler_flag.m4)
73 sinclude(config/ac-macros/plugins.m4)
74 sinclude(config/ac-macros/ha_ndbcluster.m4)
75 sinclude(config/ac-macros/large_file.m4)
76 sinclude(config/ac-macros/misc.m4)
77 sinclude(config/ac-macros/readline.m4)
78 sinclude(config/ac-macros/ssl.m4)
79 sinclude(config/ac-macros/zlib.m4)
81 # Remember to add a directory sql/share/LANGUAGE
82 AVAILABLE_LANGUAGES="\
83 czech danish dutch english estonian french german greek hungarian \
84 italian japanese korean norwegian norwegian-ny polish portuguese \
85 romanian russian serbian slovak spanish swedish ukrainian"
87 #####
88 #####
90 AC_SUBST(MYSQL_U_SCORE_VERSION)
91 AC_SUBST(MYSQL_NO_DASH_VERSION)
92 AC_SUBST(MYSQL_BASE_VERSION)
93 AC_SUBST(MYSQL_VERSION_ID)
94 AC_SUBST(MYSQL_PREVIOUS_BASE_VERSION)
95 AC_SUBST(MYSQL_COPYRIGHT_YEAR)
96 AC_SUBST(PROTOCOL_VERSION)
97 AC_DEFINE_UNQUOTED([PROTOCOL_VERSION], [$PROTOCOL_VERSION],
98                    [mysql client protocol version])
99 AC_SUBST(DOT_FRM_VERSION)
100 AC_DEFINE_UNQUOTED([DOT_FRM_VERSION], [$DOT_FRM_VERSION],
101                    [Version of .frm files])
102 AC_SUBST(SHARED_LIB_MAJOR_VERSION)
103 AC_SUBST(SHARED_LIB_VERSION)
104 AC_SUBST(AVAILABLE_LANGUAGES)
106 # Check whether a debug mode should be enabled.
107 AC_ARG_WITH([debug],
108     AS_HELP_STRING([--with-debug@<:@=full@:>@],
109       [Enable various amounts of debugging support (full adds a slow memory checker).]),
110     [with_debug=$withval],
111     [with_debug=no])
113 # Whether the maintainer mode should be enabled.
114 MY_MAINTAINER_MODE
116 # Canonicalize the configuration name.
118 # Check whether --with-system-type or --without-system-type was given.
119 AC_ARG_WITH(system-type,
120     [  --with-system-type      Set the system type, like "sun-solaris10"],
121     [SYSTEM_TYPE="$withval"],
122     [SYSTEM_TYPE="$host_vendor-$host_os"])
123 AC_ARG_WITH(machine-type,
124     [  --with-machine-type     Set the machine type, like "powerpc"],
125     [MACHINE_TYPE="$withval"],
126     [MACHINE_TYPE="$host_cpu"])
127 AC_SUBST(SYSTEM_TYPE)
128 AC_DEFINE_UNQUOTED([SYSTEM_TYPE], ["$SYSTEM_TYPE"],
129                    [Name of system, eg sun-solaris])
130 AC_SUBST(MACHINE_TYPE)
131 AC_DEFINE_UNQUOTED([MACHINE_TYPE], ["$MACHINE_TYPE"],
132                    [Machine type name, eg sparc])
134 # Detect intel x86 like processor
135 BASE_MACHINE_TYPE=$MACHINE_TYPE
136 case $MACHINE_TYPE in
137   i?86) BASE_MACHINE_TYPE=i386 ;;
138 esac
140 # Save some variables and the command line options for mysqlbug
141 SAVE_CC="$CC"
142 SAVE_CXX="$CXX"
143 SAVE_ASFLAGS="$ASFLAGS"
144 SAVE_CFLAGS="$CFLAGS"
145 SAVE_CXXFLAGS="$CXXFLAGS"
146 SAVE_LDFLAGS="$LDFLAGS"
147 SAVE_CXXLDFLAGS="$CXXLDFLAGS"
148 CONF_COMMAND="$0 $ac_configure_args"
149 AC_SUBST(CONF_COMMAND)
150 AC_SUBST(SAVE_CC)
151 AC_SUBST(SAVE_CXX)
152 AC_SUBST(SAVE_ASFLAGS)
153 AC_SUBST(SAVE_CFLAGS)
154 AC_SUBST(SAVE_CXXFLAGS)
155 AC_SUBST(SAVE_LDFLAGS)
156 AC_SUBST(SAVE_CXXLDFLAGS)
157 AC_SUBST(CXXLDFLAGS)
159 #AC_ARG_PROGRAM                 # Automaticly invoked by AM_INIT_AUTOMAKE
161 AM_SANITY_CHECK
162 # This is needed is SUBDIRS is set
163 AC_PROG_MAKE_SET
165 ##############################################################################
166 # The below section needs to be done before AC_PROG_CC
167 ##############################################################################
169 # Hack for OS X/Darwin and Metrowerks CodeWarrior
170 AC_ARG_WITH(darwin-mwcc,
171 [  --with-darwin-mwcc      Use Metrowerks CodeWarrior wrappers on OS X/Darwin],[
172  if [ "with_darwin_mwcc" = yes ] ; then
173   builddir=`pwd`
174   ccwrapper="$builddir/support-files/MacOSX/mwcc-wrapper"
175   arwrapper="$builddir/support-files/MacOSX/mwar-wrapper"
176   CC="$ccwrapper"
177   CXX="$ccwrapper"
178   LD="$ccwrapper"
179   AR="$arwrapper"
180   RANLIB=:
181   export CC CXX LD AR RANLIB
182   AC_SUBST(AR)
183   AC_SUBST(RANLIB)
184  fi
187 AM_CONDITIONAL(DARWIN_MWCC, test x$with_darwin_mwcc = xyes)
189 if test "x${CFLAGS-}" = x ; then
190   cflags_is_set=no
191 else
192   cflags_is_set=yes
195 if test "x${CPPFLAGS-}" = x ; then
196   cppflags_is_set=no
197 else
198   cppflags_is_set=yes
201 if test "x${LDFLAGS-}" = x ; then
202   ldflags_is_set=no
203 else
204   ldflags_is_set=yes
207 ################ End of section to be done before AC_PROG_CC #################
209 # The following hack should ensure that configure doesn't add optimizing
210 # or debugging flags to CFLAGS or CXXFLAGS
211 # C_EXTRA_FLAGS are flags that are automaticly added to both
212 # CFLAGS and CXXFLAGS
213 CFLAGS="$CFLAGS $C_EXTRA_FLAGS "
214 CXXFLAGS="$CXXFLAGS $C_EXTRA_FLAGS "
216 dnl Checks for programs.
217 AC_PROG_AWK
218 AC_PROG_CC
219 AC_PROG_CXX
220 AC_PROG_CPP
222 # Print version of CC and CXX compiler (if they support --version)
223 case $SYSTEM_TYPE in
224   *netware*)
225 CC_VERSION=`$CC -version | grep -i version`
226     ;;
227   *)
228 CC_VERSION=`$CC --version | sed 1q`
229     ;;
230 esac
231 if test $? -eq "0"
232 then
233   AC_MSG_CHECKING("C Compiler version")
234   AC_MSG_RESULT("$CC $CC_VERSION")
235 else
236 CC_VERSION=""
238 AC_SUBST(CC_VERSION)
239 MYSQL_CHECK_CXX_VERSION
241 # Fix for sgi gcc / sgiCC which tries to emulate gcc
242 if test "$CC" = "sgicc"
243 then
244   ac_cv_prog_gcc="no"
246 if test "$CXX" = "sgi++"
247 then
248   GXX="no"
251 if test "$ac_cv_prog_gcc" = "yes"
252 then
253   AS="$CC -c"
254   AC_SUBST(AS)
255 else
256   AC_PATH_PROG(AS, as, as)
259 # Still need ranlib for readline; local static use only so no libtool.
260 AC_PROG_RANLIB
261 # We use libtool
262 #AC_LIBTOOL_WIN32_DLL
263 AC_PROG_LIBTOOL
265 # Ensure that we have --preserve-dup-deps defines, otherwise we get link
266 # problems of 'mysql' with CXX=g++
267 LIBTOOL="$LIBTOOL --preserve-dup-deps"
268 AC_SUBST(LIBTOOL)dnl
270 AC_SUBST(NM)dnl
272 ##############################################################################
273 # In automake 1.12, the extension on generated yacc/bison header files changed
274 ##############################################################################
276 YACC_HEXT="h"
277 MAKEFILE_1ST=`head -1 "$srcdir/Makefile.in"`
278 AMAKE_MAJOR=`expr "$MAKEFILE_1ST" : '.*generated by automake \([[0-9]]*\).*'`
279 if test $? -eq "0" ; then
280   if test "$AMAKE_MAJOR" -gt "1" ; then
281     YACC_HEXT="hh"
282     CXXFLAGS="$CXXFLAGS -DYACC_HEXT_HH"
283   elif test "$AMAKE_MAJOR" -eq "1" ; then
284     AMAKE_MINOR=`expr "$MAKEFILE_1ST" : '.*generated by automake 1.\([[0-9]]*\).*'`
285     if test $? -eq "0" ; then
286       if test "$AMAKE_MINOR" -ge "12" ; then
287         YACC_HEXT="hh"
288         CXXFLAGS="$CXXFLAGS -DYACC_HEXT_HH"
289       fi
290     fi
291   fi
293 AC_SUBST(YACC_HEXT)
295 ##############################################################################
297 # NM= "$NM -X64"
298 #archive_expsym_cmds= `echo "$archive_expsym_cmds" | sed -e '/"$(CC)"//'`
299 #archive_expsym_cmds= "$CC -q64 $archive_expsym_cmds"
300 #  CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed -e 's/-fbranch-probabilities//; s/-Wall//; s/-ansi//; s/-pedantic//; s/-Wcheck//'`
302 #AC_LIBTOOL_DLOPEN AC_LIBTOOL_WIN32_DLL AC_DISABLE_FAST_INSTALL AC_DISABLE_SHARED AC_DISABLE_STATIC
304 # AC_PROG_INSTALL
305 AC_PROG_INSTALL
306 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
308 # Not critical since the generated file is distributed
309 AC_CHECK_PROGS(YACC, ['bison -y -p MYSQL'])
310 AC_CHECK_PROG(PDFMANUAL, pdftex, manual.pdf)
311 AC_CHECK_PROG(DVIS,      tex,    manual.dvi)
313 AC_PATH_PROG(uname_prog, uname, no)
315 # We should go through this and put all the explictly system dependent
316 # stuff in one place
317 AC_MSG_CHECKING(operating system)
318 AC_CACHE_VAL(mysql_cv_sys_os,
320 if test "$uname_prog" != "no"; then
321   mysql_cv_sys_os="`uname`"
322 else
323   mysql_cv_sys_os="Not Solaris"
326 AC_MSG_RESULT($mysql_cv_sys_os)
328 # This should be rewritten to use $target_os
329 case "$target_os" in
330   sco3.2v5*) 
331      CFLAGS="$CFLAGS -DSCO"
332      CXXFLAGS="$CXXFLAGS -DSCO"
333      LD='$(CC) $(CFLAGS)'
334      case "$CFLAGS" in
335        *-belf*) 
336          AC_SYS_COMPILER_FLAG(-belf,sco_belf_option,CFLAGS,[],[
337          case "$LDFLAGS" in
338            *-belf*) ;;
339            *) AC_MSG_WARN([Adding -belf option to ldflags.])
340               LDFLAGS="$LDFLAGS -belf"
341            ;;
342          esac
343          ])
344        ;;
345        *)
346          AC_SYS_COMPILER_FLAG(-belf,sco_belf_option,CFLAGS,[],[
347          case "$LDFLAGS" in
348            *-belf*) ;;
349            *)
350              AC_MSG_WARN([Adding -belf option to ldflags.])
351              LDFLAGS="$LDFLAGS -belf"
352            ;;
353          esac
354          ])
355        ;;
356      esac
357   ;;
358   sysv5UnixWare* | sysv5OpenUNIX8*) 
359     if test "$GCC" != "yes"; then
360       # Use the built-in alloca()
361       CFLAGS="$CFLAGS -Kalloca"
362     fi
363     CXXFLAGS="$CXXFLAGS -DNO_CPLUSPLUS_ALLOCA"
364   ;;
365   sysv5SCO_SV6.0.0*)
366     if test "$GCC" != "yes"; then
367       # Use the built-in alloca()
368       CFLAGS="$CFLAGS -Kalloca"
369       CXXFLAGS="$CFLAGS -Kalloca"
370       # Use no_implicit for templates
371       CXXFLAGS="$CXXFLAGS -Tno_implicit"
372       AC_DEFINE([HAVE_EXPLICIT_TEMPLATE_INSTANTIATION],
373         [1], [Defined by configure. Use explicit template instantiation.])
374     fi
375   ;;
376 esac
377 AC_SUBST(CC)
378 AC_SUBST(CFLAGS)
379 AC_SUBST(CXX)
380 AC_SUBST(CXXFLAGS)
381 AC_SUBST(ASFLAGS)
382 AC_SUBST(LD)
383 AC_SUBST(INSTALL_SCRIPT)
385 export CC CXX CFLAGS LD LDFLAGS AR ARFLAGS
387 if test "$GCC" = "yes"
388 then
389   # mysqld requires -fno-implicit-templates.
390   # Disable exceptions as they seams to create problems with gcc and threads.
391   # mysqld doesn't use run-time-type-checking, so we disable it.
392   # We should use -Wno-invalid-offsetof flag to disable some warnings from gcc
393   # regarding offset() usage in C++ which are done in a safe manner in the
394   # server
395   CXXFLAGS="$CXXFLAGS -fno-implicit-templates -fno-exceptions -fno-rtti"
396   AC_DEFINE([HAVE_EXPLICIT_TEMPLATE_INSTANTIATION],
397     [1], [Defined by configure. Use explicit template instantiation.])
400 MYSQL_PROG_AR
402 # libmysqlclient versioning when linked with GNU ld.
403 if $LD --version 2>/dev/null| grep GNU >/dev/null 2>&1; then
404   LD_VERSION_SCRIPT="-Wl,--version-script=\$(top_builddir)/libmysql/libmysql.ver"
405   AC_CONFIG_FILES(libmysql/libmysql.ver)
407 AC_SUBST(LD_VERSION_SCRIPT)
410 # Avoid bug in fcntl on some versions of linux
411 AC_MSG_CHECKING([if we should use 'skip-external-locking' as default for $target_os])
412 # Any variation of Linux
413 if expr "$target_os" : "[[Ll]]inux.*" > /dev/null
414 then
415   MYSQLD_DEFAULT_SWITCHES="--skip-external-locking"
416   TARGET_LINUX="true"
417   AC_MSG_RESULT([yes])
418   AC_DEFINE([TARGET_OS_LINUX], [1], [Whether we build for Linux])
419 else
420   MYSQLD_DEFAULT_SWITCHES=""
421   TARGET_LINUX="false"
422   AC_MSG_RESULT([no])
424 AC_SUBST(MYSQLD_DEFAULT_SWITCHES)
425 AC_SUBST(TARGET_LINUX)
427 dnl Find paths to some shell programs
428 AC_PATH_PROG(LN, ln, ln)
429 # This must be able to take a -f flag like normal unix ln.
430 AC_PATH_PROG(LN_CP_F, ln, ln)
431 case $SYSTEM_TYPE in
432   *netware*) ;;
433   *)
434     # If ln -f does not exists use -s (AFS systems)
435     if test -n "$LN_CP_F"; then
436       LN_CP_F="$LN_CP_F -s"
437     fi
438     ;;
439 esac
441 AC_PATH_PROG(MV, mv, mv)
442 AC_PATH_PROG(RM, rm, rm)
443 AC_PATH_PROG(CP, cp, cp)
444 AC_PATH_PROG(SED, sed, sed)
445 AC_PATH_PROG(CMP, cmp, cmp)
446 AC_PATH_PROG(CHMOD, chmod, chmod)
447 AC_PATH_PROG(HOSTNAME, hostname, hostname)
448 AC_PATH_PROG(DIFF, diff, diff)
449 # Check for a GNU tar named 'gtar', or 'gnutar' (MacOS X) and
450 # fall back to 'tar' otherwise and hope that it's a GNU tar as well
451 AC_CHECK_PROGS(TAR, gnutar gtar tar)
453 dnl We use a path for perl so the script startup works
454 dnl We make sure to use perl, not perl5, in hopes that the RPMs will
455 dnl not depend on the perl5 binary being installed (probably a bug in RPM)
456 AC_PATH_PROG(PERL, perl, no)
457 if test "$PERL" != "no" && $PERL -e 'require 5' > /dev/null 2>&1
458 then
459   PERL5=$PERL
460 else
461   AC_PATH_PROG(PERL5, perl5, no)
462   if test "$PERL5" != no
463   then
464     PERL=$PERL5
465     ac_cv_path_PERL=$ac_cv_path_PERL5
466   fi
469 AC_SUBST(HOSTNAME)
470 AC_SUBST(PERL)
471 AC_SUBST(PERL5)
473 # Enable the abi_check rule only if gcc is available
475 if test "$GCC" != "yes" || expr "$CC" : ".*icc.*"
476 then
477   ABI_CHECK=""
478 else
479   ABI_CHECK="abi_check"
482 AC_SUBST(ABI_CHECK)
484 # Look for PS usage.  We use double dollar-signs in FIND_PROC because this
485 # value is written to a makefile, which interprets away one level of
486 # dollar-signs.  So, interpretation stages are  m4 and then shell in autoconf,
487 # then Make, then shell.  The autoconf substitution uses single quotes, so 
488 # no unprotected single quotes should appear in the expression.
489 AC_PATH_PROG(PS, ps, ps)
490 AC_MSG_CHECKING("how to check if pid exists")
491 PS=$ac_cv_path_PS
492 # Linux style
493 if $PS wwwp $$ 2> /dev/null | grep -- "$0" > /dev/null
494 then
495   FIND_PROC="$PS wwwp \$\$PID | grep -v \" grep\" | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" > /dev/null"
496 # Solaris
497 elif $PS -fp $$ 2> /dev/null | grep -- $0 > /dev/null
498 then
499   FIND_PROC="$PS -p \$\$PID | grep -v \" grep\" | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" > /dev/null"
500 # BSD style
501 elif $PS -uaxww 2> /dev/null | grep -- $0 > /dev/null
502 then
503   FIND_PROC="$PS -uaxww | grep -v \" grep\" | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" | grep \" \$\$PID \" > /dev/null"
504 # SysV style
505 elif $PS -ef 2> /dev/null | grep -- $0 > /dev/null
506 then
507   FIND_PROC="$PS -ef | grep -v \" grep\" | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" | grep \" \$\$PID \" > /dev/null"
508 # Do anybody use this?
509 elif $PS $$ 2> /dev/null | grep -- $0 > /dev/null
510 then
511   FIND_PROC="$PS \$\$PID | grep -v \" grep\" | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" > /dev/null"
512 else
513   case $SYSTEM_TYPE in
514     *freebsd*|*dragonfly*)
515       FIND_PROC="$PS p \$\$PID | grep -v \" grep\" | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" > /dev/null"
516       ;;
517     *darwin*)
518       FIND_PROC="$PS -uaxww | grep -v \" grep\" | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" | grep \" \$\$PID \" > /dev/null"
519       ;;
520     *cygwin*)
521       FIND_PROC="$PS -e | grep -v \" grep\" | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" | grep \" \$\$PID \" > /dev/null"
522       ;;
523     *netware*)
524       FIND_PROC=
525       ;;
526     *)
527       AC_MSG_ERROR([Could not find the right ps and/or grep switches. Which OS is this?  See the Installation chapter in the Reference Manual.])
528   esac
530 AC_SUBST(FIND_PROC)
531 AC_MSG_RESULT("$FIND_PROC")
533 # Check if a pid is valid
534 AC_PATH_PROG(KILL, kill, kill)
535 AC_MSG_CHECKING("for kill switches")
536 if $ac_cv_path_KILL -0 $$
537 then
538   CHECK_PID="$ac_cv_path_KILL -0 \$\$PID > /dev/null 2> /dev/null"
539 elif kill -s 0 $$
540 then
541   CHECK_PID="$ac_cv_path_KILL -s 0 \$\$PID > /dev/null 2> /dev/null"
542 else
543   AC_MSG_WARN([kill -0 to check for pid seems to fail])
544     CHECK_PID="$ac_cv_path_KILL -s SIGCONT \$\$PID > /dev/null 2> /dev/null"
546 AC_SUBST(CHECK_PID)
547 AC_MSG_RESULT("$CHECK_PID")
549 # We need an ANSI C compiler
550 AM_PROG_CC_STDC
552 # We need an assembler, too
553 AM_PROG_AS
554 CCASFLAGS="$CCASFLAGS $ASFLAGS"
556 # Check if we need noexec stack for assembler
557 AC_CHECK_NOEXECSTACK
559 if test "$am_cv_prog_cc_stdc" = "no"
560 then
561   AC_MSG_ERROR([MySQL requires an ANSI C compiler (and a C++ compiler). Try gcc. See the Installation chapter in the Reference Manual.])
564 NOINST_LDFLAGS="-static"
566 static_nss=""
567 STATIC_NSS_FLAGS=""
568 OTHER_LIBC_LIB=""
569 AC_ARG_WITH(other-libc,
570  [  --with-other-libc=DIR   Link against libc and other standard libraries 
571                           installed in the specified non-standard location 
572                           overriding default. Originally added to be able to
573                           link against glibc 2.2 without making the user 
574                           upgrade the standard libc installation.],
576    other_libc_include="$withval/include"
577    other_libc_lib="$withval/lib"
578    with_other_libc="yes"
579    enable_shared="no"
580    all_is_static="yes"
581    CFLAGS="$CFLAGS -I$other_libc_include"
582    # There seems to be a feature in gcc that treats system and libc headers
583    # silently when they violatate ANSI C++ standard, but it is strict otherwise
584    # since gcc cannot now recognize that our headers are libc, we work around
585    # by telling it to be permissive. Note that this option only works with
586    # new versions of gcc (2.95.x and above)
587    CXXFLAGS="$CXXFLAGS -fpermissive -I$other_libc_include"
588    if test -f "$other_libc_lib/libnss_files.a"
589    then
590      # libc has been compiled with --enable-static-nss
591      # we need special flags, but we will have to add those later
592      STATIC_NSS_FLAGS="-lc -lnss_files -lnss_dns -lresolv"
593      STATIC_NSS_FLAGS="$STATIC_NSS_FLAGS $STATIC_NSS_FLAGS"
594      OTHER_LIBC_LIB="-static -L$other_libc_lib"
595      static_nss=1
596    else
597      # this is a dirty hack. We if we detect static nss glibc in the special
598      # location, we do not re-direct the linker to get libraries from there
599      # during check. The reason is that if we did, we would have to find a
600      # way to append the special static nss flags to LIBS every time we do
601      # any check - this is definitely feasible, but not worthwhile the risk
602      # of breaking other things. So for our purposes it would be sufficient
603      # to assume that whoever is using static NSS knows what he is doing and
604      # has sensible libraries in the regular location
605      LDFLAGS="$LDFLAGS -static -L$other_libc_lib "
606    fi
607    
608    # When linking against custom libc installed separately, we want to force
609    # all binary builds to be static, including the build done by configure
610    # itself to test for system features.
611    with_mysqld_ldflags="-all-static"
612    with_client_ldflags="-all-static"
613    NOINST_LDFLAGS="-all-static"
614  ],
616   other_libc_include=
617   other_libc_lib=
618   with_other_libc="no"
621 AC_SUBST(NOINST_LDFLAGS)
624 # Check if we are using Linux and a glibc compiled with static nss
625 # (this is true on the MySQL build machines to avoid NSS problems)
627 AC_CHECK_TOOL([NM], [nm]) 
629 if test "$TARGET_LINUX" = "true" -a "$static_nss" = ""
630 then
631   tmp=`$NM ${other_libc_lib:-/usr/lib*}/libc.a | grep _nss_files_getaliasent_r1`
632   if test -n "$tmp"
633   then
634      STATIC_NSS_FLAGS="-lc -lnss_files -lnss_dns -lresolv"
635      STATIC_NSS_FLAGS="$STATIC_NSS_FLAGS $STATIC_NSS_FLAGS"
636      static_nss=1
637   fi
640 AC_MSG_CHECKING(whether features provided by the user community should be included.)
641 AC_ARG_ENABLE(community-features,
642     AC_HELP_STRING(
643         [--disable-community-features], 
644         [Disable additional features provided by the user community.]),
645     [ ENABLE_COMMUNITY_FEATURES=$enableval ],
646     [ ENABLE_COMMUNITY_FEATURES=yes ]
647     )
649 if test "$ENABLE_COMMUNITY_FEATURES" = "yes"
650 then
651   AC_DEFINE([COMMUNITY_SERVER], [1],
652             [Whether features provided by the user community should be included])
653   AC_MSG_RESULT([yes])
654 else
655   AC_MSG_RESULT([no])
658 AC_ARG_WITH(server-suffix,
659     [  --with-server-suffix    Append value to the version string.],
660     [ MYSQL_SERVER_SUFFIX=`echo "$withval" | sed -e  's/^\(...................................\)..*$/\1/'` ],
661     [ MYSQL_SERVER_SUFFIX= ]
662     )
663 AC_SUBST(MYSQL_SERVER_SUFFIX)
665 # Set flags if we want to force to use pthreads
666 AC_ARG_WITH(pthread,
667     [  --with-pthread          Force use of pthread library.],
668     [ with_pthread=$withval ],
669     [ with_pthread=no ]
670     )
672 # Force use of thread libs LIBS
673 AC_ARG_WITH(named-thread-libs,
674     [  --with-named-thread-libs=ARG
675                           Use specified thread libraries instead of 
676                           those automatically found by configure.],
677     [ with_named_thread=$withval ],
678     [ with_named_thread=no ]
679     )
681 # Force use of a curses libs
682 AC_ARG_WITH(named-curses-libs,
683     [  --with-named-curses-libs=ARG
684                           Use specified curses libraries instead of 
685                           those automatically found by configure.],
686     [ with_named_curses=$withval ],
687     [ with_named_curses=no ]
688     )
690 # Make thread safe client
691 AC_ARG_ENABLE(thread-safe-client,
692     [  --disable-thread-safe-client   
693                           Compile the client without threads.],
694     [ THREAD_SAFE_CLIENT=$enableval ],
695     [ THREAD_SAFE_CLIENT=yes ]
696     )
698 # compile with strings functions in assembler
699 AC_ARG_ENABLE(assembler,
700     [  --enable-assembler      Use assembler versions of some string 
701                           functions if available.],
702     [ ENABLE_ASSEMBLER=$enableval ],
703     [ ENABLE_ASSEMBLER=no ]
704     )
706 AC_MSG_CHECKING(if we should use assembler functions)
707 # For now we only support assembler on i386 and sparc systems
708 AM_CONDITIONAL(ASSEMBLER_x86, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "i386" && $AS strings/strings-x86.s -o checkassembler >/dev/null 2>&1 && test -f checkassembler && (rm -f checkassembler; exit 0;))
709 AM_CONDITIONAL(ASSEMBLER_sparc32, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "sparc")
710 AM_CONDITIONAL(ASSEMBLER_sparc64, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "sparcv9")
711 AM_CONDITIONAL(ASSEMBLER, test "$ASSEMBLER_x86_TRUE" = "" -o "$ASSEMBLER_sparc32_TRUE" = "")
713 if test "$ASSEMBLER_TRUE" = ""
714 then
715   AC_MSG_RESULT([yes])
716 else
717   AC_MSG_RESULT([no])
720 # Add query profiler
721 AC_MSG_CHECKING(if SHOW PROFILE should be enabled.)
722 AC_ARG_ENABLE(profiling,
723     AS_HELP_STRING([--enable-profiling], [Build a version with query profiling code (req. community-features)]),
724     [ ENABLED_PROFILING=$enableval ],
725     [ ENABLED_PROFILING=$ENABLE_COMMUNITY_FEATURES ])
727 if test "$ENABLED_PROFILING" = "yes"
728 then
729   if test "$ENABLE_COMMUNITY_FEATURES" = "yes";
730   then
731     AC_DEFINE([ENABLED_PROFILING], [1],
732               [If SHOW PROFILE should be enabled])
733     AC_MSG_RESULT([yes]) 
734   else
735     ENABLED_PROFILING="no"
736     AC_MSG_RESULT([no, overridden by community-features disabled])
737   fi
738 else
739   AC_MSG_RESULT([no])
742 # Use this to set the place used for unix socket used to local communication.
743 AC_ARG_WITH(unix-socket-path,
744     [  --with-unix-socket-path=SOCKET
745                           Where to put the unix-domain socket.  SOCKET must be 
746                           an absolute file name.],
747     [ MYSQL_UNIX_ADDR=$withval ],
748     [ MYSQL_UNIX_ADDR=$MYSQL_UNIX_ADDR_DEFAULT ]
749     )
750 AC_SUBST(MYSQL_UNIX_ADDR)
752 AC_ARG_WITH(tcp-port,
753     [  --with-tcp-port=port-number
754                           Which port to use for MySQL services (default 3306)],
755     [ MYSQL_TCP_PORT=$withval ],
756     [ MYSQL_TCP_PORT=$MYSQL_TCP_PORT_DEFAULT
757       # if we actually defaulted (as opposed to the pathological case of
758       # --with-tcp-port=<MYSQL_TCP_PORT_DEFAULT> which might in theory
759       # happen if whole batch of servers was built from a script), set
760       # the default to zero to indicate that; we don't lose information
761       # that way, because 0 obviously indicates that we can get the
762       # default value from MYSQL_TCP_PORT. this seems really evil, but
763       # testing for MYSQL_TCP_PORT==MYSQL_TCP_PORT_DEFAULT would make a
764       # a port of MYSQL_TCP_PORT_DEFAULT magic even if the builder did not
765       # intend it to mean "use the default, in fact, look up a good default
766       # from /etc/services if you can", but really, really meant 3306 when
767       # they passed in 3306. When they pass in a specific value, let them
768       # have it; don't second guess user and think we know better, this will
769       # just make people cross.  this makes the the logic work like this
770       # (which is complicated enough):
771       #
772       # - if a port was set during build, use that as a default.
773       #
774       # - otherwise, try to look up a port in /etc/services; if that fails,
775       #   use MYSQL_TCP_PORT_DEFAULT (at the time of this writing 3306)
776       #
777       # - allow the MYSQL_TCP_PORT environment variable to override that.
778       #
779       # - allow command-line parameters to override all of the above.
780       #
781       # the top-most MYSQL_TCP_PORT_DEFAULT is read from win/configure.js,
782       # so don't mess with that.
783       MYSQL_TCP_PORT_DEFAULT=0 ]
784     )
785 AC_SUBST(MYSQL_TCP_PORT)
786 # We might want to document the assigned port in the manual.
787 AC_SUBST(MYSQL_TCP_PORT_DEFAULT)
789 # Use this to set the place used for unix socket used to local communication.
790 AC_ARG_WITH(mysqld-user,
791     [  --with-mysqld-user=username   
792                           What user the mysqld daemon shall be run as.],
793     [ MYSQLD_USER=$withval ],
794     [ MYSQLD_USER=mysql ]
795     )
796 AC_SUBST(MYSQLD_USER)
798 # If we should allow LOAD DATA LOCAL
799 AC_MSG_CHECKING(If we should should enable LOAD DATA LOCAL by default)
800 AC_ARG_ENABLE(local-infile,
801     [  --enable-local-infile   Enable LOAD DATA LOCAL INFILE (default: disabled)],
802     [ ENABLED_LOCAL_INFILE=$enableval ],
803     [ ENABLED_LOCAL_INFILE=no ]
804     )
805 if test "$ENABLED_LOCAL_INFILE" = "yes"
806 then
807   AC_MSG_RESULT([yes])
808   AC_DEFINE([ENABLED_LOCAL_INFILE], [1],
809             [If LOAD DATA LOCAL INFILE should be enabled by default])
810 else
811   AC_MSG_RESULT([no])
814 # If we should allow init-file, skip-grant-table and bootstrap options
815 AC_MSG_CHECKING(If we should should enable init-file, skip-grant-table options and bootstrap)
816 AC_ARG_ENABLE(grant-options,
817     [  --disable-grant-options Disables the use of --init-file, --skip-grant-tables and --bootstrap options],
818     [ mysql_grant_options_enabled=$enableval ],
819     [ mysql_grant_options_enabled=yes ]
820     )
821 if test "$mysql_grant_options_enabled" = "yes"
822 then
823   AC_MSG_RESULT([yes])
824 else
825   AC_DEFINE([DISABLE_GRANT_OPTIONS], [1],
826             [Disables the use of --init-file, --skip-grant-tables and --bootstrap options])
827   AC_MSG_RESULT([no])
830 MYSQL_SYS_LARGEFILE
832 # Types that must be checked AFTER large file support is checked
833 AC_TYPE_SIZE_T
835 #--------------------------------------------------------------------
836 # Check for system header files
837 #--------------------------------------------------------------------
839 AC_HEADER_DIRENT
840 AC_HEADER_STDC
841 AC_HEADER_SYS_WAIT
842 AC_CHECK_HEADERS(fcntl.h fenv.h float.h floatingpoint.h fpu_control.h \
843  ieeefp.h limits.h memory.h pwd.h select.h \
844  stdlib.h stddef.h \
845  strings.h string.h synch.h sys/mman.h sys/socket.h netinet/in.h arpa/inet.h \
846  sys/timeb.h sys/types.h sys/un.h sys/vadvise.h sys/wait.h term.h \
847  unistd.h utime.h sys/utime.h termio.h termios.h sched.h crypt.h alloca.h \
848  sys/ioctl.h malloc.h sys/malloc.h sys/ipc.h sys/shm.h linux/config.h \
849  sys/prctl.h sys/resource.h sys/param.h port.h ieeefp.h \
850  execinfo.h)
852 AC_CHECK_HEADERS([xfs/xfs.h])
854 #--------------------------------------------------------------------
855 # Check for system libraries. Adds the library to $LIBS
856 # and defines HAVE_LIBM etc
857 #--------------------------------------------------------------------
859 AC_CHECK_LIB(m, floor, [], AC_CHECK_LIB(m, __infinity))
861 AC_CHECK_LIB(nsl_r, gethostbyname_r, [],
862   AC_CHECK_LIB(nsl, gethostbyname_r))
863 AC_CHECK_FUNC(gethostbyname_r)
865 AC_SEARCH_LIBS(setsockopt, socket)
866 # This may get things to compile even if bind-8 is installed
867 AC_SEARCH_LIBS(bind, bind)
868 # Check if crypt() exists in libc or libcrypt, sets LIBS if needed
869 AC_SEARCH_LIBS(crypt, crypt, AC_DEFINE(HAVE_CRYPT, 1, [crypt]))
870 # See if we need a library for address lookup.
871 AC_SEARCH_LIBS(inet_aton, [socket nsl resolv])
873 # For the sched_yield() function on Solaris
874 AC_SEARCH_LIBS(sched_yield, posix4, 
875   AC_DEFINE(HAVE_SCHED_YIELD, 1, [sched_yield]))
877 MYSQL_CHECK_ZLIB_WITH_COMPRESS
879 # For large pages support
880 if test "$TARGET_LINUX" = "true"
881 then
882   # For SHM_HUGETLB on Linux
883   AC_CHECK_DECLS(SHM_HUGETLB, 
884       AC_DEFINE([HAVE_LARGE_PAGES], [1], 
885                 [Define if you have large pages support])
886       AC_DEFINE([HUGETLB_USE_PROC_MEMINFO], [1],
887                 [Define if /proc/meminfo shows the huge page size (Linux only)])
888       , ,
889       [
890 #include <sys/shm.h>
891       ]
892   )
895 #--------------------------------------------------------------------
896 # Check for TCP wrapper support
897 #--------------------------------------------------------------------
899 AC_ARG_WITH(libwrap,
900 [  --with-libwrap[=DIR]      Compile in libwrap (tcp_wrappers) support],[
901   case "$with_libwrap" in
902   no) : ;;
903   yes|*)
904     _cppflags=${CPPFLAGS}
905     _ldflags=${LDFLAGS}
907     if test "$with_libwrap" != "yes"; then
908       CPPFLAGS="${CPPFLAGS} -I$with_libwrap/include"
909       LDFLAGS="${LDFLAGS} -L$with_libwrap/lib"
910     fi
912     _libs=${LIBS}
913     AC_CHECK_HEADER(tcpd.h,
914       LIBS="-lwrap $LIBS"
915       AC_MSG_CHECKING(for TCP wrappers library -lwrap)
916       AC_TRY_LINK([#include <tcpd.h>
917 int allow_severity = 0;
918 int deny_severity  = 0;
920 struct request_info *req;
921 ],[hosts_access (req)],
922         AC_MSG_RESULT(yes)
923         AC_DEFINE([LIBWRAP], [1], [Define if you have -lwrap])
924         AC_DEFINE([HAVE_LIBWRAP], [1], [Define if have -lwrap])
925         if test "$with_libwrap" != "yes"; then
926             WRAPLIBS="-L${with_libwrap}/lib"
927         fi
928         WRAPLIBS="${WRAPLIBS} -lwrap",
929         AC_MSG_RESULT(no)
930         CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}),
931       CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags})
932     LDFLAGS=${_ldflags} LIBS=${_libs}
933     ;;
934   esac
936 AC_SUBST(WRAPLIBS)
938 # Check for gtty if termio.h doesn't exists
939 if test "$ac_cv_header_termio_h" = "no" -a "$ac_cv_header_termios_h" = "no"
940 then
941   AC_SEARCH_LIBS(gtty, compat)
944 # We make a special variable for non-threaded version of LIBS to avoid
945 # including thread libs into non-threaded version of MySQL client library.
946 # Later in this script LIBS will be augmented with a threads library.
947 NON_THREADED_LIBS="$LIBS"
949 AC_CHECK_TYPES([int8, uint8, int16, uint16, int32, uint32, int64, uint64,
950                 uchar, uint, ulong],[],[], [
951 #include <sys/types.h>
953 AC_CHECK_TYPES([in_addr_t], [], [], [
954 #include <sys/types.h>
955 #include <sys/socket.h>
956 #include <netinet/in.h>
957 #include <arpa/inet.h>
959 AC_CHECK_TYPES([fp_except], [], [], [
960 #include <sys/types.h>
961 #include <ieeefp.h>
965 # Some system specific hacks
968 MAX_C_OPTIMIZE="-O3"
969 MAX_CXX_OPTIMIZE="-O3"
971 case $SYSTEM_TYPE in
972   *solaris2.7*)
973     # Solaris 2.7 has a broken /usr/include/widec.h
974     # Make a fixed copy in ./include
975     AC_MSG_WARN([Fixing broken include files for $SYSTEM_TYPE])
976     echo "  - Creating local copy of widec.h"
977     if test ! -d include
978     then
979       mkdir ./include
980     fi
981     builddir=`pwd`
982     sed -e "s|^#if[     ]*!defined(lint) && !defined(__lint)|#if !defined\(lint\) \&\& !defined\(__lint\) \&\& !defined\(getwc\)|" < /usr/include/widec.h > include/widec.h
983     CFLAGS="$CFLAGS -DHAVE_CURSES_H -I$builddir/include -DHAVE_RWLOCK_T"
984     CXXFLAGS="$CXXFLAGS -DHAVE_CURSES_H -I$builddir/include -DHAVE_RWLOCK_T"
985     ;;
986   *solaris2.8*)
987     # Solaris 2.8 has a broken /usr/include/widec.h
988     # Make a fixed copy in ./include
989     AC_MSG_WARN([Fixing broken include files for $SYSTEM_TYPE])
990     echo "  - Creating local copy of widec.h"
991     if test ! -d include
992     then
993       mkdir ./include
994     fi
995     builddir=`pwd`
996     sed -e "s|^#if[     ]*!defined(__lint)|#if !defined\(__lint\) \&\& !defined\(getwc\)|" < /usr/include/widec.h > include/widec.h
997     CFLAGS="$CFLAGS -DHAVE_CURSES_H -I$builddir/include -DHAVE_RWLOCK_T"
998     CXXFLAGS="$CXXFLAGS -DHAVE_CURSES_H -I$builddir/include -DHAVE_RWLOCK_T"
999     ;;
1000   *solaris2.5.1*)
1001     AC_MSG_WARN([Enabling getpass() workaround for Solaris 2.5.1])
1002     CFLAGS="$CFLAGS -DHAVE_BROKEN_GETPASS -DSOLARIS -DHAVE_RWLOCK_T";
1003     CXXFLAGS="$CXXFLAGS -DHAVE_RWLOCK_T -DSOLARIS"
1004     ;;
1005   *solaris*)
1006     CFLAGS="$CFLAGS -DHAVE_RWLOCK_T"
1007     CXXFLAGS="$CXXFLAGS -DHAVE_RWLOCK_T"
1008     ;;
1009   *SunOS*)
1010     AC_MSG_WARN([Enabling getpass() workaround for SunOS])
1011     CFLAGS="$CFLAGS -DHAVE_BROKEN_GETPASS -DSOLARIS";
1012     ;;
1013   *hpux10.20*)
1014     AC_MSG_WARN([Enabling workarounds for hpux 10.20])
1015     CFLAGS="$CFLAGS -DHAVE_BROKEN_SNPRINTF -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX10 -DSIGNAL_WITH_VIO_CLOSE -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT -DHAVE_POSIX1003_4a_MUTEX"
1016     CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_SNPRINTF -D_INCLUDE_LONGLONG -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX10 -DSIGNAL_WITH_VIO_CLOSE -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT -DHAVE_POSIX1003_4a_MUTEX"
1017     if test "$with_named_thread" = "no"
1018     then 
1019       AC_MSG_WARN([Using --with-named-thread=-lpthread])
1020       with_named_thread="-lcma"
1021     fi
1022     ;;
1023   *hpux11.*)
1024     AC_MSG_WARN([Enabling workarounds for hpux 11])
1025     CFLAGS="$CFLAGS -DHPUX11  -DSNPRINTF_RETURN_TRUNC -DHAVE_BROKEN_PREAD -DHAVE_BROKEN_GETPASS -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT"
1026     CXXFLAGS="$CXXFLAGS -DHPUX11  -DSNPRINTF_RETURN_TRUNC -DHAVE_BROKEN_PREAD -D_INCLUDE_LONGLONG -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT"
1027     if test "$with_named_thread" = "no"
1028     then 
1029       AC_MSG_WARN([Using --with-named-thread=-lpthread])
1030       with_named_thread="-lpthread"
1031     fi
1032     # Fixes for HPUX 11.0 compiler
1033     if test "$ac_cv_prog_gcc" = "no"
1034     then
1035       CFLAGS="$CFLAGS -DHAVE_BROKEN_INLINE"
1036 # set working flags first in line, letting override it (i. e. for debug):
1037       CXXFLAGS="+O2 $CXXFLAGS"
1038       MAX_C_OPTIMIZE=""
1039       MAX_CXX_OPTIMIZE=""
1040       ndb_cxxflags_fix="$ndb_cxxflags_fix -Aa"
1041     fi
1042     ;;
1043   *rhapsody*)
1044     if test "$ac_cv_prog_gcc" = "yes"
1045     then
1046       CPPFLAGS="$CPPFLAGS -traditional-cpp "
1047       CFLAGS="-DHAVE_CTHREADS_WRAPPER -DDO_NOT_REMOVE_THREAD_WRAPPERS"
1048       CXXFLAGS="-DHAVE_CTHREADS_WRAPPER"
1049       if test $with_named_curses = "no"
1050       then
1051         with_named_curses=""
1052       fi
1053     fi
1054     ;;
1055   *darwin5*)
1056     if test "$ac_cv_prog_gcc" = "yes"
1057     then
1058       FLAGS="-traditional-cpp -DHAVE_DARWIN5_THREADS -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DHAVE_BROKEN_REALPATH"
1059       CFLAGS="$CFLAGS $FLAGS"
1060       CXXFLAGS="$CXXFLAGS $FLAGS"
1061       MAX_C_OPTIMIZE="-O"
1062       with_named_curses=""
1063     fi
1064     ;;
1065   *darwin6*)
1066     if test "$ac_cv_prog_gcc" = "yes"
1067     then
1068       FLAGS="-D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DHAVE_BROKEN_REALPATH -DDONT_DECLARE_CXA_PURE_VIRTUAL "
1069       CFLAGS="$CFLAGS $FLAGS"
1070       CXXFLAGS="$CXXFLAGS $FLAGS"
1071       MAX_C_OPTIMIZE="-O"
1072     fi
1073     ;;
1074   *darwin*)
1075     if test "$ac_cv_prog_gcc" = "yes"
1076     then
1077       FLAGS="-D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT  -DDONT_DECLARE_CXA_PURE_VIRTUAL"
1078       CFLAGS="$CFLAGS $FLAGS"
1079       CXXFLAGS="$CXXFLAGS $FLAGS"
1080       MAX_C_OPTIMIZE="-O"
1081     fi
1082     ;;
1083   *freebsd*|*dragonfly*)
1084     AC_MSG_WARN([Adding fix for interrupted reads])
1085     OSVERSION=`sysctl -a | grep osreldate | awk '{ print $2 }'`
1086     if test "$OSVERSION" -gt "480100" && \
1087        test "$OSVERSION" -lt "500000" || \
1088        test "$OSVERSION" -gt "500109"
1089     then
1090        CXXFLAGS="$CXXFLAGS -DMYSQLD_NET_RETRY_COUNT=1000000"
1091     else
1092        CFLAGS="$CFLAGS -DHAVE_BROKEN_REALPATH"
1093        CXXFLAGS="$CXXFLAGS -DMYSQLD_NET_RETRY_COUNT=1000000 -DHAVE_BROKEN_REALPATH"
1094     fi
1095     ;;
1096   *netbsd*)
1097     AC_MSG_WARN([Adding flag -Dunix])
1098     CFLAGS="$CFLAGS -Dunix"
1099     CXXFLAGS="$CXXFLAGS -Dunix"
1100     OVERRIDE_MT_LD_ADD="\$(top_srcdir)/mit-pthreads/obj/libpthread.a"
1101     ;;
1102   *bsdi*)
1103     AC_MSG_WARN([Adding fix for BSDI])
1104     CFLAGS="$CFLAGS -D__BSD__ -DHAVE_BROKEN_REALPATH"
1105     AC_DEFINE_UNQUOTED([SOCKOPT_OPTLEN_TYPE], [size_t],
1106                        [Last argument to get/setsockopt])
1107     ;;
1108    *sgi-irix6*)
1109     if test "$with_named_thread" = "no"
1110     then 
1111       AC_MSG_WARN([Using --with-named-thread=-lpthread])
1112       with_named_thread="-lpthread"
1113     fi
1114     CXXFLAGS="$CXXFLAGS -D_BOOL"
1115     ;;
1116     *aix4.3*)
1117       AC_MSG_WARN([Adding defines for AIX])
1118       CFLAGS="$CFLAGS -Wa,-many -DUNDEF_HAVE_INITGROUPS -DSIGNALS_DONT_BREAK_READ"
1119       CXXFLAGS="$CXXFLAGS -Wa,-many -DUNDEF_HAVE_INITGROUPS -DSIGNALS_DONT_BREAK_READ"
1120     ;;
1121 dnl Is this the right match for DEC OSF on alpha?
1122     *dec-osf*)
1123       if test "$ac_cv_prog_gcc" = "yes" && test "$host_cpu" = "alpha"
1124       then
1125           AC_MSG_WARN([Adding defines for DEC OSF on alpha])
1126           CFLAGS="$CFLAGS -mieee"
1127           CXXFLAGS="$CXXFLAGS -mieee"
1128       fi
1129       AC_MSG_WARN([Adding defines for OSF1])
1130       # gethostbyname_r is deprecated and doesn't work ok on OSF1
1131       CFLAGS="$CFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R -DSNPRINTF_RETURN_TRUNC"
1132       CXXFLAGS="$CXXFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R -DSNPRINTF_RETURN_TRUNC"
1133       # fix to handle include of <stdint.h> correctly on OSF1 with cxx compiler
1134       CXXFLAGS="$CXXFLAGS -I/usr/include/cxx -I/usr/include/cxx_cname -I/usr/include -I/usr/include.dtk"
1135     ;;
1136   *netware*)
1137     # No need for curses library so set it to null
1138     with_named_curses=""
1140     # No thread library - in LibC
1141     with_named_thread=""
1142     
1143     #
1144     # Edit Makefile.in files.
1145     #
1146     echo -n "configuring Makefile.in files for NetWare... "
1147     for file in sql/Makefile.in extra/Makefile.in client/Makefile.in
1148     do
1149     # echo "#### $file ####"
1150       filedir="`dirname $file`"
1151       filebase="`basename $file`"
1152       filesed=$filedir/$filebase.sed
1153       #
1154       # Backup and always use original file
1155       #
1156       if test -f $file.bk
1157       then
1158         cp -fp $file.bk $file
1159       else
1160         cp -fp $file $file.bk
1161       fi
1162       case $file in
1163         sql/Makefile.in)
1164           # Use gen_lex_hash.linux instead of gen_lex_hash
1165           # Add library dependencies to mysqld_DEPENDENCIES
1166           lib_DEPENDENCIES="\$(openssl_libs) \$(yassl_libs)"
1167           cat > $filesed << EOF
1168 s,\(\./gen_lex_hash\)\$(EXEEXT),\1.linux,
1169 s%\(mysqld_DEPENDENCIES = \)%\1$lib_DEPENDENCIES %
1171           ;;
1172         extra/Makefile.in)
1173           cat > $filesed << EOF
1174 s,\(extra/comp_err\)\$(EXEEXT),\1.linux,
1176           ;;
1177         libmysql/Makefile.in)
1178           cat > $filesed << EOF
1179 s,libyassl.la,.libs/libyassl.a,
1180 s,libtaocrypt.la,.libs/libtaocrypt.a,
1182           ;;
1183         libmysql_r/Makefile.in)
1184           cat > $filesed << EOF
1185 s,libyassl.la,.libs/libyassl.a,
1186 s,libtaocrypt.la,.libs/libtaocrypt.a,
1188           ;;
1189         client/Makefile.in)
1190           #
1191           cat > $filesed << EOF
1192 s,libmysqlclient.la,.libs/libmysqlclient.a,
1194           ;;
1195       esac
1196       if `sed -f $filesed $file > $file.nw`;\
1197       then
1198         mv -f $file.nw $file
1199         rm -f $filesed
1200       else
1201         exit 1
1202       fi
1203       # wait for file system changes to complete
1204       sleep 1
1205     done
1206     echo "done"
1208     #
1209     # Make sure the following files are writable.
1210     #
1211     # When the files are retrieved from some source code control systems they are read-only.
1212     #
1213     echo -n "making sure specific build files are writable... "
1214     for file in \
1215         Docs/manual.chm \
1216         Docs/mysql.info \
1217         Docs/INSTALL-BINARY \
1218         INSTALL-SOURCE \
1219         COPYING
1220     do
1221       if test -e $file; then
1222         chmod +w $file
1223       fi
1224     done
1225     echo "done"
1227     ;;
1228 esac
1231 #---START: Used in for client configure
1232 # Check if we threads are in libc or if we should use
1233 # -lpthread, -lpthreads or mit-pthreads
1234 # We have to check libc last because else it fails on Solaris 2.6
1236 with_posix_threads="no"
1237 # Search thread lib on Linux
1238 if test "$with_named_thread" = "no"
1239 then
1240     AC_MSG_CHECKING("Linux threads")
1241     if test "$TARGET_LINUX" = "true"
1242     then
1243         AC_MSG_RESULT("starting")
1244         # use getconf to check glibc contents
1245         AC_MSG_CHECKING("getconf GNU_LIBPTHREAD_VERSION")
1246         case `getconf GNU_LIBPTHREAD_VERSION | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` in
1247         NPTL* )
1248                 AC_MSG_RESULT("NPTL")
1249                 AC_DEFINE([HAVE_NPTL], [1], [NPTL threads implementation])
1250                 with_named_thread="-lpthread"
1251                 ;;
1252         LINUXTHREADS* )
1253                 AC_MSG_RESULT("Linuxthreads")
1254                 AC_DEFINE([HAVE_LINUXTHREADS], [1], 
1255                       [Whether we are using Xavier Leroy's LinuxThreads])
1256                 with_named_thread="-lpthread"
1257                 ;;
1258         * )
1259                 AC_MSG_RESULT("unknown")
1260                 ;;
1261         esac
1262         if test "$with_named_thread" = "no"
1263         then
1264           # old method, check headers
1265           # Look for LinuxThreads.
1266           AC_MSG_CHECKING("LinuxThreads in header file comment")
1267           res=`grep Linuxthreads /usr/include/pthread.h 2>/dev/null | wc -l`
1268           if test "$res" -gt 0
1269           then
1270             AC_MSG_RESULT("Found")
1271             AC_DEFINE([HAVE_LINUXTHREADS], [1],
1272                   [Whether we are using Xavier Leroy's LinuxThreads])
1273             # Linux 2.0 sanity check
1274             AC_TRY_COMPILE([#include <sched.h>], [int a = sched_get_priority_min(1);], ,
1275                   AC_MSG_ERROR([Syntax error in sched.h. Change _P to __P in the /usr/include/sched.h file. See the Installation chapter in the Reference Manual]))
1276             # RedHat 5.0 does not work with dynamic linking of this. -static also
1277             # gives a speed increase in linux so it does not hurt on other systems.
1278             with_named_thread="-lpthread"
1279           else
1280             AC_MSG_RESULT("Not found")
1281             # If this is a linux machine we should barf
1282             AC_MSG_ERROR([This is a Linux system without a working getconf, 
1283 and Linuxthreads was not found. Please install it (or a new glibc) and try again.  
1284 See the Installation chapter in the Reference Manual for more information.])
1285           fi
1286         else
1287             AC_MSG_RESULT("no need to check headers")
1288         fi
1289         
1290         AC_MSG_CHECKING("for pthread_create in -lpthread")
1291         ac_save_LIBS="$LIBS"
1292         LIBS="$LIBS -lpthread"
1293         AC_TRY_LINK( [#include <pthread.h>],
1294               [ (void) pthread_create((pthread_t*) 0,(pthread_attr_t*) 0, 0, 0); ],
1295               AC_MSG_RESULT("yes"),
1296               [ AC_MSG_RESULT("no")
1297                 AC_MSG_ERROR([
1298 This is a Linux system claiming to support threads, either Linuxthreads or NPTL, but linking a test program failed.  
1299 Please install one of these (or a new glibc) and try again.  
1300 See the Installation chapter in the Reference Manual for more information.]) ]
1301               )
1302         LIBS="$ac_save_LIBS"
1303     else
1304         AC_MSG_RESULT("no")
1305     fi  # "$TARGET_LINUX" 
1306 fi  # "$with_named_thread" = "no" -a "$with_mit_threads" = "no"
1309 # Hack for DEC-UNIX (OSF1 -> Tru64)
1310 if test "$with_named_thread" = "no" -a "$with_mit_threads" = "no"
1311 then
1312     AC_MSG_CHECKING("DEC threads post OSF/1 3.2")
1313     if test -f /usr/shlib/libpthread.so -a -f /usr/lib/libmach.a -a -f /usr/ccs/lib/cmplrs/cc/libexc.a
1314     then
1315       with_named_thread="-lpthread -lmach -lexc"
1316       CFLAGS="$CFLAGS -D_REENTRANT"
1317       CXXFLAGS="$CXXFLAGS -D_REENTRANT"
1318       AC_DEFINE(HAVE_DEC_THREADS, [1], [Whether we are using DEC threads])
1319       AC_MSG_RESULT("yes")
1320     else
1321       AC_MSG_RESULT("no")
1322     fi  # DEC threads
1323 fi  # "$with_named_thread" = "no" -a "$with_mit_threads" = "no"
1326 dnl This is needed because -lsocket has to come after the thread
1327 dnl library on SCO.
1328 AC_DEFUN([MYSQL_REMOVE_SOCKET_FROM_LIBS_HACK], [
1329   LIBS=`echo " $LIBS " | sed -e 's/ -lsocket / /g'`
1331 # Hack for SCO UNIX
1332 if test "$with_named_thread" = "no"
1333 then
1334   AC_MSG_CHECKING("SCO threads")
1335   if expr "$SYSTEM_TYPE" : ".*sco.*" > /dev/null
1336   then
1337     if test -f /usr/lib/libgthreads.a -o -f /usr/lib/libgthreads.so
1338     then
1339       MYSQL_REMOVE_SOCKET_FROM_LIBS_HACK
1340       with_named_thread="-lgthreads -lsocket -lgthreads"
1341       # sched.h conflicts with fsu-threads
1342       touch ./include/sched.h
1343       touch ./include/semaphore.h
1345       # We must have gcc
1346       if expr "$CC" : ".*gcc.*"
1347       then
1348         AC_MSG_RESULT("yes")
1349       else
1350         AC_MSG_ERROR([On SCO UNIX MySQL must be compiled with gcc. See the Installation chapter in the Reference Manual.])
1351       fi
1352       AC_MSG_RESULT("yes")
1353     elif test -f /usr/local/lib/libpthread.a -o -f /usr/local/lib/libpthread.so
1354     then
1355       MYSQL_REMOVE_SOCKET_FROM_LIBS_HACK
1356       with_named_thread="-lpthread -lsocket"
1357       # sched.h conflicts with fsu-threads
1358       # touch ./include/sched.h
1360       AC_MSG_CHECKING("for gcc")
1361       # We must have gcc
1362       if expr "$CC" : ".*gcc.*"
1363       then
1364         AC_MSG_RESULT("yes")
1365       else
1366         AC_MSG_ERROR([On SCO UNIX MySQL must be compiled with gcc. See the Installation chapter in the Reference Manual.])
1367       fi
1368       AC_MSG_RESULT("yes")
1369     # Hack for SCO UnixWare 7.1.x
1370     #
1371     elif test "$with_named_thread" = "no"
1372     then
1373       AC_MSG_RESULT("no")
1374       AC_MSG_CHECKING("SCO UnixWare 7.1.x native threads")
1375       if expr "$SYSTEM_TYPE" : ".*sco.*" > /dev/null
1376       then
1377         if test -f /usr/lib/libthread.so -o -f /usr/lib/libthreadT.so
1378         then
1379           MYSQL_REMOVE_SOCKET_FROM_LIBS_HACK
1380           if expr "$CC" : ".*gcc.*"
1381           then
1382             with_named_thread="-pthread -lsocket -lnsl"
1383           else
1384             with_named_thread="-Kthread -lsocket -lnsl"
1385           fi
1386           if expr "$SYSTEM_TYPE" : ".*unixware7.0.0" > /dev/null
1387           then
1388             AC_DEFINE(HAVE_UNIXWARE7_THREADS, [1])
1389           fi
1390           AC_MSG_RESULT("yes")
1391           # We must have cc
1392           AC_MSG_CHECKING("for gcc")
1393           if expr "$CC" : ".*gcc.*"
1394           then
1395             CC="$CC -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
1396             CXX="$CXX -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
1397           else
1398             CC="$CC -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
1399             CXX="$CXX -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK"
1400           fi
1401         else
1402           AC_MSG_ERROR([configure: error: Can't find thread libs on SCO UnixWare7. See the Installation chapter in the Reference Manual.]) 
1403         fi
1404       else
1405         AC_MSG_RESULT("no")
1406       fi
1407     else
1408       AC_MSG_ERROR([On SCO UNIX MySQL requires that the FSUThreads package is installed. See the Installation chapter in the Reference Manual.])
1409     fi
1410   else
1411     AC_MSG_RESULT("no")
1412   fi
1416 # Check for SCO threading libraries
1418 if test "$with_named_thread" = "no"
1419 then
1420   AC_MSG_CHECKING([SCO OpenServer 6, UnixWare 7 or OpenUNIX 8 native threads])
1421   if expr "$SYSTEM_TYPE" : ".*UnixWare.*" > /dev/null || \
1422      expr "$SYSTEM_TYPE" : ".*SCO_SV6.*" > /dev/null || \
1423      expr "$SYSTEM_TYPE" : ".*OpenUNIX.*" > /dev/null
1424   then
1425     if test -f /usr/lib/libthread.so -o -f /usr/lib/libthreadT.so
1426     then
1427       MYSQL_REMOVE_SOCKET_FROM_LIBS_HACK
1428       if expr "$CC" : ".*gcc.*" > /dev/null
1429       then
1430         with_named_thread="-pthread -lsocket -lnsl"
1431         CC="$CC -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
1432         CXX="$CXX -pthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
1433       else
1434         with_named_thread="-Kthread -lsocket -lnsl"
1435         CC="$CC -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
1436         CXX="$CXX -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
1437       fi
1438       if expr "$SYSTEM_TYPE" : ".*unixware7.0.0" > /dev/null
1439       then
1440         AC_DEFINE(HAVE_UNIXWARE7_THREADS, [1], [Have UnixWare 7 (or similar) almost-POSIX threading library])
1441       fi
1442       AC_MSG_RESULT(yes)
1443     else
1444       AC_MSG_ERROR([configure: error: Can't find thread library on SCO/Caldera system. See the Installation chapter in the Reference Manual.]) 
1445     fi
1446   else
1447     AC_MSG_RESULT(no)
1448   fi
1451 # Hack for Siemens UNIX
1452 if test "$with_named_thread" = "no"
1453 then
1454   AC_MSG_CHECKING("Siemens threads")
1455   if test -f /usr/lib/libxnet.so -a "$SYSTEM_TYPE" = "sni-sysv4"
1456   then
1457     LIBS="-lxnet $LIBS"
1458     NON_THREADED_LIBS="-lxnet $NON_THREADED_LIBS"
1459     with_named_thread="-Kthread $LDFLAGS -lxnet"
1460     LD_FLAGS=""
1461     CFLAGS="-Kthread $CFLAGS"
1462     CXXFLAGS="-Kthread $CXXFLAGS"
1463     AC_MSG_RESULT("yes")
1464   else
1465     AC_MSG_RESULT("no")
1466   fi
1469 # Use library named -lpthread
1470 if test "$with_named_thread" = "no" -a "$with_pthread" = "yes"
1471 then
1472     with_named_thread="-lpthread"
1475 #---END:
1477 # Hack for Solaris >= 2.5
1478 # We want both the new and the old interface
1480 if test "$with_named_thread" = "no"
1481 then
1482   AC_MSG_CHECKING("Solaris threads")
1483   if test -f /usr/lib/libpthread.so -a -f /usr/lib/libthread.so
1484   then
1485     with_named_thread="-lpthread -lthread"
1486     AC_MSG_RESULT("yes")
1487   else
1488     AC_MSG_RESULT("no")
1489   fi
1492 # Should we use named pthread library ?
1493 AC_MSG_CHECKING("named thread libs:")
1494 if test "$with_named_thread" != "no"
1495 then
1496   LIBS="$with_named_thread $LIBS $with_named_thread"
1497   CLIENT_THREAD_LIBS="$with_named_thread"
1498   with_posix_threads="yes"
1499   AC_MSG_RESULT("$with_named_thread")
1500 else
1501   AC_MSG_RESULT("no")
1502   # pthread_create is in standard libraries (As in BSDI 3.0)
1503   AC_MSG_CHECKING("for pthread_create in -libc");
1504   AC_TRY_LINK(
1505   [#include <pthread.h>],
1506   [ (void) pthread_create((pthread_t*) 0,(pthread_attr_t*) 0, 0, 0); ],
1507   with_posix_threads=yes, with_posix_threads=no)
1508   AC_MSG_RESULT("$with_posix_threads")
1509   if test "$with_posix_threads" = "no"
1510   then
1511     AC_MSG_CHECKING("for pthread_create in -lpthread")
1512     ac_save_LIBS="$LIBS"
1513     LIBS="$LIBS -lpthread"
1514     CLIENT_THREAD_LIBS="-lpthread"
1515     AC_TRY_LINK(
1516     [#include <pthread.h>],
1517     [ (void) pthread_create((pthread_t*) 0,(pthread_attr_t*) 0, 0, 0); ],
1518     with_posix_threads=yes, with_posix_threads=no)
1519     AC_MSG_RESULT("$with_posix_threads")
1520     if test "$with_posix_threads" = "no"
1521     then
1522       LIBS=" $ac_save_LIBS -lpthreads"
1523       CLIENT_THREAD_LIBS="-lpthreads"
1524       AC_MSG_CHECKING("for pthread_create in -lpthreads")
1525       AC_TRY_LINK(
1526       [#include <pthread.h>],
1527       [ pthread_create((pthread_t*) 0,(pthread_attr_t*) 0, 0, 0); ],
1528       with_posix_threads=yes, with_posix_threads=no)
1529       AC_MSG_RESULT("$with_posix_threads")
1530       if test "$with_posix_threads" = "no"
1531       then
1532         # This is for FreeBSD
1533         LIBS="$ac_save_LIBS -pthread"
1534         CLIENT_THREAD_LIBS="-pthread"
1535         AC_MSG_CHECKING("for pthread_create in -pthread")
1536         AC_TRY_LINK(
1537         [#include <pthread.h>],
1538         [ pthread_create((pthread_t*) 0,(pthread_attr_t*) 0, 0, 0); ],
1539         with_posix_threads=yes, with_posix_threads=no)
1540         AC_MSG_RESULT("$with_posix_threads")
1541       fi
1542     fi
1543   fi
1546 #---START: Used in for client configure
1547 # Must be checked after, because strtok_r may be in -lpthread
1548 # On AIX strtok_r is in libc_r
1550 my_save_LIBS="$LIBS"
1551 AC_CHECK_LIB(pthread,strtok_r)
1552 LIBS="$my_save_LIBS"
1553 if test "$ac_cv_lib_pthread_strtok_r" = "no"
1554 then
1555   AC_CHECK_LIB(c_r,strtok_r)
1556   case "$with_osf32_threads---$target_os" in
1557     # Don't keep -lc_r in LIBS; -pthread handles it magically
1558     yes---* | *---freebsd* | *---hpux*) LIBS="$my_save_LIBS" ;;
1560   esac
1561   AC_CHECK_FUNCS(strtok_r pthread_init)
1562 else
1563   AC_CHECK_FUNCS(strtok_r)
1565 #---END:
1567 # dlopen, dlerror
1568 case "$with_mysqld_ldflags " in
1570   *"-all-static "*)
1571     # No need to check for dlopen when mysqld is linked with
1572     # -all-static as it won't be able to load any functions.
1573     # NOTE! It would be better if it was possible to test if dlopen
1574     # can be used, but a good way to test it couldn't be found
1576     ;;
1578   *)
1579     # Check for dlopen, needed for user definable functions
1580     # This must be checked after threads on AIX
1581     # We only need this for mysqld, not for the clients.
1583     my_save_LIBS="$LIBS"
1584     LIBS=""
1585     AC_CHECK_LIB(dl,dlopen)
1586     LIBDL=$LIBS
1587     LIBS="$my_save_LIBS"
1588     AC_SUBST(LIBDL)
1590     my_save_LIBS="$LIBS"
1591     LIBS="$LIBS $LIBDL"
1592     AC_CHECK_FUNCS(dlopen dlerror)
1593     LIBS="$my_save_LIBS"
1595     ;;
1596 esac
1599 # System characteristics
1600 case $SYSTEM_TYPE in
1601   *netware*) ;;
1602   *)
1603 AC_SYS_RESTARTABLE_SYSCALLS
1604     ;;
1605 esac
1607 # Build optimized or debug version ?
1608 # First check for gcc and g++
1609 if test "$GCC" = "yes"
1610 then
1611   DEBUG_CFLAGS="-g"
1612   DEBUG_OPTIMIZE_CC="-O"
1613   OPTIMIZE_CFLAGS="$MAX_C_OPTIMIZE"
1614 else
1615   DEBUG_CFLAGS="-g"
1616   DEBUG_OPTIMIZE_CC=""
1617   case $SYSTEM_TYPE in                               
1618     *solaris*)
1619       OPTIMIZE_CFLAGS="-O1"
1620       ;;
1621     *)
1622       OPTIMIZE_CFLAGS="-O"
1623       ;;
1624   esac
1626 if test "$GXX" = "yes"
1627 then
1628   DEBUG_CXXFLAGS="-g"
1629   DEBUG_OPTIMIZE_CXX="-O"
1630   OPTIMIZE_CXXFLAGS="$MAX_CXX_OPTIMIZE"
1631 else
1632   DEBUG_OPTIMIZE_CXX=""
1633   case $SYSTEM_TYPE in
1634     *solaris*)
1635       DEBUG_CXXFLAGS="-g0"
1636       OPTIMIZE_CXXFLAGS="-O1"
1637       ;;
1638     *)
1639       DEBUG_CXXFLAGS="-g"
1640       OPTIMIZE_CXXFLAGS="-O"
1641       ;;
1642   esac
1645 case $SYSTEM_TYPE in
1646   *netware*)
1647     DEBUG_CFLAGS="-g -DDEBUG -sym internal,codeview4"
1648     DEBUG_CXXFLAGS="-g -DDEBUG -sym internal,codeview4"
1649     DEBUG_OPTIMIZE_CC="-DDEBUG"
1650     DEBUG_OPTIMIZE_CXX="-DDEBUG"
1651     OPTIMIZE_CFLAGS="-O3 -DNDEBUG"
1652     OPTIMIZE_CXXFLAGS="-O3 -DNDEBUG"
1653     ;;
1654 esac
1656 # If the user specified CFLAGS, we won't add any optimizations
1657 if test -n "$SAVE_CFLAGS"
1658 then
1659   OPTIMIZE_CFLAGS=""
1660   DEBUG_OPTIMIZE_CC=""
1662 # Ditto for CXXFLAGS
1663 if test -n "$SAVE_CXXFLAGS"
1664 then
1665   OPTIMIZE_CXXFLAGS=""
1666   DEBUG_OPTIMIZE_CXX=""
1669 if test "$with_debug" = "yes"
1670 then
1671   # Medium debug.
1672   AC_DEFINE([DBUG_ON], [1], [Use libdbug])
1673   CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC -DSAFE_MUTEX $CFLAGS"
1674   CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DSAFE_MUTEX $CXXFLAGS"
1675 elif test "$with_debug" = "full"
1676 then
1677   # Full debug. Very slow in some cases
1678   AC_DEFINE([DBUG_ON], [1], [Use libdbug])
1679   CFLAGS="$DEBUG_CFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS"
1680   CXXFLAGS="$DEBUG_CXXFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS"
1681 else
1682   # Optimized version. No debug
1683   AC_DEFINE([DBUG_OFF], [1], [Don't use libdbug])
1684   CFLAGS="$OPTIMIZE_CFLAGS $CFLAGS"
1685   CXXFLAGS="$OPTIMIZE_CXXFLAGS $CXXFLAGS"
1688 AC_ARG_WITH([valgrind],
1689   [AS_HELP_STRING([--with-valgrind],
1690     [Valgrind instrumentation @<:@default=no@:>@])],
1691     [], [with_valgrind=no])
1693 if test "$with_valgrind" != "no"
1694 then
1695   AC_CHECK_HEADERS([valgrind/valgrind.h valgrind/memcheck.h],
1696     [AC_DEFINE([HAVE_VALGRIND], [1], [Define for Valgrind support])])
1699 # Debug Sync Facility. NOTE: depends on 'with_debug'. Must be behind it.
1700 AC_MSG_CHECKING(if Debug Sync Facility should be enabled.)
1701 AC_ARG_ENABLE(debug_sync,
1702               AS_HELP_STRING([--enable-debug-sync],
1703                              [Build a version with Debug Sync Facility]),
1704               [ enable_debug_sync=$enableval ],
1705               [ enable_debug_sync=$with_debug ])
1707 if test "$enable_debug_sync" != "no"
1708 then
1709   AC_DEFINE([ENABLED_DEBUG_SYNC], [1],
1710             [If Debug Sync Facility should be enabled])
1711   AC_MSG_RESULT([yes]) 
1712 else
1713   AC_MSG_RESULT([no])
1716 # If we should allow error injection tests
1717 AC_ARG_WITH(error-inject,
1718     AC_HELP_STRING([--with-error-inject],[Enable error injection in MySQL Server]),
1719     [ with_error_inject=$withval ],
1720     [ with_error_inject=no ])
1722 if test $with_debug != "no"
1723 then
1724   if test "$with_error_inject" = "yes"
1725   then
1726     AC_DEFINE([ERROR_INJECT_SUPPORT], [1],
1727               [Enable error injection in MySQL Server])
1728   fi
1731 AC_ARG_WITH([fast-mutexes],
1732             AC_HELP_STRING([--with-fast-mutexes], 
1733             [Compile with fast mutexes (default is disabled)]),
1734             [with_fast_mutexes=$withval], [with_fast_mutexes=no])
1736 if test "$with_fast_mutexes" != "no"
1737 then
1738   if test "$with_debug" != "no"
1739   then
1740     AC_MSG_WARN(['--with-fast-mutexes' ignored when '--with-debug' is given])
1741   else
1742     AC_DEFINE([MY_PTHREAD_FASTMUTEX], [1], 
1743               [Define to 1 if you want to use fast mutexes])
1744   fi
1747 AC_ARG_WITH([atomic-ops],
1748             AC_HELP_STRING([--with-atomic-ops=rwlocks|smp|up],
1749             [Implement atomic operations using pthread rwlocks or atomic CPU
1750              instructions for multi-processor (default) or uniprocessor
1751              configuration]), , [with_atomic_ops=smp])
1752 case "$with_atomic_ops" in
1753   "up") AC_DEFINE([MY_ATOMIC_MODE_DUMMY], [1],
1754                   [Assume single-CPU mode, no concurrency]) ;;
1755   "rwlocks") AC_DEFINE([MY_ATOMIC_MODE_RWLOCKS], [1],
1756                   [Use pthread rwlocks for atomic ops]) ;;
1757   "smp") ;;
1758    *) AC_MSG_ERROR(["$with_atomic_ops" is not a valid value for --with-atomic-ops]) ;;
1759 esac
1761 AC_CACHE_CHECK([whether the compiler provides atomic builtins],
1762                [mysql_cv_gcc_atomic_builtins], [AC_TRY_RUN([
1763   int main()
1764   {
1765     int foo= -10; int bar= 10;
1766     if (!__sync_fetch_and_add(&foo, bar) || foo)
1767       return -1;
1768     bar= __sync_lock_test_and_set(&foo, bar);
1769     if (bar || foo != 10)
1770       return -1;
1771     bar= __sync_val_compare_and_swap(&bar, foo, 15);
1772     if (bar)
1773       return -1;
1774     return 0;
1775   }
1776 ], [mysql_cv_gcc_atomic_builtins=yes],
1777    [mysql_cv_gcc_atomic_builtins=no],
1778    [mysql_cv_gcc_atomic_builtins=no])])
1780 if test "x$mysql_cv_gcc_atomic_builtins" = xyes; then
1781   AC_DEFINE(HAVE_GCC_ATOMIC_BUILTINS, 1,
1782             [Define to 1 if compiler provides atomic builtins.])
1785 # Force static compilation to avoid linking problems/get more speed
1786 AC_ARG_WITH(mysqld-ldflags,
1787     [  --with-mysqld-ldflags   Extra linking arguments for mysqld],
1788     [MYSQLD_EXTRA_LDFLAGS=$withval],
1789     [MYSQLD_EXTRA_LDFLAGS=])
1790 AC_SUBST(MYSQLD_EXTRA_LDFLAGS)
1792 AC_ARG_WITH(client-ldflags,
1793     [  --with-client-ldflags   Extra linking arguments for clients],
1794     [CLIENT_EXTRA_LDFLAGS=$withval],
1795     [CLIENT_EXTRA_LDFLAGS=])
1796 AC_SUBST(CLIENT_EXTRA_LDFLAGS)
1798 AC_ARG_WITH(mysqld-libs,
1799     [  --with-mysqld-libs   Extra libraries to link with for mysqld],
1800     [MYSQLD_EXTRA_LIBS=$withval],
1801     [MYSQLD_EXTRA_LIBS=])
1802 AC_SUBST(MYSQLD_EXTRA_LIBS)
1804 AC_ARG_WITH(lib-ccflags,
1805     [  --with-lib-ccflags      Extra CC options for libraries],
1806     [LIB_EXTRA_CCFLAGS=$withval],
1807     [LIB_EXTRA_CCFLAGS=])
1808 AC_SUBST(LIB_EXTRA_CCFLAGS)
1810 # Avoid stupid bug on some OS 
1811 AC_ARG_WITH(low-memory,
1812     [  --with-low-memory       Try to use less memory to compile to avoid 
1813                           memory limitations.],
1814     [with_lowmem=$withval],
1815     [with_lowmem=no])
1816 if test "$with_lowmem" = "yes"
1817 then
1818   if test "$ac_cv_prog_gcc" = "yes" 
1819   then 
1820     LM_CFLAGS="-fno-inline"
1821   else
1822     LM_CFLAGS="-O0"
1823   fi
1824 else
1825   LM_CFLAGS=""
1827 AC_SUBST(LM_CFLAGS)
1829 AC_ARG_WITH(comment,
1830     [  --with-comment          Comment about compilation environment.],
1831     [with_comment=$withval],
1832     [with_comment=no])
1833 if test "$with_comment" != "no"
1834 then
1835   COMPILATION_COMMENT=$with_comment
1836 else
1837   COMPILATION_COMMENT="Source distribution"
1839 AC_SUBST(COMPILATION_COMMENT)
1841 AC_MSG_CHECKING("need of special linking flags")
1842 if test "$TARGET_LINUX" = "true" -a "$ac_cv_prog_gcc" = "yes" -a "$all_is_static" != "yes"
1843 then
1844   LDFLAGS="$LDFLAGS -rdynamic"
1845   AC_MSG_RESULT("-rdynamic")
1846 else
1847   case "$SYSTEM_TYPE$with_mysqld_ldflags " in
1848   *freebsd*"-all-static "*|*dragonfly*"-all-static "*)
1849     AC_MSG_RESULT("none")
1850     ;;
1851   *freebsd*|*dragonfly*)
1852     MYSQLD_EXTRA_LDFLAGS="$MYSQLD_EXTRA_LDFLAGS -export-dynamic"
1853     AC_MSG_RESULT("-export-dynamic")
1854     ;;
1855   *)
1856     AC_MSG_RESULT("none")
1857     ;;
1858   esac
1861 dnl Checks for typedefs, structures, and compiler characteristics.
1862 AC_C_CONST
1863 AC_C_INLINE
1864 AC_TYPE_OFF_T
1865 AC_STRUCT_ST_RDEV
1866 AC_HEADER_TIME
1867 AC_STRUCT_TM
1868 MYSQL_NEEDS_MYSYS_NEW
1869 # AC_CHECK_SIZEOF return 0 when it does not find the size of a
1870 # type. We want a error instead.
1871 AC_CHECK_SIZEOF(char, 1)
1872 if test "$ac_cv_sizeof_char" -eq 0
1873 then
1874   AC_MSG_ERROR([No size for char type.
1875 A likely cause for this could be that there isn't any
1876 static libraries installed. You can verify this by checking if you have libm.a
1877 in /lib, /usr/lib or some other standard place.  If this is the problem,
1878 install the static libraries and try again.  If this isn't the problem,
1879 examine config.log for possible errors.  If you want to report this, use
1880 'scripts/mysqlbug' and include at least the last 20 rows from config.log!])
1882 AC_CHECK_SIZEOF(char*, 4)
1883 AC_CHECK_SIZEOF(short, 2)
1884 AC_CHECK_SIZEOF(int, 4)
1885 if test "$ac_cv_sizeof_int" -eq 0
1886 then
1887   AC_MSG_ERROR("No size for int type.")
1889 AC_CHECK_SIZEOF(long, 4)
1890 if test "$ac_cv_sizeof_long" -eq 0
1891 then
1892   AC_MSG_ERROR("No size for long type.")
1894 AC_CHECK_SIZEOF(long long, 8)
1895 if test "$ac_cv_sizeof_long_long" -eq 0
1896 then
1897   AC_MSG_ERROR("MySQL needs a long long type.")
1899 # off_t is not a builtin type
1900 AC_CHECK_SIZEOF(off_t, 4)
1901 if test "$ac_cv_sizeof_off_t" -eq 0
1902 then
1903   AC_MSG_ERROR("MySQL needs a off_t type.")
1907 dnl check if time_t is unsigned
1910 MYSQL_CHECK_TIME_T
1913 dnl check size of time_t
1916 AC_CHECK_SIZEOF(time_t, 8)
1917 if test "$ac_cv_sizeof_time_t" -eq 0
1918 then
1919   AC_MSG_ERROR("MySQL needs a time_t type.")
1922 # do we need #pragma interface/#pragma implementation ?
1923 # yes if it's gcc 2.x, and not icc pretending to be gcc, and not cygwin
1924 AC_MSG_CHECKING(the need for @%:@pragma interface/implementation)
1925 # instead of trying to match SYSTEM_TYPE and CC_VERSION (that doesn't
1926 # follow any standard), we'll use well-defined preprocessor macros:
1927 AC_TRY_CPP([
1928 #if !defined(__CYGWIN__) && !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ < 3)
1929 #error USE_PRAGMA_IMPLEMENTATION
1930 #endif
1931 ],AC_MSG_RESULT(no) ,AC_MSG_RESULT(yes) ; CXXFLAGS="$CXXFLAGS -DUSE_PRAGMA_IMPLEMENTATION")
1933 # This always gives a warning. Ignore it unless you are cross compiling
1934 AC_C_BIGENDIAN
1935 #---START: Used in for client configure
1936 # Check base type of last arg to accept
1937 MYSQL_TYPE_ACCEPT
1938 #---END:
1939 # Figure out what type of struct rlimit to use with setrlimit
1940 MYSQL_TYPE_STRUCT_RLIMIT
1941 # Find where the stack goes
1942 MYSQL_STACK_DIRECTION
1943 # We want to skip alloca on irix unconditionally. It may work on some version..
1944 MYSQL_FUNC_ALLOCA
1945 # Do struct timespec have members tv_sec or ts_sec
1946 MYSQL_TIMESPEC_TS
1947 # Do we have the tzname variable
1948 MYSQL_TZNAME
1949 # Do the c++ compiler have a bool type
1950 MYSQL_CXX_BOOL
1951 # Check some common bugs with gcc 2.8.# on sparc
1952 case $SYSTEM_TYPE in
1953   *netware*) ;;
1954   *)
1955     MYSQL_CHECK_LONGLONG_TO_FLOAT
1956     if test "$ac_cv_conv_longlong_to_float" != "yes"
1957     then
1958       AC_MSG_ERROR([Your compiler cannot convert a longlong value to a float!
1959  If you are using gcc 2.8.# you should upgrade to egcs 1.0.3 or newer and try
1960     again])
1961     fi
1962     ;;
1963 esac
1964 AC_CHECK_TYPES([sigset_t, off_t], [], [], [#include <sys/types.h>])
1965 AC_CHECK_TYPES([size_t], [], [], [#include <stdio.h>])
1966 AC_CHECK_TYPES([u_int32_t])
1968 MYSQL_PTHREAD_YIELD
1970 ######################################################################
1971 # For readline/libedit (We simply move the mimimum amount of stuff from
1972 # the readline/libedit configure.in here)
1974 dnl Checks for header files.
1975 AC_CHECK_HEADERS(malloc.h sys/cdefs.h)
1977 dnl Checks for library functions.
1978 AC_FUNC_ALLOCA
1979 AC_PROG_GCC_TRADITIONAL
1980 AC_TYPE_SIGNAL
1981 AC_CHECK_FUNCS(re_comp regcomp strdup)
1983 dnl Sun compilers have their own vis.h that is about something
1984 dnl totally different. So, not to change the libedit source, we
1985 dnl do some additional checks before we define HAVE_VIS_H.
1986 AC_CHECK_HEADER(vis.h,
1987   [AC_CHECK_FUNC(strvis,
1988     [AC_DEFINE([HAVE_VIS_H], [1],[Found vis.h and the strvis() function])])])
1990 AC_CHECK_FUNCS(strlcat strlcpy)
1991 AC_CHECK_FUNCS(issetugid getuid geteuid getgid getegid)
1992 AC_CHECK_FUNCS(fgetln)
1993 AC_CHECK_FUNCS(getline flockfile)
1995 # from old readline settting:
1997 MAKE_SHELL=/bin/sh
1998 AC_SUBST(MAKE_SHELL)
2000 # Already-done: stdlib.h string.h unistd.h termios.h
2001 AC_CHECK_HEADERS(varargs.h stdarg.h dirent.h locale.h ndir.h sys/dir.h \
2002  sys/file.h sys/ndir.h sys/ptem.h sys/pte.h sys/select.h sys/stream.h \
2003  sys/mman.h curses.h termcap.h termio.h termbits.h asm/termbits.h grp.h \
2004 paths.h semaphore.h)
2006 # Already-done: strcasecmp
2007 AC_CHECK_FUNCS(lstat putenv select setenv setlocale strcoll tcgetattr)
2009 AC_STAT_MACROS_BROKEN
2010 MYSQL_SIGNAL_CHECK
2011 MYSQL_CHECK_GETPW_FUNCS
2012 MYSQL_HAVE_TIOCGWINSZ
2013 MYSQL_HAVE_FIONREAD
2014 MYSQL_HAVE_TIOCSTAT
2015 MYSQL_STRUCT_DIRENT_D_INO
2016 MYSQL_STRUCT_DIRENT_D_NAMLEN
2017 MYSQL_TYPE_SIGHANDLER
2018 MYSQL_CHECK_MULTIBYTE
2019 if test "$with_named_curses" = "no"
2020 then
2021   MYSQL_CHECK_LIB_TERMCAP
2022 else
2023   TERMCAP_LIB="$with_named_curses"
2025 AC_SUBST(TERMCAP_LIB)
2027 # Check if the termcap function 'tgoto' is already declared in
2028 # system header files or if it need to be declared locally
2029 AC_CHECK_DECLS(tgoto,,,[
2030 #ifdef HAVE_CURSES_H
2031 # include <curses.h>
2032 #elif HAVE_NCURSES_H
2033 # include <ncurses.h>
2034 #endif
2035 #ifdef HAVE_TERM_H
2036 # include <term.h>
2037 #endif
2040 LIBEDIT_LOBJECTS=""
2041 AC_CHECK_FUNC(strunvis, ,[LIBEDIT_LOBJECTS="$LIBEDIT_LOBJECTS unvis.o"])
2042 AC_CHECK_FUNC(strvis,   ,[LIBEDIT_LOBJECTS="$LIBEDIT_LOBJECTS vis.o"])
2043 AC_CHECK_FUNC(strlcpy,  ,[LIBEDIT_LOBJECTS="$LIBEDIT_LOBJECTS strlcpy.o"])
2044 AC_CHECK_FUNC(strlcat,  ,[LIBEDIT_LOBJECTS="$LIBEDIT_LOBJECTS strlcat.o"])
2045 AC_CHECK_FUNC(fgetln,   ,[LIBEDIT_LOBJECTS="$LIBEDIT_LOBJECTS fgetln.o"])
2046 AC_SUBST(LIBEDIT_LOBJECTS)
2047 enable_readline="yes"
2049 # End of readline/libedit stuff
2050 #########################################################################
2052 dnl Checks for library functions.
2055 # The following code disables intrinsic function support while we test for
2056 # library functions.  This is to avoid configure problems with Intel ecc
2057 # compiler
2059 ORG_CFLAGS="$CFLAGS"
2060 if test "$GCC" != "yes"; then
2061   AC_SYS_COMPILER_FLAG(-nolib_inline,nolib_inline,CFLAGS,[],[])
2064 #AC_FUNC_MMAP
2065 AC_TYPE_SIGNAL
2066 MYSQL_TYPE_QSORT
2067 AC_FUNC_UTIME_NULL
2068 AC_FUNC_VPRINTF
2070 AC_CHECK_DECLS([fdatasync, bzero])
2072 AC_CHECK_FUNCS(alarm bfill bmove bsearch bzero \
2073   chsize cuserid fchmod fcntl \
2074   fconvert fdatasync fesetround finite fpresetsticky fpsetmask fsync ftruncate \
2075   getcwd gethostbyaddr_r gethostbyname_r getpass getpassphrase getpwnam \
2076   getpwuid getrlimit getrusage getwd index initgroups isnan \
2077   localtime_r gethrtime gmtime_r \
2078   locking longjmp lrand48 madvise mallinfo memcpy memmove \
2079   mkstemp mlockall perror poll pread pthread_attr_create mmap mmap64 getpagesize \
2080   pthread_attr_getstacksize pthread_attr_setprio pthread_attr_setschedparam \
2081   pthread_attr_setstacksize pthread_condattr_create pthread_getsequence_np \
2082   pthread_key_delete pthread_rwlock_rdlock pthread_setprio \
2083   pthread_setprio_np pthread_setschedparam pthread_sigmask readlink \
2084   realpath rename rint rwlock_init setupterm \
2085   shmget shmat shmdt shmctl sigaction sigemptyset sigaddset \
2086   sighold sigset sigthreadmask port_create sleep \
2087   snprintf socket stpcpy strcasecmp strerror strsignal strnlen strpbrk strstr \
2088   strtol strtoll strtoul strtoull tell tempnam thr_setconcurrency vidattr \
2089   posix_fallocate backtrace backtrace_symbols backtrace_symbols_fd printstack \
2090   fedisableexcept)
2095 case "$target" in
2096  *-*-aix4* | *-*-sco*)
2097         # (grr) aix 4.3 has a stub for clock_gettime, (returning ENOSYS)
2098         # and using AC_TRY_RUN is hard when cross-compiling
2099         # We also disable for SCO for the time being, the headers for the
2100         # thread library we use conflicts with other headers.
2101     ;;
2102  *) AC_CHECK_FUNCS(clock_gettime)
2103     ;;
2104 esac
2106 case "$mysql_cv_sys_os" in
2107  OS400) # i5/OS (OS/400) emits a SIGILL (Function not implemented) when
2108         # unsupported priority values are passed to pthread_setschedprio.
2109         # Since the only supported value is 1, treat it as inexistent.
2110     ;;
2111  SunOS) # Bug#42599 error: `pthread_setschedprio' was not declared in this scope
2112         # In some installations, the pthread.h header used by GCC does not
2113         # declare the pthread_setscheprio prototype, but the function is
2114         # implemented. Since the function is used in C++ code, ensure that
2115         # the function prototype is present.
2116      AC_MSG_CHECKING([whether pthread_setschedprio is declared])
2117      AC_LANG_PUSH([C++])
2118      AC_COMPILE_IFELSE([
2119        AC_LANG_PROGRAM([#include <pthread.h>],
2120                       [(void)(pthread_setschedprio);])],
2121        [ac_cv_func_pthread_setschedprio=yes],
2122        [ac_cv_func_pthread_setschedprio=no])
2123      AC_LANG_POP([C++])
2124      AC_MSG_RESULT([$ac_cv_func_pthread_setschedprio])
2125      if test "$ac_cv_func_pthread_setschedprio" = yes; then
2126        AC_DEFINE(HAVE_PTHREAD_SETSCHEDPRIO, 1,
2127                  [Define to 1 if you have the `pthread_setschedprio' function.])
2128      fi
2129     ;;
2130  *) AC_CHECK_FUNCS(pthread_setschedprio)
2131     ;;
2132 esac
2134 # Check that isinf() is available in math.h and can be used in both C and C++ 
2135 # code
2136 AC_MSG_CHECKING(for isinf in <math.h>)
2137 AC_TRY_LINK([#include <math.h>], [float f = 0.0; int r = isinf(f); return r],
2138   AC_MSG_RESULT(yes)
2139   AC_MSG_CHECKING(whether isinf() is safe to use in C code)
2140   AC_TRY_RUN([
2141 #include <math.h>
2142 int main()
2144   double a= 10.0;
2145   double b= 1e308;
2147   return !isinf(a * b);
2150   [AC_MSG_RESULT(yes)],
2151   [AC_MSG_RESULT(no)
2152    AC_DEFINE([HAVE_BROKEN_ISINF], [1],
2153              [Define to 1 if isinf() uses 80-bit register for intermediate values])
2154   ],
2155   [
2156 # Let's be optimistic when cross-compiling, since the only compiler known
2157 # to be affected by this isinf() bug is GCC 4.3 on 32-bit x86.
2158    AC_MSG_RESULT([[cross-compiling, assuming 'yes']])
2159   ])
2160   AC_MSG_CHECKING(whether isinf() can be used in C++ code)
2161   AC_LANG_SAVE
2162   AC_LANG_CPLUSPLUS
2163   AC_TRY_LINK([#include <math.h>], [float f = 0.0; int r = isinf(f); return r],
2164     AC_MSG_RESULT(yes)
2165     AC_DEFINE(HAVE_ISINF, [1], [isinf() macro or function]),
2166     AC_MSG_RESULT(no))
2167   AC_LANG_RESTORE,
2168   AC_MSG_RESULT(no))
2170 CFLAGS="$ORG_CFLAGS"
2172 # Sanity check: We chould not have any fseeko symbol unless
2173 # large_file_support=yes
2174 AC_CHECK_FUNC(fseeko,
2175 [if test "$large_file_support" = no -a "$TARGET_LINUX" = "true";
2176 then
2177   AC_MSG_ERROR("Found fseeko symbol but large_file_support is not enabled!")
2181 # Check definition of gethostbyaddr_r (glibc2 defines this with 8 arguments)
2182 ac_save_CXXFLAGS="$CXXFLAGS"
2183 AC_CACHE_CHECK([style of gethost* routines], mysql_cv_gethost_style,
2184 AC_LANG_SAVE
2185 AC_LANG_CPLUSPLUS
2187 # Test whether madvise() is declared in C++ code -- it is not on some
2188 # systems, such as Solaris
2189 AC_CHECK_DECLS(madvise, [], [], [#if HAVE_SYS_MMAN_H
2190 #include <sys/types.h>
2191 #include <sys/mman.h>
2192 #endif])
2194 # Do not treat warnings as errors if we are linking against other libc
2195 # this is to work around gcc not being permissive on non-system includes
2196 # with respect to ANSI C++
2197 # We also remove the -fbranch-probabilities option as this will give warnings
2198 # about not profiled code, which confuses configure
2199 # We also must remove -W and -Wcheck which on icc produces warnings that
2200 # we don't want to catch with -Werror
2202 if test "$ac_cv_prog_gxx" = "yes" -a "$with_other_libc" = "no"
2203 then
2204   CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed -e 's/-fbranch-probabilities//; s/-Wall//; s/-ansi//; s/-pedantic//; s/-Wcheck//'`
2207 AC_TRY_COMPILE(
2208 [#undef inline
2209 #if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
2210 #define _REENTRANT
2211 #endif
2212 #include <pthread.h>
2213 #include <sys/types.h>
2214 #include <sys/socket.h>
2215 #include <netinet/in.h>
2216 #include <arpa/inet.h>
2217 #include <netdb.h>],
2218 [int skr;
2219  struct hostent *foo = gethostbyaddr_r((const char *) 0,
2220   0, 0, (struct hostent *) 0, (char *) NULL,  0, &skr); return (foo == 0);],
2221 mysql_cv_gethost_style=solaris, mysql_cv_gethost_style=other))
2222 AC_LANG_RESTORE
2223 CXXFLAGS="$ac_save_CXXFLAGS"
2224 if test "$mysql_cv_gethost_style" = "solaris"
2225 then
2226   AC_DEFINE([HAVE_SOLARIS_STYLE_GETHOST], [1],
2227             [Solaris define gethostbyaddr_r with 7 arguments. glibc2 defines this with 8 arguments])
2230 #---START: Used in for client configure
2232 # Check definition of gethostbyname_r (glibc2.0.100 is different from Solaris)
2233 ac_save_CXXFLAGS="$CXXFLAGS"
2234 AC_CACHE_CHECK([style of gethostbyname_r routines], mysql_cv_gethostbyname_style,
2235 AC_LANG_SAVE
2236 AC_LANG_CPLUSPLUS
2237 if test "$ac_cv_prog_gxx" = "yes" -a "$with_other_libc" = "no"
2238 then
2239   CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed -e 's/-fbranch-probabilities//; s/-Wall//; s/-ansi//; s/-pedantic//; s/-Wcheck//'`
2241 AC_TRY_COMPILE(
2242 [#undef inline
2243 #if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
2244 #define _REENTRANT
2245 #endif
2246 #include <pthread.h>
2247 #include <sys/types.h>
2248 #include <sys/socket.h>
2249 #include <netinet/in.h>
2250 #include <arpa/inet.h>
2251 #include <netdb.h>],
2252 [int skr;
2254  skr = gethostbyname_r((const char *) 0,
2255   (struct hostent*) 0, (char*) 0, 0, (struct hostent **) 0, &skr);],
2256 mysql_cv_gethostbyname_style=glibc2, mysql_cv_gethostbyname_style=other))
2257 AC_LANG_RESTORE
2258 CXXFLAGS="$ac_save_CXXFLAGS"
2259 if test "$mysql_cv_gethostbyname_style" = "glibc2"
2260 then
2261   AC_DEFINE([HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE], [1],
2262             [Solaris define gethostbyname_r with 5 arguments. glibc2 defines this with 6 arguments])
2265 # Check 3rd argument of getthostbyname_r
2266 ac_save_CXXFLAGS="$CXXFLAGS"
2267 AC_CACHE_CHECK([3 argument to gethostbyname_r routines], mysql_cv_gethostbyname_arg,
2268 AC_LANG_SAVE
2269 AC_LANG_CPLUSPLUS
2270 if test "$ac_cv_prog_gxx" = "yes" -a "$with_other_libc" = "no"
2271 then
2272   CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed -e 's/-fbranch-probabilities//; s/-Wall//; s/-ansi//; s/-pedantic//; s/-Wcheck//'`
2274 AC_TRY_COMPILE(
2275 [#undef inline
2276 #if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
2277 #define _REENTRANT
2278 #endif
2279 #include <pthread.h>
2280 #include <sys/types.h>
2281 #include <sys/socket.h>
2282 #include <netinet/in.h>
2283 #include <arpa/inet.h>
2284 #include <netdb.h>],
2285 [int skr;
2287  skr = gethostbyname_r((const char *) 0, (struct hostent*) 0, (struct hostent_data*) 0);],
2288 mysql_cv_gethostbyname_arg=hostent_data, mysql_cv_gethostbyname_arg=char))
2289 AC_LANG_RESTORE
2290 CXXFLAGS="$ac_save_CXXFLAGS"
2291 if test "$mysql_cv_gethostbyname_arg" = "hostent_data"
2292 then
2293   AC_DEFINE([HAVE_GETHOSTBYNAME_R_RETURN_INT], [1],
2294             [In OSF 4.0f the 3'd argument to gethostbyname_r is hostent_data *])
2298 # Check definition of pthread_getspecific
2299 AC_CACHE_CHECK("args to pthread_getspecific", mysql_cv_getspecific_args,
2300 AC_TRY_COMPILE(
2301 [#if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
2302 #define _REENTRANT
2303 #endif
2304 #define _POSIX_PTHREAD_SEMANTICS 
2305 #include <pthread.h> ],
2306 [ void *pthread_getspecific(pthread_key_t key);
2307 pthread_getspecific((pthread_key_t) NULL); ],
2308 mysql_cv_getspecific_args=POSIX, mysql_cv_getspecific_args=other))
2309   if test "$mysql_cv_getspecific_args" = "other"
2310   then
2311     AC_DEFINE([HAVE_NONPOSIX_PTHREAD_GETSPECIFIC], [1],
2312               [For some non posix threads])
2313   fi
2315   # Check definition of pthread_mutex_init
2316   AC_CACHE_CHECK("args to pthread_mutex_init", mysql_cv_mutex_init_args,
2317   AC_TRY_COMPILE(
2318 [#if !defined(SCO) && !defined(__osf__)
2319 #define _REENTRANT
2320 #endif
2321 #define _POSIX_PTHREAD_SEMANTICS 
2322 #include <pthread.h> ],
2324   pthread_mutexattr_t attr;
2325   pthread_mutex_t mp;
2326   pthread_mutex_init(&mp,&attr); ],
2327 mysql_cv_mutex_init_args=POSIX, mysql_cv_mutex_init_args=other))
2328   if test "$mysql_cv_mutex_init_args" = "other"
2329   then
2330     AC_DEFINE([HAVE_NONPOSIX_PTHREAD_MUTEX_INIT], [1],
2331               [For some non posix threads])
2332   fi
2333 #---END:
2335 #---START: Used in for client configure
2336 # Check definition of readdir_r
2337 AC_CACHE_CHECK("args to readdir_r", mysql_cv_readdir_r,
2338 AC_TRY_LINK(
2339 [#if !defined(SCO) && !defined(__osf__)
2340 #define _REENTRANT
2341 #endif
2342 #define _POSIX_PTHREAD_SEMANTICS 
2343 #include <pthread.h>
2344 #include <dirent.h>],
2345 [ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
2346 readdir_r((DIR *) NULL, (struct dirent *) NULL, (struct dirent **) NULL); ],
2347 mysql_cv_readdir_r=POSIX, mysql_cv_readdir_r=other))
2348 if test "$mysql_cv_readdir_r" = "POSIX"
2349 then
2350   AC_DEFINE([HAVE_READDIR_R], [1], [POSIX readdir_r])
2353 # Check definition of posix sigwait()
2354 AC_CACHE_CHECK("style of sigwait", mysql_cv_sigwait,
2355 AC_TRY_LINK(
2356 [#if !defined(SCO) && !defined(__osf__)
2357 #define _REENTRANT
2358 #endif
2359 #define _POSIX_PTHREAD_SEMANTICS 
2360 #include <pthread.h>
2361 #include <signal.h>],
2362 [#ifndef _AIX
2363 sigset_t set;
2364 int sig;
2365 sigwait(&set,&sig);
2366 #endif],
2367 mysql_cv_sigwait=POSIX, mysql_cv_sigwait=other))
2368 if test "$mysql_cv_sigwait" = "POSIX"
2369 then
2370   AC_DEFINE([HAVE_SIGWAIT], [1], [POSIX sigwait])
2373 if test "$mysql_cv_sigwait" != "POSIX"
2374 then
2375 unset mysql_cv_sigwait
2376 # Check definition of posix sigwait()
2377 AC_CACHE_CHECK("style of sigwait", mysql_cv_sigwait,
2378 AC_TRY_LINK(
2379 [#if !defined(SCO) && !defined(__osf__)
2380 #define _REENTRANT
2381 #endif
2382 #define _POSIX_PTHREAD_SEMANTICS 
2383 #include <pthread.h>
2384 #include <signal.h>],
2385 [sigset_t set;
2386 int sig;
2387 sigwait(&set);],
2388 mysql_cv_sigwait=NONPOSIX, mysql_cv_sigwait=other))
2389 if test "$mysql_cv_sigwait" = "NONPOSIX"
2390 then
2391   AC_DEFINE([HAVE_NONPOSIX_SIGWAIT], [1], [sigwait with one argument])
2394 #---END:
2396 # Check if pthread_attr_setscope() exists
2397 AC_CACHE_CHECK("for pthread_attr_setscope", mysql_cv_pthread_attr_setscope,
2398 AC_TRY_LINK(
2399 [#if !defined(SCO) && !defined(__osf__)
2400 #define _REENTRANT
2401 #endif
2402 #define _POSIX_PTHREAD_SEMANTICS 
2403 #include <pthread.h>],
2404 [pthread_attr_t thr_attr;
2405 pthread_attr_setscope(&thr_attr,0);],
2406 mysql_cv_pthread_attr_setscope=yes, mysql_cv_pthread_attr_setscope=no))
2407 if test "$mysql_cv_pthread_attr_setscope" = "yes"
2408 then
2409   AC_DEFINE([HAVE_PTHREAD_ATTR_SETSCOPE], [1], [pthread_attr_setscope])
2412 # Check for bad includes
2413 AC_MSG_CHECKING("can netinet files be included")
2414 AC_TRY_COMPILE(
2415 [#include <sys/types.h>
2416 #include <sys/socket.h>
2417 #include <netinet/in_systm.h>
2418 #include <netinet/in.h>
2419 #include <netinet/ip.h>
2420 #include <netinet/tcp.h>],
2421 [ printf("1\n"); ],
2422 netinet_inc=yes, netinet_inc=no)
2423 if test "$netinet_inc" = "no"
2424 then
2425   AC_DEFINE([HAVE_BROKEN_NETINET_INCLUDES], [1], [Can netinet be included])
2427 AC_MSG_RESULT("$netinet_inc")
2429 AC_CACHE_CHECK([support for weak symbols], mysql_cv_weak_symbol,
2430 [AC_TRY_LINK([],[
2431   extern void __attribute__((weak)) foo(void);
2432 ], [mysql_cv_weak_symbol=yes], [mysql_cv_weak_symbol=no])])
2434 if test "x$mysql_cv_weak_symbol" = xyes; then
2435   AC_DEFINE(HAVE_WEAK_SYMBOL, 1,
2436             [Define to 1 if compiler supports weak symbol attribute.])
2439 AC_CACHE_CHECK([whether __bss_start is defined], mysql_cv_bss_start,
2440 [AC_TRY_LINK([],[
2441   extern char *__bss_start;
2442   return __bss_start ? 1 : 0;
2443 ], [mysql_cv_bss_start=yes], [mysql_cv_bss_start=no])])
2445 if test "x$mysql_cv_bss_start" = xyes; then
2446   AC_DEFINE(HAVE_BSS_START, 1,
2447             [Define to 1 if compiler defines __bss_start.])
2450 AC_LANG_SAVE
2451 AC_LANG_CPLUSPLUS
2452 AC_CHECK_HEADERS(cxxabi.h)
2453 AC_CACHE_CHECK([for abi::__cxa_demangle], mysql_cv_cxa_demangle,
2454 [AC_TRY_LINK([#include <cxxabi.h>], [
2455   char *foo= 0; int bar= 0;
2456   foo= abi::__cxa_demangle(foo, foo, 0, &bar);
2457 ], [mysql_cv_cxa_demangle=yes], [mysql_cv_cxa_demangle=no])])
2458 AC_LANG_RESTORE
2460 if test "x$mysql_cv_cxa_demangle" = xyes; then
2461   AC_DEFINE(HAVE_ABI_CXA_DEMANGLE, 1,
2462             [Define to 1 if you have the `abi::__cxa_demangle' function.])
2465 #--------------------------------------------------------------------
2466 # Check for requested features
2467 #--------------------------------------------------------------------
2469 MYSQL_CHECK_BIG_TABLES
2470 MYSQL_CHECK_MAX_INDEXES
2471 MYSQL_CHECK_VIO
2472 MYSQL_CHECK_SSL
2474 #--------------------------------------------------------------------
2475 # Declare our plugin modules
2476 # Has to be done late, as the plugin may need to check for existence of
2477 # functions tested above
2478 #--------------------------------------------------------------------
2480 MYSQL_STORAGE_ENGINE(partition, partition, [Partition Support],
2481         [MySQL Partitioning Support], [max,max-no-ndb])
2483 dnl -- ndbcluster requires partition to be enabled
2485 MYSQL_CONFIGURE_PLUGINS([none])
2487 # Only build client code?
2488 AC_ARG_WITH(server,
2489     [  --without-server        Only build the client.],
2490     [with_server=$withval],
2491     [with_server=yes]
2494 AC_ARG_WITH(embedded-server,
2495     [  --with-embedded-server  Build the embedded server (libmysqld).],
2496     [with_embedded_server=$withval],
2497     [with_embedded_server=no]
2500 AC_ARG_WITH(query_cache,
2501     [  --without-query-cache   Do not build query cache.],
2502     [with_query_cache=$withval],
2503     [with_query_cache=yes]
2506 if test "$with_query_cache" = "yes"
2507 then
2508   AC_DEFINE([HAVE_QUERY_CACHE], [1], [If we want to have query cache])
2511 AC_ARG_WITH(geometry,
2512     [  --without-geometry      Do not build geometry-related parts.],
2513     [with_geometry=$withval],
2514     [with_geometry=yes]
2517 if test "$with_geometry" = "yes"
2518 then
2519   AC_DEFINE([HAVE_SPATIAL], [1], [Spatial extentions])
2520   AC_DEFINE([HAVE_RTREE_KEYS], [1], [RTree keys])
2523 AC_ARG_WITH(embedded_privilege_control,
2524     [  --with-embedded-privilege-control
2525                           Build parts to check user's privileges.
2526                           Only affects embedded library.],
2527     [with_embedded_privilege_control=$withval],
2528     [with_embedded_privilege_control=no]
2531 if test "$with_embedded_privilege_control" = "yes"
2532 then
2533   AC_DEFINE([HAVE_EMBEDDED_PRIVILEGE_CONTROL], [1],
2534             [Access checks in embedded library])
2537 tools_dirs=""
2539 AC_ARG_WITH([mysqlmanager],
2540   AC_HELP_STRING([--with-mysqlmanager], [Build the mysqlmanager binary: yes/no (default: build if server is built.)]),,)
2542 if test "$with_mysqlmanager" = "yes" -o \
2543         '(' "$with_mysqlmanager:$with_server" = ":yes" -a \
2544             -d "$srcdir/server-tools" ')' ; then
2545   tools_dirs="server-tools"
2548 AC_SUBST(tools_dirs)
2550 #MYSQL_CHECK_CPU
2552 libmysqld_dirs=
2553 if test "$with_embedded_server" = "yes"
2554 then
2555   libmysqld_dirs=libmysqld
2557   # We can't build embedded library without building the server, because
2558   # we depend on libmysys, libmystrings, libmyisam, etc.
2559   with_server=yes
2561 # XXX: We need to add @libmysqld_extra_libs@ (or whatever) so that
2562 # mysql_config --libmysqld-libs will print out something like
2563 # -L/path/to/lib/mysql -lmysqld -lmyisam -lmysys -lmystrings -ldbug ...
2564 AC_SUBST([libmysqld_dirs])
2566 # Shall we build the docs?
2567 AC_ARG_WITH(docs,
2568     [  --without-docs          Skip building of the documentation.],
2569     [with_docs=$withval],
2570     [with_docs=yes]
2573 if test "$with_docs" = "yes"
2574 then
2575   docs_dirs="Docs"
2576   if test -f "$srcdir/Docs/manual.chm" ; then
2577     extra_docs="manual.chm"
2578   fi
2579 else
2580   docs_dirs=""
2581   extra_docs=""
2583 AC_SUBST(docs_dirs)
2584 AC_SUBST(extra_docs)
2586 # Shall we build the man pages?
2587 AC_ARG_WITH(man,
2588     [  --without-man          Skip building of the man pages.],
2589     [with_man=$withval],
2590     [with_man=yes]
2593 # Don't build readline, i have it already
2594 AC_ARG_WITH(readline,
2595     [  --without-readline      Use system readline instead of bundled copy.],
2596     [ with_readline=$withval ],
2597     [ with_readline=undefined ]
2598     )
2599     
2600 AC_ARG_WITH(libedit,
2601     [  --without-libedit       Use system libedit instead of bundled copy.],
2602     [ with_libedit=$withval ],
2603     [ with_libedit=undefined ]
2604     )
2606 if test "$with_readline/$with_libedit" = "undefined/undefined" -a ! -e "$srcdir/cmd-line-utils"
2607 then
2608   with_readline=no
2609   with_libedit=no
2613 # We support next variants of compilation:
2614 #                              --with-readline
2615 #                |       yes      |  no  |               undefined
2616 # --with-libedit |                |      |
2617 # ---------------+----------------+------+----------------------------------
2618 #       yes      |      ERROR!    |   use libedit from mysql sources
2619 # ---------------+----------------+------+----------------------------------
2620 #       no       | use readline   | use system readline or external libedit
2621 #                | from mysql     | according to results of m4 tests
2622 # ---------------+ sources (if it +      +----------------------------------
2623 #    undefined   | is presented)  |      | use libedit from mysql sources
2624                    
2626 compile_readline="no"
2627 compile_libedit="no"
2629 if [test "$with_libedit" = "yes"] && [test "$with_readline" = "yes"]
2630 then
2631     AC_MSG_ERROR([You can not use --with-readline and --with-libedit at the same time, please choose one of it])
2634 readline_topdir=""
2635 readline_basedir=""
2636 readline_dir=""
2637 readline_h_ln_cmd=""
2638 readline_link=""
2639 want_to_use_readline="no"
2641 case $SYSTEM_TYPE in
2642   *netware*)
2643     # For NetWare, do not need readline
2644     echo "Skipping readline"
2645     ;;
2646   *)
2647     if [test "$with_libedit" = "yes"] || [test "$with_libedit" = "undefined"] && [test "$with_readline" = "undefined"]
2648     then
2649         readline_topdir="cmd-line-utils"
2650         readline_basedir="libedit"
2651         readline_dir="$readline_topdir/$readline_basedir"
2652         readline_link="\$(top_builddir)/cmd-line-utils/libedit/libedit.a"
2653         readline_h_ln_cmd="\$(LN) -s \$(top_srcdir)/cmd-line-utils/libedit/readline readline"
2654         compile_libedit=yes
2655         AC_DEFINE_UNQUOTED(HAVE_HIST_ENTRY, 1)
2656         AC_DEFINE_UNQUOTED(USE_LIBEDIT_INTERFACE, 1)
2657     elif test "$with_readline" = "yes"
2658     then
2659         readline_topdir="cmd-line-utils"
2660         readline_basedir="readline"
2661         readline_dir="$readline_topdir/$readline_basedir"
2662         readline_link="\$(top_builddir)/cmd-line-utils/readline/libreadline.a"
2663         readline_h_ln_cmd="\$(LN) -s \$(top_srcdir)/cmd-line-utils/readline readline"
2664         compile_readline=yes
2665         want_to_use_readline="yes"
2666         AC_DEFINE_UNQUOTED(USE_NEW_READLINE_INTERFACE, 1)
2667     else
2668         # Use system readline library
2669         AC_LANG_SAVE
2670         AC_LANG_CPLUSPLUS
2671         MYSQL_CHECK_LIBEDIT_INTERFACE
2672         MYSQL_CHECK_NEW_RL_INTERFACE
2673         MYSQL_CHECK_READLINE_DECLARES_HIST_ENTRY
2674         AC_LANG_RESTORE
2675         if [test "$mysql_cv_new_rl_interface" = "yes"] && [test -d "$srcdir/cmd-line-utils/readline"]
2676         then
2677             # Use the new readline interface, but only if the package includes a bundled libreadline
2678             # this way we avoid linking commercial source with GPL readline
2679             readline_link="-lreadline"
2680             want_to_use_readline="yes"
2681         elif [test "$mysql_cv_libedit_interface" = "yes"]
2682         then
2683             # Use libedit
2684             readline_link="-ledit"
2685         else
2686            AC_MSG_ERROR([Could not find system readline or libedit libraries
2687               Use --with-readline or --with-libedit to use the bundled
2688               versions of libedit or readline])
2689         fi
2690     fi
2692     # if there is no readline, but we want to build with readline, we fail
2693     if [test "$want_to_use_readline" = "yes"] && [test ! -d "$srcdir/cmd-line-utils/readline"]
2694     then
2695         AC_MSG_ERROR([This commercially licensed MySQL source package can't
2696               be built with libreadline. Please use --with-libedit to use
2697               the bundled version of libedit instead.])
2698     fi
2699     ;;
2700 esac
2702 AC_SUBST(readline_dir)
2703 AC_SUBST(readline_topdir)
2704 AC_SUBST(readline_basedir)
2705 AC_SUBST(readline_link)
2706 AC_SUBST(readline_h_ln_cmd)
2710 # Include man pages, if desired, adapted to the configured parts.
2711 if test X"$with_man" = Xyes
2712 then
2713   # First, create the list of all man pages present.
2714   MANLISTFIL=manlist.$$
2715   TMPLISTFIL=`echo $MANLISTFIL | sed -e 's/manlist/tmplist/'`
2716   if test -f $MANLISTFIL -o -f $TMPLISTFIL
2717   then
2718     echo "Temp file '$MANLISTFIL' or '$TMPLISTFIL' already exists in '`pwd`' - aborting"
2719     exit 1
2720   fi
2721   touch $MANLISTFIL $TMPLISTFIL
2723   ls $srcdir/man/*.[[18]] > $MANLISTFIL
2725   # Then, remove all those pages from the list which are specific to parts
2726   # (table handlers, features, ...) which are not configured in this run.
2727   AC_MSG_CHECKING("for man pages to remove")
2728   MAN_DROP="dropping"
2729   if test X"$with_plugin_ndbcluster" != Xyes
2730   then
2731     MAN_DROP="$MAN_DROP ndbcluster"
2732     grep -v '/ndb' $MANLISTFIL > $TMPLISTFIL ; mv -f $TMPLISTFIL $MANLISTFIL
2733   fi
2734   if test X"$with_embedded_server" != Xyes
2735   then
2736     MAN_DROP="$MAN_DROP embedded"
2737     grep -v 'embedded' $MANLISTFIL > $TMPLISTFIL ; mv -f $TMPLISTFIL $MANLISTFIL
2738   fi
2739   if test X"$with_plugin_innobase" != Xyes -a X"$with_plugin_innodb_plugin" != Xyes
2740   then
2741     MAN_DROP="$MAN_DROP innodb"
2742     grep -v 'inno' $MANLISTFIL > $TMPLISTFIL ; mv -f $TMPLISTFIL $MANLISTFIL
2743   fi
2744   AC_MSG_RESULT([$MAN_DROP])
2746   # Finally, split the man pages into sections 1 and 8.
2747   # Get rid of line breaks.
2748   man1_files=`sed -n -e '/\.1$/s/^.*man\///p' <$MANLISTFIL`
2749   man8_files=`sed -n -e '/\.8$/s/^.*man\///p' <$MANLISTFIL`
2751   man_dirs="man"
2752   man1_files=`echo $man1_files`
2753   man8_files=`echo $man8_files`
2754   rm -f $MANLISTFIL $TMPLISTFIL
2755 else
2756   man_dirs=""
2757   man1_files=""
2758   man8_files=""
2760 AC_SUBST(man_dirs)
2761 AC_SUBST(man1_files)
2762 AC_SUBST(man8_files)
2764 # If we have threads generate some library functions and test programs
2765 sql_server_dirs=
2766 sql_server=
2767 server_scripts=
2769 dnl This probably should be cleaned up more - for now the threaded
2770 dnl client is just using plain-old libs.
2771 sql_client_dirs="strings mysys dbug extra regex libmysql"
2773 AM_CONDITIONAL(THREAD_SAFE_CLIENT, test "$THREAD_SAFE_CLIENT" != "no")
2775 if test "$THREAD_SAFE_CLIENT" != "no"
2776 then
2777   sql_client_dirs="$sql_client_dirs libmysql_r"
2778   AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should the client be thread safe])
2780 sql_client_dirs="$sql_client_dirs client"
2782 CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
2784 AC_SUBST(CLIENT_LIBS)
2785 AC_SUBST(CLIENT_THREAD_LIBS)
2786 AC_SUBST(NON_THREADED_LIBS)
2787 AC_SUBST(STATIC_NSS_FLAGS)
2788 AC_SUBST(sql_client_dirs)
2790 # If configuring for NetWare, build the netware directory
2791 netware_dir=
2792 if expr "$SYSTEM_TYPE" : ".*netware.*" > /dev/null
2793 then
2794   netware_dir="netware"
2796 AC_SUBST(netware_dir)
2797 AM_CONDITIONAL(HAVE_NETWARE, test "$netware_dir" = "netware")
2799 if test "$with_server" != "no" -o "$THREAD_SAFE_CLIENT" != "no"
2800 then
2801   AC_DEFINE([THREAD], [1],
2802             [Define if you want to have threaded code. This may be undef on client code])
2803   # Avoid _PROGRAMS names
2804   THREAD_LOBJECTS="thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o my_thr_init.o mf_keycache.o"
2805   AC_SUBST(THREAD_LOBJECTS)
2807 AM_CONDITIONAL(NEED_THREAD, test "$with_server" != "no" -o "$THREAD_SAFE_CLIENT" != "no")
2809 if test "$with_server" != "no"
2810 then
2811   server_scripts="mysqld_safe mysql_install_db"
2812   sql_server_dirs="strings mysys dbug extra regex storage plugin"
2814   sql_server="vio sql"
2817 # "innochecksum" is not in the "innobase/" subdirectory, but should be switched
2818 AM_CONDITIONAL([BUILD_INNODB_TOOLS], [test X"$with_plugin_innobase" = Xyes -o X"$with_plugin_innodb_plugin" = Xyes ])
2820 # IMPORTANT - do not modify LIBS past this line - this hack is the only way
2821 # I know to add the static NSS magic if we have static NSS libraries with
2822 # glibc - Sasha
2824 LDFLAGS="$LDFLAGS $OTHER_LIBC_LIB"
2825 LIBS="$LIBS $STATIC_NSS_FLAGS"
2827 AC_SUBST(sql_server_dirs)
2828 AC_SUBST(sql_server)
2829 AC_SUBST(server_scripts)
2831 AC_SUBST(mysql_plugin_dirs)
2832 AC_SUBST(mysql_plugin_libs)
2833 AC_SUBST(mysql_plugin_defs)
2836 # Now that sql_client_dirs and sql_server_dirs are stable, determine the union.
2837 # We support client-only builds by "--without-server", but not vice versa,
2838 # so we start with the client list, then add each server item not yet present.
2839 sql_union_dirs=" $sql_client_dirs "
2840 for DIR in $sql_server_dirs
2842   if echo " $sql_union_dirs " | grep " $DIR " >/dev/null
2843   then
2844     :  # already present, skip
2845   else
2846     sql_union_dirs="$sql_union_dirs $DIR "
2847   fi
2848 done
2849 AC_SUBST(sql_union_dirs)
2852 # Setup maintainer mode options by the end to not disturb
2853 # system and other checks.
2855 MY_MAINTAINER_MODE_SETUP
2857 # Some usefull subst
2858 AC_SUBST(CC)
2859 AC_SUBST(GXX)
2861 # Set configuration options for make_binary_distribution
2862 case $SYSTEM_TYPE in
2863   *netware*)
2864     MAKE_BINARY_DISTRIBUTION_OPTIONS="$MAKE_BINARY_DISTRIBUTION_OPTIONS --no-strip"
2865     ;;
2866   *)
2867     : # no change for other platforms yet
2868     ;;
2869 esac
2870 AC_SUBST(MAKE_BINARY_DISTRIBUTION_OPTIONS)
2872 # Output results
2873 if test -d "$srcdir/cmd-line-utils/readline" ; then
2874   AC_CONFIG_FILES(cmd-line-utils/readline/Makefile)
2877 AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl
2878  unittest/Makefile unittest/mytap/Makefile unittest/mytap/t/Makefile dnl
2879  unittest/mysys/Makefile unittest/strings/Makefile dnl
2880  unittest/examples/Makefile unittest/my_decimal/Makefile dnl
2881  strings/Makefile regex/Makefile storage/Makefile dnl
2882  man/Makefile BUILD/Makefile vio/Makefile dnl
2883  libmysql/Makefile libmysql_r/Makefile client/Makefile dnl
2884  sql/Makefile sql/share/Makefile dnl
2885  sql/sql_builtin.cc sql-common/Makefile dnl
2886  dbug/Makefile scripts/Makefile include/Makefile dnl
2887  tests/Makefile Docs/Makefile support-files/Makefile dnl
2888  support-files/MacOSX/Makefile support-files/RHEL4-SElinux/Makefile dnl
2889  server-tools/Makefile server-tools/instance-manager/Makefile dnl
2890  cmd-line-utils/Makefile cmd-line-utils/libedit/Makefile dnl
2891  libmysqld/Makefile libmysqld/examples/Makefile dnl
2892  mysql-test/Makefile mysql-test/lib/My/SafeProcess/Makefile dnl
2893  netware/Makefile sql-bench/Makefile dnl
2894  include/mysql_version.h plugin/Makefile win/Makefile)
2896 AC_CONFIG_COMMANDS([default], , test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h)
2898 # Ensure that table handlers gets all modifications to CFLAGS/CXXFLAGS
2899 AC_CONFIG_COMMANDS_POST(ac_configure_args="$ac_configure_args CFLAGS='$CFLAGS' CXXFLAGS='$CXXFLAGS'")
2901 AC_OUTPUT
2903 # Add warning if user configures with --with-ndbcluster
2904 if test X"$with_plugin_ndbcluster" = Xyes ; then
2905   echo 
2906   echo This version of MySQL Cluster is no longer maintained.
2907   echo Please use the separate sources provided for MySQL Cluster instead.
2908   echo See http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster.html
2909   echo for more details.
2912 # The first line "Thank you ..." is checked in ./Do-compile to verify that configure
2913 # ended sucessfully - don't remove it.
2914 echo
2915 echo "Thank you for choosing MySQL!"
2916 echo
2917 echo "Remember to check the platform specific part of the reference manual"
2918 echo "for hints about installing MySQL on your platform."
2919 echo "Also have a look at the files in the Docs directory."
2920 echo