124
# Valid values are: darwin,fedora,rhel,ubuntu
125
set_VENDOR_DISTRIBUTION ()
154
# Validate the distribution name, or toss an erro
155
# values: darwin,fedora,rhel,ubuntu,debian,opensuse
156
function set_VENDOR_DISTRIBUTION ()
127
158
local dist=`echo "$1" | tr '[A-Z]' '[a-z]'`
150
set_VENDOR_RELEASE ()
187
# Validate a Vendor's release name/number
188
function set_VENDOR_RELEASE ()
152
190
local release=`echo "$1" | tr '[A-Z]' '[a-z]'`
153
case "$VENDOR_DISTRIBUTION" in
193
echo "VENDOR_DISTRIBUTION:$VENDOR_DISTRIBUTION"
194
echo "VENDOR_RELEASE:$release"
197
case $VENDOR_DISTRIBUTION in
155
VENDOR_RELEASE='mountain'
201
VENDOR_RELEASE='snow_leopard'
204
VENDOR_RELEASE='mountain'
207
VENDOR_RELEASE='mountain'
211
VENDOR_RELEASE='mountain_lion'
215
VENDOR_RELEASE='unknown'
158
220
VENDOR_RELEASE="$release"
221
if [[ "x$VENDOR_RELEASE" == '18' ]]; then
222
VENDOR_RELEASE='sphericalcow'
161
226
VENDOR_RELEASE="$release"
229
VENDOR_RELEASE="$release"
164
232
VENDOR_RELEASE="$release"
233
if [[ "x$VENDOR_RELEASE" == 'x12.04' ]]; then
234
VENDOR_RELEASE="precise"
235
elif [[ "x$VENDOR_RELEASE" == 'x12.10' ]]; then
236
VENDOR_RELEASE="quantal"
167
240
VENDOR_RELEASE="$release"
179
# Valid values are: apple, redhat, centos, canonical
252
# Valid values are: apple, redhat, centos, canonical, oracle, suse
253
function set_VENDOR ()
182
255
local vendor=`echo "$1" | tr '[A-Z]' '[a-z]'`
205
296
set_VENDOR_DISTRIBUTION $2
206
297
set_VENDOR_RELEASE $3
299
# Set which vendor/versions we trust for autoreconf
300
case $VENDOR_DISTRIBUTION in
302
if [[ "x$VENDOR_RELEASE" == 'x18' ]]; then
303
AUTORECONF_REBUILD_HOST=true
304
elif [[ "x$VENDOR_RELEASE" == 'xsphericalcow' ]]; then
305
AUTORECONF_REBUILD_HOST=true
306
elif [[ "x$VENDOR_RELEASE" == 'x19' ]]; then
307
AUTORECONF_REBUILD_HOST=true
311
if [[ "x$VENDOR_RELEASE" == 'xprecise' ]]; then
312
AUTORECONF_REBUILD_HOST=true
313
elif [[ "x$VENDOR_RELEASE" == 'xquantal' ]]; then
314
AUTORECONF_REBUILD_HOST=true
209
determine_target_platform ()
321
function determine_target_platform ()
211
323
UNAME_MACHINE_ARCH=`(uname -m) 2>/dev/null` || UNAME_MACHINE_ARCH=unknown
212
324
UNAME_KERNEL=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
213
325
UNAME_KERNEL_RELEASE=`(uname -r) 2>/dev/null` || UNAME_KERNEL_RELEASE=unknown
215
if [[ $(uname) == 'Darwin' ]]; then
327
if [[ -x '/usr/bin/sw_vers' ]]; then
328
local _VERSION=`/usr/bin/sw_vers -productVersion`
329
set_VENDOR 'apple' 'darwin' $_VERSION
330
elif [[ $(uname) == 'Darwin' ]]; then
216
331
set_VENDOR 'apple' 'darwin' 'mountain'
217
332
elif [[ -f '/etc/fedora-release' ]]; then
218
333
local fedora_version=`cat /etc/fedora-release | awk ' { print $3 } '`
219
334
set_VENDOR 'redhat' 'fedora' $fedora_version
220
if [[ "x$VENDOR_RELEASE" == 'x17' ]]; then
221
AUTORECONF_REBUILD_HOST=true
223
335
elif [[ -f '/etc/centos-release' ]]; then
224
336
local centos_version=`cat /etc/centos-release | awk ' { print $7 } '`
225
337
set_VENDOR 'centos' 'rhel' $centos_version
229
341
set_VENDOR 'suse' $suse_distribution $suse_version
230
342
elif [[ -f '/etc/redhat-release' ]]; then
231
343
local rhel_version=`cat /etc/redhat-release | awk ' { print $7 } '`
232
set_VENDOR 'redhat' 'rhel' $rhel_version
344
local _vendor=`rpm -qf /etc/redhat-release`
345
set_VENDOR $_vendor 'rhel' $rhel_version
346
elif [[ -f '/etc/os-release' ]]; then
347
source '/etc/os-release'
348
set_VENDOR $ID $ID $VERSION_ID
349
elif [[ -x '/usr/bin/lsb_release' ]]; then
350
local _ID=`/usr/bin/lsb_release -s -i`
351
local _VERSION=`/usr/bin/lsb_release -s -r`
352
set_VENDOR $_ID $_ID $_VERSION_ID
233
353
elif [[ -f '/etc/lsb-release' ]]; then
234
local debian_DISTRIB_ID=`cat /etc/lsb-release | grep DISTRIB_ID | awk -F= ' { print $2 } '`
235
local debian_version=`cat /etc/lsb-release | grep DISTRIB_CODENAME | awk -F= ' { print $2 } '`
236
set_VENDOR 'canonical' $debian_DISTRIB_ID $debian_version
237
if [[ "x$VENDOR_RELEASE" == 'xprecise' ]]; then
238
AUTORECONF_REBUILD_HOST=true
354
source '/etc/lsb-release'
355
set_VENDOR 'canonical' $DISTRIB_ID $DISTRIB_CODENAME
361
function run_configure ()
247
363
# We will run autoreconf if we are required
248
364
run_autoreconf_if_required
262
382
# Arguments for configure
265
# Set ENV DEBUG in order to enable debugging
267
CONFIGURE_ARG='--enable-debug'
270
# Set ENV ASSERT in order to enable assert
271
if [[ -n "$ASSERT" ]]; then
273
ASSERT_ARG='--enable-assert'
274
CONFIGURE_ARG="$ASSERT_ARG $CONFIGURE_ARG"
383
local BUILD_CONFIGURE_ARG=
385
# If ENV DEBUG is set we enable both debug and asssert, otherwise we see if this is a VCS checkout and if so enable assert
386
# Set ENV ASSERT in order to enable assert.
387
# If we are doing a valgrind run, we always compile with assert disabled
388
if $valgrind_run; then
389
BUILD_CONFIGURE_ARG+= " CXXFLAGS=-DNDEBUG "
390
BUILD_CONFIGURE_ARG+= " CFLAGS=-DNDEBUG "
393
BUILD_CONFIGURE_ARG+=' --enable-debug --enable-assert'
394
elif [[ -n "$VCS_CHECKOUT" ]]; then
395
BUILD_CONFIGURE_ARG+=' --enable-assert'
399
if [[ -n "$CONFIGURE_ARG" ]]; then
400
BUILD_CONFIGURE_ARG+=" $CONFIGURE_ARG"
403
if [[ -n "$PREFIX_ARG" ]]; then
404
BUILD_CONFIGURE_ARG+=" $PREFIX_ARG"
277
408
# If we are executing on OSX use CLANG, otherwise only use it if we find it in the ENV
280
CC=clang CXX=clang++ $top_srcdir/configure $CONFIGURE_ARG || die "Cannot execute CC=clang CXX=clang++ $top_srcdir/configure $CONFIGURE_ARG $PREFIX_ARG"
411
CC=clang CXX=clang++ $top_srcdir/configure $BUILD_CONFIGURE_ARG || die "Cannot execute CC=clang CXX=clang++ configure $BUILD_CONFIGURE_ARG"
283
command_exists gcc44 || die "Could not locate gcc44"
284
CC=gcc44 CXX=gcc44 $top_srcdir/configure $CONFIGURE_ARG $PREFIX_ARG || die "Cannot execute CC=gcc44 CXX=gcc44 $top_srcdir/configure $CONFIGURE_ARG $PREFIX_ARG"
415
command_exists 'gcc44' || die "Could not locate gcc44"
416
CC=gcc44 CXX=gcc44 $top_srcdir/configure $BUILD_CONFIGURE_ARG || die "Cannot execute CC=gcc44 CXX=gcc44 configure $BUILD_CONFIGURE_ARG"
287
$top_srcdir/configure $CONFIGURE_ARG $PREFIX_ARG || die "Cannot execute configure $CONFIGURE_ARG $PREFIX_ARG"
420
$CONFIGURE $BUILD_CONFIGURE_ARG
425
if [ $ret -ne 0 ]; then
426
die "Could not execute $CONFIGURE $BUILD_CONFIGURE_ARG"
291
429
if [ ! -f 'Makefile' ]; then
292
die "Programmer error, configure was run but no Makefile existed afterward"
430
die "Programmer error, configure was run but no Makefile existed after $CONFIGURE was run"
296
setup_gdb_command () {
434
function setup_gdb_command () {
297
435
GDB_TMPFILE=$(mktemp /tmp/gdb.XXXXXXXXXX)
298
436
echo 'set logging overwrite on' > $GDB_TMPFILE
299
437
echo 'set logging on' >> $GDB_TMPFILE
304
442
GDB_COMMAND="gdb -f -batch -x $GDB_TMPFILE"
307
setup_valgrind_command () {
445
function setup_valgrind_command () {
308
446
VALGRIND_PROGRAM=`type -p valgrind`
309
447
if [[ -n "$VALGRIND_PROGRAM" ]]; then
310
VALGRIND_COMMAND="$VALGRIND_PROGRAM --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE"
316
if [[ -n "$PREFIX_ARG" ]]; then
317
OLD_PREFIX_ARG=$PREFIX_ARG
321
if [[ -n "$1" ]]; then
322
PREFIX_ARG="--prefix=$1"
328
if [[ -n "$OLD_PREFIX_ARG" ]]; then
329
PREFIX_ARG=$OLD_TESTS_ENVIRONMENT
336
push_TESTS_ENVIRONMENT ()
448
VALGRIND_COMMAND="$VALGRIND_PROGRAM --error-exitcode=1 --leak-check=yes --show-reachable=yes --malloc-fill=A5 --free-fill=DE --xml=yes --xml-file=\"valgrind-%p.xml\""
452
function save_BUILD ()
454
if [[ -n "$OLD_CONFIGURE" ]]; then
455
die "OLD_CONFIGURE($OLD_CONFIGURE) was set on push, programmer error!"
458
if [[ -n "$OLD_CONFIGURE_ARG" ]]; then
459
die "OLD_CONFIGURE_ARG($OLD_CONFIGURE_ARG) was set on push, programmer error!"
462
if [[ -n "$OLD_PREFIX" ]]; then
463
die "OLD_PREFIX($OLD_PREFIX) was set on push, programmer error!"
466
if [[ -n "$OLD_MAKE" ]]; then
467
die "OLD_MAKE($OLD_MAKE) was set on push, programmer error!"
338
470
if [[ -n "$OLD_TESTS_ENVIRONMENT" ]]; then
339
die "OLD_TESTS_ENVIRONMENT was set on push, programmer error!"
471
die "OLD_TESTS_ENVIRONMENT($OLD_TESTS_ENVIRONMENT) was set on push, programmer error!"
474
if [[ -n "$CONFIGURE" ]]; then
475
OLD_CONFIGURE=$CONFIGURE
478
if [[ -n "$CONFIGURE_ARG" ]]; then
479
OLD_CONFIGURE_ARG=$CONFIGURE_ARG
482
if [[ -n "$MAKE" ]]; then
342
486
if [[ -n "$TESTS_ENVIRONMENT" ]]; then
343
487
OLD_TESTS_ENVIRONMENT=$TESTS_ENVIRONMENT
348
pop_TESTS_ENVIRONMENT ()
491
function restore_BUILD ()
493
if [[ -n "$OLD_CONFIGURE" ]]; then
494
CONFIGURE=$OLD_CONFIGURE
497
if [[ -n "$OLD_CONFIGURE_ARG" ]]; then
498
CONFIGURE_ARG=$OLD_CONFIGURE_ARG
501
if [[ -n "$OLD_PREFIX" ]]; then
502
PREFIX_ARG=$OLD_PREFIX
505
if [[ -n "$OLD_MAKE" ]]; then
351
509
if [[ -n "$OLD_TESTS_ENVIRONMENT" ]]; then
352
510
TESTS_ENVIRONMENT=$OLD_TESTS_ENVIRONMENT
353
OLD_TESTS_ENVIRONMENT=
517
OLD_TESTS_ENVIRONMENT=
357
522
function safe_pushd ()
415
577
TESTS_ENVIRONMENT="$VALGRIND_COMMAND"
418
make_target 'check' || return 1
420
pop_TESTS_ENVIRONMENT
583
# If we aren't going to error, we will clean up our environment
584
if [ "$ret" -eq 0 ]; then
592
if [ "$ret" -ne 0 ]; then
423
597
function make_install_system ()
425
599
local INSTALL_LOCATION=$(mktemp -d /tmp/XXXXXXXXXX)
426
push_PREFIX_ARG $INSTALL_LOCATION
602
PREFIX_ARG="--prefix=$INSTALL_LOCATION"
428
604
if [ ! -d $INSTALL_LOCATION ] ; then
429
605
die "ASSERT temp directory not found '$INSTALL_LOCATION'"
501
function make_for_mingw32 ()
503
# Make sure it is clean
504
if [ -f Makefile -o -f configure ]; then
505
make_maintainer_clean
507
assert_no_file 'Makefile'
509
if command_exists mingw32-configure; then
512
mingw32-configure || die 'mingw32-configure failed'
673
function check_mingw ()
675
command_exists 'mingw64-configure'
677
if [ "$ret" -ne 0 ]; then
681
command_exists 'mingw64-make'
683
if [ "$ret" -ne 0 ]; then
690
function check_clang ()
692
command_exists 'clang'
694
if [ "$ret" -ne 0 ]; then
701
function check_clang_analyzer ()
703
command_exists 'scan-build'
705
if [ "$ret" -ne 0 ]; then
712
function make_skeleton ()
717
if [ $ret -eq 0 ]; then
513
718
assert_file 'Makefile'
515
if command_exists mingw32-make; then
516
mingw32-make || die 'mingw32-make failed'
720
make_target 'all' 'warn'
722
if [ $ret -ne 0 ]; then
725
if [[ -n "$DISPLAY" ]]; then
726
if command_exists 'wine'; then
727
TESTS_ENVIRONMENT='wine'
731
if [[ -n "$TESTS_ENVIRONMENT" ]]; then
732
make_target 'check' 'warn' || warn "$MAKE check failed"
737
if $jenkins_build_environment; then
738
make_target 'clean' 'warn'
745
function make_for_mingw ()
747
if ! check_mingw; then
751
# Make sure it is clean
752
if [ -f Makefile -o -f configure ]; then
753
make_maintainer_clean
760
CONFIGURE='mingw64-configure'
762
CONFIGURE_ARGS='--enable-static --disable-shared'
772
function make_for_clang ()
774
if ! check_clang; then
778
# Make sure it is clean
779
if [ -f Makefile -o -f configure ]; then
780
make_maintainer_clean
800
function make_for_clang_analyzer ()
802
if ! check_clang; then
806
if ! check_clang_analyzer; then
807
die 'clang-analyzer was not found'
810
# Make sure it is clean
811
if [ -f Makefile -o -f configure ]; then
812
make_maintainer_clean
821
CONFIGURE_ARGS='--enable-debug'
826
make_target 'clean' 'warn'
828
scan-build -o clang-html make -j4 -k
521
835
# If we are locally testing, we should make sure the environment is setup correctly
631
951
eval "./bootstrap.sh maintainer-clean" || die "failed 'maintainer-clean'"
954
function make_install_html ()
956
run_configure_if_required
957
assert_file 'configure'
959
make_target 'install-html'
634
962
function make_gdb ()
636
run_configure_if_required
638
if command_exists gdb; then
640
push_TESTS_ENVIRONMENT
966
if command_exists 'gdb'; then
967
run_configure_if_required
642
969
# Set ENV GDB_COMMAND
643
970
if [[ -z "$GDB_COMMAND" ]]; then
707
1046
function make_rpm ()
709
if [ -f 'rpm.am' -o -d 'rpm' ]; then
710
run_configure_if_required
1048
if command_exists 'rpmbuild'; then
1049
if [ -f 'rpm.am' -o -d 'rpm' ]; then
1050
run_configure_if_required
1053
if $jenkins_build_environment; then
717
1063
run_configure_if_required
718
1064
make_target 'maintainer-clean' 'no_error'
1066
# Lets make sure we really cleaned up the environment
1067
assert_no_file 'Makefile'
1068
assert_no_file 'configure'
1069
assert_no_directory 'autom4te.cache'
721
1072
function make_check ()
816
1179
echo "bootstrap.sh [options] optional_target ..."
1180
echo " -a # Just run autoreconf";
1181
echo " -p # Print ENV";
1182
echo " -c # Just run configure";
1183
echo " -m # Just run maintainer-clean";
1184
echo " -t # Make target";
1185
echo " -d # Enable debug";
1186
echo " -h # Show help";
1187
echo " -v # Be more verbose in output";
869
1242
# Set ENV MAKE in order to override "make"
870
1243
if [[ -z "$MAKE" ]]; then
871
if command_exists gmake; then
1244
if command_exists 'gmake'; then
872
1245
MAKE=`type -p gmake`
874
if command_exists make; then
1247
if command_exists 'make'; then
875
1248
MAKE=`type -p make`
922
1296
if [[ -z "$BOOTSTRAP_LIBTOOLIZE" ]]; then
923
1297
echo "Couldn't find glibtoolize, it is required on OSX"
926
1301
BOOTSTRAP_LIBTOOLIZE=`type -p libtoolize`
928
1303
if [[ -z "$BOOTSTRAP_LIBTOOLIZE" ]]; then
929
1304
echo "Couldn't find libtoolize, it is required"
933
1310
if $VERBOSE; then
934
1311
LIBTOOLIZE_OPTIONS="--verbose $BOOTSTRAP_LIBTOOLIZE_OPTIONS"
937
1315
LIBTOOLIZE_OPTIONS="--debug $BOOTSTRAP_LIBTOOLIZE_OPTIONS"
1318
# Here we set LIBTOOLIZE to true since we are going to invoke it via BOOTSTRAP_LIBTOOLIZE
975
1355
if [[ -n "$GNU_BUILD_FLAGS" ]]; then
976
AUTORECONF="$AUTORECONF $GNU_BUILD_FLAGS"
1356
AUTORECONF_ARGS="$GNU_BUILD_FLAGS"
980
1360
run $AUTORECONF '--help' &> /dev/null || die "Failed to run AUTORECONF:$AUTORECONF"
1363
function print_setup ()
985
1365
saved_debug_status=$DEBUG
1205
1607
'make_default')
1611
if ! check_clang; then
1612
die "clang was not found"
1615
if ! make_for_clang; then
1616
die "Failed to build clang: $?"
1620
if ! check_clang_analyzer; then
1621
die "clang-analyzer was not found"
1623
if ! check_clang; then
1624
die "clang was not found"
1627
if ! make_for_clang_analyzer; then
1628
die "Failed to build clang-analyzer: $?"
1632
if ! check_mingw; then
1633
die "mingw was not found"
1636
if ! make_for_mingw; then
1637
die "Failed to build mingw: $?"
1212
1641
make_for_snapshot
1651
make_maintainer_clean
1249
1691
local TARGET_OPTION_ARG=
1250
1692
local VERBOSE_OPTION=false
1694
local OLD_CONFIGURE=
1695
local OLD_CONFIGURE_ARG=
1698
local OLD_TESTS_ENVIRONMENT=
1252
1700
# If we call autoreconf on the platform or not
1253
1701
local AUTORECONF_REBUILD_HOST=false
1254
1702
local AUTORECONF_REBUILD=false
1256
1704
local -r top_srcdir=`pwd`
1258
if [ -z "$top_srcdir" ]; then
1707
if [ -z "$CONFIGURE" ]; then
1708
CONFIGURE="$top_srcdir/configure"
1262
1712
# Variables for determine_target_platform () and rebuild_host_os ()
1263
1713
# UNAME_MACHINE_ARCH= uname -m
1264
1714
# VENDOR= apple, redhat, centos, canonical
1287
1737
# We don't want Jenkins overriding other variables, so we NULL them.
1288
1738
if [ -z "$MAKE_TARGET" ]; then
1289
1739
if $jenkins_build_environment; then
1290
MAKE_TARGET='jenkins'
1740
if [[ -n "$label" ]]; then
1741
check_make_target $label
1742
if [ $? -eq 0 ]; then
1743
MAKE_TARGET="$label"
1747
if [ -z "$MAKE_TARGET" ]; then