#!/bin/bash

# Invoke this script from the "$root" directory,
#  which contains "emacs/" and "build/".
# Beware that you cannot build two emacs simultaneously -- the
#  build stores temporary data in the afs source dir(s) during the
#  compile, and multiple simultaneous builds can collide.

root=/afs/.athena.mit.edu/astaff/project/emacs/temp
src_dir="$root"/emacs
if [ -z "$ATHENA_SYS" ] ; then echo "Error, ATHENA_SYS not set." ; echo 1 ; fi
bld_dir="$root"/build/"$ATHENA_SYS"
mkdir -p "$bld_dir"

# Prefix of path where things will be installed
prefix=/mit/emacs

# /afs/athena.mit.edu/astaff/project/emacs/beta/src/emacs/configure CC=gcc CPPFLAGS=-I/usr/athena/include LDFLAGS=-L/usr/athena/lib --with-hesiod --with-kerberos --prefix=/afs/athena.mit.edu/astaff/project/emacs/beta --exec-prefix=/afs/athena.mit.edu/astaff/project/emacs/beta/arch/i386_rhel4 --enable-asserts --with-x-toolkit=gtk

cd "$bld_dir" && \
"$src_dir"/configure \
  CC=gcc \
  CPPFLAGS="-I/usr/athena/include" \
  LDFLAGS="-L/usr/athena/lib" \
  --with-hesiod \
  --with-kerberos \
  --prefix="$prefix" \
  --exec-prefix="$prefix"/arch/$ATHENA_SYS \
  --enable-asserts \
  --with-x-toolkit=gtk

cat <<EOF
Now you may "cd $bld_dir" and "make bootstrap"
Remember to MOVE ASIDE old binaries before you "make install",
because overwriting them can terminate people's currently-running emacsen.
EOF
