~brianaker/libmemcached/libmemcached-gearman-remove

929.1.243 by Brian Aker
Update testing.
1
#!/bin/bash
1063.1.9 by Brian Aker
Update m4 rules.
2
# 
1143.1.1 by Brian Aker
Clarification in DNS test.
3
# Copyright (C) 2012-2013 Brian Aker
1063.1.9 by Brian Aker
Update m4 rules.
4
# All rights reserved.
5
# 
6
# Redistribution and use in source and binary forms, with or without
7
# modification, are permitted provided that the following conditions are
8
# met:
9
# 
10
#     * Redistributions of source code must retain the above copyright
11
# notice, this list of conditions and the following disclaimer.
12
# 
13
#     * Redistributions in binary form must reproduce the above
14
# copyright notice, this list of conditions and the following disclaimer
15
# in the documentation and/or other materials provided with the
16
# distribution.
17
# 
18
#     * The names of its contributors may not be used to endorse or
19
# promote products derived from this software without specific prior
20
# written permission.
21
# 
22
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
34
35
# Environment Variables that will influence the build:
36
#   AUTOMAKE
37
#   AUTORECONF
38
#   LIBTOOLIZE
39
#   MAKE
40
#   PREFIX
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
41
#   LOG_COMPILER
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
42
#   VERBOSE
43
#   WARNINGS
44
#
45
1164.1.6 by Brian Aker
update ddm4
46
use_banner ()
47
{
48
  echo "#####################################################################################"
49
  echo "#"
50
  echo "#"
51
  echo "#"
52
  echo "#    TARGET:$1"
53
  echo "#"
54
  echo "#"
55
  echo "#"
56
  echo "#####################################################################################"
57
}
58
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
59
command_not_found_handle ()
60
{
1127.1.9 by Brian Aker
Update for mingw compile.
61
  warn "$@: command not found"
62
63
  #if $DEBUG; then 
64
    echo ""
65
    echo "Stack trace:"
66
    local frame=0
67
    while caller $frame; do
68
      ((frame++));
69
    done
70
    echo ""
71
  #fi
72
73
  return 127
74
}
75
1164.1.6 by Brian Aker
update ddm4
76
error ()
1127.1.9 by Brian Aker
Update for mingw compile.
77
{ 
78
  echo "$BASH_SOURCE:$BASH_LINENO: $@" >&2
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
79
}
80
1164.1.6 by Brian Aker
update ddm4
81
die ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
82
{ 
83
  echo "$BASH_SOURCE:$BASH_LINENO: $@" >&2
84
  exit 1; 
85
}
86
1164.1.6 by Brian Aker
update ddm4
87
warn ()
1127.1.9 by Brian Aker
Update for mingw compile.
88
{ 
89
  echo "$BASH_SOURCE:$BASH_LINENO: $@"
90
  #echo "$BASH_SOURCE:$BASH_LINENO: $@" >&1
91
}
92
1164.1.6 by Brian Aker
update ddm4
93
nassert ()
1086.1.9 by Brian Aker
Update bootstrap.sh
94
{
95
  local param_name=\$"$1"
1164.1.6 by Brian Aker
update ddm4
96
  local param_value="$(eval "expr \"$param_name\" ")"
1086.1.9 by Brian Aker
Update bootstrap.sh
97
98
  if [ -n "$param_value" ]; then
99
    echo "$bash_source:$bash_lineno: assert($param_name) had value of "$param_value"" >&2
100
    exit 1
101
  fi
102
}
103
1164.1.6 by Brian Aker
update ddm4
104
assert ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
105
{
106
  local param_name=\$"$1"
1164.1.6 by Brian Aker
update ddm4
107
  local param_value="$(eval "expr \"$param_name\" ")"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
108
109
  if [ -z "$param_value" ]; then
1086.1.9 by Brian Aker
Update bootstrap.sh
110
    echo "$bash_source:$bash_lineno: assert($param_name)" >&2
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
111
    exit 1
112
  fi
113
}
114
1164.1.6 by Brian Aker
update ddm4
115
assert_file ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
116
{
117
  if [ ! -f "$1" ]; then
118
    echo "$BASH_SOURCE:$BASH_LINENO: assert($1) does not exist: $2" >&2
119
    exit 1; 
120
  fi
121
}
122
1164.1.6 by Brian Aker
update ddm4
123
assert_no_file ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
124
{
125
  if [ -f "$1" ]; then
126
    echo "$BASH_SOURCE:$BASH_LINENO: assert($1) file exists: $2" >&2
127
    exit 1;
128
  fi
129
}
130
1164.1.6 by Brian Aker
update ddm4
131
assert_no_directory ()
1127.1.9 by Brian Aker
Update for mingw compile.
132
{
133
  if [ -d "$1" ]; then
134
    echo "$BASH_SOURCE:$BASH_LINENO: assert($1) directory exists: $2" >&2
135
    exit 1;
136
  fi
137
}
138
1164.1.6 by Brian Aker
update ddm4
139
assert_exec_file ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
140
{
141
  if [ ! -f "$1" ]; then
142
    echo "$BASH_SOURCE:$BASH_LINENO: assert($1) does not exist: $2" >&2
143
    exit 1;
144
  fi
145
146
  if [ ! -x "$1" ]; then
147
    echo "$BASH_SOURCE:$BASH_LINENO: assert($1) exists but is not executable: $2" >&2
148
    exit 1;
149
  fi
150
}
151
1164.1.6 by Brian Aker
update ddm4
152
command_exists ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
153
{
1072.1.1 by Brian Aker
Fix how we do manpages.
154
  type "$1" &> /dev/null ;
155
}
156
1164.1.6 by Brian Aker
update ddm4
157
rebuild_host_os ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
158
{
159
  HOST_OS="${UNAME_MACHINE_ARCH}-${VENDOR}-${VENDOR_DISTRIBUTION}-${VENDOR_RELEASE}-${UNAME_KERNEL}-${UNAME_KERNEL_RELEASE}"
160
  if [ -z "$1" ]; then
1164.1.6 by Brian Aker
update ddm4
161
    if $verbose; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
162
      echo "HOST_OS=$HOST_OS"
163
    fi
164
  fi
165
}
166
1155.1.2 by Brian Aker
Update to latest ddm4
167
# Validate the distribution name, or toss an erro
168
#  values: darwin,fedora,rhel,ubuntu,debian,opensuse
1164.1.6 by Brian Aker
update ddm4
169
set_VENDOR_DISTRIBUTION ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
170
{
1164.1.6 by Brian Aker
update ddm4
171
  local dist="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
172
  case "$dist" in
173
    darwin)
174
      VENDOR_DISTRIBUTION='darwin'
175
      ;;
176
    fedora)
177
      VENDOR_DISTRIBUTION='fedora'
178
      ;;
179
    rhel)
180
      VENDOR_DISTRIBUTION='rhel'
181
      ;;
1155.1.2 by Brian Aker
Update to latest ddm4
182
    debian)
183
      VENDOR_DISTRIBUTION='debian'
184
      ;;
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
185
    ubuntu)
186
      VENDOR_DISTRIBUTION='ubuntu'
187
      ;;
1155.1.2 by Brian Aker
Update to latest ddm4
188
    suse)
189
      VENDOR_DISTRIBUTION='opensuse'
190
      ;;
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
191
    opensuse)
192
      VENDOR_DISTRIBUTION='opensuse'
193
      ;;
194
    *)
195
      die "attempt to set an invalid VENDOR_DISTRIBUTION=$dist"
196
      ;;
197
  esac
198
}
199
1155.1.2 by Brian Aker
Update to latest ddm4
200
# Validate a Vendor's release name/number 
1164.1.6 by Brian Aker
update ddm4
201
set_VENDOR_RELEASE ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
202
{
1164.1.6 by Brian Aker
update ddm4
203
  local release="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
1161.1.1 by Brian Aker
Update ddm4
204
1164.1.6 by Brian Aker
update ddm4
205
  if $verbose; then 
1161.1.1 by Brian Aker
Update ddm4
206
    echo "VENDOR_DISTRIBUTION:$VENDOR_DISTRIBUTION"
207
    echo "VENDOR_RELEASE:$release"
208
  fi
209
210
  case $VENDOR_DISTRIBUTION in
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
211
    darwin)
1161.1.1 by Brian Aker
Update ddm4
212
      case $release in
1155.1.2 by Brian Aker
Update to latest ddm4
213
        10.6*)
214
          VENDOR_RELEASE='snow_leopard'
215
          ;;
216
        10.7*)
217
          VENDOR_RELEASE='mountain'
218
          ;;
219
        mountain)
220
          VENDOR_RELEASE='mountain'
221
          ;;
1161.1.1 by Brian Aker
Update ddm4
222
        10.8.*)
223
          echo "mountain_lion"
1155.1.2 by Brian Aker
Update to latest ddm4
224
          VENDOR_RELEASE='mountain_lion'
225
          ;;
1171.1.1 by Brian Aker
Update for mavericks
226
        10.9)
227
          echo "mavericks"
228
          VENDOR_RELEASE='mavericks'
229
          ;;
230
        10.9.*)
231
          echo "mavericks"
232
          VENDOR_RELEASE='mavericks'
233
          ;;
1155.1.2 by Brian Aker
Update to latest ddm4
234
        *)
1171.1.1 by Brian Aker
Update for mavericks
235
          echo $release
1155.1.2 by Brian Aker
Update to latest ddm4
236
          VENDOR_RELEASE='unknown'
237
          ;;
238
      esac
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
239
      ;;
240
    fedora)
241
      VENDOR_RELEASE="$release"
1155.1.2 by Brian Aker
Update to latest ddm4
242
      if [[ "x$VENDOR_RELEASE" == '18' ]]; then
243
        VENDOR_RELEASE='sphericalcow'
244
      fi
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
245
      ;;
246
    rhel)
247
      VENDOR_RELEASE="$release"
248
      ;;
1157.1.4 by Brian Aker
Update to latest bootstra.
249
    debian)
250
      VENDOR_RELEASE="$release"
251
      ;;
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
252
    ubuntu)
253
      VENDOR_RELEASE="$release"
1155.1.2 by Brian Aker
Update to latest ddm4
254
      if [[ "x$VENDOR_RELEASE" == 'x12.04' ]]; then
255
        VENDOR_RELEASE="precise"
256
      elif [[ "x$VENDOR_RELEASE" == 'x12.10' ]]; then
257
        VENDOR_RELEASE="quantal"
1159.1.5 by Brian Aker
Update to latest bootstrap
258
      elif [[ "x$VENDOR_RELEASE" == 'x13.04' ]]; then
259
        VENDOR_RELEASE="raring"
1155.1.2 by Brian Aker
Update to latest ddm4
260
      fi
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
261
      ;;
262
    opensuse)
263
      VENDOR_RELEASE="$release"
264
      ;;
265
    unknown)
266
      die "attempt to set VENDOR_RELEASE without setting VENDOR_DISTRIBUTION"
267
      ;;
268
    *)
269
      die "attempt to set with an invalid VENDOR_DISTRIBUTION=$VENDOR_DISTRIBUTION"
