~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to BUILD/SETUP.sh

  • Committer: Stewart Smith
  • Date: 2008-06-30 05:33:25 UTC
  • mfrom: (12.2.8 drizzle)
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: stewart@flamingspork.com-20080630053325-mwrv6bjaufcpvj8n
merge my work

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 4"
84
 
 
85
 
if [ "x$warning_mode" != "xpedantic" ]; then
86
 
# Both C and C++ warnings
87
 
  warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W"
88
 
  warnings="$warnings -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare"
89
 
  warnings="$warnings -Wwrite-strings -Wunused-function -Wunused-label -Wunused-value -Wunused-variable"
90
 
 
91
 
# For more warnings, uncomment the following line
92
 
# warnings="$global_warnings -Wshadow"
93
 
 
94
 
# C warnings
95
 
  c_warnings="$warnings -Wunused-parameter"
96
 
# C++ warnings
97
 
  cxx_warnings="$warnings"
98
 
# cxx_warnings="$cxx_warnings -Woverloaded-virtual -Wsign-promo"
99
 
  cxx_warnings="$cxx_warnings -Wreorder"
100
 
  cxx_warnings="$cxx_warnings -Wctor-dtor-privacy -Wnon-virtual-dtor"
101
 
# Added unless --with-debug=full
102
 
  debug_extra_cflags="-O1 -Wuninitialized"
103
 
else
104
 
  warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE"
105
 
  c_warnings="$warnings"
106
 
  cxx_warnings="$warnings -std=c++98"
107
 
# NOTE: warning mode should not influence optimize/debug mode.
108
 
# Please feel free to add a separate option if you don't feel it's an overkill.
109
 
  debug_extra_cflags="-O0"
110
 
# Reset CPU flags (-mtune), they don't work in -pedantic mode
111
 
  check_cpu_cflags=""
112
 
fi
113
 
 
114
 
# Set flags for various build configurations.
115
 
# Used in -valgrind builds
116
 
valgrind_flags="-UFORCE_INIT_OF_VARS -DHAVE_purify "
117
 
valgrind_flags="$valgrind_flags -DMYSQL_SERVER_SUFFIX=-valgrind-max"
118
 
#
119
 
# Used in -debug builds
120
 
debug_cflags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS "
121
 
debug_cflags="$debug_cflags -DSAFE_MUTEX"
122
 
error_inject="--with-error-inject "
123
 
#
124
 
# Base C++ flags for all builds
125
 
base_cxxflags="-felide-constructors -fno-exceptions -fno-rtti"
126
 
#
127
 
# Flags for optimizing builds.
128
 
# Be as fast as we can be without losing our ability to backtrace.
129
 
fast_cflags="-O3 -fno-omit-frame-pointer"
130
 
 
131
 
debug_configs="--with-debug$full_debug"
132
 
if [ -z "$full_debug" ]
133
 
then
134
 
  debug_cflags="$debug_cflags $debug_extra_cflags"
135
 
fi
136
 
 
137
 
#
138
 
# Configuration options.
139
 
#
140
 
base_configs="--prefix=$prefix --enable-assembler "
141
 
base_configs="$base_configs --with-extra-charsets=complex "
142
 
base_configs="$base_configs --enable-thread-safe-client "
143
 
base_configs="$base_configs --with-big-tables"
144
 
 
145
 
if test -d "$path/../cmd-line-utils/readline"
146
 
then
147
 
    base_configs="$base_configs --with-readline"
148
 
elif test -d "$path/../cmd-line-utils/libedit"
149
 
then
150
 
    base_configs="$base_configs --with-libedit"
151
 
fi
152
 
 
153
 
static_link="--with-mysqld-ldflags=-all-static "
154
 
static_link="$static_link --with-client-ldflags=-all-static"
155
 
# we need local-infile in all binaries for rpl000001
156
 
# if you need to disable local-infile in the client, write a build script
157
 
# and unset local_infile_configs
158
 
local_infile_configs="--enable-local-infile"
159
 
 
160
 
 
161
 
max_no_embedded_configs="--with-plugins=max"
162
 
max_configs="--with-plugins=max --with-libevent"
163
 
 
164
 
#
165
 
# CPU and platform specific compilation flags.
166
 
#
167
 
alpha_cflags="$check_cpu_cflags -Wa,-m$cpu_flag"
168
 
amd64_cflags="$check_cpu_cflags"
169
 
amd64_cxxflags=""  # If dropping '--with-big-tables', add here  "-DBIG_TABLES"
170
 
pentium_cflags="$check_cpu_cflags"
171
 
pentium64_cflags="$check_cpu_cflags -m64"
172
 
ppc_cflags="$check_cpu_cflags"
173
 
sparc_cflags="-mcpu=ultrasparc"
174
 
 
175
 
if gmake --version > /dev/null 2>&1
176
 
then
177
 
  make=gmake
178
 
else
179
 
  make=make
180
 
fi
181
 
 
182
 
if test -z "$CC" ; then
183
 
  CC=gcc
184
 
fi
185
 
 
186
 
if test -z "$CXX" ; then
187
 
  CXX=gcc
188
 
fi
189
 
 
190
 
# If ccache (a compiler cache which reduces build time)
191
 
# (http://samba.org/ccache) is installed, use it.
192
 
# We use 'grep' and hope 'grep' will work as expected
193
 
# (returns 0 if finds lines)
194
 
if test "$USING_GCOV" != "1"
195
 
then
196
 
  # Not using gcov; Safe to use ccache
197
 
  CCACHE_GCOV_VERSION_ENABLED=1
198
 
fi
199
 
 
200
 
if ccache -V > /dev/null 2>&1 && test "$CCACHE_GCOV_VERSION_ENABLED" = "1"
201
 
then
202
 
  echo "$CC" | grep "ccache" > /dev/null || CC="ccache $CC"
203
 
  echo "$CXX" | grep "ccache" > /dev/null || CXX="ccache $CXX"
204
 
fi
205
 
 
206
 
# gcov
207
 
 
208
 
# The  -fprofile-arcs and -ftest-coverage options cause GCC to instrument the
209
 
# code with profiling information used by gcov.
210
 
# The -DDISABLE_TAO_ASM is needed to avoid build failures in Yassl.
211
 
# The -DHAVE_gcov enables code to write out coverage info even when crashing.
212
 
 
213
 
gcov_compile_flags="-fprofile-arcs -ftest-coverage"
214
 
gcov_compile_flags="$gcov_compile_flags -DDISABLE_TAO_ASM"
215
 
gcov_compile_flags="$gcov_compile_flags -DMYSQL_SERVER_SUFFIX=-gcov -DHAVE_gcov"
216
 
 
217
 
# GCC4 needs -fprofile-arcs -ftest-coverage on the linker command line (as well
218
 
# as on the compiler command line), and this requires setting LDFLAGS for BDB.
219
 
 
220
 
gcov_link_flags="-fprofile-arcs -ftest-coverage"
221
 
 
222
 
gcov_configs="--disable-shared"
223
 
 
224
 
# gprof
225
 
 
226
 
gprof_compile_flags="-O2 -pg -g"
227
 
 
228
 
gprof_link_flags="--disable-shared $static_link"
229