|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. |
| 4 | +# |
| 5 | +# This program is free software; you can redistribute it and/or |
| 6 | +# modify it under the terms of the GNU Library General Public |
| 7 | +# License as published by the Free Software Foundation; version 2 |
| 8 | +# of the License. |
| 9 | +# |
| 10 | +# This program is distributed in the hope that it will be useful, |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | +# Library General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU Library General Public |
| 16 | +# License along with this library; if not, write to the Free |
| 17 | +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
| 18 | +# MA 02110-1301, USA |
| 19 | + |
| 20 | +######################################################################## |
| 21 | + |
| 22 | +get_key_value() |
| 23 | +{ |
| 24 | + echo "$1" | sed 's/^--[a-zA-Z_-]*=//' |
| 25 | +} |
| 26 | + |
| 27 | +usage() |
| 28 | +{ |
| 29 | +cat <<EOF |
| 30 | +Usage: $0 [-h|-n] [configure-options] |
| 31 | + -h, --help Show this help message. |
| 32 | + -n, --just-print Don't actually run any commands; just print them. |
| 33 | + -c, --just-configure Stop after running configure. |
| 34 | + --with-debug=full Build with full debug(no optimizations, keep call stack). |
| 35 | + --warning-mode=[old|pedantic|maintainer] |
| 36 | + Influences the debug flags. Old is default. |
| 37 | + --prefix=path Build with prefix 'path'. |
| 38 | +
|
| 39 | +Note: this script is intended for internal use by MySQL developers. |
| 40 | +EOF |
| 41 | +} |
| 42 | + |
| 43 | +parse_options() |
| 44 | +{ |
| 45 | + while test $# -gt 0 |
| 46 | + do |
| 47 | + case "$1" in |
| 48 | + --prefix=*) |
| 49 | + prefix=`get_key_value "$1"`;; |
| 50 | + --with-debug=full) |
| 51 | + full_debug="=full";; |
| 52 | + --warning-mode=*) |
| 53 | + warning_mode=`get_key_value "$1"`;; |
| 54 | + -c | --just-configure) |
| 55 | + just_configure=1;; |
| 56 | + -n | --just-print | --print) |
| 57 | + just_print=1;; |
| 58 | + -h | --help) |
| 59 | + usage |
| 60 | + exit 0;; |
| 61 | + *) |
| 62 | + echo "Unknown option '$1'" |
| 63 | + exit 1;; |
| 64 | + esac |
| 65 | + shift |
| 66 | + done |
| 67 | +} |
| 68 | + |
| 69 | +######################################################################## |
| 70 | + |
| 71 | +if test ! -f sql/mysqld.cc |
| 72 | +then |
| 73 | + echo "You must run this script from the MySQL top-level directory" |
| 74 | + exit 1 |
| 75 | +fi |
| 76 | + |
| 77 | +prefix="/usr/local/mysql" |
| 78 | +just_print= |
| 79 | +just_configure= |
| 80 | +warning_mode= |
| 81 | +maintainer_mode= |
| 82 | +full_debug= |
| 83 | + |
| 84 | +parse_options "$@" |
| 85 | + |
| 86 | +if test -n "$MYSQL_BUILD_PREFIX" |
| 87 | +then |
| 88 | + prefix="$MYSQL_BUILD_PREFIX" |
| 89 | +fi |
| 90 | + |
| 91 | +set -e |
| 92 | + |
| 93 | +# |
| 94 | +# Check for the CPU and set up CPU specific flags. We may reset them |
| 95 | +# later. |
| 96 | +# |
| 97 | +path=`dirname $0` |
| 98 | +. "$path/check-cpu" |
| 99 | + |
| 100 | +export AM_MAKEFLAGS |
| 101 | +AM_MAKEFLAGS="-j 6" |
| 102 | + |
| 103 | +# SSL library to use.--with-ssl will select our bundled yaSSL |
| 104 | +# implementation of SSL. To use openSSl you will nee too point out |
| 105 | +# the location of openSSL headers and lbs on your system. |
| 106 | +# Ex --with-ssl=/usr |
| 107 | +SSL_LIBRARY=--with-ssl |
| 108 | + |
| 109 | +if [ "x$warning_mode" = "xpedantic" ]; then |
| 110 | + warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE" |
| 111 | + c_warnings="$warnings" |
| 112 | + cxx_warnings="$warnings -std=c++98" |
| 113 | +# NOTE: warning mode should not influence optimize/debug mode. |
| 114 | +# Please feel free to add a separate option if you don't feel it's an overkill. |
| 115 | + debug_extra_cflags="-O0" |
| 116 | +# Reset CPU flags (-mtune), they don't work in -pedantic mode |
| 117 | + check_cpu_cflags="" |
| 118 | +elif [ "x$warning_mode" = "xmaintainer" ]; then |
| 119 | + c_warnings="-Wall -Wextra" |
| 120 | + cxx_warnings="$c_warnings -Wno-unused-parameter" |
| 121 | + maintainer_mode="--enable-mysql-maintainer-mode" |
| 122 | + debug_extra_cflags="-g3" |
| 123 | +else |
| 124 | +# Both C and C++ warnings |
| 125 | + warnings="-Wall -Wextra -Wunused -Wwrite-strings" |
| 126 | + |
| 127 | +# For more warnings, uncomment the following line |
| 128 | +# warnings="$warnings -Wshadow" |
| 129 | + |
| 130 | +# C warnings |
| 131 | + c_warnings="$warnings" |
| 132 | +# C++ warnings |
| 133 | + cxx_warnings="$warnings -Wno-unused-parameter" |
| 134 | +# cxx_warnings="$cxx_warnings -Woverloaded-virtual -Wsign-promo" |
| 135 | + cxx_warnings="$cxx_warnings -Wnon-virtual-dtor" |
| 136 | + debug_extra_cflags="-O0 -g3 -gdwarf-2" |
| 137 | +fi |
| 138 | + |
| 139 | +# Set flags for various build configurations. |
| 140 | +# Used in -valgrind builds |
| 141 | +valgrind_flags="-DMYSQL_SERVER_SUFFIX=-valgrind-max" |
| 142 | +valgrind_configs="--with-valgrind" |
| 143 | +# |
| 144 | +# Used in -debug builds |
| 145 | +debug_cflags="-DEXTRA_DEBUG " |
| 146 | +debug_cflags="$debug_cflags -DSAFE_MUTEX" |
| 147 | +error_inject="--with-error-inject " |
| 148 | +# |
| 149 | +# Base C++ flags for all builds |
| 150 | +base_cxxflags="-felide-constructors" |
| 151 | +# |
| 152 | +# Flags for optimizing builds. |
| 153 | +# Be as fast as we can be without losing our ability to backtrace. |
| 154 | +fast_cflags="-O3 -fno-omit-frame-pointer" |
| 155 | + |
| 156 | +debug_configs="--with-debug" |
| 157 | +if [ -z "$full_debug" ] |
| 158 | +then |
| 159 | + debug_cflags="$debug_cflags $debug_extra_cflags" |
| 160 | +fi |
| 161 | + |
| 162 | + |
| 163 | +# |
| 164 | +# Configuration options. |
| 165 | +# |
| 166 | +base_configs="--prefix=$prefix --enable-assembler " |
| 167 | +base_configs="$base_configs --with-extra-charsets=complex " |
| 168 | +base_configs="$base_configs --enable-thread-safe-client " |
| 169 | +base_configs="$base_configs --with-big-tables $maintainer_mode" |
| 170 | + |
| 171 | + |
| 172 | +if test -d "$path/../cmd-line-utils/libedit" |
| 173 | +then |
| 174 | + base_configs="$base_configs --with-libedit" |
| 175 | +fi |
| 176 | + |
| 177 | +static_link="--with-mysqld-ldflags=-all-static " |
| 178 | +static_link="$static_link --with-client-ldflags=-all-static" |
| 179 | +# we need local-infile in all binaries for rpl000001 |
| 180 | +# if you need to disable local-infile in the client, write a build script |
| 181 | +# and unset local_infile_configs |
| 182 | +local_infile_configs="--enable-local-infile" |
| 183 | + |
| 184 | + |
| 185 | +max_no_embedded_configs="$SSL_LIBRARY --with-plugins=max" |
| 186 | +max_no_ndb_configs="$SSL_LIBRARY --with-plugins=max-no-ndb --with-embedded-server" |
| 187 | +max_configs="$SSL_LIBRARY --with-plugins=max --with-embedded-server" |
| 188 | + |
| 189 | +# |
| 190 | +# CPU and platform specific compilation flags. |
| 191 | +# |
| 192 | +alpha_cflags="$check_cpu_cflags -Wa,-m$cpu_flag" |
| 193 | +amd64_cflags="$check_cpu_cflags" |
| 194 | +amd64_cxxflags="" # If dropping '--with-big-tables', add here "-DBIG_TABLES" |
| 195 | +pentium_cflags="$check_cpu_cflags" |
| 196 | +pentium64_cflags="$check_cpu_cflags -m64" |
| 197 | +ppc_cflags="$check_cpu_cflags" |
| 198 | +sparc_cflags="" |
| 199 | + |
| 200 | +if gmake --version > /dev/null 2>&1 |
| 201 | +then |
| 202 | + make=gmake |
| 203 | +else |
| 204 | + make=make |
| 205 | +fi |
| 206 | + |
| 207 | +if test -z "$CC" ; then |
| 208 | + CC=gcc |
| 209 | +fi |
| 210 | + |
| 211 | +if test -z "$CXX" ; then |
| 212 | + CXX=g++ |
| 213 | +fi |
| 214 | + |
| 215 | +# If ccache (a compiler cache which reduces build time) |
| 216 | +# (http://samba.org/ccache) is installed, use it. |
| 217 | +# We use 'grep' and hope 'grep' will work as expected |
| 218 | +# (returns 0 if finds lines) |
| 219 | +if test "$USING_GCOV" != "1" |
| 220 | +then |
| 221 | + # Not using gcov; Safe to use ccache |
| 222 | + CCACHE_GCOV_VERSION_ENABLED=1 |
| 223 | +fi |
| 224 | + |
| 225 | +if ccache -V > /dev/null 2>&1 && test "$CCACHE_GCOV_VERSION_ENABLED" = "1" |
| 226 | +then |
| 227 | + echo "$CC" | grep "ccache" > /dev/null || CC="ccache $CC" |
| 228 | + echo "$CXX" | grep "ccache" > /dev/null || CXX="ccache $CXX" |
| 229 | +fi |
| 230 | + |
| 231 | +# gcov |
| 232 | + |
| 233 | +# The -fprofile-arcs and -ftest-coverage options cause GCC to instrument the |
| 234 | +# code with profiling information used by gcov. |
| 235 | +# The -DDISABLE_TAO_ASM is needed to avoid build failures in Yassl. |
| 236 | +# The -DHAVE_gcov enables code to write out coverage info even when crashing. |
| 237 | + |
| 238 | +gcov_compile_flags="-fprofile-arcs -ftest-coverage" |
| 239 | +gcov_compile_flags="$gcov_compile_flags -DDISABLE_TAO_ASM" |
| 240 | +gcov_compile_flags="$gcov_compile_flags -DMYSQL_SERVER_SUFFIX=-gcov -DHAVE_gcov" |
| 241 | + |
| 242 | +# GCC4 needs -fprofile-arcs -ftest-coverage on the linker command line (as well |
| 243 | +# as on the compiler command line), and this requires setting LDFLAGS for BDB. |
| 244 | + |
| 245 | +gcov_link_flags="-fprofile-arcs -ftest-coverage" |
| 246 | + |
| 247 | +gcov_configs="--with-gcov" |
| 248 | + |
| 249 | +# gprof |
| 250 | + |
| 251 | +gprof_compile_flags="-O2 -pg -g" |
| 252 | + |
| 253 | +gprof_link_flags="--disable-shared $static_link" |
| 254 | + |
0 commit comments