270
      ;;
271
  esac
272
}
273
274
1155.1.2 by Brian Aker
Update to latest ddm4
275
#  Valid values are: apple, redhat, centos, canonical, oracle, suse
1164.1.6 by Brian Aker
update ddm4
276
set_VENDOR ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
277
{
1164.1.6 by Brian Aker
update ddm4
278
  local vendor="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
279
280
  case $vendor in
281
    apple)
282
      VENDOR='apple'
283
      ;;
284
    redhat)
285
      VENDOR='redhat'
286
      ;;
1155.1.2 by Brian Aker
Update to latest ddm4
287
    fedora)
288
      VENDOR='redhat'
289
      ;;
290
    redhat-release-server-*)
291
      VENDOR='redhat'
292
      ;;
293
    enterprise-release-*)
294
      VENDOR='oracle'
295
      ;;
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
296
    centos)
297
      VENDOR='centos'
298
      ;;
299
    canonical)
300
      VENDOR='canonical'
301
      ;;
1155.1.2 by Brian Aker
Update to latest ddm4
302
    ubuntu)
303
      VENDOR='canonical'
304
      ;;
305
    debian)
306
      VENDOR='debian'
307
      ;;
308
    opensuse)
309
      VENDOR='suse'
310
      ;;
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
311
    suse)
312
      VENDOR='suse'
313
      ;;
314
    *)
315
      die "An attempt was made to set an invalid VENDOR=$_vendor"
316
      ;;
317
  esac
318
1164.1.6 by Brian Aker
update ddm4
319
  set_VENDOR_DISTRIBUTION "$2"
320
  set_VENDOR_RELEASE "$3"
1155.1.2 by Brian Aker
Update to latest ddm4
321
322
  # Set which vendor/versions we trust for autoreconf
323
  case $VENDOR_DISTRIBUTION in
324
    fedora)
325
      if [[ "x$VENDOR_RELEASE" == 'x18' ]]; then
326
        AUTORECONF_REBUILD_HOST=true
327
      elif [[ "x$VENDOR_RELEASE" == 'xsphericalcow' ]]; then
328
        AUTORECONF_REBUILD_HOST=true
329
      elif [[ "x$VENDOR_RELEASE" == 'x19' ]]; then
330
        AUTORECONF_REBUILD_HOST=true
331
      fi
332
      ;;
333
    canonical)
334
      if [[ "x$VENDOR_RELEASE" == 'xprecise' ]]; then
335
        AUTORECONF_REBUILD_HOST=true
336
      elif [[ "x$VENDOR_RELEASE" == 'xquantal' ]]; then
337
        AUTORECONF_REBUILD_HOST=true
338
      fi
339
      ;;
340
  esac
341
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
342
}
343
1164.1.6 by Brian Aker
update ddm4
344
determine_target_platform ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
345
{
1164.1.6 by Brian Aker
update ddm4
346
  UNAME_MACHINE_ARCH="$(uname -m 2>/dev/null)" || UNAME_MACHINE_ARCH=unknown
347
  UNAME_KERNEL="$(uname -s 2>/dev/null)"  || UNAME_SYSTEM=unknown
348
  UNAME_KERNEL_RELEASE="$(uname -r 2>/dev/null)" || UNAME_KERNEL_RELEASE=unknown
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
349
1155.1.2 by Brian Aker
Update to latest ddm4
350
  if [[ -x '/usr/bin/sw_vers' ]]; then 
1164.1.6 by Brian Aker
update ddm4
351
    local _VERSION="$(/usr/bin/sw_vers -productVersion)"
1155.1.2 by Brian Aker
Update to latest ddm4
352
    set_VENDOR 'apple' 'darwin' $_VERSION
353
  elif [[ $(uname) == 'Darwin' ]]; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
354
    set_VENDOR 'apple' 'darwin' 'mountain'
355
  elif [[ -f '/etc/fedora-release' ]]; then 
1164.1.6 by Brian Aker
update ddm4
356
    local fedora_version="$(awk ' { print $3 } ' < /etc/fedora-release)"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
357
    set_VENDOR 'redhat' 'fedora' $fedora_version
358
  elif [[ -f '/etc/centos-release' ]]; then
1164.1.6 by Brian Aker
update ddm4
359
    local centos_version="$(awk ' { print $7 } ' < /etc/centos-release)"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
360
    set_VENDOR 'centos' 'rhel' $centos_version
361
  elif [[ -f '/etc/SuSE-release' ]]; then
1164.1.6 by Brian Aker
update ddm4
362
    local suse_distribution="$(head -1 /etc/SuSE-release | awk ' { print $1 } ')"
363
    local suse_version="$(head -1 /etc/SuSE-release | awk ' { print $2 } ')"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
364
    set_VENDOR 'suse' $suse_distribution $suse_version
365
  elif [[ -f '/etc/redhat-release' ]]; then
1164.1.6 by Brian Aker
update ddm4
366
    local rhel_version="$(awk ' { print $7 } ' < /etc/redhat-release)"
367
    local _vendor="$(rpm -qf /etc/redhat-release)"
1155.1.2 by Brian Aker
Update to latest ddm4
368
    set_VENDOR $_vendor 'rhel' $rhel_version
369
  elif [[ -f '/etc/os-release' ]]; then 
370
    source '/etc/os-release'
371
    set_VENDOR $ID $ID $VERSION_ID
372
  elif [[ -x '/usr/bin/lsb_release' ]]; then 
1164.1.6 by Brian Aker
update ddm4
373
    local _ID="$(/usr/bin/lsb_release -s -i)"
374
    local _VERSION="$(/usr/bin/lsb_release -s -r)"
1155.1.2 by Brian Aker
Update to latest ddm4
375
    set_VENDOR $_ID $_ID $_VERSION_ID
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
376
  elif [[ -f '/etc/lsb-release' ]]; then 
1155.1.2 by Brian Aker
Update to latest ddm4
377
    source '/etc/lsb-release'
378
    set_VENDOR 'canonical' $DISTRIB_ID $DISTRIB_CODENAME
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
379
  fi
380
381
  rebuild_host_os
382
}
383
1164.1.6 by Brian Aker
update ddm4
384
run_configure ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
385
{
386
  # We will run autoreconf if we are required
387
  run_autoreconf_if_required
388
389
  # We always begin at the root of our build
1164.1.6 by Brian Aker
update ddm4
390
  if [ ! $? ]; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
391
    die "Programmer error, we entered run_configure with a stacked directory"
392
  fi
393
1127.1.9 by Brian Aker
Update for mingw compile.
394
  if ! command_exists "$CONFIGURE"; then
395
    die "$CONFIGURE does not exist"
396
  fi
397
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
398
  local BUILD_DIR="$1"
399
  if [[ -n "$BUILD_DIR" ]]; then
400
    rm -r -f $BUILD_DIR
401
    mkdir -p $BUILD_DIR
402
  fi
403
404
  # Arguments for configure
1164.1.6 by Brian Aker
update ddm4
405
  local BUILD_CONFIGURE_ARG='' 
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
406
1164.1.6 by Brian Aker
update ddm4
407
  # If debug is set we enable both debug and asssert, otherwise we see if this is a VCS checkout and if so enable assert
1161.1.1 by Brian Aker
Update ddm4
408
  # Set ENV ASSERT in order to enable assert.
409
  # If we are doing a valgrind run, we always compile with assert disabled
410
  if $valgrind_run; then
1164.1.6 by Brian Aker
update ddm4
411
    BUILD_CONFIGURE_ARG="--enable-assert=no $BUILD_CONFIGURE_ARG"
1161.1.1 by Brian Aker
Update ddm4
412
  else
1164.1.6 by Brian Aker
update ddm4
413
    if $debug; then 
414
      BUILD_CONFIGURE_ARG="--enable-debug --enable-assert $BUILD_CONFIGURE_ARG"
1161.1.1 by Brian Aker
Update ddm4
415
    elif [[ -n "$VCS_CHECKOUT" ]]; then
1164.1.6 by Brian Aker
update ddm4
416
      BUILD_CONFIGURE_ARG="--enable-assert $BUILD_CONFIGURE_ARG"
1161.1.1 by Brian Aker
Update ddm4
417
    fi
1127.1.9 by Brian Aker
Update for mingw compile.
418
  fi
419
420
  if [[ -n "$CONFIGURE_ARG" ]]; then 
1164.1.6 by Brian Aker
update ddm4
421
    BUILD_CONFIGURE_ARG="$CONFIGURE_ARG $BUILD_CONFIGURE_ARG"
1148.2.1 by Brian Aker
Harmonize WIN32, and update bootstrap
422
  fi
423
424
  if [[ -n "$PREFIX_ARG" ]]; then 
1164.1.6 by Brian Aker
update ddm4
425
    BUILD_CONFIGURE_ARG="$PREFIX_ARG $BUILD_CONFIGURE_ARG"
1127.1.9 by Brian Aker
Update for mingw compile.
426
  fi
427
428
  ret=1;
1072.1.4 by Brian Aker
Update
429
  # If we are executing on OSX use CLANG, otherwise only use it if we find it in the ENV
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
430
  case $HOST_OS in
431
    rhel-5*)
1127.1.9 by Brian Aker
Update for mingw compile.
432
      command_exists 'gcc44' || die "Could not locate gcc44"
1164.1.6 by Brian Aker
update ddm4
433
      run CC=gcc44 CXX=gcc44 $top_srcdir/configure "$BUILD_CONFIGURE_ARG" || die "Cannot execute CC=gcc44 CXX=gcc44 configure $BUILD_CONFIGURE_ARG"
1127.1.9 by Brian Aker
Update for mingw compile.
434
      ret=$?
1072.1.4 by Brian Aker
Update
435
      ;;
436
    *)
1164.1.6 by Brian Aker
update ddm4
437
      run $CONFIGURE "$BUILD_CONFIGURE_ARG"
1127.1.9 by Brian Aker
Update for mingw compile.
438
      ret=$?
1072.1.4 by Brian Aker
Update
439
      ;;
440
  esac
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
441
1127.1.9 by Brian Aker
Update for mingw compile.
442
  if [ $ret -ne 0 ]; then
1148.2.1 by Brian Aker
Harmonize WIN32, and update bootstrap
443
    die "Could not execute $CONFIGURE $BUILD_CONFIGURE_ARG"
1127.1.9 by Brian Aker
Update for mingw compile.
444
  fi
445
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
446
  if [ ! -f 'Makefile' ]; then
1127.1.9 by Brian Aker
Update for mingw compile.
447
    die "Programmer error, configure was run but no Makefile existed after $CONFIGURE was run"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
448
  fi
