~drizzle-trunk/libdrizzle/jenkins-Libdrizzle-109

« back to all changes in this revision

Viewing changes to bootstrap.sh

  • Committer: Continuous Integration
  • Date: 2013-05-12 22:57:40 UTC
  • mfrom: (122.1.1 libdrizzle-5.1)
  • Revision ID: ci@drizzle.org-20130512225740-n9n9673m65kb4ogf
Merge lp:~brianaker/libdrizzle/ddm4-update-may Build: jenkins-Libdrizzle-107

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
function nassert ()
81
81
{
82
82
  local param_name=\$"$1"
83
 
  local param_value=`eval "expr \"$param_name\" "`
 
83
  local param_value="$(eval "expr \"$param_name\" ")"
84
84
 
85
85
  if [ -n "$param_value" ]; then
86
86
    echo "$bash_source:$bash_lineno: assert($param_name) had value of "$param_value"" >&2
91
91
function assert ()
92
92
{
93
93
  local param_name=\$"$1"
94
 
  local param_value=`eval "expr \"$param_name\" "`
 
94
  local param_value="$(eval "expr \"$param_name\" ")"
95
95
 
96
96
  if [ -z "$param_value" ]; then
97
97
    echo "$bash_source:$bash_lineno: assert($param_name)" >&2
145
145
{
146
146
  HOST_OS="${UNAME_MACHINE_ARCH}-${VENDOR}-${VENDOR_DISTRIBUTION}-${VENDOR_RELEASE}-${UNAME_KERNEL}-${UNAME_KERNEL_RELEASE}"
147
147
  if [ -z "$1" ]; then
148
 
    if $VERBOSE; then
 
148
    if $verbose; then
149
149
      echo "HOST_OS=$HOST_OS"
150
150
    fi
151
151
  fi
155
155
#  values: darwin,fedora,rhel,ubuntu,debian,opensuse
156
156
function set_VENDOR_DISTRIBUTION ()
157
157
{
158
 
  local dist=`echo "$1" | tr '[A-Z]' '[a-z]'`
 
158
  local dist="$(echo "$1" | tr '[A-Z]' '[a-z]')"
159
159
  case "$dist" in
160
160
    darwin)
161
161
      VENDOR_DISTRIBUTION='darwin'
187
187
# Validate a Vendor's release name/number 
188
188
function set_VENDOR_RELEASE ()
189
189
{
190
 
  local release=`echo "$1" | tr '[A-Z]' '[a-z]'`
 
190
  local release="$(echo "$1" | tr '[A-Z]' '[a-z]')"
191
191
 
192
 
  if $DEBUG; then 
 
192
  if $verbose; then 
193
193
    echo "VENDOR_DISTRIBUTION:$VENDOR_DISTRIBUTION"
194
194
    echo "VENDOR_RELEASE:$release"
195
195
  fi
234
234
        VENDOR_RELEASE="precise"
235
235
      elif [[ "x$VENDOR_RELEASE" == 'x12.10' ]]; then
236
236
        VENDOR_RELEASE="quantal"
 
237
      elif [[ "x$VENDOR_RELEASE" == 'x13.04' ]]; then
 
238
        VENDOR_RELEASE="raring"
237
239
      fi
238
240
      ;;
239
241
    opensuse)
252
254
#  Valid values are: apple, redhat, centos, canonical, oracle, suse
253
255
function set_VENDOR ()
254
256
{
255
 
  local vendor=`echo "$1" | tr '[A-Z]' '[a-z]'`
 
257
  local vendor="$(echo "$1" | tr '[A-Z]' '[a-z]')"
256
258
 
257
259
  case $vendor in
258
260
    apple)
293
295
      ;;
294
296
  esac
295
297
 
296
 
  set_VENDOR_DISTRIBUTION $2
297
 
  set_VENDOR_RELEASE $3
 
298
  set_VENDOR_DISTRIBUTION "$2"
 
299
  set_VENDOR_RELEASE "$3"
298
300
 
299
301
  # Set which vendor/versions we trust for autoreconf
300
302
  case $VENDOR_DISTRIBUTION in
320
322
 
321
323
function determine_target_platform ()
322
324
{
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
326
328
 
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'
364
366
  run_autoreconf_if_required
365
367
 
366
368
  # We always begin at the root of our build
367
 
  if [ ! popd ]; then
 
369
  popd
 
370
  if [ ! $? ]; then
368
371
    die "Programmer error, we entered run_configure with a stacked directory"
369
372
  fi
370
373
 
380
383
  fi
381
384
 
382
385
  # Arguments for configure
383
 
  local BUILD_CONFIGURE_ARG= 
 
386
  local BUILD_CONFIGURE_ARG='' 
384
387
 
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"
391
393
  else
392
 
    if $DEBUG; then 
393
 
      BUILD_CONFIGURE_ARG+=' --enable-debug --enable-assert'
 
394
    if $debug; then 
 
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"
396
398
    fi
397
399
  fi
398
400
 
399
401
  if [[ -n "$CONFIGURE_ARG" ]]; then 
400
 
    BUILD_CONFIGURE_ARG+=" $CONFIGURE_ARG"
 
402
    BUILD_CONFIGURE_ARG="$CONFIGURE_ARG $BUILD_CONFIGURE_ARG"
401
403
  fi
402
404
 
403
405
  if [[ -n "$PREFIX_ARG" ]]; then 
404
 
    BUILD_CONFIGURE_ARG+=" $PREFIX_ARG"
 
406
    BUILD_CONFIGURE_ARG="$PREFIX_ARG $BUILD_CONFIGURE_ARG"
405
407
  fi
406
408
 
407
409
  ret=1;
408
410
  # If we are executing on OSX use CLANG, otherwise only use it if we find it in the ENV
409
411
  case $HOST_OS in
410
412
    *-darwin-*)
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"
412
414
      ret=$?
413
415
      ;;
414
416
    rhel-5*)
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"
417
419
      ret=$?
