summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/bare/build-tools
blob: 8ea01d3933fe8a0b8c3e21b5fd137ca388655bbd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#
# $Id$
#
# Tools to help doing build scripts. Adapted from Joel's bit
# script.
#

#
# USERCHANGE - uncomment this if you want to watch the commands.
#
# set -x

start=`date`

#
# Common exit routine for this script so we can print the starting
# and ending times.
#

my_exit()
{
  stop=`date`

  echo
  echo "Started:  " $start
  echo "Finished: " $stop
  exit $1
}

#
# Handle a fatal error.
#

fatal_error()
{
  echo "ERROR: $*" >&2
  my_exit 1
}

#
# Checks the status returned by executables and exits if it is non-zero.
#

check_fatal()
{
  if [ $1 -ne 0 ] ; then
    shift
    fatal_error $*
  fi
}

#
# Test for a valid path, exit if not found
#

test_path()
{
  test -d $* || fatal_error "cannot find $*"
  return 0
}

#
# Create a directory and check it was made correctly.
#

checked_mkdir()
{
  mkdir -p $1
  check_fatal $? "unable to make directory $1"
  return 0
}