1072.1.4 by Brian Aker
Update
449
}
450
1164.1.6 by Brian Aker
update ddm4
451
setup_gdb_command ()
452
{
1072.1.4 by Brian Aker
Update
453
  GDB_TMPFILE=$(mktemp /tmp/gdb.XXXXXXXXXX)
1164.1.6 by Brian Aker
update ddm4
454
  echo 'set logging overwrite on' > "$GDB_TMPFILE"
455
  echo 'set logging on' >> "$GDB_TMPFILE"
456
  echo 'set environment LIBTEST_IN_GDB=1' >> "$GDB_TMPFILE"
457
  echo 'run' >> "$GDB_TMPFILE"
458
  echo 'thread apply all bt' >> "$GDB_TMPFILE"
459
  echo 'quit' >> "$GDB_TMPFILE"
1072.1.4 by Brian Aker
Update
460
  GDB_COMMAND="gdb -f -batch -x $GDB_TMPFILE"
461
}
462
1164.1.6 by Brian Aker
update ddm4
463
setup_valgrind_command ()
464
{
465
  VALGRIND_PROGRAM="$(type -p valgrind)"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
466
  if [[ -n "$VALGRIND_PROGRAM" ]]; then
1161.1.19 by Brian Aker
Fix for bootstrap
467
    VALGRIND_COMMAND="$VALGRIND_PROGRAM --error-exitcode=1 --leak-check=yes --malloc-fill=A5 --free-fill=DE --xml=yes --xml-file=\"valgrind-%p.xml\""
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
468
  fi
469
}
470
1164.1.6 by Brian Aker
update ddm4
471
save_BUILD ()
1127.1.9 by Brian Aker
Update for mingw compile.
472
{
473
  if [[ -n "$OLD_CONFIGURE" ]]; then
474
    die "OLD_CONFIGURE($OLD_CONFIGURE) was set on push, programmer error!"
475
  fi
476
477
  if [[ -n "$OLD_CONFIGURE_ARG" ]]; then
478
    die "OLD_CONFIGURE_ARG($OLD_CONFIGURE_ARG) was set on push, programmer error!"
479
  fi
480
1148.2.1 by Brian Aker
Harmonize WIN32, and update bootstrap
481
  if [[ -n "$OLD_PREFIX" ]]; then
482
    die "OLD_PREFIX($OLD_PREFIX) was set on push, programmer error!"
483
  fi
484
1127.1.9 by Brian Aker
Update for mingw compile.
485
  if [[ -n "$OLD_MAKE" ]]; then
486
    die "OLD_MAKE($OLD_MAKE) was set on push, programmer error!"
487
  fi
488
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
489
  if [[ -n "$OLD_LOG_COMPILER" ]]; then
490
    die "OLD_LOG_COMPILER($OLD_LOG_COMPILER) was set on push, programmer error!"
1127.1.9 by Brian Aker
Update for mingw compile.
491
  fi
492
493
  if [[ -n "$CONFIGURE" ]]; then
494
    OLD_CONFIGURE=$CONFIGURE
495
  fi
496
497
  if [[ -n "$CONFIGURE_ARG" ]]; then
498
    OLD_CONFIGURE_ARG=$CONFIGURE_ARG
499
  fi
500
501
  if [[ -n "$MAKE" ]]; then
502
    OLD_MAKE=$MAKE
503
  fi
504
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
505
  if [[ -n "$LOG_COMPILER" ]]; then
506
    OLD_LOG_COMPILER=$LOG_COMPILER
1127.1.9 by Brian Aker
Update for mingw compile.
507
  fi
508
}
509
1164.1.6 by Brian Aker
update ddm4
510
restore_BUILD ()
1127.1.9 by Brian Aker
Update for mingw compile.
511
{
512
  if [[ -n "$OLD_CONFIGURE" ]]; then
513
    CONFIGURE=$OLD_CONFIGURE
514
  fi
515
516
  if [[ -n "$OLD_CONFIGURE_ARG" ]]; then
517
    CONFIGURE_ARG=$OLD_CONFIGURE_ARG
518
  fi
519
1148.2.1 by Brian Aker
Harmonize WIN32, and update bootstrap
520
  if [[ -n "$OLD_PREFIX" ]]; then
1148.2.2 by Brian Aker
Adding missing windows file.
521
    PREFIX_ARG=$OLD_PREFIX
1148.2.1 by Brian Aker
Harmonize WIN32, and update bootstrap
522
  fi
523
1127.1.9 by Brian Aker
Update for mingw compile.
524
  if [[ -n "$OLD_MAKE" ]]; then
525
    MAKE=$OLD_MAKE
526
  fi
527
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
528
  if [[ -n "$OLD_LOG_COMPILER" ]]; then
529
    LOG_COMPILER=$OLD_LOG_COMPILER
1127.1.9 by Brian Aker
Update for mingw compile.
530
  fi
531
532
  OLD_CONFIGURE=
533
  OLD_CONFIGURE_ARG=
1148.2.1 by Brian Aker
Harmonize WIN32, and update bootstrap
534
  OLD_PREFIX=
1127.1.9 by Brian Aker
Update for mingw compile.
535
  OLD_MAKE=
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
536
  OLD_LOG_COMPILER=
1143.1.1 by Brian Aker
Clarification in DNS test.
537
538
  export -n CC CXX
1127.1.9 by Brian Aker
Update for mingw compile.
539
}
540
1164.1.6 by Brian Aker
update ddm4
541
make_valgrind ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
542
{
543
  # If the env VALGRIND_COMMAND is set then we assume it is valid
544
  local valgrind_was_set=false
545
  if [[ -z "$VALGRIND_COMMAND" ]]; then
546
    setup_valgrind_command
547
    if [[ -n "$VALGRIND_COMMAND" ]]; then
548
      valgrind_was_set=true
549
    fi
550
  else
551
    valgrind_was_set=true
552
  fi
553
554
  # If valgrind_was_set is set to no we bail
555
  if ! $valgrind_was_set; then
556
    echo 'valgrind was not present'
557
    return 1
558
  fi
559
1148.2.2 by Brian Aker
Adding missing windows file.
560
  save_BUILD
561
1161.1.1 by Brian Aker
Update ddm4
562
  valgrind_run=true
563
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
564
  # If we are required to run configure, do so now
1161.1.1 by Brian Aker
Update ddm4
565
  run_configure
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
566
1086.1.9 by Brian Aker
Update bootstrap.sh
567
  # If we don't have a configure, then most likely we will be missing libtool
568
  assert_file 'configure'
1161.1.14 by Brian Aker
Update bootstrap
569
  if [[ -x 'libtool' ]]; then
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
570
    LOG_COMPILER="./libtool --mode=execute $VALGRIND_COMMAND"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
571
  else
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
572
    LOG_COMPILER="$VALGRIND_COMMAND"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
573
  fi
574
1161.1.6 by Brian Aker
Adding all for bootstrap
575
  make_target 'all'
1161.1.1 by Brian Aker
Update ddm4
576
  make_target 'check'
577
  ret=$?
578
579
  valgrind_run=false
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
580
1148.2.2 by Brian Aker
Adding missing windows file.
581
  restore_BUILD
1161.1.1 by Brian Aker
Update ddm4
582
583
  if [ "$ret" -ne 0 ]; then
584
    return 1
585
  fi
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
586
}
587
1164.1.6 by Brian Aker
update ddm4
588
make_install_system ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
589
{
1164.1.6 by Brian Aker
update ddm4
590
  local INSTALL_LOCATION="$(mktemp -d /tmp/XXXXXXXXXX)"
1148.2.2 by Brian Aker
Adding missing windows file.
591
592
  save_BUILD
593
  PREFIX_ARG="--prefix=$INSTALL_LOCATION"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
594
595
  if [ ! -d $INSTALL_LOCATION ] ; then
596
    die "ASSERT temp directory not found '$INSTALL_LOCATION'"
597
  fi
598
599
  run_configure #install_buid_dir
600
601
  make_target 'install'
602
603
  make_target 'installcheck'
604
605
  make_target 'uninstall'
606
1072.1.4 by Brian Aker
Update
607
  rm -r -f $INSTALL_LOCATION
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
608
  make 'distclean'
609
610
  if [ -f 'Makefile' ]; then
611
    die "ASSERT Makefile should not exist"
612
  fi
613
1148.2.2 by Brian Aker
Adding missing windows file.
614
  restore_BUILD
1072.1.4 by Brian Aker
Update
615
}
616
1164.1.6 by Brian Aker
update ddm4
617
make_darwin_malloc ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
618
{
619
  run_configure_if_required
620
621
  old_MallocGuardEdges=$MallocGuardEdges
1072.1.4 by Brian Aker
Update
622
  MallocGuardEdges=1
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
623
  old_MallocErrorAbort=$MallocErrorAbort
1072.1.4 by Brian Aker
Update
624
  MallocErrorAbort=1
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
625
  old_MallocScribble=$MallocScribble
1072.1.4 by Brian Aker
Update
626
  MallocScribble=1
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
627
1072.1.4 by Brian Aker
Update
628
  make_check
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
629
630
  MallocGuardEdges=$old_MallocGuardEdges
631
  MallocErrorAbort=$old_MallocErrorAbort
632
  MallocScribble=$old_MallocScribble
633
}
634
635
# This will reset our environment, and make sure built files are available.
1164.1.6 by Brian Aker
update ddm4
636
make_for_snapshot ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
637
{
1161.1.4 by Brian Aker
Import latest bootstrap.sh
638
  # Lets make sure we have a clean environment
639
  assert_no_file 'Makefile'
640
  assert_no_file 'configure'
641
  assert_no_directory 'autom4te.cache'
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
642
643
  run_configure
1161.1.9 by Brian Aker
Fixes for
644
  make_target 'all'
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
645
  make_target 'distclean'
646
647
  # We should have a configure, but no Makefile at the end of this exercise
648
  assert_no_file 'Makefile'
649
  assert_exec_file 'configure'
650
}
651
1164.1.6 by Brian Aker
update ddm4
652
check_mingw ()
1127.1.9 by Brian Aker
Update for mingw compile.
653
{
654
  command_exists 'mingw64-configure'
655
  ret=$?
656
  if [ "$ret" -ne 0 ]; then
657
    return 1
658
  fi
659
660
  command_exists 'mingw64-make'
661
  ret=$?
662
  if [ "$ret" -ne 0 ]; then
663
    return 1
664
  fi
665
666
  return 0
667
}
668
1164.1.6 by Brian Aker
update ddm4
669
check_clang ()
1143.1.1 by Brian Aker
Clarification in DNS test.
670
{
671
  command_exists 'clang'
672
  ret=$?
673
  if [ "$ret" -ne 0 ]; then
674
    return 1
675
  fi
676
677
  return 0
678
}
679
1164.1.6 by Brian Aker
update ddm4
680
check_clang_analyzer ()
1143.1.1 by Brian Aker
Clarification in DNS test.
681
{
682
  command_exists 'scan-build'
683
  ret=$?
684
  if [ "$ret" -ne 0 ]; then
685
    return 1
686
  fi
687
688
  return 0
689
}
690
1164.1.6 by Brian Aker
update ddm4
691
make_skeleton ()
1127.1.9 by Brian Aker
Update for mingw compile.
692
{
693
  run_configure
694
  ret=$?
695
696
  if [ $ret -eq 0 ]; then
697
    assert_file 'Makefile'
698
699
    make_target 'all' 'warn'
700
    ret=$?
701
    if [ $ret -ne 0 ]; then
702
      warn "$MAKE failed"
703
    else
704
      if [[ -n "$DISPLAY" ]]; then
705
        if command_exists 'wine'; then
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
706
          LOG_COMPILER='wine'
1127.1.9 by Brian Aker
Update for mingw compile.
707
        fi
708
      fi
709
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
710
      if [[ -n "$LOG_COMPILER" ]]; then
1127.1.9 by Brian Aker
Update for mingw compile.
711
        make_target 'check' 'warn' || warn "$MAKE check failed"
712
        ret=$?
713
      fi
714
    fi
715
716
    if $jenkins_build_environment; then
717
      make_target 'clean' 'warn'
718
    fi
719
  fi
720
721
  return $ret
722
}
723
1164.1.6 by Brian Aker
update ddm4
724
make_for_mingw ()
1127.1.9 by Brian Aker
Update for mingw compile.
725
{
726
  if ! check_mingw; then
1143.1.1 by Brian Aker
Clarification in DNS test.
727
    return 1
1127.1.9 by Brian Aker
Update for mingw compile.
728
  fi
729
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
730
  # Make sure it is clean
731
  if [ -f Makefile -o -f configure ]; then
732
    make_maintainer_clean
733
  fi
1127.1.9 by Brian Aker
Update for mingw compile.
734
735
  run_autoreconf
736
737
  save_BUILD
738
739
  CONFIGURE='mingw64-configure'
740
  MAKE='mingw64-make'
1143.1.1 by Brian Aker
Clarification in DNS test.
741
  CONFIGURE_ARGS='--enable-static --disable-shared'
742
743
  make_skeleton
744
  ret=$?
745
746
  restore_BUILD
747
748
  return $ret
749
}
750
1164.1.6 by Brian Aker
update ddm4
751
make_for_clang ()
1143.1.1 by Brian Aker
Clarification in DNS test.
752
{
753
  if ! check_clang; then
754
    return 1
755
  fi
756
757
  # Make sure it is clean
758
  if [ -f Makefile -o -f configure ]; then
759
    make_maintainer_clean
760
  fi
761
762
  run_autoreconf
763
764
  save_BUILD
765
766
  CC=clang CXX=clang++
767
  export CC CXX
768
769
  make_skeleton
770
  ret=$?
771
772
  make_target 'check'
773
774
  restore_BUILD
775
776
  return $ret
777
}
778
1164.1.6 by Brian Aker
update ddm4
779
make_for_clang_analyzer ()
1143.1.1 by Brian Aker
Clarification in DNS test.
780
{
781
  if ! check_clang; then
782
    return 1
783
  fi
784
785
  if ! check_clang_analyzer; then
786
    die 'clang-analyzer was not found'
787
  fi
788
789
  # Make sure it is clean
790
  if [ -f Makefile -o -f configure ]; then
791
    make_maintainer_clean
792
  fi
793
794
  run_autoreconf
795
796
  save_BUILD
797
798
  CC=clang CXX=clang++
799
  export CC CXX
1164.1.6 by Brian Aker
update ddm4
800
  CONFIGURE='scan-build ./configure'
1143.1.1 by Brian Aker
Clarification in DNS test.
801
  CONFIGURE_ARGS='--enable-debug'
802
1164.1.6 by Brian Aker
update ddm4
803
  run_configure
1143.1.1 by Brian Aker
Clarification in DNS test.
804
805
  scan-build -o clang-html make -j4 -k
1127.1.9 by Brian Aker
Update for mingw compile.
806
807
  restore_BUILD
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
808
}
809
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
810
# If we are locally testing, we should make sure the environment is setup correctly
1164.1.6 by Brian Aker
update ddm4
811
check_for_jenkins ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
812
{
813
  if ! $jenkins_build_environment; then
1161.1.4 by Brian Aker
Import latest bootstrap.sh
814
    echo "Not inside of jenkins, simulating environment"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
815
816
    if [ -f 'configure' ]; then
817
      make_maintainer_clean
818
    fi
819
820
    if $BOOTSTRAP_SNAPSHOT; then
821
      make_for_snapshot
822
    fi
823
  fi
824
}
825
1164.1.6 by Brian Aker
update ddm4
826
make_universe ()
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
827
{
1164.1.6 by Brian Aker
update ddm4
828
  use_banner 'make maintainer-clean'
829
  make_maintainer_clean
830
831
  use_banner 'snapshot'
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
832
  make_for_snapshot
1164.1.6 by Brian Aker
update ddm4
833
834
  use_banner 'valgrind'
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
835
  make_valgrind
1164.1.6 by Brian Aker
update ddm4
836
837
  use_banner 'gdb'
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
838
  make_gdb
1164.1.6 by Brian Aker
update ddm4
839
840
  use_banner 'rpm'
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
841
  make_rpm
1164.1.6 by Brian Aker
update ddm4
842
843
  use_banner 'clang'
1143.1.1 by Brian Aker
Clarification in DNS test.
844
  make_for_clang
1164.1.6 by Brian Aker
update ddm4
845
846
  use_banner 'clang analyzer'
1143.1.1 by Brian Aker
Clarification in DNS test.
847
  make_for_clang_analyzer
1127.1.9 by Brian Aker
Update for mingw compile.
848
1164.1.6 by Brian Aker
update ddm4
849
  use_banner 'mingw'
850
  check_mingw
851
  if [ $? -eq 0 ]; then
1127.1.9 by Brian Aker
Update for mingw compile.
852
    make_for_mingw
853
  fi
854
1164.1.6 by Brian Aker
update ddm4
855
  use_banner 'make distcheck'
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
856
  make_distcheck
1164.1.6 by Brian Aker
update ddm4
857
858
  use_banner 'make install'
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
859
  make_install_system
860
}
861
1164.1.6 by Brian Aker
update ddm4
862
check_snapshot ()
1161.1.9 by Brian Aker
Fixes for
863
{
864
  if [ -n "$BOOTSTRAP_SNAPSHOT_CHECK" ]; then
865
    assert_file "$BOOTSTRAP_SNAPSHOT_CHECK" 'snapshot check failed'
866
  fi
867
}
868
1164.1.6 by Brian Aker
update ddm4
869
make_for_continuus_integration ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
870
{
871
  # Setup the environment if we are local
872
  check_for_jenkins
873
874
  # No matter then evironment, we should not have a Makefile at this point
875
  assert_no_file 'Makefile'
876
877
  # Platforms which require bootstrap should have some setup done before we hit this stage.
878
  # If we are building locally, skip this step, unless we are just testing locally. 
879
  if $BOOTSTRAP_SNAPSHOT; then
1161.1.4 by Brian Aker
Import latest bootstrap.sh
880
    if $BOOTSTRAP_SNAPSHOT; then
881
      assert_file 'configure'
882
    fi
883
1161.1.9 by Brian Aker
Fixes for
884
    check_snapshot
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
885
  else
886
    # If we didn't require a snapshot, then we should not have a configure
887
    assert_no_file 'configure'
888
889
    run_autoreconf
890
  fi
891
892
  assert_no_file 'Makefile' 'Programmer error, Makefile existed where build state should have been clean'
893
894
  case $HOST_OS in
1072.1.4 by Brian Aker
Update
895
    *)