418
420
      ;;
419
421
    *)
420
 
      $CONFIGURE $BUILD_CONFIGURE_ARG
 
422
      eval "$CONFIGURE $BUILD_CONFIGURE_ARG"
421
423
      ret=$?
422
424
      ;;
423
425
  esac
431
433
  fi
432
434
}
433
435
 
434
 
function setup_gdb_command () {
 
436
function setup_gdb_command ()
 
437
{
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"
443
446
}
444
447
 
445
 
function setup_valgrind_command () {
446
 
  VALGRIND_PROGRAM=`type -p valgrind`
 
448
function setup_valgrind_command ()
 
449
{
 
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\""
449
453
  fi
521
525
 
522
526
function safe_pushd ()
523
527
{
524
 
  pushd $1 &> /dev/null ;
 
528
  pushd "$1" &> /dev/null ;
525
529
 
526
530
  if [ -n "$BUILD_DIR" ]; then
527
 
    if $VERBOSE; then
 
531
    if $verbose; then
528
532
      echo "BUILD_DIR=$BUILD_DIR"
529
533
    fi
530
534
  fi
532
536
 
533
537
function safe_popd ()
534
538
{
535
 
  local directory_to_delete=`pwd`
 
539
  local directory_to_delete="$(pwd)"
536
540
  popd &> /dev/null ;
537
541
  if [ $? -eq 0 ]; then
538
542
    if [[ "$top_srcdir" == "$directory_to_delete" ]]; then
571
575
 
572
576
  # If we don't have a configure, then most likely we will be missing libtool
573
577
  assert_file 'configure'
574
 
  if [[ -f 'libtool' ]]; then
 
578
  if [[ -x 'libtool' ]]; then
575
579
    TESTS_ENVIRONMENT="./libtool --mode=execute $VALGRIND_COMMAND"
576
580
  else
577
581
    TESTS_ENVIRONMENT="$VALGRIND_COMMAND"
578
582
  fi
579
583
 
 
584
  make_target 'all'
580
585
  make_target 'check'
581
586
  ret=$?
582
587
 
596
601
 
597
602
function make_install_system ()
598
603
{
599
 
  local INSTALL_LOCATION=$(mktemp -d /tmp/XXXXXXXXXX)
 
604
  local INSTALL_LOCATION="$(mktemp -d /tmp/XXXXXXXXXX)"
600
605
 
601
606
  save_BUILD
602
607
  PREFIX_ARG="--prefix=$INSTALL_LOCATION"
642
647
  MallocScribble=$old_MallocScribble
643
648
}
644
649
 
645
 
function snapshot_check ()
646
 
{
647
 
  if [ ! -f "$BOOTSTRAP_SNAPSHOT_CHECK" ]; then
648
 
    make_for_snapshot
649
 
  fi
650
 
 
651
 
  if [ -n "$BOOTSTRAP_SNAPSHOT_CHECK" ]; then
652
 
    assert_file "$BOOTSTRAP_SNAPSHOT_CHECK" 'snapshot check failed'
653
 
  fi
654
 
}
655
 
 
656
650
# This will reset our environment, and make sure built files are available.
657
651
function make_for_snapshot ()
658
652
{
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'
661
657
 
662
658
  run_configure
663
 
  make_target 'dist'
 
659
  make_target 'all'
664
660
  make_target 'distclean'
665
661
 
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'
669
 
 
670
 
  snapshot_check
671
665
}
672
666
 
673
667
function check_mingw ()
836
830
function check_for_jenkins ()
837
831
{
838
832
  if ! $jenkins_build_environment; then
839
 
    echo "Not inside of jenkins"
 
833
    echo "Not inside of jenkins, simulating environment"
840
834
 
841
835
    if [ -f 'configure' ]; then
842
836
      make_maintainer_clean
857
851
  make_for_clang
858
852
  make_for_clang_analyzer
859
853
 
860
 
  if [ check_mingw -eq 0 ]; then
 
854
  check_mingw
 
855
  if [ $? -eq 0 ]; then
861
856
    make_for_mingw
862
857
  fi
863
858
 
865
860
  make_install_system
866
861
}
867
862
 
 
863
function check_snapshot ()
 
864
{
 
865
  if [ -n "$BOOTSTRAP_SNAPSHOT_CHECK" ]; then
 
866
    assert_file "$BOOTSTRAP_SNAPSHOT_CHECK" 'snapshot check failed'
 
867
  fi
 
868
}
 
869
 
868
870
function make_for_continuus_integration ()
869
871
{
870
872
  # Setup the environment if we are local
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
879
 
    snapshot_check
 
881
    if $BOOTSTRAP_SNAPSHOT; then
 
882
      assert_file 'configure'
 
883
    fi
 
884
 
 
885
    check_snapshot
880
886
  else
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'
888
894
 
889
895
  case $HOST_OS in
890
 
    *-fedora-*)
891
 
      run_configure
892
 
 
893
 
      assert_exec_file 'configure'
894
 
      assert_file 'Makefile'
895
 
 
896
 
      make_target 'all'
897
 
 
898
 
      # make rpm includes "make distcheck"
899
 
      if [[ -f rpm.am ]]; then
900
 
        make_rpm
901
 
      elif [[ -d rpm ]]; then
902
 
        make_rpm
903
 
      else
904
 
        make_distcheck
905
 
      fi
906
 
 
907
 
      assert_exec_file 'configure'
908
 
      assert_file 'Makefile'
909
 
 
910
 
      make_install_system
911
 
      ;;
912
 
    *-precise-*)
913
 
      run_configure
914
 
 
915
 
      assert_exec_file 'configure'
916
 
      assert_file 'Makefile'
917
 
 
918
 
      make_target 'all'
919
 
 
920
 
      make_distcheck
921
 
 
922
 
      assert_exec_file 'configure'
923
 
      assert_file 'Makefile'
924
 
 
925
 
      make_valgrind
926
 
 
927
 
      assert_exec_file 'configure'
928
 
      assert_file 'Makefile'
929
 
 
930
 
      make_install_system
931
 
      ;;
932
896
    *)
933
897
      make_jenkins_default
934
898
      ;;
945
909
  # We start off with a clean env
946
910
  make_maintainer_clean
947
911
 
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'"
952
916
}
953
917
 
954
918
function make_install_html ()
1014
978
  fi
1015
979
 
1016
980
  if [ -n "$TESTS_ENVIRONMENT" ]; then
1017
 
    if $VERBOSE; then
 
981
    if $verbose; then
1018
982
      echo "TESTS_ENVIRONMENT=$TESTS_ENVIRONMENT"
1019
983
    fi
1020
984
  fi
1024
988
  fi
1025
989
 
1026
990
  # $2 represents error or warn
1027
 
  run $MAKE $1
 
991
  run "$MAKE" "$1"
1028
992
  ret=$?
1029
993
 
1030
994
  if [ $ret -ne 0 ]; then
1031
995
    if [ -n "$2" ]; then
1032
996
      warn "Failed to execute $MAKE $1: $ret"
 
997
    elif [ $ret -eq 2 ]; then
 
998
      die "Failed to execute $MAKE $1"
1033
999
    else
1034
1000
      die "Failed to execute $MAKE $1: $ret"
1035
1001
    fi
1120
1086
    die "Programmer error, tried to call run_autoreconf () but AUTORECONF was not set"
1121
1087
  fi
1122
1088
 
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"
1126
1092
  fi
1127
1093
 
1128
 
  run $AUTORECONF $AUTORECONF_ARGS || die "Cannot execute $AUTORECONF"
 
1094
  run "$AUTORECONF" "$AUTORECONF_ARGS" || die "Cannot execute $AUTORECONF"
1129
1095
 
1130
1096
  eval 'bash -n configure' || die "autoreconf generated a malformed configure"
1131
1097
}
1132
1098
 
1133
1099
function run ()
1134
1100
{
1135
 
  if $VERBOSE; then
 
1101
  if $verbose; then
1136
1102
    echo "\`$@' $ARGS"
1137
1103
  fi
1138
1104
 
1140
1106
    return 127;
1141
1107
  fi
1142
1108
 
1143
 
  eval $@ $ARGS
 
1109
  eval "$@" "$ARGS"
1144
1110
1145
1111
 
1146
1112
function parse_command_line_options ()
1153
1119
    case $opt in
1154
1120
      a) #--autoreconf
1155
1121
        AUTORECONF_OPTION=true
1156
 
        MAKE_TARGET='autoreconf'
 
1122
        MAKE_TARGET+='autoreconf'
1157
1123
        ;;
1158
1124
      p) #--print-env
