~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to BUILD/SETUP.sh

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
########################################################################
 
4
 
 
5
get_key_value()
 
6
{
 
7
  echo "$1" | sed 's/^--[a-zA-Z_-]*=//'
 
8
}
 
9
 
 
10
usage()
 
11
{
 
12
cat <<EOF 
 
13
Usage: $0 [-h|-n] [configure-options]
 
14
  -h, --help              Show this help message.
 
15
  -n, --just-print        Don't actually run any commands; just print them.
 
16
  -c, --just-configure    Stop after running configure.
 
17
  --with-debug=full       Build with full debug.
 
18
  --warning-mode=[old|pedantic]
 
19
                          Influences the debug flags. Old is default.
 
20
  --prefix=path           Build with prefix 'path'.
 
21
 
 
22
Note: this script is intended for internal use by MySQL developers.
 
23
EOF
 
24
}
 
25
 
 
26
parse_options()
 
27
{
 
28
  while test $# -gt 0
 
29
  do
 
30
    case "$1" in
 
31
    --prefix=*)
 
32
      prefix=`get_key_value "$1"`;;
 
33
    --with-debug=full)
 
34
      full_debug="=full";;
 
35
    --warning-mode=*)
 
36
      warning_mode=`get_key_value "$1"`;;
 
37
    -c | --just-configure)
 
38
      just_configure=1;;
 
39
    -n | --just-print | --print)
 
40
      just_print=1;;
 
41
    -h | --help)
 
42
      usage
 
43
      exit 0;;
 
44
    *)
 
45
      echo "Unknown option '$1'"
 
46
      exit 1;;
 
47
    esac
 
48
    shift
 
49
  done
 
50
}
 
51
 
 
52
########################################################################
 
53
 
 
54
if test ! -f sql/mysqld.cc
 
55
then
 
56
  echo "You must run this script from the MySQL top-level directory"
 
57
  exit 1
 
58
fi
 
59
 
 
60
prefix="/usr/local/mysql"
 
61
just_print=
 
62
just_configure=
 
63
full_debug=
 
64
warning_mode=
 
65
 
 
66
parse_options "$@"
 
67
 
 
68
if test -n "$MYSQL_BUILD_PREFIX"
 
69
then
 
70
  prefix="$MYSQL_BUILD_PREFIX"
 
71
fi
 
72
 
 
73
set -e
 
74
 
 
75
#
 
76
# Check for the CPU and set up CPU specific flags. We may reset them
 
77
# later.
 
78
 
79
path=`dirname $0`
 
80
. "$path/check-cpu"
 
81
 
 
82
export AM_MAKEFLAGS
 
83
AM_MAKEFLAGS="-j 6"
 
84
 
 
85
# SSL library to use.--with-ssl will select our bundled yaSSL
 
86
# implementation of SSL. To use openSSl you will nee too point out
 
87
# the location of openSSL headers and lbs on your system.
 
88
# Ex --with-ssl=/usr
 
89
SSL_LIBRARY=--with-ssl
 
90
 
 
91
if [ "x$warning_mode" != "xpedantic" ]; then
 
92
# Both C and C++ warnings
 
93
  warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W"
 
94
  warnings="$warnings -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare"
 
95
  warnings="$warnings -Wwrite-strings -Wunused-function -Wunused-label -Wunused-value -Wunused-variable"
 
96
 
 
97
# For more warnings, uncomment the following line
 
98
# warnings="$global_warnings -Wshadow"
 
99
 
 
100
# C warnings
 
101
  c_warnings="$warnings -Wunused-parameter"
 
102
# C++ warnings
 
103
  cxx_warnings="$warnings"
 
104
# cxx_warnings="$cxx_warnings -Woverloaded-virtual -Wsign-promo"
 
105
  cxx_warnings="$cxx_warnings -Wreorder"
 
106
  cxx_warnings="$cxx_warnings -Wctor-dtor-privacy -Wnon-virtual-dtor"
 
107
# Added unless --with-debug=full
 
108
  debug_extra_cflags="-O0 -g3 -gdwarf-2" #1 -Wuninitialized"
 
109
else
 
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
fi
 
119
 
 
120
# Set flags for various build configurations.
 
121
# Used in -valgrind builds
 
122
valgrind_flags="-USAFEMALLOC -UFORCE_INIT_OF_VARS -DHAVE_purify "
 
123
valgrind_flags="$valgrind_flags -DMYSQL_SERVER_SUFFIX=-valgrind-max"
 
124
#
 
125
# Used in -debug builds
 
126
debug_cflags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS "
 
127
debug_cflags="$debug_cflags -DSAFEMALLOC -DPEDANTIC_SAFEMALLOC -DSAFE_MUTEX"
 
128
error_inject="--with-error-inject "
 
129
#
 
130
# Base C++ flags for all builds
 
131
base_cxxflags="-felide-constructors -fno-exceptions -fno-rtti"
 