1086.1.9 by Brian Aker
Update bootstrap.sh
896
      make_jenkins_default
1072.1.4 by Brian Aker
Update
897
      ;;
898
  esac
899
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
900
  make_maintainer_clean
1072.1.4 by Brian Aker
Update
901
}
902
1086.1.9 by Brian Aker
Update bootstrap.sh
903
# The point to this test is to test bootstrap.sh itself
1164.1.6 by Brian Aker
update ddm4
904
self_test ()
1086.1.9 by Brian Aker
Update bootstrap.sh
905
{
906
  # We start off with a clean env
907
  make_maintainer_clean
908
1164.1.6 by Brian Aker
update ddm4
909
#  eval "./bootstrap.sh jenkins" || die "failed 'jenkins'"
910
#  eval "./bootstrap.sh all" || die "failed 'all'"
911
#  eval "./bootstrap.sh gdb" || die "failed 'gdb'"
912
#  eval "./bootstrap.sh maintainer-clean" || die "failed 'maintainer-clean'"
1086.1.9 by Brian Aker
Update bootstrap.sh
913
}
914
1164.1.6 by Brian Aker
update ddm4
915
make_install_html ()
1127.1.9 by Brian Aker
Update for mingw compile.
916
{
917
  run_configure_if_required
918
  assert_file 'configure'
919
920
  make_target 'install-html'
921
}
922
1164.1.6 by Brian Aker
update ddm4
923
make_gdb ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
924
{
1148.2.2 by Brian Aker
Adding missing windows file.
925
  save_BUILD
926
1127.1.9 by Brian Aker
Update for mingw compile.
927
  if command_exists 'gdb'; then
928
    run_configure_if_required
1072.1.4 by Brian Aker
Update
929
930
    # Set ENV GDB_COMMAND
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
931
    if [[ -z "$GDB_COMMAND" ]]; then
1072.1.4 by Brian Aker
Update
932
      setup_gdb_command
933
    fi
934
1086.1.9 by Brian Aker
Update bootstrap.sh
935
    # If we don't have a configure, then most likely we will be missing libtool
936
    assert_file 'configure'
937
    if [[ -f 'libtool' ]]; then
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
938
      LOG_COMPILER="./libtool --mode=execute $GDB_COMMAND"
1072.1.4 by Brian Aker
Update
939
    else
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
940
      LOG_COMPILER="$GDB_COMMAND"
1072.1.4 by Brian Aker
Update
941
    fi
942
1127.1.9 by Brian Aker
Update for mingw compile.
943
    make_target 'check'
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
944
945
    if [ -f 'gdb.txt' ]; then
946
      rm 'gdb.txt'
947
    fi
948
949
    if [ -f '.gdb_history' ]; then
950
      rm '.gdb_history'
951
    fi
1127.1.9 by Brian Aker
Update for mingw compile.
952
953
    if $jenkins_build_environment; then
954
      make_target 'clean'
955
    fi
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
956
  else
957
    echo 'gdb was not present'
958
    return 1
959
  fi
1148.2.2 by Brian Aker
Adding missing windows file.
960
961
  restore_BUILD
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
962
}
963
964
# $1 target to compile
965
# $2 to die, or not to die, based on contents
1164.1.6 by Brian Aker
update ddm4
966
make_target ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
967
{
1121.1.3 by Brian Aker
Update bootstrap.sh
968
  if [ -z "$1" ]; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
969
    die "Programmer error, no target provided for make"
970
  fi
971
972
  if [ ! -f 'Makefile' ]; then
973
    die "Programmer error, make was called before configure"
974
    run_configure
975
  fi
976
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
977
  if [ -n "$LOG_COMPILER" ]; then
1164.1.6 by Brian Aker
update ddm4
978
    if $verbose; then
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
979
      echo "LOG_COMPILER=$LOG_COMPILER"
1121.1.3 by Brian Aker
Update bootstrap.sh
980
    fi
1072.1.4 by Brian Aker
Update
981
  fi
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
982
1121.1.3 by Brian Aker
Update bootstrap.sh
983
  if [ -z "$MAKE" ]; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
984
    die "MAKE was not set"
985
  fi
986
1127.1.9 by Brian Aker
Update for mingw compile.
987
  # $2 represents error or warn
1164.1.6 by Brian Aker
update ddm4
988
  run "$MAKE" "$1"
1127.1.9 by Brian Aker
Update for mingw compile.
989
  ret=$?
990
991
  if [ $ret -ne 0 ]; then
992
    if [ -n "$2" ]; then
1143.1.1 by Brian Aker
Clarification in DNS test.
993
      warn "Failed to execute $MAKE $1: $ret"
1164.1.6 by Brian Aker
update ddm4
994
    elif [ $ret -eq 2 ]; then
995
      die "Failed to execute $MAKE $1"
1127.1.9 by Brian Aker
Update for mingw compile.
996
    else
1143.1.1 by Brian Aker
Clarification in DNS test.
997
      die "Failed to execute $MAKE $1: $ret"
1127.1.9 by Brian Aker
Update for mingw compile.
998
    fi
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
999
  fi
1127.1.9 by Brian Aker
Update for mingw compile.
1000
1001
  return $ret
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1002
}
1003
1164.1.6 by Brian Aker
update ddm4
1004
make_distcheck ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1005
{
1006
  make_target 'distcheck'
1007
}
1008
1164.1.6 by Brian Aker
update ddm4
1009
make_rpm ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1010
{
1127.1.9 by Brian Aker
Update for mingw compile.
1011
  if command_exists 'rpmbuild'; then
1012
    if [ -f 'rpm.am' -o -d 'rpm' ]; then
1164.1.6 by Brian Aker
update ddm4
1013
      mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
1014
      mkdir -p ~/rpmbuild/RPMS/{i386,i486,i586,i686,noarch,athlon}
1015
1127.1.9 by Brian Aker
Update for mingw compile.
1016
      run_configure_if_required
1185.2.1 by Brian Aker
RPM update.
1017
      make_target 'dist-rpm'
1018
1019
      mkdir artifacts
1020
      cp *gz *rpm artifacts
1127.1.9 by Brian Aker
Update for mingw compile.
1021
1022
      if $jenkins_build_environment; then
1023
        make_target 'clean'
1024
      fi
1025
1026
    fi
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
1027
  fi
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1028
}
1029
1164.1.6 by Brian Aker
update ddm4
1030
make_maintainer_clean ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1031
{
1032
  run_configure_if_required
1033
  make_target 'maintainer-clean' 'no_error'
1127.1.9 by Brian Aker
Update for mingw compile.
1034
1035
  # Lets make sure we really cleaned up the environment
1036
  assert_no_file 'Makefile'
1037
  assert_no_file 'configure'
1038
  assert_no_directory 'autom4te.cache'
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1039
}
1040
1164.1.6 by Brian Aker
update ddm4
1041
make_distclean ()
1042
{
1043
  run_configure_if_required
1044
  make_target 'distclean' 'no_error'
1045
1046
  # Lets make sure we really cleaned up the environment
1047
  assert_no_file 'Makefile'
1048
  assert_file 'configure'
1049
}
1050
1051
make_check ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1052
{
1053
  make_target 'check'
1054
}
1055
1164.1.6 by Brian Aker
update ddm4
1056
make_jenkins_default ()
1086.1.9 by Brian Aker
Update bootstrap.sh
1057
{
1058
  run_configure
1059
  make_target 'all'
1060
}
1061
1164.1.6 by Brian Aker
update ddm4
1062
make_default ()
1086.1.9 by Brian Aker
Update bootstrap.sh
1063
{
1064
  run_configure_if_required
1065
  make_target 'all'
1066
}
1067
1164.1.6 by Brian Aker
update ddm4
1068
run_configure_if_required () 
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1069
{
1070
  run_autoreconf_if_required
1071
1072
  if [ ! -f 'Makefile' ]; then
1073
    run_configure
1074
  fi
1075
1076
  assert_file 'Makefile' 'configure did not produce a Makefile'
1077
}
1078
1164.1.6 by Brian Aker
update ddm4
1079
run_make_maintainer_clean_if_possible () 
1157.1.4 by Brian Aker
Update to latest bootstra.
1080
{
1081
  if [ -f 'Makefile' ]; then
1082
    make_maintainer_clean
1083
  fi
1084
}
1085
1164.1.6 by Brian Aker
update ddm4
1086
run_autoreconf_if_required () 
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1087
{
1088
  if [ ! -x 'configure' ]; then
1089
    run_autoreconf
1090
  fi
1091
1092
  assert_exec_file 'configure'
1155.1.2 by Brian Aker
Update to latest ddm4
1093
  bash -n configure
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1094
}
1095
1164.1.6 by Brian Aker
update ddm4
1096
run_autoreconf () 
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1097
{
1098
  if [[ -z "$AUTORECONF" ]]; then
1099
    die "Programmer error, tried to call run_autoreconf () but AUTORECONF was not set"
1100
  fi
1101
1164.1.6 by Brian Aker
update ddm4
1102
  if $use_libtool; then
1121.1.3 by Brian Aker
Update bootstrap.sh
1103
    assert $BOOTSTRAP_LIBTOOLIZE
1182.1.2 by Brian Aker
Update bootstrap.
1104
    if $jenkins_build_environment; then
1105
      run "$BOOTSTRAP_LIBTOOLIZE" '--copy' '--install' || die "Cannot execute $BOOTSTRAP_LIBTOOLIZE"
1106
    else
1107
      run "$BOOTSTRAP_LIBTOOLIZE" '--copy' '--install' '--force' || die "Cannot execute $BOOTSTRAP_LIBTOOLIZE"
1108
    fi
1121.1.3 by Brian Aker
Update bootstrap.sh
1109
  fi
1110
1164.1.6 by Brian Aker
update ddm4
1111
  run "$AUTORECONF" "$AUTORECONF_ARGS" || die "Cannot execute $AUTORECONF"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1112
1113
  eval 'bash -n configure' || die "autoreconf generated a malformed configure"
1114
}
1115
1164.1.6 by Brian Aker
update ddm4
1116
run ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1117
{
1164.1.6 by Brian Aker
update ddm4
1118
  if $verbose; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1119
    echo "\`$@' $ARGS"
1120
  fi
1121
1127.1.9 by Brian Aker
Update for mingw compile.
1122
  if [ -z "$1" ]; then
1123
    return 127;
1124
  fi
1125
1164.1.6 by Brian Aker
update ddm4
1126
  eval "$@" "$ARGS"
1070.1.3 by Brian Aker
Updates from ddm4
1127
} 
1128
1164.1.6 by Brian Aker
update ddm4
1129
parse_command_line_options ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1130
{
1086.1.9 by Brian Aker
Update bootstrap.sh
1131
  local SHORTOPTS=':apcmt:dvh'
1132
1164.1.6 by Brian Aker
update ddm4
1133
  nassert OPT_TARGET
1083.1.2 by Brian Aker
OSX lacks getopt long support :(
1134
1135
  while getopts "$SHORTOPTS" opt; do
1136
    case $opt in
1137
      a) #--autoreconf
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1138
        AUTORECONF_OPTION=true
1164.1.6 by Brian Aker
update ddm4
1139
        OPT_TARGET+='autoreconf'
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1140
        ;;
1083.1.2 by Brian Aker
OSX lacks getopt long support :(
1141
      p) #--print-env
1164.1.6 by Brian Aker
update ddm4
1142
        print_setup_opt=true
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1143
        ;;
1083.1.2 by Brian Aker
OSX lacks getopt long support :(
1144
      c) # --configure
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1145
        CONFIGURE_OPTION=true
1164.1.6 by Brian Aker
update ddm4
1146
        OPT_TARGET+='configure'
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1147
        ;;
1083.1.2 by Brian Aker
OSX lacks getopt long support :(
1148
      m) # maintainer-clean
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1149
        CLEAN_OPTION=true
1164.1.6 by Brian Aker
update ddm4
1150
        ;;
1151
      o) # target