1159
 
        PRINT_SETUP_OPTION=true
 
1125
        print_setup_opt=true
1160
1126
        ;;
1161
1127
      c) # --configure
1162
1128
        CONFIGURE_OPTION=true
1163
 
        MAKE_TARGET='configure'
 
1129
        MAKE_TARGET+='configure'
1164
1130
        ;;
1165
1131
      m) # maintainer-clean
1166
1132
        CLEAN_OPTION=true
1167
 
        MAKE_TARGET='clean_op'
1168
1133
        ;;
1169
1134
      t) # target
1170
1135
        TARGET_OPTION=true
1171
1136
        TARGET_OPTION_ARG="$OPTARG"
1172
 
        MAKE_TARGET="$OPTARG"
 
1137
        MAKE_TARGET+="$OPTARG"
1173
1138
        ;;
1174
1139
      d) # debug
1175
 
        DEBUG_OPTION=true
 
1140
        opt_debug=true
1176
1141
        enable_debug
1177
1142
        ;;
1178
1143
      h) # help
1188
1153
        exit
1189
1154
        ;;
1190
1155
      v) # verbose
1191
 
        VERBOSE_OPTION=true
1192
 
        VERBOSE=true
 
1156
        opt_verbose=true
 
1157
        verbose=true
1193
1158
        ;;
