2004-11-03 12:39:38 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2011-05-25 12:39:11 +02:00
|
|
|
# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
2010-12-28 19:57:23 +01:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Library General Public
|
|
|
|
# License as published by the Free Software Foundation; version 2
|
|
|
|
# of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Library General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Library General Public
|
|
|
|
# License along with this library; if not, write to the Free
|
|
|
|
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
|
|
|
# MA 02111-1307, USA
|
|
|
|
|
2006-04-07 02:25:59 +04:00
|
|
|
########################################################################
|
|
|
|
|
|
|
|
get_key_value()
|
|
|
|
{
|
|
|
|
echo "$1" | sed 's/^--[a-zA-Z_-]*=//'
|
|
|
|
}
|
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
Usage: $0 [-h|-n] [configure-options]
|
|
|
|
-h, --help Show this help message.
|
|
|
|
-n, --just-print Don't actually run any commands; just print them.
|
|
|
|
-c, --just-configure Stop after running configure.
|
2011-05-06 11:20:01 +02:00
|
|
|
--with-debug=full Build with full debug(no optimizations, keep call stack).
|
2010-07-24 10:31:48 -03:00
|
|
|
--warning-mode=[old|pedantic|maintainer]
|
2006-04-07 02:25:59 +04:00
|
|
|
Influences the debug flags. Old is default.
|
|
|
|
--prefix=path Build with prefix 'path'.
|
|
|
|
|
|
|
|
Note: this script is intended for internal use by MySQL developers.
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
parse_options()
|
|
|
|
{
|
|
|
|
while test $# -gt 0
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
--prefix=*)
|
|
|
|
prefix=`get_key_value "$1"`;;
|
2011-05-06 11:20:01 +02:00
|
|
|
--with-debug=full)
|
|
|
|
full_debug="=full";;
|
2006-04-07 02:25:59 +04:00
|
|
|
--warning-mode=*)
|
|
|
|
warning_mode=`get_key_value "$1"`;;
|
|
|
|
-c | --just-configure)
|
|
|
|
just_configure=1;;
|
|
|
|
-n | --just-print | --print)
|
|
|
|
just_print=1;;
|
|
|
|
-h | --help)
|
|
|
|
usage
|
|
|
|
exit 0;;
|
|
|
|
*)
|
|
|
|
echo "Unknown option '$1'"
|
|
|
|
exit 1;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
|
2006-08-30 23:20:01 +02:00
|
|
|
if test ! -f sql/mysqld.cc
|
2001-01-30 20:43:16 -05:00
|
|
|
then
|
2000-12-18 23:24:19 +02:00
|
|
|
echo "You must run this script from the MySQL top-level directory"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2006-04-07 02:25:59 +04:00
|
|
|
prefix="/usr/local/mysql"
|
2003-10-08 21:50:05 +03:00
|
|
|
just_print=
|
2001-03-04 22:34:26 +01:00
|
|
|
just_configure=
|
2006-04-07 02:25:59 +04:00
|
|
|
warning_mode=
|
2010-07-24 10:31:48 -03:00
|
|
|
maintainer_mode=
|
2011-05-06 11:20:01 +02:00
|
|
|
full_debug=
|
2006-04-07 02:25:59 +04:00
|
|
|
|
|
|
|
parse_options "$@"
|
|
|
|
|
2005-09-28 08:04:08 -07:00
|
|
|
if test -n "$MYSQL_BUILD_PREFIX"
|
2005-09-16 18:10:36 -07:00
|
|
|
then
|
2006-04-07 02:25:59 +04:00
|
|
|
prefix="$MYSQL_BUILD_PREFIX"
|
2005-09-16 18:10:36 -07:00
|
|
|
fi
|
|
|
|
|
2001-01-30 20:43:16 -05:00
|
|
|
set -e
|
|
|
|
|
2006-04-07 02:25:59 +04:00
|
|
|
#
|
|
|
|
# Check for the CPU and set up CPU specific flags. We may reset them
|
|
|
|
# later.
|
|
|
|
#
|
|
|
|
path=`dirname $0`
|
|
|
|
. "$path/check-cpu"
|
|
|
|
|
2001-01-30 20:43:16 -05:00
|
|
|
export AM_MAKEFLAGS
|
2008-11-05 18:40:23 +03:00
|
|
|
AM_MAKEFLAGS="-j 6"
|
2000-12-18 23:24:19 +02:00
|
|
|
|
2006-05-17 13:59:37 +02:00
|
|
|
# SSL library to use.--with-ssl will select our bundled yaSSL
|
|
|
|
# implementation of SSL. To use openSSl you will nee too point out
|
|
|
|
# the location of openSSL headers and lbs on your system.
|
|
|
|
# Ex --with-ssl=/usr
|
|
|
|
SSL_LIBRARY=--with-ssl
|
2005-11-02 15:45:25 +02:00
|
|
|
|
2010-07-24 10:31:48 -03:00
|
|
|
if [ "x$warning_mode" = "xpedantic" ]; then
|
|
|
|
warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE"
|
|
|
|
c_warnings="$warnings"
|
|
|
|
cxx_warnings="$warnings -std=c++98"
|
|
|
|
# NOTE: warning mode should not influence optimize/debug mode.
|
|
|
|
# Please feel free to add a separate option if you don't feel it's an overkill.
|
|
|
|
debug_extra_cflags="-O0"
|
|
|
|
# Reset CPU flags (-mtune), they don't work in -pedantic mode
|
|
|
|
check_cpu_cflags=""
|
|
|
|
elif [ "x$warning_mode" = "xmaintainer" ]; then
|
|
|
|
c_warnings="-Wall -Wextra"
|
|
|
|
cxx_warnings="$c_warnings -Wno-unused-parameter"
|
|
|
|
maintainer_mode="--enable-mysql-maintainer-mode"
|
|
|
|
debug_extra_cflags="-g3"
|
|
|
|
else
|
2006-04-07 02:25:59 +04:00
|
|
|
# Both C and C++ warnings
|
2010-07-02 15:30:47 -03:00
|
|
|
warnings="-Wall -Wextra -Wunused -Wwrite-strings"
|
2005-11-02 15:45:25 +02:00
|
|
|
|
2006-12-15 00:51:37 +02:00
|
|
|
# For more warnings, uncomment the following line
|
2010-07-02 15:30:47 -03:00
|
|
|
# warnings="$warnings -Wshadow"
|
2007-01-27 03:46:45 +02:00
|
|
|
|
2006-04-07 02:25:59 +04:00
|
|
|
# C warnings
|
2010-07-02 15:30:47 -03:00
|
|
|
c_warnings="$warnings"
|
2006-04-07 02:25:59 +04:00
|
|
|
# C++ warnings
|
2010-07-02 15:30:47 -03:00
|
|
|
cxx_warnings="$warnings -Wno-unused-parameter"
|
2007-12-14 15:21:37 +02:00
|
|
|
# cxx_warnings="$cxx_warnings -Woverloaded-virtual -Wsign-promo"
|
2010-10-19 11:49:31 -02:00
|
|
|
cxx_warnings="$cxx_warnings -Wnon-virtual-dtor"
|
2010-07-02 15:30:47 -03:00
|
|
|
debug_extra_cflags="-O0 -g3 -gdwarf-2"
|
2006-04-07 02:25:59 +04:00
|
|
|
fi
|
2000-12-18 23:24:19 +02:00
|
|
|
|
2006-04-07 02:25:59 +04:00
|
|
|
# Set flags for various build configurations.
|
|
|
|
# Used in -valgrind builds
|
2010-05-20 13:40:42 +03:00
|
|
|
# Override -DFORCE_INIT_OF_VARS from debug_cflags. It enables the macro
|
|
|
|
# LINT_INIT(), which is only useful for silencing spurious warnings
|
|
|
|
# of static analysis tools. We want LINT_INIT() to be a no-op in Valgrind.
|
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.
Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.
Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost.
The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.
Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
2010-07-08 18:20:08 -03:00
|
|
|
valgrind_flags="-UFORCE_INIT_OF_VARS -DHAVE_purify "
|
2006-04-07 02:25:59 +04:00
|
|
|
valgrind_flags="$valgrind_flags -DMYSQL_SERVER_SUFFIX=-valgrind-max"
|
2010-05-20 13:40:42 +03:00
|
|
|
valgrind_configs="--with-valgrind"
|
2006-04-07 02:25:59 +04:00
|
|
|
#
|
|
|
|
# Used in -debug builds
|
|
|
|
debug_cflags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS "
|
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.
Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.
Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost.
The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.
Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
2010-07-08 18:20:08 -03:00
|
|
|
debug_cflags="$debug_cflags -DSAFE_MUTEX"
|
2006-02-03 12:05:29 -05:00
|
|
|
error_inject="--with-error-inject "
|
2006-04-07 02:25:59 +04:00
|
|
|
#
|
|
|
|
# Base C++ flags for all builds
|
|
|
|
base_cxxflags="-felide-constructors -fno-exceptions -fno-rtti"
|
|
|
|
#
|
|
|
|
# Flags for optimizing builds.
|
|
|
|
# Be as fast as we can be without losing our ability to backtrace.
|
2001-04-13 22:09:33 +03:00
|
|
|
fast_cflags="-O3 -fno-omit-frame-pointer"
|
2004-10-04 13:43:16 +02:00
|
|
|
|
2010-08-06 09:59:38 -03:00
|
|
|
debug_configs="--with-debug"
|
2011-05-06 11:20:01 +02:00
|
|
|
if [ -z "$full_debug" ]
|
|
|
|
then
|
|
|
|
debug_cflags="$debug_cflags $debug_extra_cflags"
|
|
|
|
fi
|
|
|
|
|
2000-12-18 23:24:19 +02:00
|
|
|
|
2006-04-07 02:25:59 +04:00
|
|
|
#
|
|
|
|
# Configuration options.
|
|
|
|
#
|
|
|
|
base_configs="--prefix=$prefix --enable-assembler "
|
|
|
|
base_configs="$base_configs --with-extra-charsets=complex "
|
2007-01-25 09:18:10 +01:00
|
|
|
base_configs="$base_configs --enable-thread-safe-client "
|
2010-07-24 10:31:48 -03:00
|
|
|
base_configs="$base_configs --with-big-tables $maintainer_mode"
|
2006-04-07 02:25:59 +04:00
|
|
|
|
2007-01-25 08:46:07 +01:00
|
|
|
if test -d "$path/../cmd-line-utils/readline"
|
|
|
|
then
|
|
|
|
base_configs="$base_configs --with-readline"
|
|
|
|
elif test -d "$path/../cmd-line-utils/libedit"
|
|
|
|
then
|
|
|
|
base_configs="$base_configs --with-libedit"
|
|
|
|
fi
|
|
|
|
|
2006-04-07 02:25:59 +04:00
|
|
|
static_link="--with-mysqld-ldflags=-all-static "
|
|
|
|
static_link="$static_link --with-client-ldflags=-all-static"
|
2002-03-02 12:45:44 -07:00
|
|
|
# we need local-infile in all binaries for rpl000001
|
|
|
|
# if you need to disable local-infile in the client, write a build script
|
|
|
|
# and unset local_infile_configs
|
|
|
|
local_infile_configs="--enable-local-infile"
|
2000-12-18 23:24:19 +02:00
|
|
|
|
2006-04-07 02:25:59 +04:00
|
|
|
|
2006-05-01 21:33:09 -07:00
|
|
|
max_no_embedded_configs="$SSL_LIBRARY --with-plugins=max"
|
|
|
|
max_no_ndb_configs="$SSL_LIBRARY --with-plugins=max-no-ndb --with-embedded-server"
|
|
|
|
max_configs="$SSL_LIBRARY --with-plugins=max --with-embedded-server"
|
2006-04-07 02:25:59 +04:00
|
|
|
|
|
|
|
#
|
|
|
|
# CPU and platform specific compilation flags.
|
|
|
|
#
|
|
|
|
alpha_cflags="$check_cpu_cflags -Wa,-m$cpu_flag"
|
|
|
|
amd64_cflags="$check_cpu_cflags"
|
|
|
|
amd64_cxxflags="" # If dropping '--with-big-tables', add here "-DBIG_TABLES"
|
2007-02-26 17:06:10 +01:00
|
|
|
pentium_cflags="$check_cpu_cflags"
|
2006-04-07 02:25:59 +04:00
|
|
|
pentium64_cflags="$check_cpu_cflags -m64"
|
|
|
|
ppc_cflags="$check_cpu_cflags"
|
|
|
|
sparc_cflags=""
|
2000-12-18 23:24:19 +02:00
|
|
|
|
2001-01-30 20:43:16 -05:00
|
|
|
if gmake --version > /dev/null 2>&1
|
|
|
|
then
|
2000-12-18 23:24:19 +02:00
|
|
|
make=gmake
|
|
|
|
else
|
|
|
|
make=make
|
|
|
|
fi
|
2001-10-30 16:31:35 +02:00
|
|
|
|
2005-10-06 17:54:43 +03:00
|
|
|
if test -z "$CC" ; then
|
|
|
|
CC=gcc
|
|
|
|
fi
|
|
|
|
|
2003-05-23 18:20:57 +02:00
|
|
|
if test -z "$CXX" ; then
|
2003-04-09 14:53:20 +02:00
|
|
|
CXX=gcc
|
|
|
|
fi
|
2003-05-23 18:20:57 +02:00
|
|
|
|
|
|
|
# If ccache (a compiler cache which reduces build time)
|
|
|
|
# (http://samba.org/ccache) is installed, use it.
|
|
|
|
# We use 'grep' and hope 'grep' will work as expected
|
|
|
|
# (returns 0 if finds lines)
|
2007-01-29 01:47:35 +02:00
|
|
|
if test "$USING_GCOV" != "1"
|
|
|
|
then
|
|
|
|
# Not using gcov; Safe to use ccache
|
|
|
|
CCACHE_GCOV_VERSION_ENABLED=1
|
|
|
|
fi
|
|
|
|
|
2007-01-07 12:21:42 -05:00
|
|
|
if ccache -V > /dev/null 2>&1 && test "$CCACHE_GCOV_VERSION_ENABLED" = "1"
|
2003-05-23 18:20:57 +02:00
|
|
|
then
|
2006-08-29 01:13:06 +02:00
|
|
|
echo "$CC" | grep "ccache" > /dev/null || CC="ccache $CC"
|
|
|
|
echo "$CXX" | grep "ccache" > /dev/null || CXX="ccache $CXX"
|
2003-05-23 18:20:57 +02:00
|
|
|
fi
|
2007-08-15 18:10:16 -06:00
|
|
|
|
|
|
|
# gcov
|
|
|
|
|
|
|
|
# The -fprofile-arcs and -ftest-coverage options cause GCC to instrument the
|
|
|
|
# code with profiling information used by gcov.
|
|
|
|
# The -DDISABLE_TAO_ASM is needed to avoid build failures in Yassl.
|
|
|
|
# The -DHAVE_gcov enables code to write out coverage info even when crashing.
|
|
|
|
|
|
|
|
gcov_compile_flags="-fprofile-arcs -ftest-coverage"
|
|
|
|
gcov_compile_flags="$gcov_compile_flags -DDISABLE_TAO_ASM"
|
|
|
|
gcov_compile_flags="$gcov_compile_flags -DMYSQL_SERVER_SUFFIX=-gcov -DHAVE_gcov"
|
|
|
|
|
|
|
|
# GCC4 needs -fprofile-arcs -ftest-coverage on the linker command line (as well
|
|
|
|
# as on the compiler command line), and this requires setting LDFLAGS for BDB.
|
|
|
|
|
|
|
|
gcov_link_flags="-fprofile-arcs -ftest-coverage"
|
|
|
|
|
2011-05-25 12:39:11 +02:00
|
|
|
gcov_configs="--with-gcov"
|
2007-08-15 18:10:16 -06:00
|
|
|
|
|
|
|
# gprof
|
|
|
|
|
|
|
|
gprof_compile_flags="-O2 -pg -g"
|
|
|
|
|
|
|
|
gprof_link_flags="--disable-shared $static_link"
|
|
|
|
|