1152
        CONFIGURE_ARG="$OPTARG"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1153
        ;;
1083.1.2 by Brian Aker
OSX lacks getopt long support :(
1154
      t) # target
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1155
        TARGET_OPTION=true
1083.1.2 by Brian Aker
OSX lacks getopt long support :(
1156
        TARGET_OPTION_ARG="$OPTARG"
1164.1.6 by Brian Aker
update ddm4
1157
        OPT_TARGET+="$OPTARG"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1158
        ;;
1083.1.2 by Brian Aker
OSX lacks getopt long support :(
1159
      d) # debug
1164.1.6 by Brian Aker
update ddm4
1160
        opt_debug=true
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1161
        enable_debug
1162
        ;;
1086.1.9 by Brian Aker
Update bootstrap.sh
1163
      h) # help
1164
        echo "bootstrap.sh [options] optional_target ..."
1155.1.1 by Brian Aker
Fix for lp:1164442
1165
        echo "  -a # Just run autoreconf";
1166
        echo "  -p # Print ENV";
1167
        echo "  -c # Just run configure";
1168
        echo "  -m # Just run maintainer-clean";
1164.1.6 by Brian Aker
update ddm4
1169
        echo "  -o # Specify configure arguments";
1155.1.1 by Brian Aker
Fix for lp:1164442
1170
        echo "  -t # Make target";
1171
        echo "  -d # Enable debug";
1172
        echo "  -h # Show help";
1173
        echo "  -v # Be more verbose in output";
1086.1.9 by Brian Aker
Update bootstrap.sh
1174
        exit
1175
        ;;
1083.1.2 by Brian Aker
OSX lacks getopt long support :(
1176
      v) # verbose
1164.1.6 by Brian Aker
update ddm4
1177
        opt_verbose=true
1178
        verbose=true
1083.1.2 by Brian Aker
OSX lacks getopt long support :(
1179
        ;;
1180
      :)
1181
        echo "Option -$OPTARG requires an argument." >&2
1182
        exit 1
1183
        ;;
1184
      *)
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1185
        echo "$0: error - unrecognized option $1" 1>&2
1186
        exit 1
1187
        ;;
1072.1.8 by Brian Aker
Add new method which allows someone to "take" a value from a result object.
1188
    esac
1189
  done
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1190
1086.1.9 by Brian Aker
Update bootstrap.sh
1191
  shift $((OPTIND-1))
1192
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1193
  if [ -n "$1" ]; then
1164.1.6 by Brian Aker
update ddm4
1194
    OPT_TARGET="$@"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1195
  fi
