source: scripts/locker-build @ 11b9017

debianrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 11b9017 was 56e4869, checked in by Nelson Elhage <nelhage@mit.edu>, 12 years ago
Add usage and clean up the build script a lot.
  • Property mode set to 100755
File size: 2.5 KB
Line 
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
14
15die() {
16      echo "$@" 2>&1;
17      exit 1;
18}
19
20usage () {
21    echo "Usage: $0 [-n] [-o OUTPUT-TGZ] VERSION SOURCE-TARBALL"
22    exit 2;
23}
24
25exittrap() { :; }
26for sig in 1 2 13 15; do trap "exit $(($sig + 128))" $sig; done
27trap 'exittrap' EXIT
28
29SRC_TGZ=
30OUT_TGZ=
31DRYRUN=
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
47
48NAME="$1"
49SRC_TGZ="$2"
50
51test -z "$NAME" && usage
52test -z "$SRC_TGZ"  && usage
53
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
68TMPDIR=$(mktemp -d /tmp/barnowl-build-XXXXXX) || die "Unable to mktemp"
69
70exittrap() { rm -rf "$TMPDIR"; }
71
72$TAR -C "$TMPDIR" -xzvf "$SRC_TGZ" || die "Unable to untar"
73
74(
75    cd "$TMPDIR"/* || die "Unable to cd to $TMPDIR"
76
77    BARNOWL="/afs/sipb.mit.edu/project/barnowl/arch/$ATHENA_SYS"
78    export PKG_CONFIG_PATH="$BARNOWL/lib/pkgconfig"
79
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"
86
87    $MAKE clean  || die "make clean failed"
88
89    CPUS=$(athinfo localhost cpuspeed | grep -c MHz)
90    if [ "$CPUS" = 0 ]; then
91        CPUS=1
92    fi
93
94    $MAKE -j$CPUS EXE=$NAME all || die "make failed"
95
96    if [ -n "$DRYRUN" ]; then
97        echo "Build completed; Dropping to a shell..."
98        $SHELL
99    else
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
106    fi
107)
108
109if [ -n "$OUT_TGZ" ]; then
110    $TAR -C "$TMPDIR/"*/tgz -czvf "$OUT_TGZ" . || die "Make tarball failed"
111fi
112
113rm -rf "$TMPDIR"
114exittrap() { :; }
Note: See TracBrowser for help on using the repository browser.