mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / BUILD / build_mccge.sh
blobac6e82d6ea2c6a153e829a72809b76c715f0e011
1 #!/bin/sh
3 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
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.
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.
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
20 die()
22 echo "ERROR: $@"; exit 1;
25 get_key_value()
27 echo "$1" | sed 's/^--[a-zA-Z_-]*=//'
30 developer_usage()
32 cat <<EOF
34 This script can be used by developers of MySQL, early adopters wanting
35 to try out early versions of MySQL before binary versions are
36 available, anyone needing a version with a special patch included that
37 needs to be built from source code, or anyone else wanting to exercise
38 full control over the MySQL build process.
40 This help text is targeted towards those that want to debug and test
41 MySQL using source code releases. If you have downloaded a source code
42 release and simply want to build a usable binary, you should read the
43 --sysadmin-help instead.
45 The script is also designed to be used by anyone receiving a source
46 code release of MySQL Cluster Carrier Grade Edition. The default
47 behaviour is to build the standard MySQL Cluster Carrier Grade Edition
48 package. Three environment variables can be used to change the
49 default behaviour:
51 MYSQL_DEVELOPER
52 Defining this variable is similar to setting the --developer flag
53 MYSQL_DEVELOPER_PACKAGE=package
54 Defining this variable is similar to setting the --package=*
55 variable
56 MYSQL_DEVELOPER_DEBUG
57 Defining this variable sets the --with-debug flag
59 Options used with this script always override any default behaviour.
60 The default package is MySQL Cluster Carrier Grade (standard) Edition.
61 For developers, the default package is MySQL Cluster Carrier Grade
62 Extended Edition, and the default build behaviour is to build with
63 autotools. If you want to skip autotools and start from a source code
64 release you can use the --no-autotools flag.
66 More information for developers can be found in --help,
67 --sysadmin-help, and --extended-help.
69 The most common usage for developers is to set the three variables
70 mentioned previously and then simply to run the script without any
71 additional parameters, using them only when needing to change some
72 things like not requiring debug build. If some of these environment
73 variables have already been set, you can use the corresponding options
74 to unset them and reverse their effects.
75 EOF
78 sysadmin_usage()
80 cat <<EOF
82 This script can be used to build MySQL Cluster Carrier Grade Edition
83 based on a source code release you received from MySQL. It can also
84 be used to build many variants other variants of MySQL, in particular
85 various performance-optimised versions of MySQL.
87 It is assumed that you are building on a computer which is of the
88 same type as that on which you intend to run MySQL/MySQL Cluster.
90 The simplest possible way to run this script is to allow it to use the
91 built-in defaults everywhere, invoking it simply as (from top-level
92 MySQL directory):
94 shell> BUILD/build_mccge.sh
96 This performs the following operations:
97 1) Detects the operating system. Currently, Linux, FreeBSD, Solaris
98 8/9/10/11, and Mac OS X are supported by this script.
99 2) Detect the type of CPU being used. Currently supported processors
100 are: x86 for all supported operating systems, Itanium for Linux
101 with GCC, and x86 + SPARC for Solaris using the Forte compiler and
102 finally x86 on Linux using the Intel compiler.
103 3) Invokes the GCC compiler.
104 4) Builds a set of MySQL/MySQL Cluster binaries; for
105 more information about these, see --extended-help.
106 5) Default compiler is always gcc.
108 The default version assumes that you have a source code tarball from
109 which you are building, and thus autoconf and automake do not need to
110 be run. If you have downloaded a BitKeeper tree then you should read
111 --developer-help.
113 If you are building MySQL/MySQL Cluster for commercial
114 use then you need to set the --commercial flag to ensure that the
115 commercial libraries are compiled in, rather than the GPL-only
116 libraries. The default is to build a GPL version of MySQL Cluster
117 Carrier Grade Edition.
119 If your building on a Solaris SPARC machine and you want to compile
120 using SunStudio you must set
121 --compiler=forte; if you want to build using the Intel compiler on
122 Linux, you need to set --compiler=icc.
124 A synonym for forte is SunStudio, so one can also use
125 --compiler=SunStudio.
127 If you want to make sure that a 64-bit version is built then you
128 should add the flag --64. This is always set on Solaris machines and
129 when check-cpu is able to discover that a 64-bit CPU is being used. If
130 you want to ensure that a 32-bit binary is produced, use --32 instead.
132 If you need the binaries to be installed in a different location from
133 /usr/local/mysql, then you should set --prefix to point to where you
134 want the binaries installed.
136 Using a data directory other than the default (PREFIX/data) can be
137 done when starting the MySQL Server, or by invoking this script with
138 the --datadir option.
140 If you want your binaries stripped of surplus debug or other
141 information, use the --strip option.
143 If you want debug information in the binary (for example, to be
144 able to send gdb core dumps to MySQL Support), then you should add the
145 flag --with-debug; if you want a production build with only debugging
146 information in the binary then use --debug.
148 If your aim is not to build MySQL Cluster Carrier Grade Edition, you
149 can also use this script to build MySQL Classic and MySQL Enterprise Pro
150 versions; see the --extended-help for descriptions of these packages.
154 usage()
156 cat <<EOF
158 Usage: $0 [options]
159 --help Show this help message.
160 --sysadmin-help Show help for system administrators wishing
161 to build MySQL Cluster Carrier Grade Edition
162 or other MySQL versions.
163 --developer-help Show help for developers trying to build MySQL
164 --with-help Show extended help on --with-xxx options to
165 configure
166 --extended-help Show extended help message
167 --without-debug Build non-debug version
168 --use-comment Set the comment in the build
169 --with-fast-mutexes Use try/retry method of acquiring mutex
170 --with-debug Build debug version
171 --with-debug=full Build with full debug.
172 --with-link-time-optimizer
173 Link time optimizations enabled (Requires GCC 4.5
174 if GCC used), available for icc as well. This flag
175 is only considered if also fast is set.
176 --configure-only Stop after running configure.
177 --use-autotools Start by running autoconf, automake,.. tools
178 --no-autotools Start from configure
179 --print-only Print commands that the script will execute,
180 but do not actually execute
181 --prefix=path Build with prefix 'path'
182 --datadir=path Build with data directory set to non-standard
183 'path'
184 --debug Build normal version, but add debug
185 information to binary
186 --developer Use extensions that most MySQL developers use
187 --no-developer Do not use extensions that most developers of
188 MySQL use
189 --commercial Use commercial libraries
190 --gpl Use gpl libraries
191 --compiler=[gcc|icc|forte|SunStudio] Select compiler
192 --cpu=[x86|x86_64|sparc|itanium] Select CPU type
193 x86 => x86 and 32-bit binary
194 x86_64 => x86 and 64 bit binary
195 --warning-mode=[extra|pedantic|normal|no] Set warning mode level
196 --warnings Set warning mode to normal
197 --32 Build a 32-bit binary even if CPU is 64-bit
198 --64 Build a 64-bit binary even if not sure a
199 64-bit CPU is being used
200 --package=[cge|extended|pro|classic] Select package to build
201 --parallelism=number Define parallelism in make
202 --strip Strip binaries
203 --error-inject Enable error injection into MySQL Server and
204 data nodes
205 --valgrind Build with valgrind
206 --fast Optimise for CPU architecture built on
207 --static-linking Statically link system libraries into binaries
208 --use-tcmalloc Link with tcmalloc instead of standard malloc (Linux only)
209 --with-flags * Pass extra --with-xxx options to configure
211 if test "x$1" != "x" ; then
212 echo "Failure Message: $1"
216 extended_usage()
218 cat <<EOF
220 Extended help text for this script:
221 -----------------------------------
222 This script is intended to make it easier for customers using MySQL
223 Cluster Carrier Grade Edition, customers using performance-optimised
224 MySQL versions and developers to build the product from source on
225 these platforms/compilers: Linux/x86 (32-bit and 64-bit) (either using
226 gcc or icc), Linux Itanium, Solaris 8,9,10 and 11 x86 and SPARC using
227 gcc or SunStudio and MacOSX/x86/gcc.
229 The script automatically detects CPU type and operating system; The
230 default compiler is always gcc.
232 To build on other platforms you can use the --print-only option on a
233 supported platform and edit the output for a proper set of commands on
234 the specific platform you are using. MySQL also provides custom builds
235 for any type of platform that is officially supported for MySQL
236 Cluster. For a list of supported platforms, see
237 http://www.mysql.com/support/supportedplatforms/cluster.html.
239 Using the --package option, it is also possible to build a "classic"
240 version of MySQL having only the MyISAM storage engine, a "Pro"
241 package including all storage engines and other features except MySQL
242 Cluster, and an "extended" package including these features plus MySQL
243 Cluster (this is the default if the --developer option is used).
245 Different MySQL storage engines are included in the build, depending
246 on which --package option is used. The comment and version strong
247 suffix are also set according to the package selected.
249 --package=cge
250 storage engines:
251 ARCHIVE, BLACKHOLE, CSV, FEDERATED, MYISAM, NDB
252 (All storage engines except InnoDB)
253 comment: MySQL Cluster Carrier Grade Edition GPL/Commercial version
254 built from source
255 version string suffix: -cge
257 --package=extended
258 storage engines:
259 ARCHIVE, BLACKHOLE, CSV, FEDERATED, MYISAM, INNODB, NDB
260 (All storage engines)
261 comment: MySQL Cluster Carrier Grade Extended Edition GPL/Commercial
262 version built from source
263 version string suffix: -cge-extended
265 --package=pro
266 storage engines:
267 ARCHIVE, BLACKHOLE, CSV, FEDERATED, INNODB, MYISAM
268 (All storage engines except NDB)
269 comment: MySQL Pro GPL/Commercial version built from
270 source
271 version string suffix: [none]
273 --package=classic
274 storage engines: CSV, MYISAM
275 comment: MySQL Classic GPL/Commercial version built
276 from source
277 version string suffix: [none]
279 All packages except Classic include support for user-defined
280 partitioning.
282 If --with-debug is used, an additional "-debug" is appended to the
283 version string.
285 --commercial
286 This flag prevents the use of GPL libraries which cannot be used
287 under a commercial license, such as the readline library.
289 --with-debug[=full]
290 This option will ensure that the version is built with debug
291 information enabled; the optimisation level is decreased to -O.
293 --developer
294 This option changes a number of things to make the version built
295 more appropriate to the debugging and testing needs of developers.
296 It changes the default package to "extended". It also changes the
297 default warning mode from "none" to "normal", which allows an
298 extensive list of warnings to be generated.
300 --error-inject
301 This flag is used only when the --developer option is also used, and
302 enables error injection in both the MySQL Server and in MySQL
303 Cluster data nodes.
305 The following is a list of the default configure options used for all
306 packages:
308 --prefix: /usr/local/mysql (can be overridden)
310 --libexecdir: <prefix>/bin (can be overridden)
312 --localstatedir: <prefix>/data, unless --datadir is used, in which
313 case it defaults to <datadir>/data (can be overridden by setting
314 --localstatedir explicitly).
316 --enable-local-infile: Enable use of the LOAD DATA FROM LOCAL INFILE
317 command (cannot be overridden).
319 --enable-thread-safe-client: Enable the multi-threaded mysql client
320 library (cannot be overridden).
322 --with-big-tables: Enable use of tables with more than 4G rows (cannot
323 be overridden).
325 --with-extra-charsets=all: Enable use of all character sets supported
326 by MySQL (cannot be overridden).
328 --with-ssl: Enable use of yaSSL library included in the MySQL source
329 if possible (GCC and same CC and CXX).
330 (cannot be overridden).
332 --with-pic: Build all binaries using position independent assembler
333 to avoid problems with dynamic linkers (cannot be overridden).
335 --without-example-engine: Ensure that the example engine isn't built,
336 it cannot do any useful things, it's merely intended as documentation.
337 (cannot be overridden)
339 --with-csv-storage-engine: Ensure that the CSV storage engine is
340 included in all builds. Since CSV is required for log tables in
341 MySQL 5.1, this option cannot be overridden.
343 (Note that MyISAM support is always built into the MySQL Server; the
344 server *cannot* be built without MyISAM.)
346 --with-mysqld-ldflags=-static
347 --with-client-ldflags=-static
348 Ensures that binaries for, respectively, the MySQL server and client
349 are built with static libraries except for the system libraries,
350 which use dynamically loaded libraries provided by the operating
351 system. Building with --developer sets these to all-static instead,
352 to build everything statically.
354 In addition there are some configure options that are specific to
355 Linux operating systems:
357 --enable-assembler
358 Include assembler code optimisations for a number of mostly string
359 methods. Used for x86 processors only.
361 Neither of the preceding options can be disabled.
363 MySQL Cluster Carrier Grade edition also adds the following options
364 (also used by the extended package):
366 --with-ndbcluster
367 Include the NDB Cluster storage engine, its kernel, management
368 server, and client, as well as support for the NDB and MGM APIs.
370 --without-ndb-debug
371 Do not include specific NDB debug code, not even in debug versions
372 (cannot be overridden).
374 Package-specific options:
375 -------------------------
376 --with-innodb
377 Specifically included in the "pro" and "extended" packages, and not
378 in any of the others.
380 --with-comment
381 Sets the comment for the MySQL version, by package, as described
382 above.
384 --with-server-suffix
385 Sets the server suffix on the MySQL version, by package, as
386 described above.
388 Other options used:
389 -------------------
390 --with-readline
391 Use the GPL readline library for command editing functions; not
392 available with commercial packages.
394 --with-libedit
395 Use the BSD licensed library for command editing functions; used for
396 commercial packages.
398 --with-zlib-dir=bundled
399 Use the zlib package bundled with MySQL.
401 --with-mysqld-libs=-lmtmalloc
402 Used on Solaris to ensure that the proper malloc library is used.
403 Investigations have shown mtmalloc to be the best choice on Solaris,
404 also umem has good performance on Solaris but better debugging
405 capabilities.
407 Compiler options:
408 -----------------
410 This section describes the compiler options for each of the different
411 platforms supported by this script.
413 The --fast option adds -mtune=cpu_arg to the C/C++ flags (provides
414 support for Nocona, K8, and other processors).
416 Use of the --debug option adds -g to the C/C++ flags.
418 In all cases it is possible to override the definition of CC and CXX
419 by calling the script as follows:
420 CC="/usr/local/bin/gcc" CXX="/usr/local/bin/gcc" BUILD/build_mccge.sh
422 FreeBSD/x86/gcc
423 ---------------
424 No flags are used. Instead, configure determines the proper flags to
425 use.
427 Linux/x86+Itanium/gcc
428 -------------
429 For debug builds -O is used and otherwise -O3 is used.Discovery of a
430 Nocona or Core 2 Duo CPU causes a 64-bit binary to be built;
431 otherwise, the binary is 32-bit. To build a 64-bit binary, -m64 is
432 added to the C/C++ flags. (To build a 32-bit binary on a 64-bit CPU,
433 use the --32 option as described previously.)
435 Linux/x86+Itanium/icc
436 -------------
437 Flags used:
438 CC = icc -static-libgcc -static-intel
439 C++ = icpc -static-libgcc -static-intel
440 C/C++ flags = -mp -restrict
442 On Itanium we also add -no-ftz and to CC and C++ flags.
444 Note that if the user of this script sets CC or CXX explicitly then
445 also -static-libgcc and -static-intel needs to be set in the CC and
446 CXX.
448 The non-debug versions also add the following:
449 C/C++ flags += -O3 unroll2 -ip
451 The fast version adds (if --with-link-time-optimizer is used):
452 C/C++ flags += -ipo
454 On discovery of a Core 2 Duo architecture while using icc, -xT is also
455 added to the C/C++ flags; this provides optimisations specific to Core
456 2 Duo. This is added only when the --fast flag is set.
458 Solaris/x86/gcc
459 ---------------
460 All builds on Solaris are by default 64-bit, so -m64 is always used in
461 the C/C++ flags. LDFLAGS is set to -m64 -O/-O2/-O3. If for
462 some reason a 32-bit Solaris is used it is necessary to add the flag
463 --32 to the script invocation. Due to bugs in compiling with -O3 on
464 Solaris only -O2 is used by default, when --fast flag is used -O3 will
465 be used instead.
467 Sets -m64 (default) or -m32 (if specifically set) in LDFLAGS and
468 C/C++ flags.
470 Solaris/Sparc/Forte
471 -------------------
472 Uses cc as CC and CC as CXX
473 Note that SunStudio uses different binaries for C and C++ compilers.
475 Set -m64 (default) or -m32 (if specifically set) in ASFLAGS,
476 LDFLAGS and C/C++ flags.
478 Sets ASFLAGS=LDFLAGS=compiler flags=xarch=sparc, so that we compile
479 Sparc v9 binaries, also -mt is set in all those since we're always
480 building a multithreaded program.
482 C flags = -xstrconst This flag is set only on SPARC
483 C++ flags = -noex
485 Set the following C/C++ flags:
486 -fsimple=1
487 -ftrap=%none
488 -nofstore This flag is set only on x86
489 -xbuiltin=%all
490 -xlibmil
491 -xlibmopt
493 Set the C++ flag:
494 -noex
495 -features=no%except This flag is set only on x86
497 When compiling with fast we set (-ipo only used if we have
498 set --with-link-time-optimizer):
499 C/C++ flags: -xtarget=native -xunroll=3 -xipo
500 LDFLAGS: -xipo
502 When not compiling with fast we always set -xtarget=generic
504 When compiling with fast on SPARC we also set:
505 C/C++ flags: -xbinopt=prepare
506 LDFLAGS: -xbinopt=prepare
508 When compiling with fast on x86 we also set:
509 C/C++ flags: -xregs=frameptr
510 When not compiling with fast we set on x86
511 C/C++ flags: -xregs=no%frameptr
513 On SPARC we set
514 ASFLAGS = LDFLAGS = C/C++ flags = -xarch=sparc
516 The optimisation level is
517 -xO Debug builds
518 -xO2 Production build on SPARC
519 -xO3 Production build on x86
520 -xO4 Fast builds on SPARC/x86
522 MacOSX/x86/gcc
523 --------------
524 C/C++ flags include -fno-common -arch i386.
525 When 64-bits builds then i386 is replaced by x86_64.
527 Non-debug versions also add -Os -felide-constructors, where "-Os"
528 means the build is space-optimised as long as the space optimisations
529 do not negatively affect performance. Debug versions use -O.
531 Mac OS X builds will always be 32-bit by default, when --64 is added
532 the build will be 64 bit instead. Thus the flag --m64 is added only
533 when specifically given as an option.
537 with_usage()
539 cat <<EOF
541 To obtain extended help on the --with-* options available, run this
542 script with --configure-only to create a configuration file. Then
543 issue the command ./configure --help to get an extensive list of
544 possible configure options.
546 The remainder of this text focuses on those options which are useful
547 in building binaries for MySQL Cluster Carrier Grade Edition.
549 --with-ndb-sci=/opt/DIS
550 Used to build a MySQL Cluster Carrier Grade Edition that can use the
551 SCI Transporter. The Dolphin SCI installation must be completed
552 first (see
553 http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-interconnects.html
554 for more information).
556 --with-ndb-test
557 Compile the MySQL Cluster test programs.
559 --with-ndb-port=PORT
560 Change the default port for the MySQL Cluster management server.
562 --with-ndb-port-base=PORT
563 Change the default port base for MySQL Cluster data nodes.
565 --without-query-cache
566 Build the MySQL Server without the query cache, which is often not
567 of value in MySQL Cluster applications.
569 --with-atomic-ops=rwlocks|smp|up
570 Implement atomic operations using pthread
571 rwlocks or atomic CPU instructions for
572 multi-processor (default) or single-processor
573 configurations.
575 --without-geometry Do not build geometry-related portions of the
576 MySQL Server. Seldom used in MySQL Cluster
577 applications.
579 --with-ndb-cc-flags=FLAGS
580 This option can be used to build MySQL Cluster with error injection
581 on the data nodes. It can be used to pass special options to
582 programs in the NDB kernel for special test builds.
583 The option for enabling data node error injection is -DERROR_INSERT.
587 parse_package()
589 case "$package" in
590 classic )
591 package="classic"
593 pro )
594 package="pro"
596 extended )
597 package="extended"
599 cge )
600 package="cge"
603 echo "Unknown package '$package'"
604 exit 1
606 esac
609 parse_warning_mode()
611 case "$warning_mode" in
612 pedantic )
613 warning_mode="pedantic"
615 extra_warnings | extra-warnings | extra )
616 warning_mode="extra"
618 no )
619 warning_mode=
621 normal )
622 warning_mode="normal"
625 echo "Unknown warning mode '$warning_mode'"
626 exit 1
628 esac
632 # We currently only support x86, Itanium and UltraSparc processors.
634 parse_cpu_type()
636 case "$cpu_type" in
637 x86 )
638 cpu_type="x86"
639 if test "x$m64" = "x" ; then
640 m64="no"
643 x86_64 )
644 cpu_type="x86"
645 if test "x$m64" = "x" ; then
646 m64="yes"
649 itanium )
650 cpu_type="itanium"
652 sparc )
653 cpu_type="sparc"
656 echo "Unknown CPU type $cpu_type"
657 exit 1
659 esac
660 return
664 # We currently only support gcc, icc and Forte.
666 parse_compiler()
668 case "$compiler" in
669 gcc )
670 compiler="gcc"
672 icc )
673 compiler="icc"
675 forte | SunStudio | sunstudio )
676 compiler="forte"
679 echo "Unknown compiler '$compiler'"
680 exit 1
682 esac
685 parse_options()
687 while test $# -gt 0
689 case "$1" in
690 --prefix=*)
691 prefix=`get_key_value "$1"`
693 --datadir=*)
694 datadir=`get_key_value "$1"`
696 --with-link-time-optimizer)
697 with_link_time_optimizer="yes"
699 --with-debug=full)
700 full_debug="=full"
701 with_debug_flag="yes"
702 fast_flag="no"
704 --without-debug)
705 with_debug_flag="no"
706 if test "x$fast_flag" != "xyes" ; then
707 fast_flag="generic"
710 --use-comment)
711 without_comment="no"
713 --with-fast-mutexes)
714 with_fast_mutexes="yes"
716 --use-tcmalloc)
717 use_tcmalloc="yes"
719 --with-debug)
720 with_debug_flag="yes"
721 fast_flag="no"
723 --debug)
724 compile_debug_flag="yes"
726 --no-developer)
727 developer_flag="no"
729 --developer)
730 developer_flag="yes"
732 --commercial)
733 gpl="no"
735 --gpl)
736 gpl="yes"
738 --compiler=*)
739 compiler=`get_key_value "$1"`
740 parse_compiler
742 --cpu=*)
743 cpu_type=`get_key_value "$1"`
744 parse_cpu_type
746 --warning-mode=*)
747 warning_mode=`get_key_value "$1"`
748 parse_warning_mode
750 --warnings)
751 warning_mode="normal"
753 --32)
754 if test "x$explicit_size_set" != "x" ; then
755 echo "Cannot set both --32 and --64"
756 exit 1
758 explicit_size_set="yes"
759 m64="no"
761 --64)
762 if test "x$explicit_size_set" != "x" ; then
763 echo "Cannot set both --32 and --64"
764 exit 1
766 explicit_size_set="yes"
767 m64="yes"
769 --package=*)
770 package=`get_key_value "$1"`
771 parse_package
773 --parallelism=*)
774 parallelism=`get_key_value "$1"`
776 --use-autotools)
777 use_autotools="yes"
779 --no-autotools)
780 use_autotools="no"
782 --configure-only)
783 just_configure="yes"
785 --print-only)
786 just_print="yes"
788 --static-linking)
789 static_linking_flag="yes"
791 --strip)
792 strip_flag="yes"
794 --error-inject)
795 error_inject_flag="yes"
797 --valgrind)
798 valgrind="yes"
800 --fast)
801 fast_flag="yes"
803 --with-flags)
804 shift
805 break
807 --with-help)
808 with_usage
809 exit 0
811 --sysadmin-help)
812 sysadmin_usage
813 exit 0
815 --developer-help)
816 developer_usage
817 exit 0
819 --extended-help)
820 extended_usage
821 exit 0
823 --help)
824 usage
825 exit 0
828 echo "Unknown option '$1'"
829 exit 1
831 esac
832 shift
833 done
834 for flag in $@
836 with_flags="$with_flags $flag"
837 done
841 # We currently only support Linux, FreeBSD/OpenBSD, Mac OS X and Solaris
843 check_os()
845 case "`uname -s`" in
846 Linux)
847 os="linux"
849 FreeBSD|OpenBSD)
850 os="bsd"
852 Darwin)
853 os="MacOSX"
855 SunOS)
856 os="Solaris"
859 os="Unknown"
861 esac
865 set_cpu_base()
867 if test "x$cpu_type" = "x" ; then
868 if test "x$cpu_arg" = "x" ; then
869 usage "CPU type not discovered, cannot proceed"
870 exit 1
872 case "$cpu_arg" in
873 core2 | nocona | prescott | pentium* | i*86 )
874 # Intel CPU
875 cpu_base_type="x86"
877 athlon* | opteron* | k6 | k8 )
878 # AMD CPU
879 cpu_base_type="x86"
881 sparc )
882 cpu_base_type="sparc"
884 itanium )
885 cpu_base_type="itanium"
888 usage "CPU type $cpu_arg not handled by this script"
889 exit 1
891 esac
892 else
893 cpu_base_type="$cpu_type"
894 check_cpu_cflags=""
896 if test "x$os" = "xMacOSX" ; then
897 if test "x$m64" = "x" ; then
898 m64="no"
900 elif test "x$os" = "xSolaris" ; then
901 if test "x$m64" = "x" ; then
902 m64="yes"
904 elif test "x$m64" = "x" ; then
905 if test "x$cpu_arg" = "xnocona" || test "x$cpu_arg" = "xcore2" || \
906 test "x$cpu_arg" = "xathlon64" || test "x$cpu_arg" = "xopteron" ; then
907 m64="yes"
908 else
909 m64="no"
912 echo "Discovered CPU of type $cpu_base_type ($cpu_arg) on $os"
913 if test "x$m64" = "xyes" ; then
914 echo "Will compile 64-bit binaries"
915 else
916 echo "Will compile 32-bit binaries"
918 return 0
922 # Add to the variable commands with the configure command
924 init_configure_commands()
926 cflags="$c_warnings $base_cflags $compiler_flags"
927 cxxflags="$cxx_warnings $base_cxxflags $compiler_flags"
928 configure="./configure $base_configs $with_flags"
930 env_flags="CC=\"$CC\" CFLAGS=\"$cflags\" CXX=\"$CXX\" CXXFLAGS=\"$cxxflags\""
931 if test "x$LDFLAGS" != "x" ; then
932 env_flags="$env_flags LDFLAGS=\"$LDFLAGS\""
934 if test "x$ASFLAGS" != "x" ; then
935 env_flags="$env_flags ASFLAGS=\"$ASFLAGS\""
937 commands="$commands
938 $env_flags $configure"
942 # Initialise the variable commands with the commands needed to generate
943 # the configure script.
945 init_auto_commands()
947 set_libtoolize_version
948 commands="\
949 $make -k maintainer-clean || true
950 /bin/rm -rf */.deps/*.P configure config.cache
951 /bin/rm -rf storage/*/configure storage/*/config.cache autom4te.cache
952 /bin/rm -rf storage/*/autom4te.cache;"
954 # --add-missing instructs automake to install missing auxiliary files
955 # and --force to overwrite them if they already exist
957 commands="$commands
958 aclocal || die \"Can't execute aclocal\"
959 autoheader || die \"Can't execute autoheader\"
960 $LIBTOOLIZE --automake --copy --force || die \"Can't execute libtoolize\"
961 automake --add-missing --copy --force || die \"Can't execute automake\"
962 autoconf || die \"Can't execute autoconf\""
966 # Add to the variable commands the make command and possibly also
967 # strip commands
969 add_make_commands()
971 AM_MAKEFLAGS="-j $parallelism"
972 commands="$commands
973 $make $AM_MAKEFLAGS"
975 if test "x$strip_flag" = "xyes" ; then
976 commands="$commands
977 mkdir -p tmp
978 nm --numeric-sort sql/mysqld > tmp/mysqld.sym
979 objdump -d sql/mysqld > tmp/mysqld.S
980 strip sql/mysqld
981 strip storage/ndb/src/kernel/ndbd
982 strip storage/ndb/src/mgmsrv/ndb_mgmd
983 strip storage/ndb/src/mgmclient/ndb_mgm"
988 # Set make version, but only gmake is supported :)
990 set_make_version()
992 if gmake --version > /dev/null 2>&1
993 then
994 make=gmake
995 else
996 make=make
998 if test "x`$make --version | grep GNU`" = "x" ; then
999 die "Only gmake is supported"
1004 # Find a libtoolize binary, both libtoolize and glibtoolize are
1005 # ok, use first found.
1007 set_libtoolize_version()
1009 LIBTOOLIZE=not_found
1010 save_ifs="$IFS"; IFS=':'
1011 for dir in $PATH
1013 if test -x $dir/libtoolize
1014 then
1015 LIBTOOLIZE=libtoolize
1016 echo "Found libtoolize in $dir"
1017 break
1019 if test -x $dir/glibtoolize
1020 then
1021 LIBTOOLIZE=glibtoolize
1022 echo "Found glibtoolize in $dir"
1023 break
1025 done
1026 IFS="$save_ifs"
1027 if test "x$LIBTOOLIZE" = "xnot_found" ; then
1028 die "Found no libtoolize version, quitting here"
1030 return
1034 # If ccache (a compiler cache which reduces build time)
1035 # (http://samba.org/ccache) is installed, use it.
1036 # We use 'grep' and hope that 'grep' works as expected
1037 # (returns 0 if finds lines)
1038 # We do not use ccache when gcov is used. Also only when
1039 # gcc is used.
1041 set_ccache_usage()
1043 if test "x$compiler" = "xgcc" ; then
1044 if ccache -V > /dev/null 2>&1 && test "$USING_GCOV" != "1"
1045 then
1046 echo "$CC" | grep "ccache" > /dev/null || CC="ccache $CC"
1047 echo "$CXX" | grep "ccache" > /dev/null || CXX="ccache $CXX"
1053 # Set flags for various build configurations.
1054 # Used in -valgrind builds
1056 set_valgrind_flags()
1058 if test "x$valgrind_flag" = "xyes" ; then
1059 loc_valgrind_flags="-USAFEMALLOC -UFORCE_INIT_OF_VARS -DHAVE_purify "
1060 loc_valgrind_flags="$loc_valgrind_flags -DMYSQL_SERVER_SUFFIX=-valgrind-max"
1061 compiler_flags="$compiler_flags $loc_valgrind_flags"
1062 with_flags="$with_flags --with-valgrind"
1067 # Set up warnings; default is to use no warnings, but if warning_mode
1068 # is used a lot of warning flags are set up. These flags are valid only
1069 # for gcc, so for other compilers we ignore the warning_mode.
1071 set_warning_flags()
1073 if test "x$developer_flag" = "xyes" && test "x$warning_mode" = "x" ; then
1074 warning_mode="normal"
1076 if test "x$compiler" = "xgcc" ; then
1077 if test "x$warning_mode" = "normal" || test "x$warning_mode" = "extra" ; then
1078 # Both C and C++ warnings
1079 warnings="$warnings -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs"
1080 warnings="$warnings -Wcomment -W"
1081 warnings="$warnings -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare"
1082 warnings="$warnings -Wwrite-strings -Wunused-function -Wunused-label"
1083 warnings="$warnings -Wunused-value -Wunused-variable"
1085 if test "x$warning_mode" = "extra" ; then
1086 warnings="$warnings -Wshadow"
1088 # C warnings
1089 c_warnings="$warnings -Wunused-parameter"
1090 # C++ warnings
1091 cxx_warnings="$warnings -Woverloaded-virtual -Wsign-promo -Wreorder"
1092 cxx_warnings="$warnings -Wctor-dtor-privacy -Wnon-virtual-dtor"
1093 # Added unless --with-debug=full
1094 if test "x$full_debug" = "x" ; then
1095 compiler_flags="$compiler_flags -Wuninitialized"
1097 elif test "x$warning_mode" = "xpedantic" ; then
1098 warnings="-W -Wall -ansi -pedantic -Wno-long-long -D_POSIX_SOURCE"
1099 c_warnings="$warnings"
1100 cxx_warnings="$warnings -std=c++98"
1101 # Reset CPU flags (-mtune), they don't work in -pedantic mode
1102 check_cpu_cflags=""
1108 # Used in -debug builds
1110 set_with_debug_flags()
1112 if test "x$with_debug_flag" = "xyes" ; then
1113 if test "x$developer_flag" = "xyes" ; then
1114 loc_debug_flags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS "
1115 loc_debug_flags="$loc_debug_flags -DSAFEMALLOC -DPEDANTIC_SAFEMALLOC"
1116 compiler_flags="$compiler_flags $loc_debug_flags"
1122 # Flag for optimizing builds for developers.
1124 set_no_omit_frame_pointer_for_developers()
1126 if test "x$fast_flag" != "xno" ; then
1127 if test "x$developer_flag" = "xyes" && test "x$compiler" = "xgcc" ; then
1128 # Be as fast as we can be without losing our ability to backtrace.
1129 compiler_flags="$compiler_flags -fno-omit-frame-pointer"
1135 # Add -g to all builds that requested debug information in build
1137 set_debug_flag()
1139 if test "x$compile_debug_flags" = "xyes" ; then
1140 compiler_flags="$compiler_flags -g"
1145 # We compile in SSL support if we can, this isn't possible if CXX
1146 # and CC aren't the same and we're not using GCC.
1148 set_ssl()
1150 if test "x$compiler" = "xgcc" && \
1151 test "x$CC" = "x$CXX" ; then
1152 base_configs="$base_configs --with-ssl"
1157 # Base options used by all packages
1159 # SSL library to use. --with-ssl selects the bundled yaSSL
1160 # implementation of SSL. To use openSSL, you must point out the location
1161 # of the openSSL headers and libs on your system.
1162 # For example: --with-ssl=/usr
1164 set_base_configs()
1166 base_configs="$base_configs --prefix=$prefix"
1167 base_configs="$base_configs --libexecdir=$prefix/bin"
1168 base_configs="$base_configs --with-zlib-dir=bundled"
1169 if test "x$datadir" = "x" ; then
1170 base_configs="$base_configs --localstatedir=$prefix/data"
1171 else
1172 base_configs="$base_configs --localstatedir=$datadir"
1174 if test "x$with_debug_flag" = "xyes" ; then
1175 base_configs="$base_configs --with-debug$full_debug"
1177 base_configs="$base_configs --enable-local-infile"
1178 base_configs="$base_configs --enable-thread-safe-client"
1179 base_configs="$base_configs --with-big-tables"
1180 base_configs="$base_configs --with-extra-charsets=all"
1181 if test "x$with_fast_mutexes" = "xyes" ; then
1182 base_configs="$base_configs --with-fast-mutexes"
1184 base_configs="$base_configs --with-pic"
1185 base_configs="$base_configs --with-csv-storage-engine"
1186 base_configs="$base_configs --with-perfschema"
1190 # Add all standard engines and partitioning (included as part of MySQL
1191 # Cluster storage engine as well) as part of MySQL Server. These are
1192 # added in all packages except the classic package.
1194 set_base_engines()
1196 engine_configs="--with-archive-storage-engine"
1197 engine_configs="$engine_configs --with-blackhole-storage-engine"
1198 engine_configs="$engine_configs --without-example-storage-engine"
1199 engine_configs="$engine_configs --with-federated-storage-engine"
1200 engine_configs="$engine_configs --with-partition"
1201 base_configs="$base_configs $engine_configs"
1204 set_innodb_engine()
1206 base_configs="$base_configs --with-innodb"
1209 set_ndb_engine()
1211 base_configs="$base_configs --with-ndbcluster"
1212 base_configs="$base_configs --without-ndb-debug"
1215 set_pro_package()
1217 if test "x$without_comment" != "xyes" ; then
1218 base_configs="$base_configs --with-comment=\"MySQL Enterprise Pro $version_text built from source\""
1220 if test "x$with_debug_flag" = "xyes" ; then
1221 base_configs="$base_configs --with-server-suffix=\"-debug\""
1225 set_cge_extended_package()
1227 if test "x$without_comment" != "xyes" ; then
1228 base_configs="$base_configs --with-comment=\"MySQL Cluster Carrier Grade Extended Edition $version_text built from source\""
1230 if test "x$with_debug_flag" = "xyes" ; then
1231 base_configs="$base_configs --with-server-suffix=\"-cge-extended-debug\""
1232 else
1233 base_configs="$base_configs --with-server-suffix=\"-cge-extended\""
1237 set_cge_package()
1239 if test "x$without_comment" != "xyes" ; then
1240 base_configs="$base_configs --with-comment=\"MySQL Cluster Carrier Grade Edition $version_text built from source\""
1242 if test "x$with_debug_flag" = "xyes" ; then
1243 base_configs="$base_configs --with-server-suffix=\"-cge-debug\""
1244 else
1245 base_configs="$base_configs --with-server-suffix=\"-cge\""
1249 set_classic_package()
1251 if test "x$without_comment" != "xyes" ; then
1252 base_configs="$base_configs --with-comment=\"MySQL Classic $version_text built from source\""
1254 if test "x$with_debug_flag" = "xyes" ; then
1255 base_configs="$base_configs --with-server-suffix=\"-debug\""
1257 base_configs="$base_configs --without-example-storage-engine"
1261 # Special handling of readline; use readline from the MySQL
1262 # distribution if building a GPL version, otherwise use libedit.
1264 set_readline_package()
1266 if test -d "$path/../cmd-line-utils/readline" && test "x$gpl" = "xyes" ; then
1267 base_configs="$base_configs --with-readline"
1268 elif test -d "$path/../cmd-line-utils/libedit" ; then
1269 base_configs="$base_configs --with-libedit"
1274 # If fast flag set by user we also add architecture as discovered to
1275 # compiler flags to make binary optimised for architecture at hand.
1276 # We use this feature on gcc compilers.
1278 set_gcc_special_options()
1280 if test "x$fast_flag" = "xyes" && test "x$compiler" = "xgcc" ; then
1281 compiler_flags="$compiler_flags $check_cpu_cflags"
1285 set_cc_and_cxx_for_gcc()
1287 if test "x$CC" = "x" ; then
1288 CC="gcc -static-libgcc -fno-exceptions"
1290 if test "x$CXX" = "x" ; then
1291 CXX="gcc -static-libgcc -fno-exceptions"
1295 set_cc_and_cxx_for_icc()
1297 if test "x$CC" = "x" ; then
1298 CC="icc -static-intel -static-libgcc"
1300 if test "x$CXX" = "x" ; then
1301 CXX="icpc -static-intel -static-libgcc"
1305 set_cc_and_cxx_for_forte()
1307 if test "x$CC" = "x" ; then
1308 CC="cc"
1310 if test "x$CXX" = "x" ; then
1311 CXX="CC"
1316 # If we discover a Core 2 Duo architecture and we have enabled the fast
1317 # flag, we enable a compile especially optimised for Core 2 Duo. This
1318 # feature is currently available on Intel's icc compiler only.
1320 set_icc_special_options()
1322 if test "x$fast_flag" = "xyes" && test "x$cpu_arg" = "xcore2" && \
1323 test "x$compiler" = "xicc" ; then
1324 compiler_flags="$compiler_flags -xT"
1329 # FreeBSD Section
1331 set_bsd_configs()
1333 if test "x$cpu_base_type" != "xx86" ; then
1334 usage "Only x86 CPUs supported for FreeBSD"
1335 exit 1
1337 if test "x$compiler" != "xgcc" ; then
1338 usage "Only gcc supported for FreeBSD"
1339 exit 1
1341 base_configs="$base_configs --enable-assembler"
1342 if test "x$fast_flag" != "xno" ; then
1343 compiler_flags="$compiler_flags -O3"
1344 else
1345 compiler_flags="$compiler_flags -O0"
1347 set_cc_and_cxx_for_gcc
1350 check_64_bits()
1352 echo "Checking for 32/64-bits compilation"
1353 echo "int main() { return 0; }" > temp_test.c
1354 if test "x$m64" = "xyes" ; then
1355 cmd="$CC $compile_flags -m64 temp_test.c"
1356 if ! $cmd 2>1 ; then
1357 m64="no"
1358 echo "Changing to 32-bits since 64-bits didn't work"
1359 else
1360 echo "Will use 64-bits"
1362 else
1363 cmd="$CC $compile_flags -m32 temp_test.c"
1364 if ! $cmd 2>1 ; then
1365 m64="yes"
1366 echo "Changing to 64-bits since 32-bits didn't work"
1367 else
1368 echo "Will use 32-bits"
1371 rm temp_test.c
1375 # Get GCC version
1377 get_gcc_version()
1379 # check if compiler is gcc and dump its version
1380 cc_verno=`$cc -dumpversion 2>/dev/null`
1381 if test "x$?" = "x0" ; then
1382 set -- `echo $cc_verno | tr '.' ' '`
1383 cc_ver="GCC"
1384 cc_major=$1
1385 cc_minor=$2
1386 cc_patch=$3
1387 gcc_version=`expr $cc_major '*' 100 '+' $cc_minor`
1392 # Link Time Optimizer in GCC (LTO) uses a parameter -flto
1393 # which was added to GCC 4.5, if --with-link-time-optimizer
1394 # is set then use this feature
1396 check_for_link_time_optimizer()
1398 get_gcc_version
1399 if test "$gcc_version" -ge 405 && \
1400 test "x$with_link_time_optimizer" = "xyes" ; then
1401 compiler_flags="$compiler_flags -flto"
1402 LDFLAGS="$LDFLAGS -flto"
1406 # Linux Section
1408 set_linux_configs()
1410 if test "x$cpu_base_type" != "xx86" && \
1411 test "x$cpu_base_type" != "xitanium" ; then
1412 usage "Only x86 and Itanium CPUs supported for Linux"
1413 exit 1
1415 if test "x$use_tcmalloc" = "xyes" ; then
1416 base_configs="$base_configs --with-mysqld-libs=-ltcmalloc_minimal"
1418 if test "x$cpu_base_type" = "xx86" ; then
1419 base_configs="$base_configs --enable-assembler"
1421 if test "x$compiler" = "xgcc" ; then
1422 set_cc_and_cxx_for_gcc
1423 if test "x$fast_flag" != "xno" ; then
1424 if test "x$fast_flag" = "xyes" ; then
1425 compiler_flags="$compiler_flags -O3"
1426 check_for_link_time_optimizer
1427 else
1428 compiler_flags="$compiler_flags -O2"
1430 else
1431 compiler_flags="$compiler_flags -O0"
1433 check_64_bits
1434 if test "x$m64" = "xyes" ; then
1435 compiler_flags="$compiler_flags -m64"
1436 else
1437 compiler_flags="$compiler_flags -m32"
1439 # configure will set proper compiler flags for gcc on Linux
1440 elif test "x$compiler" = "xicc" ; then
1441 compiler_flags="$compiler_flags -mp -restrict"
1442 set_cc_and_cxx_for_icc
1443 if test "x$cpu_base_type" = "xitanium" ; then
1444 compiler_flags="$compiler_flags -no-ftz"
1446 if test "x$fast_flag" != "xno" ; then
1447 compiler_flags="$compiler_flags -O3 -unroll2 -ip"
1448 if test "x$fast_flag" = "xyes" && \
1449 test "x$with_link_time_optimizer" = "xyes" ; then
1450 compiler_flags="$compiler_flags -ipo"
1451 LDFLAGS="$LDFLAGS -ipo"
1454 else
1455 usage "Only gcc and icc compilers supported for Linux"
1456 exit 1
1461 # Solaris Section
1463 set_solaris_configs()
1465 # Use mtmalloc as malloc, see Tim Cook blog
1466 # For information on optimal compiler settings, see article at
1467 # http://developers.sun.com/solaris/articles/mysql_perf_tune.html
1468 # by Luojia Chen at Sun.
1469 base_configs="$base_configs --with-named-curses=-lcurses"
1470 case "`uname -a`" in
1471 *5.8* | *5.9* )
1474 *5.10* | *5.11*)
1475 base_configs="$base_configs --with-mysqld-libs=-lmtmalloc"
1478 usage "Only versions 8,9, 10 and 11 supported for Solaris"
1479 exit 1
1480 esac
1481 if test "x$cpu_base_type" != "xx86" && \
1482 test "x$cpu_base_type" != "xsparc" ; then
1483 usage "Only x86 and Sparc CPUs supported for Solaris"
1484 exit 1
1486 if test "x$compiler" != "xgcc" && \
1487 test "x$compiler" != "xforte" ; then
1488 usage "Only gcc and Forte compilers supported for Solaris"
1489 exit 1
1491 if test "x$m64" = "xyes" ; then
1492 compiler_flags="$compiler_flags -m64"
1493 LDFLAGS="-m64"
1494 ASFLAGS="$ASFLAGS -m64"
1495 else
1496 compiler_flags="$compiler_flags -m32"
1497 LDFLAGS="-m32"
1498 ASFLAGS="$ASFLAGS -m32"
1500 if test "x$compiler" = "xgcc" ; then
1501 set_cc_and_cxx_for_gcc
1502 if test "x$cpu_base_type" != "xx86" ; then
1503 usage "gcc currently not supported for Solaris on SPARC"
1504 exit 1
1506 if test "x$fast_flag" = "xyes" ; then
1507 LDFLAGS="$LDFLAGS -O3"
1508 compiler_flags="$compiler_flags -O3"
1509 check_for_link_time_optimizer
1510 else
1511 if test "x$fast_flag" = "xgeneric" ; then
1512 LDFLAGS="$LDFLAGS -O2"
1513 compiler_flags="$compiler_flags -O2"
1514 else
1515 LDFLAGS="$LDFLAGS -O0"
1516 compiler_flags="$compiler_flags -O0"
1519 else
1520 #Using Forte compiler (SunStudio)
1521 set_cc_and_cxx_for_forte
1522 compiler_flags="$compiler_flags -mt"
1523 LDFLAGS="$LDFLAGS -mt"
1524 compiler_flags="$compiler_flags -fsimple=1"
1525 compiler_flags="$compiler_flags -ftrap=%none"
1526 compiler_flags="$compiler_flags -xbuiltin=%all"
1527 compiler_flags="$compiler_flags -xlibmil"
1528 compiler_flags="$compiler_flags -xlibmopt"
1529 if test "x$fast_flag" = "xyes" ; then
1530 compiler_flags="$compiler_flags -xtarget=native"
1531 compiler_flags="$compiler_flags -xunroll=3"
1532 if test "x$with_link_time_optimizer" = "xyes" ; then
1533 compiler_flags="$compiler_flags -xipo"
1534 LDFLAGS="$LDFLAGS -xipo"
1536 else
1537 compiler_flags="$compiler_flags -xtarget=generic"
1539 if test "x$cpu_base_type" = "xx86" ; then
1540 compiler_flags="$compiler_flags -nofstore"
1541 base_cxx_flags="$base_cxx_flags -features=no%except"
1542 if test "x$fast_flag" = "xyes" ; then
1543 compiler_flags="$compiler_flags -xregs=frameptr"
1544 compiler_flags="$compiler_flags -xO4"
1545 else
1546 compiler_flags="$compiler_flags -xregs=no%frameptr"
1547 if test "x$fast_flag" = "xgeneric" ; then
1548 compiler_flags="$compiler_flags -xO2"
1549 else
1550 compiler_flags="$compiler_flags -xO0"
1553 else
1554 #Using SPARC cpu with SunStudio (Forte) compiler
1555 ASFLAGS="$ASFLAGS -xarch=sparc"
1556 LDFLAGS="$LDFLAGS -xarch=sparc"
1557 base_cxxflags="$base_cxxflags -noex"
1558 base_cflags="$base_cflags -xstrconst"
1559 compiler_flags="$compiler_flags -xarch=sparc"
1560 if test "x$fast_flag" = "xyes" ; then
1561 compiler_flags="$compiler_flags -xbinopt=prepare"
1562 LDFLAGS="$LDFLAGS -xbinopt=prepare"
1563 compiler_flags="$compiler_flags -xO4"
1564 elif test "x$fast_flag" = "xgeneric" ; then
1565 compiler_flags="$compiler_flags -xO3"
1566 else
1567 compiler_flags="$compiler_flags -xO0"
1574 # Mac OS X Section
1576 set_macosx_configs()
1578 if test "x$cpu_base_type" != "xx86" || test "x$compiler" != "xgcc" ; then
1579 usage "Only gcc/x86 supported for Mac OS X"
1580 exit 1
1583 # Optimize for space as long as it doesn't affect performance, use some
1584 # optimisations also when not in fast mode.
1586 base_cxxflags="$base_cxxflags -felide-constructors"
1587 compiler_flags="$compiler_flags -fno-common"
1588 if test "x$m64" = "xyes" ; then
1589 compiler_flags="$compiler_flags -m64"
1590 compiler_flags="$compiler_flags -arch x86_64"
1591 else
1592 compiler_flags="$compiler_flags -m32"
1593 compiler_flags="$compiler_flags -arch i386"
1595 if test "x$fast_flag" != "xno" ; then
1596 compiler_flags="$compiler_flags -Os"
1597 else
1598 compiler_flags="$compiler_flags -O0"
1600 set_cc_and_cxx_for_gcc
1604 # Use static linking for own modules and dynamic linking for system
1605 # modules unless specifically requested to do everything statically.
1606 # Should normally not be used; static_linking_flag kept in case someone
1607 # really needs it. Available only if developer flag is also set.
1609 set_static_link_configs()
1611 if test "x$static_linking_flag" = "xyes" && test "x$developer_flag" = "xyes" ; then
1612 loc_static_link="--with-mysqld-ldflags=\"-all-static\""
1613 loc_static_link="$loc_static_link --with-client-ldflags=\"-all-static\""
1614 else
1615 loc_static_link="--with-mysqld-ldflags=\"-static\""
1616 loc_static_link="$loc_static_link --with-client-ldflags=\"-static\""
1618 base_configs="$base_configs $loc_static_link"
1622 # Enable error injection in MySQL Server (for developer build only -
1623 # extra check for developer flag required).
1625 set_error_inject_configs()
1627 if test "x$error_inject_flag" = "xyes" && test "x$developer_flag" = "xyes" ; then
1628 base_configs="$base_configs --with-error-inject"
1629 if test "x$package" = "xndb" || test "x$package" = "xextended" ; then
1630 base_configs="$base_configs --with-ndb-ccflags='-DERROR_INSERT'"
1635 set_default_package()
1637 if test "x$package" = "x" ; then
1638 if test "x$developer_flag" = "xyes" ; then
1639 package="extended"
1640 else
1641 package="cge"
1646 set_autotool_flags()
1648 if test "x$use_autotools" = "x" ; then
1649 if test "x$developer_flag" = "xno" ; then
1650 use_autotools="no"
1651 else
1652 use_autotools="yes"
1657 set_defaults_based_on_environment()
1659 if test ! -z "$MYSQL_DEVELOPER" ; then
1660 developer_flag="yes"
1662 if test ! -z "$MYSQL_DEVELOPER_DEBUG" ; then
1663 with_debug_flag="yes"
1664 fast_flag="no"
1666 if test ! -z "$MYSQL_DEVELOPER_PACKAGE" ; then
1667 package="$MYSQL_DEVELOPER_PACKAGE"
1668 parse_package
1672 ########################################################################
1674 if test ! -f sql/mysqld.cc ; then
1675 die "You must run this script from the MySQL top-level directory"
1678 cpu_type=
1679 package=
1680 prefix="/usr/local/mysql"
1681 parallelism="8"
1682 fast_flag="generic"
1683 compiler="gcc"
1684 gpl="yes"
1685 version_text=
1686 developer_flag="no"
1687 just_configure=
1688 full_debug=
1689 warning_mode=
1690 with_flags=
1691 error_inject_flag=
1692 with_debug_flag=
1693 compile_debug_flag=
1694 strip_flag=
1695 valgrind_flag=
1696 static_linking_flag=
1697 compiler_flags=
1699 cpu_base_type=
1700 warnings=
1701 c_warnings=
1702 cflags=
1703 base_cflags=
1704 cxx_warnings=
1705 base_cxxflags=
1706 base_configs=
1707 debug_flags=
1708 cxxflags=
1709 m64=
1710 explicit_size_set=
1711 datadir=
1712 commands=
1713 use_autotools=
1714 engine_configs=
1715 ASFLAGS=
1716 LDFLAGS=
1717 use_tcmalloc=
1718 without_comment="yes"
1719 with_fast_mutexes=
1720 with_link_time_optimizer=
1721 gcc_version="0"
1723 set_defaults_based_on_environment
1725 parse_options "$@"
1727 set_autotool_flags
1728 set_default_package
1730 set -e
1733 # Check for the CPU and set up CPU specific flags. We may reset them
1734 # later.
1735 # This call sets the cpu_arg and check_cpu_args parameters
1737 path=`dirname $0`
1738 if test "x$compiler" = "xgcc" ; then
1739 compiler=
1741 . "$path/check-cpu"
1742 if test "x$compiler" = "x" ; then
1743 compiler="gcc"
1745 check_os
1746 set_cpu_base
1747 if test "x$?" = "x1" ; then
1748 exit 1
1752 # Set up c_warnings and cxx_warnings; add to compiler_flags.
1753 # Possibly reset check_cpu_flags.
1755 set_warning_flags
1758 # Add to compiler_flags.
1760 set_valgrind_flags
1761 set_with_debug_flags
1762 set_no_omit_frame_pointer_for_developers
1763 set_debug_flag
1764 set_gcc_special_options
1765 set_icc_special_options
1768 # Definitions of various packages possible to compile. The default is to
1769 # build a source variant of MySQL Cluster Carrier Grade Edition
1770 # including all storage engines except InnoDB, and to use GPL libraries.
1772 set_base_configs
1773 if test "x$gpl" = "xyes" ; then
1774 version_text="GPL version"
1775 else
1776 version_text="Commercial version"
1778 if test "x$package" = "xpro" ; then
1779 set_base_engines
1780 set_innodb_engine
1781 set_pro_package
1782 elif test "x$package" = "xextended" ; then
1783 set_base_engines
1784 set_ndb_engine
1785 set_innodb_engine
1786 set_cge_extended_package
1787 elif test "x$package" = "xcge" ; then
1788 set_base_engines
1789 set_ndb_engine
1790 set_cge_package
1791 elif test "x$package" = "xclassic" ; then
1792 set_classic_package
1793 else
1794 die "No supported package was used, internal error"
1796 set_readline_package
1797 set_static_link_configs
1798 set_error_inject_configs
1801 # This section handles flags for specific combinations of compilers,
1802 # operating systems, and processors.
1805 if test "x$os" = "xlinux" ; then
1806 set_linux_configs
1807 elif test "x$os" = "xSolaris" ; then
1808 set_solaris_configs
1809 elif test "x$os" = "xMacOSX" ; then
1810 set_macosx_configs
1811 elif test "x$os" = "xbsd" ; then
1812 set_bsd_configs
1813 else
1814 die "Operating system not supported by this script"
1816 set_ssl
1818 # Final step before setting up commands is to set up proper make and
1819 # proper libtoolize versions, and to determine whether to use ccache.
1821 set_make_version
1822 set_ccache_usage
1825 # Set up commands variable from variables prepared for base
1826 # configurations, compiler flags, and warnings flags.
1828 if test "x$use_autotools" = "xyes" ; then
1829 init_auto_commands
1831 init_configure_commands
1833 if test "x$just_configure" != "xyes" ; then
1834 add_make_commands
1838 # The commands variable now contains the entire command to be run for
1839 # the build; we either execute it, or merely print it out.
1841 if test "x$just_print" = "xyes" ; then
1842 echo "$commands"
1843 else
1844 eval "set -x; $commands"