source: scripts/locker-build @ de9edab

release-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since de9edab was de9edab, checked in by Nelson Elhage <nelhage@mit.edu>, 15 years ago
locker-build: Change the shebang line to /bin/bash Solaris sh is just too crappy for me to bother trying to accomodate it. The script is still valid dash/POSIX sh, as far as I know.
  • Property mode set to 100755
File size: 2.7 KB
RevLine 
[de9edab]1#!/bin/bash
[56e4869]2
3#########################################################
4# Build script to build BarnOwl for the locker.
5
6# Usage: locker-build [-n] [-o OUTPUT-TGZ] VERSION SOURCE-TARBALL
7# -n is a dry-run, and drops to a shell in the build directory
8# -o does the install into a temporary directory and tars it into the
9#    specified tarball instead.
10# SOURCE-TARBALL is a source tarball, created by do-release
11# VERSION should be of the form 'barnowl-VERSION'
12#
13# TODO: Scrape $VERSION from the tarball
[5c81472]14
15die() {
[67dd774]16    echo "$@" 2>&1;
17    if [ -n "$TMPDIR" ]; then
18        if [ -n "$DRYRUN" ]; then
19            echo "Dropping to a shell to investigate...";
20            $SHELL
21        fi
22    fi
23    exit 1;
[56e4869]24}
25
26usage () {
27    echo "Usage: $0 [-n] [-o OUTPUT-TGZ] VERSION SOURCE-TARBALL"
28    exit 2;
[5c81472]29}
30
[56e4869]31exittrap() { :; }
32for sig in 1 2 13 15; do trap "exit $(($sig + 128))" $sig; done
33trap 'exittrap' EXIT
34
35SRC_TGZ=
36OUT_TGZ=
[5c81472]37DRYRUN=
[56e4869]38
39set -- `getopt no: "$@"`
40[ $? -eq 0 ] || usage
41
42for opt
43do
44    case "$opt" in
45        -n)
46            DRYRUN=1; shift ;;
47        -o)
48            OUT_TGZ="$2"; shift 2;;
49        --)
50            shift; break ;;
51    esac
52done
[5c81472]53
54NAME="$1"
[56e4869]55SRC_TGZ="$2"
56
57test -z "$NAME" && usage
58test -z "$SRC_TGZ"  && usage
59
[5c81472]60
61ATHENA_SYS="${ATHENA_SYS:-$(machtype -S)}"
62
63if [ "$(uname)" = "SunOS" ]; then
64    MAKE=gmake
65    TAR=gtar
66else
67    MAKE=make
68    TAR=tar
69fi
70
71attach barnowl
72aklog
73
[56e4869]74TMPDIR=$(mktemp -d /tmp/barnowl-build-XXXXXX) || die "Unable to mktemp"
[5c81472]75
[56e4869]76exittrap() { rm -rf "$TMPDIR"; }
[5c81472]77
[67dd774]78$TAR -C "$TMPDIR" -xzf "$SRC_TGZ" || die "Unable to untar"
[5c81472]79
[56e4869]80(
81    cd "$TMPDIR"/* || die "Unable to cd to $TMPDIR"
[5c81472]82
[56e4869]83    BARNOWL="/afs/sipb.mit.edu/project/barnowl/arch/$ATHENA_SYS"
84    export PKG_CONFIG_PATH="$BARNOWL/lib/pkgconfig"
[5c81472]85
[56e4869]86    CFLAGS="-I$BARNOWL/include" \
87        LDFLAGS="-L$BARNOWL/lib -Wl,-R$BARNOWL/lib" \
88        ./configure --exec-prefix="/mit/barnowl/arch/$ATHENA_SYS" \
89        --prefix="/mit/barnowl/builds/$NAME" --mandir=/mit/barnowl/man \
90        PROTECT_CFLAGS=-fno-stack-protector \
91        || die "configure failed"
[5c81472]92
[56e4869]93    $MAKE clean  || die "make clean failed"
[5c81472]94
[56e4869]95    CPUS=$(athinfo localhost cpuspeed | grep -c MHz)
96    if [ "$CPUS" = 0 ]; then
97        CPUS=1
98    fi
[5c81472]99
[56e4869]100    $MAKE -j$CPUS EXE=$NAME all || die "make failed"
[5c81472]101
[56e4869]102    if [ -n "$DRYRUN" ]; then
103        echo "Build completed; Dropping to a shell..."
104        $SHELL
[5c81472]105    else
[56e4869]106        if [ -n "$OUT_TGZ" ]; then
107            mkdir tgz
108            $MAKE EXE=$NAME DESTDIR=tgz install || die "Install failed"
109        else
110            $MAKE EXE=$NAME install || die "Install failed"
111        fi
[5c81472]112    fi
[56e4869]113)
114
[67dd774]115if [ "$?" -ne 0 ]; then
116    exit "$?"
117fi
118
[56e4869]119if [ -n "$OUT_TGZ" ]; then
120    $TAR -C "$TMPDIR/"*/tgz -czvf "$OUT_TGZ" . || die "Make tarball failed"
[5c81472]121fi
122
123rm -rf "$TMPDIR"
[56e4869]124exittrap() { :; }
Note: See TracBrowser for help on using the repository browser.