1194
1159
      :)
1195
1160
        echo "Option -$OPTARG requires an argument." >&2
1224
1189
  fi
1225
1190
 
1226
1191
  if [[ -n "$VCS_CHECKOUT" ]]; then
1227
 
    VERBOSE=true
 
1192
    verbose=true
1228
1193
  fi
1229
1194
}
1230
1195
 
1231
1196
function require_libtoolise ()
1232
1197
{
1233
 
  use_libtool=0
1234
1198
  grep '^[         ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
1235
 
    && use_libtool=1
 
1199
    && use_libtool=true
1236
1200
  grep '^[         ]*LT_INIT' configure.ac >/dev/null \
1237
 
    && use_libtool=1
 
1201
    && use_libtool=true
1238
1202
}
1239
1203
 
1240
1204
function autoreconf_setup ()
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)"
1246
1210
    else
1247
1211
      if command_exists 'make'; then
1248
 
        MAKE=`type -p make`
 
1212
        MAKE="$(type -p make)"
1249
1213
      fi
1250
1214
    fi
1251
1215
    
1252
1216
    if [ "$VCS_CHECKOUT" ]; then
1253
 
      if $DEBUG; then
 
1217
      if $debug; then
1254
1218
        MAKE="$MAKE --warn-undefined-variables"
