source: scripts/locker-build @ 56e4869

debianrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 56e4869 was 56e4869, checked in by Nelson Elhage <nelhage@mit.edu>, 13 years ago
Add usage and clean up the build script a lot.
  • Property mode set to 100755
File size: 2.5 KB
RevLine 
[56e4869]1#!/bin/sh
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() {
[56e4869]16      echo "$@" 2>&1;
17      exit 1;
18}
19
20usage () {
21    echo "Usage: $0 [-n] [-o OUTPUT-TGZ] VERSION SOURCE-TARBALL"
22    exit 2;
[5c81472]23}
24
[56e4869]25exittrap() { :; }
26for sig in 1 2 13 15; do trap "exit $(($sig + 128))" $sig; done
27trap 'exittrap' EXIT
28
29SRC_TGZ=
30OUT_TGZ=
[5c81472]31DRYRUN=
[56e4869]32
33set -- `getopt no: "$@"`
34[ $? -eq 0 ] || usage
35
36for opt
37do
38    case "$opt" in
39        -n)
40            DRYRUN=1; shift ;;
41        -o)
42            OUT_TGZ="$2"; shift 2;;
43        --)
44            shift; break ;;
45    esac
46done
[5c81472]47
48NAME="$1"
[56e4869]49SRC_TGZ="$2"
50
51test -z "$NAME" && usage
52test -z "$SRC_TGZ"  && usage
53
[5c81472]54
55ATHENA_SYS="${ATHENA_SYS:-$(machtype -S)}"
56
57if [ "$(uname)" = "SunOS" ]; then
58    MAKE=gmake
59    TAR=gtar
60else
61    MAKE=make
62    TAR=tar
63fi
64
65attach barnowl
66aklog
67
[56e4869]68TMPDIR=$(mktemp -d /tmp/barnowl-build-XXXXXX) || die "Unable to mktemp"
[5c81472]69
[56e4869]70exittrap() { rm -rf "$TMPDIR"; }
[5c81472]71
[56e4869]72$TAR -C "$TMPDIR" -xzvf "$SRC_TGZ" || die "Unable to untar"
[5c81472]73
[56e4869]74(
75    cd "$TMPDIR"/* || die "Unable to cd to $TMPDIR"
[5c81472]76
[56e4869]77    BARNOWL="/afs/sipb.mit.edu/project/barnowl/arch/$ATHENA_SYS"
78    export PKG_CONFIG_PATH="$BARNOWL/lib/pkgconfig"
[5c81472]79
[56e4869]80    CFLAGS="-I$BARNOWL/include" \
81        LDFLAGS="-L$BARNOWL/lib -Wl,-R$BARNOWL/lib" \
82        ./configure --exec-prefix="/mit/barnowl/arch/$ATHENA_SYS" \
83        --prefix="/mit/barnowl/builds/$NAME" --mandir=/mit/barnowl/man \
84        PROTECT_CFLAGS=-fno-stack-protector \
85        || die "configure failed"
[5c81472]86
[56e4869]87    $MAKE clean  || die "make clean failed"
[5c81472]88
[56e4869]89    CPUS=$(athinfo localhost cpuspeed | grep -c MHz)
90    if [ "$CPUS" = 0 ]; then
91        CPUS=1
92    fi
[5c81472]93
[56e4869]94    $MAKE -j$CPUS EXE=$NAME all || die "make failed"
[5c81472]95
[56e4869]96    if [ -n "$DRYRUN" ]; then
97        echo "Build completed; Dropping to a shell..."
98        $SHELL
[5c81472]99    else
[56e4869]100        if [ -n "$OUT_TGZ" ]; then
101            mkdir tgz
102            $MAKE EXE=$NAME DESTDIR=tgz install || die "Install failed"
103        else
104            $MAKE EXE=$NAME install || die "Install failed"
105        fi
[5c81472]106    fi
[56e4869]107)
108
109if [ -n "$OUT_TGZ" ]; then
110    $TAR -C "$TMPDIR/"*/tgz -czvf "$OUT_TGZ" . || die "Make tarball failed"
[5c81472]111fi
112
113rm -rf "$TMPDIR"
[56e4869]114exittrap() { :; }
Note: See TracBrowser for help on using the repository browser.