1072.1.8 by Brian Aker
Add new method which allows someone to "take" a value from a result object.
1196
}
1197
1164.1.6 by Brian Aker
update ddm4
1198
determine_vcs ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1199
{
1200
  if [[ -d '.git' ]]; then
1072.1.4 by Brian Aker
Update
1201
    VCS_CHECKOUT=git
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1202
  elif [[ -d '.bzr' ]]; then
1072.1.4 by Brian Aker
Update
1203
    VCS_CHECKOUT=bzr
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1204
  elif [[ -d '.svn' ]]; then
1072.1.4 by Brian Aker
Update
1205
    VCS_CHECKOUT=svn
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1206
  elif [[ -d '.hg' ]]; then
1072.1.4 by Brian Aker
Update
1207
    VCS_CHECKOUT=hg
1148.2.1 by Brian Aker
Harmonize WIN32, and update bootstrap
1208
  else
1209
    VCS_CHECKOUT=
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1210
  fi
1211
1212
  if [[ -n "$VCS_CHECKOUT" ]]; then
1164.1.6 by Brian Aker
update ddm4
1213
    verbose=true
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1214
  fi
1215
}
1216
1164.1.6 by Brian Aker
update ddm4
1217
require_libtoolise ()
1121.1.3 by Brian Aker
Update bootstrap.sh
1218
{
1219
  grep '^[         ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
1164.1.6 by Brian Aker
update ddm4
1220
    && use_libtool=true
1121.1.3 by Brian Aker
Update bootstrap.sh
1221
  grep '^[         ]*LT_INIT' configure.ac >/dev/null \
1164.1.6 by Brian Aker
update ddm4
1222
    && use_libtool=true
1121.1.3 by Brian Aker
Update bootstrap.sh
1223
}
1224
1164.1.6 by Brian Aker
update ddm4
1225
autoreconf_setup ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1226
{
1072.1.1 by Brian Aker
Fix how we do manpages.
1227
  # Set ENV MAKE in order to override "make"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1228
  if [[ -z "$MAKE" ]]; then 
1127.1.9 by Brian Aker
Update for mingw compile.
1229
    if command_exists 'gmake'; then
1164.1.6 by Brian Aker
update ddm4
1230
      MAKE="$(type -p gmake)"
1083.1.4 by Brian Aker
Update to allow rpm to be legal jenkins target.
1231
    else
1127.1.9 by Brian Aker
Update for mingw compile.
1232
      if command_exists 'make'; then
1164.1.6 by Brian Aker
update ddm4
1233
        MAKE="$(type -p make)"
1083.1.4 by Brian Aker
Update to allow rpm to be legal jenkins target.
1234
      fi
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1235
    fi
1083.1.4 by Brian Aker
Update to allow rpm to be legal jenkins target.
1236
    
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
1237
    if [ "$VCS_CHECKOUT" ]; then
1164.1.6 by Brian Aker
update ddm4
1238
      if $debug; then
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
1239
        MAKE="$MAKE --warn-undefined-variables"
1240
      fi
1241
    fi
1242
1164.1.6 by Brian Aker
update ddm4
1243
    if $debug; then
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
1244
      MAKE="$MAKE -d"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1245
    fi
1246
  fi
1247
1248
  if [[ -z "$GNU_BUILD_FLAGS" ]]; then
1182.1.2 by Brian Aker
Update bootstrap.
1249
    if $jenkins_build_environment; then
1250
      GNU_BUILD_FLAGS="--install"
1251
    else
1252
      GNU_BUILD_FLAGS="--install --force"
1253
    fi
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1254
  fi
1255
1164.1.6 by Brian Aker
update ddm4
1256
  if $verbose; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1257
    GNU_BUILD_FLAGS="$GNU_BUILD_FLAGS --verbose"
1258
  fi
1259
1088.1.11 by Brian Aker
Update m4
1260
  if [ -z "$ACLOCAL_PATH" ]; then
1261
    ACLOCAL_PATH="/usr/local/share/aclocal $ACLOCAL_PATH"
1262
  fi
1263
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1264
  if [[ -z "$WARNINGS" ]]; then
1265
    if [[ -n "$VCS_CHECKOUT" ]]; then
1266
      WARNINGS="all,error"
1267
    else
1268
      WARNINGS="all"
1269
    fi
1270
  fi
1271
1164.1.6 by Brian Aker
update ddm4
1272
  if $use_libtool; then
1121.1.3 by Brian Aker
Update bootstrap.sh
1273
    if [[ -n "$LIBTOOLIZE" ]]; then
1164.1.6 by Brian Aker
update ddm4
1274
      BOOTSTRAP_LIBTOOLIZE="$(type -p $LIBTOOLIZE)"
1121.1.3 by Brian Aker
Update bootstrap.sh
1275
1276
      if [[ -z "$BOOTSTRAP_LIBTOOLIZE" ]]; then
1277
        echo "Couldn't find user supplied libtoolize, it is required"
1155.1.1 by Brian Aker
Fix for lp:1164442
1278
        return 1
1121.1.3 by Brian Aker
Update bootstrap.sh
1279
      fi
1280
    else
1281
      # If we are using OSX, we first check to see glibtoolize is available
1282
      if [[ "$VENDOR_DISTRIBUTION" == "darwin" ]]; then
1164.1.6 by Brian Aker
update ddm4
1283
        BOOTSTRAP_LIBTOOLIZE="$(type -p glibtoolize)"
1121.1.3 by Brian Aker
Update bootstrap.sh
1284
1285
        if [[ -z "$BOOTSTRAP_LIBTOOLIZE" ]]; then
1286
          echo "Couldn't find glibtoolize, it is required on OSX"
1155.1.1 by Brian Aker
Fix for lp:1164442
1287
          return 1
1121.1.3 by Brian Aker
Update bootstrap.sh
1288
        fi
1289
      else
1164.1.6 by Brian Aker
update ddm4
1290
        BOOTSTRAP_LIBTOOLIZE="$(type -p libtoolize)"
1121.1.3 by Brian Aker
Update bootstrap.sh
1291
1292
        if [[ -z "$BOOTSTRAP_LIBTOOLIZE" ]]; then
1293
          echo "Couldn't find libtoolize, it is required"
1155.1.1 by Brian Aker
Fix for lp:1164442
1294
          return 1
1121.1.3 by Brian Aker
Update bootstrap.sh
1295
        fi
1296
      fi
1297
    fi
1161.1.1 by Brian Aker
Update ddm4
1298
1164.1.6 by Brian Aker
update ddm4
1299
    if $verbose; then
1121.1.3 by Brian Aker
Update bootstrap.sh
1300
      LIBTOOLIZE_OPTIONS="--verbose $BOOTSTRAP_LIBTOOLIZE_OPTIONS"
1301
    fi
1161.1.1 by Brian Aker
Update ddm4
1302
1164.1.6 by Brian Aker
update ddm4
1303
    if $debug; then
1121.1.3 by Brian Aker
Update bootstrap.sh
1304
      LIBTOOLIZE_OPTIONS="--debug $BOOTSTRAP_LIBTOOLIZE_OPTIONS"
1305
    fi
1161.1.1 by Brian Aker
Update ddm4
1306
1307
    # Here we set LIBTOOLIZE to true since we are going to invoke it via BOOTSTRAP_LIBTOOLIZE
1121.1.3 by Brian Aker
Update bootstrap.sh
1308
    LIBTOOLIZE=true
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1309
  fi
1310
1311
  # Test the ENV AUTOMAKE if it exists
1312
  if [[ -n "$AUTOMAKE" ]]; then
1164.1.6 by Brian Aker
update ddm4
1313
    run "$AUTOMAKE" '--help'    &> /dev/null    || die "Failed to run AUTOMAKE:$AUTOMAKE"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1314
  fi
1315
1316
  # Test the ENV AUTOCONF if it exists
1317
  if [[ -n "$AUTOCONF" ]]; then
1164.1.6 by Brian Aker
update ddm4
1318
    run "$AUTOCONF" '--help'    &> /dev/null    || die "Failed to run AUTOCONF:$AUTOCONF"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1319
  fi
1320
1321
  # Test the ENV AUTOHEADER if it exists
1322
  if [[ -n "$AUTOHEADER" ]]; then
1164.1.6 by Brian Aker
update ddm4
1323
    run "$AUTOHEADER" '--help'  &> /dev/null    || die "Failed to run AUTOHEADER:$AUTOHEADER"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1324
  fi
1325
1326
  # Test the ENV AUTOM4TE if it exists
1327
  if [[ -n "$AUTOM4TE" ]]; then
1164.1.6 by Brian Aker
update ddm4
1328
    run "$AUTOM4TE" '--help'    &> /dev/null    || die "Failed to run AUTOM4TE:$AUTOM4TE"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1329
  fi
1330
1121.1.3 by Brian Aker
Update bootstrap.sh
1331
  # Test the ENV AUTOHEADER if it exists, if not we add one and add --install
1332
  if [[ -z "$ACLOCAL" ]]; then
1333
    ACLOCAL="aclocal --install"
1334
  fi
1164.1.6 by Brian Aker
update ddm4
1335
  run "$ACLOCAL" '--help'  &> /dev/null    || die "Failed to run ACLOCAL:$ACLOCAL"
1121.1.3 by Brian Aker
Update bootstrap.sh
1336
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1337
  if [[ -z "$AUTORECONF" ]]; then
1164.1.6 by Brian Aker
update ddm4
1338
    AUTORECONF="$(type -p autoreconf)"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1339
1340
    if [[ -z "$AUTORECONF" ]]; then
1341
      die "Couldn't find autoreconf"
1342
    fi
1343
1344
    if [[ -n "$GNU_BUILD_FLAGS" ]]; then
1161.1.1 by Brian Aker
Update ddm4
1345
      AUTORECONF_ARGS="$GNU_BUILD_FLAGS"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1346
    fi
1347
  fi
1348
1164.1.6 by Brian Aker
update ddm4
1349
  run "$AUTORECONF" '--help'  &> /dev/null    || die "Failed to run AUTORECONF:$AUTORECONF"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1350
}
1351
1164.1.6 by Brian Aker
update ddm4
1352
print_setup ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1353
{
1164.1.6 by Brian Aker
update ddm4
1354
  local saved_debug_status=$debug
1355
  if $debug; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1356
    disable_debug
1357
  fi
1358
1359
  echo '----------------------------------------------' 
1360
  echo 'BOOTSTRAP ENV' 
1361
  echo "AUTORECONF=$AUTORECONF"
1362
  echo "HOST_OS=$HOST_OS"
1155.1.1 by Brian Aker
Fix for lp:1164442
1363
  echo "VENDOR=$VENDOR"
1364
  echo "VENDOR_DISTRIBUTION=$VENDOR_DISTRIBUTION"
1365
  echo "VENDOR_RELEASE=$VENDOR_RELEASE"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1366
1367
  echo "getopt()"
1368
  if $AUTORECONF_OPTION; then
1369
    echo "--autoreconf"
1370
  fi
1371
1372
  if $CLEAN_OPTION; then
1373
    echo "--clean"
1374
  fi
1375
1376
  if $CONFIGURE_OPTION; then
1377
    echo "--configure"
1378
  fi
1379
1164.1.6 by Brian Aker
update ddm4
1380
  if $opt_debug; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1381
    echo "--debug"
1382
  fi
1383
1164.1.6 by Brian Aker
update ddm4
1384
  if $print_setup_opt; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1385
    echo "--print-env"
1386
  fi
1387
1388
  if $TARGET_OPTION; then
1389
    echo "--target=$TARGET_OPTION_ARG"
1390
  fi
1391
1164.1.6 by Brian Aker
update ddm4
1392
  if $opt_verbose; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1393
    echo "--verbose"
1394
  fi
1395
1396
  if [[ -n "$MAKE" ]]; then
1397
    echo "MAKE=$MAKE"
1398
  fi
1399
1174.1.1 by Brian Aker
Update the bootstrap rules.
1400
  if [[ -n "$BOOTSTRAP_TARGET" ]]; then
1401
    echo "BOOTSTRAP_TARGET=$BOOTSTRAP_TARGET"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1402
  fi
1403
1404
  if [[ -n "$PREFIX" ]]; then
1405
    echo "PREFIX=$PREFIX"
1406
  fi
1407
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
1408
  if [[ -n "$LOG_COMPILER" ]]; then
1409
    echo "LOG_COMPILER=$LOG_COMPILER"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1410
  fi
1411
1412
  if [[ -n "$VCS_CHECKOUT" ]]; then
1413
    echo "VCS_CHECKOUT=$VCS_CHECKOUT"
1414
  fi
1415
1164.1.6 by Brian Aker
update ddm4
1416
  if $debug; then
1417
    echo "debug=true"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1418
  fi
1419
1420
  if [[ -n "$WARNINGS" ]]; then
1421
    echo "WARNINGS=$WARNINGS"
1422
  fi
1164.1.6 by Brian Aker
update ddm4
1423
1424
  if $saved_debug_status; then
1425
    echo "DEBUG=true"
1426
  fi
1427
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1428
  echo '----------------------------------------------' 
1429
1430
  if $saved_debug_status; then
1431
    enable_debug
1432
  fi
1433
}
1434
1164.1.6 by Brian Aker
update ddm4
1435
make_clean_option ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1436
{
1437
  run_configure_if_required
1438
1439
  make_maintainer_clean
1440
1441
  if [[ "$VCS_CHECKOUT" == 'git' ]]; then
1442
    run "$VCS_CHECKOUT" status --ignored
1443
  elif [[ -n "$VCS_CHECKOUT" ]]; then
1444
    run "$VCS_CHECKOUT" status
1445
  fi
1446
}
1447
1164.1.6 by Brian Aker
update ddm4
1448
make_for_autoreconf ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1449
{
1450
  if [ -f 'Makefile' ]; then
1072.1.14 by Brian Aker
Update with job builder.
1451
    make_maintainer_clean
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1452
  fi
1453
1454
  run_autoreconf
1455
1456
  assert_no_file 'Makefile'
1457
}
1458
1164.1.6 by Brian Aker
update ddm4
1459
check_make_target()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1460
{
1164.1.6 by Brian Aker
update ddm4
1461
  local ret=0
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1462
  case $1 in
1086.1.9 by Brian Aker
Update bootstrap.sh
1463
    'self')
