source: scripts/locker-build @ d3814ff

release-1.10release-1.6release-1.7release-1.8release-1.9
Last change on this file since d3814ff was 0fd5bd5, checked in by Nelson Elhage <nelhage@mit.edu>, 14 years ago
Incorporate the zephyr soname into the executable for *_deb50.
  • Property mode set to 100755
File size: 3.3 KB
RevLine 
[de9edab]1#!/bin/bash
[56e4869]2
3#########################################################
4# Build script to build BarnOwl for the locker.
[5c81472]5die() {
[67dd774]6    echo "$@" 2>&1;
7    if [ -n "$TMPDIR" ]; then
8        if [ -n "$DRYRUN" ]; then
9            echo "Dropping to a shell to investigate...";
10            $SHELL
11        fi
12    fi
13    exit 1;
[56e4869]14}
15
16usage () {
[51dbfb5]17    cat >&2 <<EOF
18Usage: $0 [-n] [-o OUTPUT-TGZ] SOURCE-TARBALL
19 -n is a dry-run, and drops to a shell in the build directory
20 -o does the install into a temporary directory and tars it into the
21    specified tarball instead.
22
23SOURCE-TARBALL is a source tarball, created by do-release.
24EOF
[56e4869]25    exit 2;
[5c81472]26}
27
[56e4869]28exittrap() { :; }
29for sig in 1 2 13 15; do trap "exit $(($sig + 128))" $sig; done
30trap 'exittrap' EXIT
31
32SRC_TGZ=
33OUT_TGZ=
[5c81472]34DRYRUN=
[56e4869]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
[5c81472]50
[3043064]51SRC_TGZ="$1"
[56e4869]52
53test -z "$SRC_TGZ"  && usage
54
[5c81472]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
[56e4869]69TMPDIR=$(mktemp -d /tmp/barnowl-build-XXXXXX) || die "Unable to mktemp"
[5c81472]70
[56e4869]71exittrap() { rm -rf "$TMPDIR"; }
[5c81472]72
[67dd774]73$TAR -C "$TMPDIR" -xzf "$SRC_TGZ" || die "Unable to untar"
[5c81472]74
[56e4869]75(
76    cd "$TMPDIR"/* || die "Unable to cd to $TMPDIR"
[db98968]77    VERS=$(perl -ne 'print $1 if m{^AC_INIT\(\[[^\]]+\],\s*\[([^\]]+)\]}' configure.ac)
[3043064]78    test -z "$VERS" && die "Unable to detect barnowl version."
79
80    echo "Building BarnOwl version $VERS"
[5c81472]81
[2b6622a6]82    opt_rpath="-Wl,-R"
83    [ $(uname) = "SunOS" ] && opt_rpath="-R"
84
[56e4869]85    BARNOWL="/afs/sipb.mit.edu/project/barnowl/arch/$ATHENA_SYS"
86    export PKG_CONFIG_PATH="$BARNOWL/lib/pkgconfig"
[5c81472]87
[0fd5bd5]88    SUFFIX=
89    case $ATHENA_SYS in
90        *_deb50)
91            # Both Debian Lenny and Ubuntu Karmic use the _deb50
92            # sysname, but they have different zephyr versions (soname
93            # 3 and 4, respectively). So for that sysname, we include
94            # the zephyr soname into the build name, and the wrapper
95            # script picks the right one.
96            if /sbin/ldconfig -p | grep -qF "libzephyr.so.4"; then
97                SUFFIX=.zephyr4
98            else
99                SUFFIX=.zephyr3
100            fi
101            ;;
102    esac
103
[56e4869]104    CFLAGS="-I$BARNOWL/include" \
[2b6622a6]105        LDFLAGS="-L$BARNOWL/lib $opt_rpath$BARNOWL/lib" \
[56e4869]106        ./configure --exec-prefix="/mit/barnowl/arch/$ATHENA_SYS" \
[3043064]107        --prefix="/mit/barnowl/builds/barnowl-$VERS" --mandir=/mit/barnowl/man \
[0fd5bd5]108        --program-suffix="-$VERS$SUFFIX" \
[e477a53]109        --with-zephyr --without-stack-protector \
[56e4869]110        || die "configure failed"
[5c81472]111
[56e4869]112    $MAKE clean  || die "make clean failed"
[5c81472]113
[56e4869]114    CPUS=$(athinfo localhost cpuspeed | grep -c MHz)
115    if [ "$CPUS" = 0 ]; then
116        CPUS=1
117    fi
[5c81472]118
[3043064]119    $MAKE -j$CPUS all || die "make failed"
[5c81472]120
[56e4869]121    if [ -n "$DRYRUN" ]; then
122        echo "Build completed; Dropping to a shell..."
123        $SHELL
[5c81472]124    else
[56e4869]125        if [ -n "$OUT_TGZ" ]; then
126            mkdir tgz
[3043064]127            $MAKE DESTDIR=tgz install || die "Install failed"
[56e4869]128        else
[3043064]129            $MAKE install || die "Install failed"
[56e4869]130        fi
[5c81472]131    fi
[56e4869]132)
133
[67dd774]134if [ "$?" -ne 0 ]; then
135    exit "$?"
136fi
137
[56e4869]138if [ -n "$OUT_TGZ" ]; then
139    $TAR -C "$TMPDIR/"*/tgz -czvf "$OUT_TGZ" . || die "Make tarball failed"
[5c81472]140fi
141
142rm -rf "$TMPDIR"
[56e4869]143exittrap() { :; }
Note: See TracBrowser for help on using the repository browser.