1255
1219
      fi
1256
1220
    fi
1257
1221
 
1258
 
    if $DEBUG; then
 
1222
    if $debug; then
1259
1223
      MAKE="$MAKE -d"
1260
1224
    fi
1261
1225
  fi
1264
1228
    GNU_BUILD_FLAGS="--install --force"
1265
1229
  fi
1266
1230
 
1267
 
  if $VERBOSE; then
 
1231
  if $verbose; then
1268
1232
    GNU_BUILD_FLAGS="$GNU_BUILD_FLAGS --verbose"
1269
1233
  fi
1270
1234
 
1271
1235
  if [ -z "$ACLOCAL_PATH" ]; then
1272
 
    ACLOCAL_PATH="/usr/local/share/aclocal $ACLOCAL_PATH"
 
1236
    ACLOCAL_PATH="/usr/local/share/aclocal"
1273
1237
  fi
1274
1238
 
1275
1239
  if [[ -z "$WARNINGS" ]]; then
1280
1244
    fi
1281
1245
  fi
1282
1246
 
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)"
1286
1250
 
1287
1251
      if [[ -z "$BOOTSTRAP_LIBTOOLIZE" ]]; then
1288
1252
        echo "Couldn't find user supplied libtoolize, it is required"
1291
1255
    else
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)"
1295
1259
 
1296
1260
        if [[ -z "$BOOTSTRAP_LIBTOOLIZE" ]]; then
1297
1261
          echo "Couldn't find glibtoolize, it is required on OSX"
1298
1262
          return 1
1299
1263
        fi
1300
1264
      else
1301
 
        BOOTSTRAP_LIBTOOLIZE=`type -p libtoolize`
 
1265
        BOOTSTRAP_LIBTOOLIZE="$(type -p libtoolize)"
1302
1266
 
1303
1267
        if [[ -z "$BOOTSTRAP_LIBTOOLIZE" ]]; then
1304
1268
          echo "Couldn't find libtoolize, it is required"
1307
1271
      fi
1308
1272
    fi
1309
1273
 
1310
 
    if $VERBOSE; then
 
1274
    if $verbose; then
1311
1275
      LIBTOOLIZE_OPTIONS="--verbose $BOOTSTRAP_LIBTOOLIZE_OPTIONS"
1312
1276
    fi
1313
1277
 
1314
 
    if $DEBUG; then
 
1278
    if $debug; then
1315
1279
      LIBTOOLIZE_OPTIONS="--debug $BOOTSTRAP_LIBTOOLIZE_OPTIONS"
1316
1280
    fi
1317
1281
 
1321
1285
 
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"
1325
1289
  fi
1326
1290
 
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"
1330
1294
  fi
1331
1295
 
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"
1335
1299
  fi
1336
1300
 
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"
1340
1304
  fi
1341
1305
 
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"
1345
1309
  fi
1346
 
  run $ACLOCAL '--help'  &> /dev/null    || die "Failed to run ACLOCAL:$ACLOCAL"
 
1310
  run "$ACLOCAL" '--help'  &> /dev/null    || die "Failed to run ACLOCAL:$ACLOCAL"
1347
1311
 
1348
1312
  if [[ -z "$AUTORECONF" ]]; then
1349
 
    AUTORECONF=`type -p autoreconf`
 
1313
    AUTORECONF="$(type -p autoreconf)"
1350
1314
 
1351
1315
    if [[ -z "$AUTORECONF" ]]; then
1352
1316
      die "Couldn't find autoreconf"
1357
1321
    fi
1358
1322
  fi
1359
1323
 
1360
 
  run $AUTORECONF '--help'  &> /dev/null    || die "Failed to run AUTORECONF:$AUTORECONF"
 
1324
  run "$AUTORECONF" '--help'  &> /dev/null    || die "Failed to run AUTORECONF:$AUTORECONF"