1464
      ;;
1121.1.3 by Brian Aker
Update bootstrap.sh
1465
    'rpm')
1466
      ;;
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1467
    'gdb')
1468
      ;;
1469
    'clean_op')
1470
      ;;
1471
    'autoreconf')
1472
      ;;
1473
    'install-system')
1474
      ;;
1475
    'configure')
1476
      ;;
1086.1.9 by Brian Aker
Update bootstrap.sh
1477
    'distcheck')
1478
      ;;
1479
    'check')
1083.1.4 by Brian Aker
Update to allow rpm to be legal jenkins target.
1480
      ;;
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1481
    'snapshot')
1482
      ;;
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
1483
    'mingw')
1484
      ;;
1485
    'universe')
1486
      ;;
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1487
    'valgrind')
1488
      ;;
1489
    'jenkins')
1490
      ;;
1491
    'distclean')
1492
      ;;
1493
    'maintainer-clean')
1494
      ;;
1495
    'install')
1496
      ;;
1497
    'all')
1498
      ;;
1121.1.3 by Brian Aker
Update bootstrap.sh
1499
    'make_default')
1500
      ;;
1143.1.1 by Brian Aker
Clarification in DNS test.
1501
    'clang')
1502
      ;;
1503
    'clang-analyzer')
1504
      ;;
1157.1.4 by Brian Aker
Update to latest bootstra.
1505
    test-*)
1506
      ;;
1507
    valgrind-*)
1508
      ;;
1509
    gdb-*)
1086.1.9 by Brian Aker
Update bootstrap.sh
1510
      ;;
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1511
    'dist')
1512
      ;;
1513
    *)
1157.1.4 by Brian Aker
Update to latest bootstra.
1514
      echo "Matched default"
1164.1.6 by Brian Aker
update ddm4
1515
      ret=1
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1516
      ;;
1517
  esac
1157.1.4 by Brian Aker
Update to latest bootstra.
1518
1164.1.6 by Brian Aker
update ddm4
1519
  return $ret
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1520
}
1521
1164.1.6 by Brian Aker
update ddm4
1522
execute_job ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1523
{
1164.1.6 by Brian Aker
update ddm4
1524
  # We should always have a target by this point
1174.1.1 by Brian Aker
Update the bootstrap rules.
1525
  assert BOOTSTRAP_TARGET
1164.1.6 by Brian Aker
update ddm4
1526
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1527
  determine_target_platform
1528
1529
  determine_vcs
1530
1531
  # Set up whatever we need to do to use autoreconf later
1164.1.6 by Brian Aker
update ddm4
1532
  use_libtool=false
1121.1.3 by Brian Aker
Update bootstrap.sh
1533
  require_libtoolise
1155.1.1 by Brian Aker
Fix for lp:1164442
1534
  if ! autoreconf_setup; then
1535
    return 1
1536
  fi
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1537
1164.1.6 by Brian Aker
update ddm4
1538
  if $print_setup_opt -o  $debug; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1539
    echo 
1540
    print_setup
1541
    echo 
1542
1543
    # Exit if all we were looking for were the currently used options
1164.1.6 by Brian Aker
update ddm4
1544
    if $print_setup_opt; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1545
      exit
1546
    fi
1072.1.4 by Brian Aker
Update
1547
  fi
1548
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
1549
  # Use OLD_LOG_COMPILER for tracking the state of the variable
1550
  local OLD_LOG_COMPILER=
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1551
1552
  # Set ENV PREFIX in order to set --prefix for ./configure
1553
  if [[ -n "$PREFIX" ]]; then 
1148.2.2 by Brian Aker
Adding missing windows file.
1554
    PREFIX_ARG="--prefix=$PREFIX"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1555
  fi
1556
1164.1.6 by Brian Aker
update ddm4
1557
  if $CLEAN_OPTION; then
1558
    make_maintainer_clean
1559
  fi
1086.1.9 by Brian Aker
Update bootstrap.sh
1560
1174.1.1 by Brian Aker
Update the bootstrap rules.
1561
  local BOOTSTRAP_TARGET_ARRAY
1562
  BOOTSTRAP_TARGET_ARRAY=( $BOOTSTRAP_TARGET )
1086.1.9 by Brian Aker
Update bootstrap.sh
1563
1174.1.1 by Brian Aker
Update the bootstrap rules.
1564
  for target in "${BOOTSTRAP_TARGET_ARRAY[@]}"
1086.1.9 by Brian Aker
Update bootstrap.sh
1565
  do
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1566
    # If we are running inside of Jenkins, we want to only run some of the possible tests
1567
    if $jenkins_build_environment; then
1086.1.9 by Brian Aker
Update bootstrap.sh
1568
      check_make_target $target
1157.1.4 by Brian Aker
Update to latest bootstra.
1569
      ret=$?
1570
      if [ $ret -ne 0 ]; then
1182.1.2 by Brian Aker
Update bootstrap.
1571
        warn "Unknown BOOTSTRAP_TARGET option: $target"
1572
        target="jenkins"
1157.1.4 by Brian Aker
Update to latest bootstra.
1573
      fi
1072.1.4 by Brian Aker
Update
1574
    fi
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1575
1164.1.6 by Brian Aker
update ddm4
1576
    if $jenkins_build_environment; then
1577
      use_banner $target
1578
    fi
1579
1157.1.4 by Brian Aker
Update to latest bootstra.
1580
    local snapshot_run=false
1161.1.1 by Brian Aker
Update ddm4
1581
    local valgrind_run=false
1157.1.4 by Brian Aker
Update to latest bootstra.
1582
1086.1.9 by Brian Aker
Update bootstrap.sh
1583
    case $target in
1584
      'self')
1585
        self_test
1586
        ;;
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1587
      'gdb')
1588
        make_gdb
1589
        ;;
1127.1.9 by Brian Aker
Update for mingw compile.
1590
      'install-html')
1591
        make_install_html
1592
        ;;
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1593
      'clean_op')
1594
        make_clean_option
1595
        ;;
1596
      'autoreconf')
1597
        make_for_autoreconf
1598
        ;;
1599
      'install-system')
1600
        make_install_system
1601
        ;;
1602
      'configure')
1603
        run_configure
1604
        ;;
1121.1.3 by Brian Aker
Update bootstrap.sh
1605
      'make_default')
1606
        make_default
1086.1.9 by Brian Aker
Update bootstrap.sh
1607
        ;;
1143.1.1 by Brian Aker
Clarification in DNS test.
1608
      'clang')
1164.1.6 by Brian Aker
update ddm4
1609
        make_distclean
1143.1.1 by Brian Aker
Clarification in DNS test.
1610
        if ! check_clang; then
1611
          die "clang was not found"
1612
        fi
1613
1614
        if ! make_for_clang; then
1615
          die "Failed to build clang: $?"
1616
        fi
1617
        ;;
1618
      'clang-analyzer')
1164.1.6 by Brian Aker
update ddm4
1619
        make_distclean
1143.1.1 by Brian Aker
Clarification in DNS test.
1620
        if ! check_clang_analyzer; then
1621
          die "clang-analyzer was not found"
1622
        fi
1623
        if ! check_clang; then
1624
          die "clang was not found"
1625
        fi
1626
1627
        if ! make_for_clang_analyzer; then
1628
          die "Failed to build clang-analyzer: $?"
1629
        fi
1630
        ;;
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
1631
      'mingw')
1164.1.6 by Brian Aker
update ddm4
1632
        make_distclean
1127.1.9 by Brian Aker
Update for mingw compile.
1633
        if ! make_for_mingw; then
1634
          die "Failed to build mingw: $?"
1635
        fi
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
1636
        ;;
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1637
      'snapshot')
1638
        make_for_snapshot
1157.1.4 by Brian Aker
Update to latest bootstra.
1639
        snapshot_run=true
1161.1.9 by Brian Aker
Fixes for
1640
        check_snapshot
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1641
        ;;
1083.1.4 by Brian Aker
Update to allow rpm to be legal jenkins target.
1642
      'rpm')
1643
        make_rpm
1644
        ;;
1161.1.1 by Brian Aker
Update ddm4
1645
      'darwin_malloc')
1646
        make_darwin_malloc
1647
        ;;
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1648
      'valgrind')
1649
        make_valgrind
1650
        ;;
1086.1.10 by Brian Aker
A number of small build fixes found while looking at mingw support.
1651
      'universe')
1652
        make_universe
1653
        ;;
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1654
      'jenkins')
