155
155
# values: darwin,fedora,rhel,ubuntu,debian,opensuse
156
156
function set_VENDOR_DISTRIBUTION ()
158
local dist=`echo "$1" | tr '[A-Z]' '[a-z]'`
158
local dist="$(echo "$1" | tr '[A-Z]' '[a-z]')"
161
161
VENDOR_DISTRIBUTION='darwin'
187
187
# Validate a Vendor's release name/number
188
188
function set_VENDOR_RELEASE ()
190
local release=`echo "$1" | tr '[A-Z]' '[a-z]'`
190
local release="$(echo "$1" | tr '[A-Z]' '[a-z]')"
193
193
echo "VENDOR_DISTRIBUTION:$VENDOR_DISTRIBUTION"
194
194
echo "VENDOR_RELEASE:$release"
321
323
function determine_target_platform ()
323
UNAME_MACHINE_ARCH=`(uname -m) 2>/dev/null` || UNAME_MACHINE_ARCH=unknown
324
UNAME_KERNEL=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
325
UNAME_KERNEL_RELEASE=`(uname -r) 2>/dev/null` || UNAME_KERNEL_RELEASE=unknown
325
UNAME_MACHINE_ARCH="$(uname -m 2>/dev/null)" || UNAME_MACHINE_ARCH=unknown
326
UNAME_KERNEL="$(uname -s 2>/dev/null)" || UNAME_SYSTEM=unknown
327
UNAME_KERNEL_RELEASE="$(uname -r 2>/dev/null)" || UNAME_KERNEL_RELEASE=unknown
327
329
if [[ -x '/usr/bin/sw_vers' ]]; then
328
local _VERSION=`/usr/bin/sw_vers -productVersion`
330
local _VERSION="$(/usr/bin/sw_vers -productVersion)"
329
331
set_VENDOR 'apple' 'darwin' $_VERSION
330
332
elif [[ $(uname) == 'Darwin' ]]; then
331
333
set_VENDOR 'apple' 'darwin' 'mountain'
332
334
elif [[ -f '/etc/fedora-release' ]]; then
333
local fedora_version=`cat /etc/fedora-release | awk ' { print $3 } '`
335
local fedora_version="$(cat /etc/fedora-release | awk ' { print $3 } ')"
334
336
set_VENDOR 'redhat' 'fedora' $fedora_version
335
337
elif [[ -f '/etc/centos-release' ]]; then
336
local centos_version=`cat /etc/centos-release | awk ' { print $7 } '`
338
local centos_version="$(cat /etc/centos-release | awk ' { print $7 } ')"
337
339
set_VENDOR 'centos' 'rhel' $centos_version
338
340
elif [[ -f '/etc/SuSE-release' ]]; then
339
local suse_distribution=`head -1 /etc/SuSE-release | awk ' { print $1 } '`
340
local suse_version=`head -1 /etc/SuSE-release | awk ' { print $2 } '`
341
local suse_distribution="$(head -1 /etc/SuSE-release | awk ' { print $1 } ')"
342
local suse_version="$(head -1 /etc/SuSE-release | awk ' { print $2 } ')"
341
343
set_VENDOR 'suse' $suse_distribution $suse_version
342
344
elif [[ -f '/etc/redhat-release' ]]; then
343
local rhel_version=`cat /etc/redhat-release | awk ' { print $7 } '`
344
local _vendor=`rpm -qf /etc/redhat-release`
345
local rhel_version="$(cat /etc/redhat-release | awk ' { print $7 } ')"
346
local _vendor="$(rpm -qf /etc/redhat-release)"
345
347
set_VENDOR $_vendor 'rhel' $rhel_version
346
348
elif [[ -f '/etc/os-release' ]]; then
347
349
source '/etc/os-release'
348
350
set_VENDOR $ID $ID $VERSION_ID
349
351
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
local _ID="$(/usr/bin/lsb_release -s -i)"
353
local _VERSION="$(/usr/bin/lsb_release -s -r)"
352
354
set_VENDOR $_ID $_ID $_VERSION_ID
353
355
elif [[ -f '/etc/lsb-release' ]]; then
354
356
source '/etc/lsb-release'
382
385
# Arguments for configure
383
local BUILD_CONFIGURE_ARG=
386
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
388
# If debug is set we enable both debug and asssert, otherwise we see if this is a VCS checkout and if so enable assert
386
389
# Set ENV ASSERT in order to enable assert.
387
390
# If we are doing a valgrind run, we always compile with assert disabled
388
391
if $valgrind_run; then
389
BUILD_CONFIGURE_ARG+= " CXXFLAGS=-DNDEBUG "
390
BUILD_CONFIGURE_ARG+= " CFLAGS=-DNDEBUG "
392
BUILD_CONFIGURE_ARG="--enable-assert=no $BUILD_CONFIGURE_ARG"
393
BUILD_CONFIGURE_ARG+=' --enable-debug --enable-assert'
395
BUILD_CONFIGURE_ARG="--enable-debug --enable-assert $BUILD_CONFIGURE_ARG"
394
396
elif [[ -n "$VCS_CHECKOUT" ]]; then
395
BUILD_CONFIGURE_ARG+=' --enable-assert'
397
BUILD_CONFIGURE_ARG="--enable-assert $BUILD_CONFIGURE_ARG"
399
401
if [[ -n "$CONFIGURE_ARG" ]]; then
400
BUILD_CONFIGURE_ARG+=" $CONFIGURE_ARG"
402
BUILD_CONFIGURE_ARG="$CONFIGURE_ARG $BUILD_CONFIGURE_ARG"
403
405
if [[ -n "$PREFIX_ARG" ]]; then
404
BUILD_CONFIGURE_ARG+=" $PREFIX_ARG"
406
BUILD_CONFIGURE_ARG="$PREFIX_ARG $BUILD_CONFIGURE_ARG"
408
410
# If we are executing on OSX use CLANG, otherwise only use it if we find it in the ENV
411
CC=clang CXX=clang++ $top_srcdir/configure $BUILD_CONFIGURE_ARG || die "Cannot execute CC=clang CXX=clang++ configure $BUILD_CONFIGURE_ARG"
413
eval "CC=clang CXX=clang++ ./configure $BUILD_CONFIGURE_ARG" || die "Cannot execute CC=clang CXX=clang++ configure $BUILD_CONFIGURE_ARG"
415
417
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"
418
eval "CC=gcc44 CXX=gcc44 $top_srcdir/configure $BUILD_CONFIGURE_ARG" || die "Cannot execute CC=gcc44 CXX=gcc44 configure $BUILD_CONFIGURE_ARG"
420
$CONFIGURE $BUILD_CONFIGURE_ARG
422
eval "$CONFIGURE $BUILD_CONFIGURE_ARG"
434
function setup_gdb_command () {
436
function setup_gdb_command ()
435
438
GDB_TMPFILE=$(mktemp /tmp/gdb.XXXXXXXXXX)
436
echo 'set logging overwrite on' > $GDB_TMPFILE
437
echo 'set logging on' >> $GDB_TMPFILE
438
echo 'set environment LIBTEST_IN_GDB=1' >> $GDB_TMPFILE
439
echo 'run' >> $GDB_TMPFILE
440
echo 'thread apply all bt' >> $GDB_TMPFILE
441
echo 'quit' >> $GDB_TMPFILE
439
echo 'set logging overwrite on' > "$GDB_TMPFILE"
440
echo 'set logging on' >> "$GDB_TMPFILE"
441
echo 'set environment LIBTEST_IN_GDB=1' >> "$GDB_TMPFILE"
442
echo 'run' >> "$GDB_TMPFILE"
443
echo 'thread apply all bt' >> "$GDB_TMPFILE"
444
echo 'quit' >> "$GDB_TMPFILE"
442
445
GDB_COMMAND="gdb -f -batch -x $GDB_TMPFILE"
445
function setup_valgrind_command () {
446
VALGRIND_PROGRAM=`type -p valgrind`
448
function setup_valgrind_command ()
450
VALGRIND_PROGRAM="$(type -p valgrind)"
447
451
if [[ -n "$VALGRIND_PROGRAM" ]]; then
448
452
VALGRIND_COMMAND="$VALGRIND_PROGRAM --error-exitcode=1 --leak-check=yes --malloc-fill=A5 --free-fill=DE --xml=yes --xml-file=\"valgrind-%p.xml\""
642
647
MallocScribble=$old_MallocScribble
645
function snapshot_check ()
647
if [ ! -f "$BOOTSTRAP_SNAPSHOT_CHECK" ]; then
651
if [ -n "$BOOTSTRAP_SNAPSHOT_CHECK" ]; then
652
assert_file "$BOOTSTRAP_SNAPSHOT_CHECK" 'snapshot check failed'
656
650
# This will reset our environment, and make sure built files are available.
657
651
function make_for_snapshot ()
659
# Make sure it is clean
660
make_maintainer_clean
653
# Lets make sure we have a clean environment
654
assert_no_file 'Makefile'
655
assert_no_file 'configure'
656
assert_no_directory 'autom4te.cache'
664
660
make_target 'distclean'
666
662
# We should have a configure, but no Makefile at the end of this exercise
667
663
assert_no_file 'Makefile'
668
664
assert_exec_file 'configure'
673
667
function check_mingw ()
876
878
# Platforms which require bootstrap should have some setup done before we hit this stage.
877
879
# If we are building locally, skip this step, unless we are just testing locally.
878
880
if $BOOTSTRAP_SNAPSHOT; then
881
if $BOOTSTRAP_SNAPSHOT; then
882
assert_file 'configure'
881
887
# If we didn't require a snapshot, then we should not have a configure
882
888
assert_no_file 'configure'
887
893
assert_no_file 'Makefile' 'Programmer error, Makefile existed where build state should have been clean'
893
assert_exec_file 'configure'
894
assert_file 'Makefile'
898
# make rpm includes "make distcheck"
899
if [[ -f rpm.am ]]; then
901
elif [[ -d rpm ]]; then
907
assert_exec_file 'configure'
908
assert_file 'Makefile'
915
assert_exec_file 'configure'
916
assert_file 'Makefile'
922
assert_exec_file 'configure'
923
assert_file 'Makefile'
927
assert_exec_file 'configure'
928
assert_file 'Makefile'
933
897
make_jenkins_default
945
909
# We start off with a clean env
946
910
make_maintainer_clean
948
eval "./bootstrap.sh jenkins" || die "failed 'jenkins'"
949
eval "./bootstrap.sh all" || die "failed 'all'"
950
eval "./bootstrap.sh gdb" || die "failed 'gdb'"
951
eval "./bootstrap.sh maintainer-clean" || die "failed 'maintainer-clean'"
912
# eval "./bootstrap.sh jenkins" || die "failed 'jenkins'"
913
# eval "./bootstrap.sh all" || die "failed 'all'"
914
# eval "./bootstrap.sh gdb" || die "failed 'gdb'"
915
# eval "./bootstrap.sh maintainer-clean" || die "failed 'maintainer-clean'"
954
918
function make_install_html ()
1120
1086
die "Programmer error, tried to call run_autoreconf () but AUTORECONF was not set"
1123
if test $use_libtool = 1; then
1089
if $use_libtool; then
1124
1090
assert $BOOTSTRAP_LIBTOOLIZE
1125
run $BOOTSTRAP_LIBTOOLIZE '--copy' '--install' '--force' || die "Cannot execute $BOOTSTRAP_LIBTOOLIZE"
1091
run "$BOOTSTRAP_LIBTOOLIZE" '--copy' '--install' '--force' || die "Cannot execute $BOOTSTRAP_LIBTOOLIZE"
1128
run $AUTORECONF $AUTORECONF_ARGS || die "Cannot execute $AUTORECONF"
1094
run "$AUTORECONF" "$AUTORECONF_ARGS" || die "Cannot execute $AUTORECONF"
1130
1096
eval 'bash -n configure' || die "autoreconf generated a malformed configure"
1133
1099
function run ()
1136
1102
echo "\`$@' $ARGS"
1242
1206
# Set ENV MAKE in order to override "make"
1243
1207
if [[ -z "$MAKE" ]]; then
1244
1208
if command_exists 'gmake'; then
1245
MAKE=`type -p gmake`
1209
MAKE="$(type -p gmake)"
1247
1211
if command_exists 'make'; then
1212
MAKE="$(type -p make)"
1252
1216
if [ "$VCS_CHECKOUT" ]; then
1254
1218
MAKE="$MAKE --warn-undefined-variables"
1259
1223
MAKE="$MAKE -d"
1264
1228
GNU_BUILD_FLAGS="--install --force"
1268
1232
GNU_BUILD_FLAGS="$GNU_BUILD_FLAGS --verbose"
1271
1235
if [ -z "$ACLOCAL_PATH" ]; then
1272
ACLOCAL_PATH="/usr/local/share/aclocal $ACLOCAL_PATH"
1236
ACLOCAL_PATH="/usr/local/share/aclocal"
1275
1239
if [[ -z "$WARNINGS" ]]; then
1283
if test $use_libtool = 1; then
1247
if $use_libtool; then
1284
1248
if [[ -n "$LIBTOOLIZE" ]]; then
1285
BOOTSTRAP_LIBTOOLIZE=`type -p $LIBTOOLIZE`
1249
BOOTSTRAP_LIBTOOLIZE="$(type -p $LIBTOOLIZE)"
1287
1251
if [[ -z "$BOOTSTRAP_LIBTOOLIZE" ]]; then
1288
1252
echo "Couldn't find user supplied libtoolize, it is required"
1292
1256
# If we are using OSX, we first check to see glibtoolize is available
1293
1257
if [[ "$VENDOR_DISTRIBUTION" == "darwin" ]]; then
1294
BOOTSTRAP_LIBTOOLIZE=`type -p glibtoolize`
1258
BOOTSTRAP_LIBTOOLIZE="$(type -p glibtoolize)"
1296
1260
if [[ -z "$BOOTSTRAP_LIBTOOLIZE" ]]; then
1297
1261
echo "Couldn't find glibtoolize, it is required on OSX"
1301
BOOTSTRAP_LIBTOOLIZE=`type -p libtoolize`
1265
BOOTSTRAP_LIBTOOLIZE="$(type -p libtoolize)"
1303
1267
if [[ -z "$BOOTSTRAP_LIBTOOLIZE" ]]; then
1304
1268
echo "Couldn't find libtoolize, it is required"
1322
1286
# Test the ENV AUTOMAKE if it exists
1323
1287
if [[ -n "$AUTOMAKE" ]]; then
1324
run $AUTOMAKE '--help' &> /dev/null || die "Failed to run AUTOMAKE:$AUTOMAKE"
1288
run "$AUTOMAKE" '--help' &> /dev/null || die "Failed to run AUTOMAKE:$AUTOMAKE"
1327
1291
# Test the ENV AUTOCONF if it exists
1328
1292
if [[ -n "$AUTOCONF" ]]; then
1329
run $AUTOCONF '--help' &> /dev/null || die "Failed to run AUTOCONF:$AUTOCONF"
1293
run "$AUTOCONF" '--help' &> /dev/null || die "Failed to run AUTOCONF:$AUTOCONF"
1332
1296
# Test the ENV AUTOHEADER if it exists
1333
1297
if [[ -n "$AUTOHEADER" ]]; then
1334
run $AUTOHEADER '--help' &> /dev/null || die "Failed to run AUTOHEADER:$AUTOHEADER"
1298
run "$AUTOHEADER" '--help' &> /dev/null || die "Failed to run AUTOHEADER:$AUTOHEADER"
1337
1301
# Test the ENV AUTOM4TE if it exists
1338
1302
if [[ -n "$AUTOM4TE" ]]; then
1339
run $AUTOM4TE '--help' &> /dev/null || die "Failed to run AUTOM4TE:$AUTOM4TE"
1303
run "$AUTOM4TE" '--help' &> /dev/null || die "Failed to run AUTOM4TE:$AUTOM4TE"
1342
1306
# Test the ENV AUTOHEADER if it exists, if not we add one and add --install
1343
1307
if [[ -z "$ACLOCAL" ]]; then
1344
1308
ACLOCAL="aclocal --install"
1346
run $ACLOCAL '--help' &> /dev/null || die "Failed to run ACLOCAL:$ACLOCAL"
1310
run "$ACLOCAL" '--help' &> /dev/null || die "Failed to run ACLOCAL:$ACLOCAL"
1348
1312
if [[ -z "$AUTORECONF" ]]; then
1349
AUTORECONF=`type -p autoreconf`
1313
AUTORECONF="$(type -p autoreconf)"
1351
1315
if [[ -z "$AUTORECONF" ]]; then
1352
1316
die "Couldn't find autoreconf"
1424
1388
echo "VCS_CHECKOUT=$VCS_CHECKOUT"
1435
1395
if [[ -n "$WARNINGS" ]]; then
1436
1396
echo "WARNINGS=$WARNINGS"
1399
if $saved_debug_status; then
1438
1403
echo '----------------------------------------------'
1440
1405
if $saved_debug_status; then
1544
1511
MAKE_TARGET="make_default"
1547
if $PRINT_SETUP_OPTION -o $DEBUG; then
1514
if $print_setup_opt -o $debug; then
1552
1519
# Exit if all we were looking for were the currently used options
1553
if $PRINT_SETUP_OPTION; then
1520
if $print_setup_opt; then
1675
1650
function main ()
1652
# Are we running inside of Jenkins?
1653
if [[ -n "$JENKINS_HOME" ]]; then
1654
declare -r jenkins_build_environment=true
1656
declare -r jenkins_build_environment=false
1677
1659
# Variables we export
1678
1660
declare -x VCS_CHECKOUT=
1680
1662
# Variables we control globally
1663
local -a MAKE_TARGET=
1682
1664
local CONFIGURE=
1665
local use_libtool=false
1669
local opt_debug=false
1670
local opt_verbose=false
1672
if [[ -n "$VERBOSE" ]]; then
1684
1676
# Options for getopt
1685
1677
local AUTORECONF_OPTION=false
1686
1678
local CLEAN_OPTION=false
1687
1679
local CONFIGURE_OPTION=false
1688
local DEBUG_OPTION=false
1689
local PRINT_SETUP_OPTION=false
1680
local print_setup_opt=false
1690
1681
local TARGET_OPTION=false
1691
1682
local TARGET_OPTION_ARG=
1692
local VERBOSE_OPTION=false
1694
1684
local OLD_CONFIGURE=
1695
1685
local OLD_CONFIGURE_ARG=
1829
1827
function disable_debug ()
1835
# Script begins here
1839
env_debug_enabled=false
1840
if [[ -n "$JENKINS_HOME" ]]; then
1841
declare -r jenkins_build_environment=true
1843
declare -r jenkins_build_environment=false
1852
export CONFIGURE_ARG
1854
export GNU_BUILD_FLAGS
1856
export LIBTOOLIZE_OPTIONS
1859
export TESTS_ENVIRONMENT
1865
export MallocGuardEdges
1866
export MallocErrorAbort
1867
export MallocScribble
1871
# We check for DEBUG twice, once before we source the config file, and once afterward
1872
env_debug_enabled=false
1873
if [[ -n "$DEBUG" ]]; then
1874
env_debug_enabled=true
1879
# Variables which only can be set by .bootstrap
1880
BOOTSTRAP_SNAPSHOT=false
1881
BOOTSTRAP_SNAPSHOT_CHECK=
1883
if [ -f '.bootstrap' ]; then
1887
if $env_debug_enabled; then
1833
function bootstrap ()
1835
local env_debug_enabled=false
1844
export CONFIGURE_ARG
1846
export GNU_BUILD_FLAGS
1848
export LIBTOOLIZE_OPTIONS
1851
export TESTS_ENVIRONMENT
1857
export MallocGuardEdges
1858
export MallocErrorAbort
1859
export MallocScribble
1863
# We check for DEBUG twice, once before we source the config file, and once afterward
1890
1864
if [[ -n "$DEBUG" ]]; then
1865
env_debug_enabled=true
1868
# Variables which only can be set by .bootstrap
1869
BOOTSTRAP_SNAPSHOT=false
1870
BOOTSTRAP_SNAPSHOT_CHECK=
1872
if [ -f '.bootstrap' ]; then
1876
# We do this in order to protect the case where DEBUG that came from the ENV (i.e. it overrides what is found in .bootstrap
1877
if $env_debug_enabled; then
1879
elif [[ -n "$DEBUG" ]]; then
1891
1880
enable_debug "Enabling DEBUG from '.bootstrap'"
1883
if $env_debug_enabled; then
1896
# We do this in order to protect the case where DEBUG
1897
if ! $env_debug_enabled; then
1891
# Script begins here
1892
declare -r program_name="$0"