1361
1325
}
1362
1326
 
1363
1327
function print_setup ()
1364
1328
{
1365
 
  saved_debug_status=$DEBUG
1366
 
  if $DEBUG; then
 
1329
  local saved_debug_status=$debug
 
1330
  if $debug; then
1367
1331
    disable_debug
1368
1332
  fi
1369
1333
 
1388
1352
    echo "--configure"
1389
1353
  fi
1390
1354
 
1391
 
  if $DEBUG_OPTION; then
 
1355
  if $opt_debug; then
1392
1356
    echo "--debug"
1393
1357
  fi
1394
1358
 
1395
 
  if $PRINT_SETUP_OPTION; then
 
1359
  if $print_setup_opt; then
1396
1360
    echo "--print-env"
1397
1361
  fi
1398
1362
 
1400
1364
    echo "--target=$TARGET_OPTION_ARG"
1401
1365
  fi
1402
1366
 
1403
 
  if $VERBOSE_OPTION; then
 
1367
  if $opt_verbose; then
1404
1368
    echo "--verbose"
1405
1369
  fi
1406
1370
 
1424
1388
    echo "VCS_CHECKOUT=$VCS_CHECKOUT"
1425
1389
  fi
1426
1390
 
1427
 
  if $VERBOSE; then
1428
 
    echo "VERBOSE=true"
1429
 
  fi
1430
 
 
1431
 
  if $DEBUG; then
1432
 
    echo "DEBUG=true"
 
1391
  if $debug; then
 
1392
    echo "debug=true"
1433
1393
  fi
1434
1394
 
1435
1395
  if [[ -n "$WARNINGS" ]]; then
1436
1396
    echo "WARNINGS=$WARNINGS"
1437
1397
  fi
 
1398
 
 
1399
  if $saved_debug_status; then
 
1400
    echo "DEBUG=true"
 
1401
  fi
 
1402
 
1438
1403
  echo '----------------------------------------------' 
1439
1404
 
1440
1405
  if $saved_debug_status; then
1468
1433
 
1469
1434
function check_make_target()
1470
1435
{
 
1436
  local ret=0
1471
1437
  case $1 in
1472
1438
    'self')
1473
1439
      ;;
1521
1487
      ;;
1522
1488
    *)
1523
1489
      echo "Matched default"
1524
 
      return 1
 
1490
      ret=1
1525
1491
      ;;
1526
1492
  esac
1527
1493
 
1528
 
  return 0
 
1494
  return $ret
1529
1495
}
1530
1496
 
1531
 
function bootstrap ()
 
1497
function execute_job ()
1532
1498
{
1533
1499
  determine_target_platform
1534
1500
 
1535
1501
  determine_vcs
1536
1502
 
1537
1503
  # Set up whatever we need to do to use autoreconf later
 
1504
  use_libtool=false
1538
1505
  require_libtoolise
1539
1506
  if ! autoreconf_setup; then
1540
1507
    return 1
1544
1511
    MAKE_TARGET="make_default"
1545
1512
  fi
1546
1513
 
1547
 
  if $PRINT_SETUP_OPTION -o  $DEBUG; then
 
1514
  if $print_setup_opt -o  $debug; then
1548
1515
    echo 
1549
1516
    print_setup
1550
1517
    echo 
1551
1518
 
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
1554
1521
      exit
1555
1522
    fi
1556
1523
  fi
1566
1533
  # We should always have a target by this point
1567
1534
  assert MAKE_TARGET
1568
1535
 
1569
 
  local MAKE_TARGET_ARRAY=($MAKE_TARGET)
 
1536
  if $CLEAN_OPTION; then
 
1537
    make_maintainer_clean
 
1538
  fi
 
1539
 
 
1540
  local MAKE_TARGET_ARRAY
 
1541
  MAKE_TARGET_ARRAY=( $MAKE_TARGET )
1570
1542
 
1571
1543
  for target in "${MAKE_TARGET_ARRAY[@]}"
1572
1544
  do
1640
1612
      'snapshot')
1641
1613
        make_for_snapshot
1642
1614
        snapshot_run=true
 
1615
        check_snapshot
1643
1616
        ;;
1644
1617
      'rpm')