132
#
 
133
# Flags for optimizing builds.
 
134
# Be as fast as we can be without losing our ability to backtrace.
 
135
fast_cflags="-O3 -fno-omit-frame-pointer"
 
136
 
 
137
debug_configs="--with-debug$full_debug"
 
138
if [ -z "$full_debug" ]
 
139
then
 
140
  debug_cflags="$debug_cflags $debug_extra_cflags"
 
141
fi
 
142
 
 
143
#
 
144
# Configuration options.
 
145
#
 
146
base_configs="--prefix=$prefix --enable-assembler "
 
147
base_configs="$base_configs --with-extra-charsets=complex "
 
148
base_configs="$base_configs --enable-thread-safe-client "
 
149
base_configs="$base_configs --with-big-tables"
 
150
 
 
151
if test -d "$path/../cmd-line-utils/readline"
 
152
then
 
153
    base_configs="$base_configs --with-readline"
 
154
elif test -d "$path/../cmd-line-utils/libedit"
 
155
then
 
156
    base_configs="$base_configs --with-libedit"
 
157
fi
 
158
 
 
159
static_link="--with-mysqld-ldflags=-all-static "
 
160
static_link="$static_link --with-client-ldflags=-all-static"
 
161
# we need local-infile in all binaries for rpl000001
 
162
# if you need to disable local-infile in the client, write a build script
 
163
# and unset local_infile_configs
 
164
local_infile_configs="--enable-local-infile"
 
165
 
 
166
 
 
167
max_no_embedded_configs="$SSL_LIBRARY --with-plugins=max"
 
168
max_no_ndb_configs="$SSL_LIBRARY --with-plugins=max-no-ndb --with-embedded-server"
 
169
max_configs="$SSL_LIBRARY --with-plugins=max --with-embedded-server"
 
170
 
 
171
#
 
172
# CPU and platform specific compilation flags.
 
173
#
 
174
alpha_cflags="$check_cpu_cflags -Wa,-m$cpu_flag"
 
175
amd64_cflags="$check_cpu_cflags"
 
176
amd64_cxxflags=""  # If dropping '--with-big-tables', add here  "-DBIG_TABLES"
 
177
pentium_cflags="$check_cpu_cflags"
 
178
pentium64_cflags="$check_cpu_cflags -m64"
 
179
ppc_cflags="$check_cpu_cflags"
 
180
sparc_cflags=""
 
181
 
 
182
if gmake --version > /dev/null 2>&1
 
183
then
 
184
  make=gmake
 
185
else
 
186
  make=make
 
187
fi
 
188
 
 
189
if test -z "$CC" ; then
 
190
  CC=gcc
 
191
fi
 
192
 
 
193
if test -z "$CXX" ; then
 
194
  CXX=gcc
 
195
fi
 
196
 
 
197
# If ccache (a compiler cache which reduces build time)
 
198
# (http://samba.org/ccache) is installed, use it.
 
199
# We use 'grep' and hope 'grep' will work as expected
 
200
# (returns 0 if finds lines)
 
201
if test "$USING_GCOV" != "1"
 
202
then
 
203
  # Not using gcov; Safe to use ccache
 
204
  CCACHE_GCOV_VERSION_ENABLED=1
 
205
fi
 
206
 
 
207
if ccache -V > /dev/null 2>&1 && test "$CCACHE_GCOV_VERSION_ENABLED" = "1"
 
208
then
 
209
  echo "$CC" | grep "ccache" > /dev/null || CC="ccache $CC"
 
210
  echo "$CXX" | grep "ccache" > /dev/null || CXX="ccache $CXX"
 
211
fi
 
212
 
 
213
# gcov
 
214
 
 
215
# The  -fprofile-arcs and -ftest-coverage options cause GCC to instrument the
 
216
# code with profiling information used by gcov.
 
217
# The -DDISABLE_TAO_ASM is needed to avoid build failures in Yassl.
 
218
# The -DHAVE_gcov enables code to write out coverage info even when crashing.
 
219
 
 
220
gcov_compile_flags="-fprofile-arcs -ftest-coverage"
 
221
gcov_compile_flags="$gcov_compile_flags -DDISABLE_TAO_ASM"
 
222
gcov_compile_flags="$gcov_compile_flags -DMYSQL_SERVER_SUFFIX=-gcov -DHAVE_gcov"
 
223
 
 
224
# GCC4 needs -fprofile-arcs -ftest-coverage on the linker command line (as well
 
225
# as on the compiler command line), and this requires setting LDFLAGS for BDB.
 
226
 
 
227
gcov_link_flags="-fprofile-arcs -ftest-coverage"
 
228
 
 
229
gcov_configs="--disable-shared"
 
230
 
 
231
# gprof
 
232
 
 
233
gprof_compile_flags="-O2 -pg -g"
 
234
 
 
235
gprof_link_flags="--disable-shared $static_link"
 
236