source: scripts/locker-build @ f1d7d0f

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