1645
1618
        make_rpm
1664
1637
    esac
1665
1638
 
1666
1639
    if $jenkins_build_environment; then
1667
 
      if ! $snapshot_run; then
1668
 
        run_make_maintainer_clean_if_possible
 
1640
      if [[ "$MAKE_TARGET" != "all" ]]; then
 
1641
        if ! $snapshot_run; then
 
1642
          run_make_maintainer_clean_if_possible
 
1643
        fi
1669
1644
      fi
1670
1645
    fi
1671
1646
 
1674
1649
 
1675
1650
function main ()
1676
1651
{
 
1652
  # Are we running inside of Jenkins?
 
1653
  if [[ -n "$JENKINS_HOME" ]]; then 
 
1654
    declare -r jenkins_build_environment=true
 
1655
  else
 
1656
    declare -r jenkins_build_environment=false
 
1657
  fi
 
1658
 
1677
1659
  # Variables we export
1678
1660
  declare -x VCS_CHECKOUT=
1679
1661
 
1680
1662
  # Variables we control globally
1681
 
  local MAKE_TARGET=
 
1663
  local -a MAKE_TARGET=
1682
1664
  local CONFIGURE=
 
1665
  local use_libtool=false
 
1666
  local verbose=false
 
1667
 
 
1668
  #getop variables
 
1669
  local opt_debug=false
 
1670
  local opt_verbose=false
 
1671
 
 
1672
  if [[ -n "$VERBOSE" ]]; then
 
1673
    verbose=true
 
1674
  fi
1683
1675
 
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
1693
1683
 
1694
1684
  local OLD_CONFIGURE=
1695
1685
  local OLD_CONFIGURE_ARG=
1701
1691
  local AUTORECONF_REBUILD_HOST=false
1702
1692
  local AUTORECONF_REBUILD=false
1703
1693
 
1704
 
  local -r top_srcdir=`pwd`
 
1694
  local -r top_srcdir="$(pwd)"
1705
1695
 
1706
1696
  # Default configure
1707
1697
  if [ -z "$CONFIGURE" ]; then
1730
1720
 
1731
1721
  rebuild_host_os no_output
1732
1722
 
1733
 
  parse_command_line_options $@
 
1723
  parse_command_line_options "$@"
1734
1724
 
1735
1725
  # If we are running under Jenkins we predetermine what tests we will run against
1736
1726
  # This MAKE_TARGET can be overridden by parse_command_line_options based MAKE_TARGET changes.
1744
1734
        fi
1745
1735
      fi
1746
1736
 
 
1737
      if [[ -n "$LABEL" ]]; then
 
1738
        check_make_target $LABEL
 
1739
        if [ $? -eq 0 ]; then
 
1740
          MAKE_TARGET="$LABEL"
 
1741
        fi
 
1742
      fi
 
1743
 
1747
1744
      if [ -z "$MAKE_TARGET" ]; then
1748
 
        MAKE_TARGET='check'
 
1745
        MAKE_TARGET='jenkins'
1749
1746
      fi
1750
1747
    fi
1751
1748
  fi
1752
1749
 
1753
 
  bootstrap
 
1750
  execute_job
 
1751
  local ret=$?
1754
1752
 
1755
1753
  jobs -l
1756
1754
  wait
1757
1755
 
1758
 
  exit 0
 
1756
  exit $ret
1759
1757
}
1760
1758
 
1761
1759
function set_branch ()
1802
1800
 
1803
1801
function enable_debug ()
1804
1802
{
1805
 
  if ! $DEBUG; then
1806
 
    local caller_loc=`caller`
1807
 
    if [ -n $1 ]; then
 
1803
  if ! $debug; then
 
1804
    local caller_loc="$(caller)"
 
1805
    if [[ -n "$1" ]]; then
1808
1806
      echo "$caller_loc Enabling debug: $1"
1809
1807
    else
1810
1808
      echo "$caller_loc Enabling debug"
1811
1809
    fi
1812
1810
    set -x
1813
 
    DEBUG=true
 
1811
    debug=true
1814
1812
  fi
1815
1813
}
1816
1814
 
1829
1827
function disable_debug ()
1830
1828
{
1831
1829
  set +x
1832
 
  DEBUG=true
 
1830
  debug=false
1833
1831
}
1834
1832
 
