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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
#!/bin/bash
#########################################################
# Build script to build BarnOwl for the locker.
die() {
echo "$@" 2>&1;
if [ -n "$TMPDIR" ]; then
if [ -n "$DRYRUN" ]; then
echo "Dropping to a shell to investigate...";
$SHELL
fi
fi
exit 1;
}
usage () {
cat >&2 <<EOF
Usage: $0 [-n] [-o OUTPUT-TGZ] SOURCE-TARBALL
-n is a dry-run, and drops to a shell in the build directory
-o does the install into a temporary directory and tars it into the
specified tarball instead.
SOURCE-TARBALL is a source tarball, created by do-release.
EOF
exit 2;
}
exittrap() { :; }
for sig in 1 2 13 15; do trap "exit $(($sig + 128))" $sig; done
trap 'exittrap' EXIT
SRC_TGZ=
OUT_TGZ=
DRYRUN=
set -- `getopt no: "$@"`
[ $? -eq 0 ] || usage
for opt
do
case "$opt" in
-n)
DRYRUN=1; shift ;;
-o)
OUT_TGZ="$2"; shift 2;;
--)
shift; break ;;
esac
done
SRC_TGZ="$1"
test -z "$SRC_TGZ" && usage
ATHENA_SYS="${ATHENA_SYS:-$(machtype -S)}"
if [ "$(uname)" = "SunOS" ]; then
MAKE=gmake
TAR=gtar
else
MAKE=make
TAR=tar
fi
attach barnowl
aklog
TMPDIR=$(mktemp -d /tmp/barnowl-build-XXXXXX) || die "Unable to mktemp"
exittrap() { rm -rf "$TMPDIR"; }
$TAR -C "$TMPDIR" -xzf "$SRC_TGZ" || die "Unable to untar"
(
cd "$TMPDIR"/* || die "Unable to cd to $TMPDIR"
VERS=$(perl -ne 'print $1 if m{^AC_INIT\(\[[^\]]+\],\s*\[([^\]]+)\]}' configure.ac)
test -z "$VERS" && die "Unable to detect barnowl version."
echo "Building BarnOwl version $VERS"
opt_rpath="-Wl,-R"
[ $(uname) = "SunOS" ] && opt_rpath="-R"
BARNOWL="/afs/sipb.mit.edu/project/barnowl/arch/$ATHENA_SYS"
export PKG_CONFIG_PATH="$BARNOWL/lib/pkgconfig"
eval $("$BARNOWL/bin/barnowl-perl-config")
SUFFIX=
case $ATHENA_SYS in
*_deb50)
# Both Debian Lenny and Ubuntu Karmic use the _deb50
# sysname, but they have different zephyr versions (soname
# 3 and 4, respectively). So for that sysname, we include
# the zephyr soname into the build name, and the wrapper
# script picks the right one.
if /sbin/ldconfig -p | grep -qF "libzephyr.so.4"; then
SUFFIX=.zephyr4
else
SUFFIX=.zephyr3
fi
;;
esac
CPPFLAGS="-I$BARNOWL/include -I/usr/athena/include" \
LDFLAGS="-L$BARNOWL/lib -L/usr/athena/lib $opt_rpath$BARNOWL/lib" \
./configure --exec-prefix="/mit/barnowl/arch/$ATHENA_SYS" \
--prefix="/mit/barnowl/builds/barnowl-$VERS" --mandir=/mit/barnowl/man \
--program-suffix="-$VERS$SUFFIX" \
--with-zephyr --without-stack-protector \
|| die "configure failed"
$MAKE clean || die "make clean failed"
CPUS=$(athinfo localhost cpuspeed | grep -c MHz)
if [ "$CPUS" = 0 ]; then
CPUS=1
fi
$MAKE -j$CPUS all || die "make failed"
$MAKE check || die "Unit tests failed"
if [ -n "$DRYRUN" ]; then
echo "Build completed; Dropping to a shell..."
$SHELL
else
if [ -n "$OUT_TGZ" ]; then
mkdir tgz
$MAKE DESTDIR=tgz install || die "Install failed"
else
$MAKE install || die "Install failed"
fi
fi
)
if [ "$?" -ne 0 ]; then
exit "$?"
fi
if [ -n "$OUT_TGZ" ]; then
$TAR -C "$TMPDIR/"*/tgz -czvf "$OUT_TGZ" . || die "Make tarball failed"
fi
rm -rf "$TMPDIR"
exittrap() { :; }
|