1655
        make_for_continuus_integration
1656
        ;;
1657
      *)
1658
        run_configure_if_required
1086.1.9 by Brian Aker
Update bootstrap.sh
1659
        make_target "$target"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1660
        ;;
1661
    esac
1086.1.9 by Brian Aker
Update bootstrap.sh
1662
  done
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1663
}
1664
1164.1.6 by Brian Aker
update ddm4
1665
main ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1666
{
1164.1.6 by Brian Aker
update ddm4
1667
  # Are we running inside of Jenkins?
1668
  if [[ -n "$JENKINS_HOME" ]]; then 
1669
    declare -r jenkins_build_environment=true
1670
  else
1671
    declare -r jenkins_build_environment=false
1672
  fi
1673
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1674
  # Variables we export
1675
  declare -x VCS_CHECKOUT=
1676
1677
  # Variables we control globally
1174.1.1 by Brian Aker
Update the bootstrap rules.
1678
  local -a BOOTSTRAP_TARGET=
1127.1.9 by Brian Aker
Update for mingw compile.
1679
  local CONFIGURE=
1164.1.6 by Brian Aker
update ddm4
1680
  local use_libtool=false
1681
  local verbose=false
1682
1683
  #getop variables
1684
  local opt_debug=false
1685
  local opt_verbose=false
1686
1687
  if [[ -n "$VERBOSE" ]]; then
1688
    verbose=true
1689
  fi
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1690
1691
  # Options for getopt
1692
  local AUTORECONF_OPTION=false
1693
  local CLEAN_OPTION=false
1694
  local CONFIGURE_OPTION=false
1164.1.6 by Brian Aker
update ddm4
1695
  local print_setup_opt=false
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1696
  local TARGET_OPTION=false
1697
  local TARGET_OPTION_ARG=
1698
1127.1.9 by Brian Aker
Update for mingw compile.
1699
  local OLD_CONFIGURE=
1700
  local OLD_CONFIGURE_ARG=
1148.2.1 by Brian Aker
Harmonize WIN32, and update bootstrap
1701
  local OLD_PREFIX=
1127.1.9 by Brian Aker
Update for mingw compile.
1702
  local OLD_MAKE=
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
1703
  local OLD_LOG_COMPILER=
1127.1.9 by Brian Aker
Update for mingw compile.
1704
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1705
  # If we call autoreconf on the platform or not
1706
  local AUTORECONF_REBUILD_HOST=false
1707
  local AUTORECONF_REBUILD=false
1708
1164.1.6 by Brian Aker
update ddm4
1709
  local -r top_srcdir="$(pwd)"
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1710
1127.1.9 by Brian Aker
Update for mingw compile.
1711
  # Default configure
1712
  if [ -z "$CONFIGURE" ]; then
1713
    CONFIGURE="$top_srcdir/configure"
1714
  fi
1715
1716
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1717
  # Variables for determine_target_platform () and rebuild_host_os ()
1718
  #   UNAME_MACHINE_ARCH= uname -m
1719
  #   VENDOR= apple, redhat, centos, canonical
1720
  #   VENDOR_RELEASE=  
1721
  #                  RHEL{rhel,Tikanga,Santiago}
1722
  #                  Ubuntu{ubuntu,Lucid,Maverick,Natty,Oneiric,Precise,Quantal}
1723
  #                  Fedora{fedora,Verne,Beefy}
1724
  #                  OSX{osx,lion,snow,mountain}
1725
  #   VENDOR_DISTRIBUTION= darwin,fedora,rhel,ubuntu
1726
  #   UNAME_KERNEL= Linux, Darwin,...
1727
  #   UNAME_KERNEL_RELEASE= Linux, Darwin,...
1728
  local UNAME_MACHINE_ARCH=unknown
1729
  local VENDOR=unknown
1730
  local VENDOR_RELEASE=unknown
1731
  local VENDOR_DISTRIBUTION=unknown
1732
  local UNAME_KERNEL=unknown
1733
  local UNAME_KERNEL_RELEASE=unknown
1734
  local HOST_OS=
1735
1736
  rebuild_host_os no_output
1072.1.4 by Brian Aker
Update
1737
1164.1.6 by Brian Aker
update ddm4
1738
  local OPT_TARGET=
1739
  parse_command_line_options "$@"
1740
1174.1.1 by Brian Aker
Update the bootstrap rules.
1741
  nassert BOOTSTRAP_TARGET
1164.1.6 by Brian Aker
update ddm4
1742
1743
  if [ -n "$OPT_TARGET" ]; then
1174.1.1 by Brian Aker
Update the bootstrap rules.
1744
    BOOTSTRAP_TARGET="$OPT_TARGET"
1164.1.6 by Brian Aker
update ddm4
1745
  fi
1086.1.9 by Brian Aker
Update bootstrap.sh
1746
1174.1.1 by Brian Aker
Update the bootstrap rules.
1747
  if [ -z "$BOOTSTRAP_TARGET" ]; then
1748
    BOOTSTRAP_TARGET="make_default"
1164.1.6 by Brian Aker
update ddm4
1749
  fi
1750
1751
  # We should always have a target by this point
1174.1.1 by Brian Aker
Update the bootstrap rules.
1752
  assert BOOTSTRAP_TARGET
1164.1.6 by Brian Aker
update ddm4
1753
1754
  execute_job
1755
  local ret=$?
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1756
1757
  jobs -l
1758
  wait
1759
1164.1.6 by Brian Aker
update ddm4
1760
  exit $ret
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1761
}
1762
1164.1.6 by Brian Aker
update ddm4
1763
set_branch ()
1121.1.3 by Brian Aker
Update bootstrap.sh
1764
{
1765
  if [ -z "$BRANCH" ]; then 
1766
    if [ -z "$CI_PROJECT_TEAM" ]; then 
1767
      die "Variable CI_PROJECT_TEAM has not been set"
1768
    fi
1769
    if [ -z "$PROJECT" ]; then 
1770
      die "Variable PROJECT has not been set"
1771
    fi
1772
    if [ -z "$BUILD_TAG" ]; then 
1773
      die "Variable BUILD_TAG has not been set"
1774
    fi
1775
1776
    BRANCH="lp:~$CI_PROJECT_TEAM/$PROJECT/$BUILD_TAG"
1777
    export BRANCH
1778
  fi
1779
1780
  if [ -z "$BRANCH" ]; then 
1781
    die "Missing values required to build BRANCH variable."
1782
  fi
1783
}
1784
1164.1.6 by Brian Aker
update ddm4
1785
merge ()
1121.1.3 by Brian Aker
Update bootstrap.sh
1786
{
1787
  if [ -z "$VCS_CHECKOUT" ]; then
1788
    die "Merges require VCS_CHECKOUT."
1789
  fi
1790
1791
  set_branch
1792
1793
  if [[ "$VCS_CHECKOUT" == 'bzr' ]]; then
1794
    if test -n "$BRANCH_TO_MERGE"; then
1795
      bzr merge $BRANCH_TO_MERGE
1796
      bzr commit --message="Merge $BRANCH_TO_MERGE Build: $BUILD_TAG" --unchanged
1797
    fi
1798
1799
    bzr push "$BRANCH"
1800
  elif [[ -n "$VCS_CHECKOUT" ]]; then
1801
    die "Merge attempt occured, current VCS setup does not support this"
1802
  fi
1803
}
1804
1164.1.6 by Brian Aker
update ddm4
1805
enable_debug ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1806
{
1164.1.6 by Brian Aker
update ddm4
1807
  if ! $debug; then
1808
    local caller_loc="$(caller)"
1809
    if [[ -n "$1" ]]; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1810
      echo "$caller_loc Enabling debug: $1"
1811
    else
1812
      echo "$caller_loc Enabling debug"
1813
    fi
1814
    set -x
1164.1.6 by Brian Aker
update ddm4
1815
    debug=true
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1816
  fi
1817
}
1818
1164.1.6 by Brian Aker
update ddm4
1819
usage ()
1121.1.3 by Brian Aker
Update bootstrap.sh
1820
{
1821
  cat << EOF
1822
  Usage: $program_name [OPTION]..
1823
1824
  Bootstrap this package from the checked-out sources, and optionally walk through CI run.
1825
1826
  Options:
1827
1828
EOF
1829
}
1830
1164.1.6 by Brian Aker
update ddm4
1831
disable_debug ()
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1832
{
1833
  set +x
1164.1.6 by Brian Aker
update ddm4
1834
  debug=false
1835
}
1836
1837
check_shell ()
1838
{
1839
  if [ -x '/usr/local/bin/shellcheck' ]; then
1840
    /usr/local/bin/shellcheck "$1"
1841
    local ret=$?
1842
1843
    if [ "$ret" -ne 0 ]; then
1844
      die "$1 failed shellcheck"
1845
    fi
1846
  fi
1847
}
1848
1849
bootstrap ()
1850
{
1851
  check_shell 'bootstrap.sh'
1852
  local env_debug_enabled=false
1853
  local debug=false
1854
1855
  export ACLOCAL
1856
  export AUTOCONF
1857
  export AUTOHEADER
1858
  export AUTOM4TE
1859
  export AUTOMAKE
1860
  export AUTORECONF
1861
  export CONFIGURE_ARG
1862
  export DEBUG
1863
  export GNU_BUILD_FLAGS
1864
  export LIBTOOLIZE
1865
  export LIBTOOLIZE_OPTIONS
1866
  export MAKE
1867
  export PREFIX_ARG
1173.1.1 by Brian Aker
Make the switch to the more modern LOG_COMPILER env.
1868
  export LOG_COMPILER
1164.1.6 by Brian Aker
update ddm4
1869
  export VERBOSE
1870
  export WARNINGS
1871
1872
  case $OSTYPE in
1873
    darwin*)
1874
      export MallocGuardEdges
1875
      export MallocErrorAbort
1876
      export MallocScribble
1877
      ;;
1878
  esac
1879
1880
  # We check for DEBUG twice, once before we source the config file, and once afterward
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1881
  if [[ -n "$DEBUG" ]]; then
1164.1.6 by Brian Aker
update ddm4
1882
    env_debug_enabled=true
1883
  fi
1884
1885
  # Variables which only can be set by .bootstrap
1886
  BOOTSTRAP_SNAPSHOT=false
1887
  BOOTSTRAP_SNAPSHOT_CHECK=
1888
1889
  if [ -f '.bootstrap' ]; then
1890
    source '.bootstrap'
1891
  fi
1892
1893
  # 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
1894
  if $env_debug_enabled; then
1895
    enable_debug
1896
  elif [[ -n "$DEBUG" ]]; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1897
    enable_debug "Enabling DEBUG from '.bootstrap'"
1164.1.6 by Brian Aker
update ddm4
1898
  fi
1899
1900
  if $env_debug_enabled; then
1083.1.1 by Brian Aker
Update updates to a current version of bootstrap.
1901
    print_setup
1902
  fi
1164.1.6 by Brian Aker
update ddm4
1903
1904
1905
  main "$@"
1906
}
1907
1908
# Script begins here
1909
declare -r program_name="$0"
1910
bootstrap "$@"