1835
 
# Script begins here
1836
 
 
1837
 
program_name=$0
1838
 
 
1839
 
env_debug_enabled=false
1840
 
if [[ -n "$JENKINS_HOME" ]]; then 
1841
 
  declare -r jenkins_build_environment=true
1842
 
else
1843
 
  declare -r jenkins_build_environment=false
1844
 
fi
1845
 
 
1846
 
export ACLOCAL
1847
 
export AUTOCONF
1848
 
export AUTOHEADER
1849
 
export AUTOM4TE
1850
 
export AUTOMAKE
1851
 
export AUTORECONF
1852
 
export CONFIGURE_ARG
1853
 
export DEBUG
1854
 
export GNU_BUILD_FLAGS
1855
 
export LIBTOOLIZE
1856
 
export LIBTOOLIZE_OPTIONS
1857
 
export MAKE
1858
 
export PREFIX_ARG
1859
 
export TESTS_ENVIRONMENT
1860
 
export VERBOSE
1861
 
export WARNINGS
1862
 
 
1863
 
case $OSTYPE in
1864
 
  darwin*)
1865
 
    export MallocGuardEdges
1866
 
    export MallocErrorAbort
1867
 
    export MallocScribble
1868
 
    ;;
1869
 
esac
1870
 
 
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
1875
 
  enable_debug
1876
 
  print_setup
1877
 
fi
1878
 
 
1879
 
# Variables which only can be set by .bootstrap
1880
 
BOOTSTRAP_SNAPSHOT=false
1881
 
BOOTSTRAP_SNAPSHOT_CHECK=
1882
 
 
1883
 
if [ -f '.bootstrap' ]; then
1884
 
  source '.bootstrap'
1885
 
fi
1886
 
 
1887
 
if $env_debug_enabled; then
1888
 
  enable_debug
1889
 
else
 
1833
function bootstrap ()
 
1834
{
 
1835
  local env_debug_enabled=false
 
1836
  local debug=false
 
1837
 
 
1838
  export ACLOCAL
 
1839
  export AUTOCONF
 
1840
  export AUTOHEADER
 
1841
  export AUTOM4TE
 
1842
  export AUTOMAKE
 
1843
  export AUTORECONF
 
1844
  export CONFIGURE_ARG
 
1845
  export DEBUG
 
1846
  export GNU_BUILD_FLAGS
 
1847
  export LIBTOOLIZE
 
1848
  export LIBTOOLIZE_OPTIONS
 
1849
  export MAKE
 
1850
  export PREFIX_ARG
 
1851
  export TESTS_ENVIRONMENT
 
1852
  export VERBOSE
 
1853
  export WARNINGS
 
1854
 
 
1855
  case $OSTYPE in
 
1856
    darwin*)
 
1857
      export MallocGuardEdges
 
1858
      export MallocErrorAbort
 
1859
      export MallocScribble
 
1860
      ;;
 
1861
  esac
 
1862
 
 
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
 
1866
  fi
 
1867
 
 
1868
  # Variables which only can be set by .bootstrap
 
1869
  BOOTSTRAP_SNAPSHOT=false
 
1870
  BOOTSTRAP_SNAPSHOT_CHECK=
 
1871
 
 
1872
  if [ -f '.bootstrap' ]; then
 
1873
    source '.bootstrap'
 
1874
  fi
 
1875
 
 
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
 
1878
    enable_debug
 
1879
  elif [[ -n "$DEBUG" ]]; then
1891
1880
    enable_debug "Enabling DEBUG from '.bootstrap'"
 
1881
  fi
 
1882
 
 
1883
  if $env_debug_enabled; then
1892
1884
    print_setup
1893
1885
  fi
1894
 
fi
1895
 
 
1896
 
# We do this in order to protect the case where DEBUG
1897
 
if ! $env_debug_enabled; then
1898
 
  DEBUG=false
1899
 
fi
1900
 
 
1901
 
main $@
 
1886
 
 
1887
 
 
1888
  main "$@"
 
1889
}
 
1890
 
 
1891
# Script begins here
 
1892
declare -r program_name="$0"
 
1893
bootstrap "$@"