#!/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/beta/src
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=/afs/athena.mit.edu/astaff/project/emacs/beta

# /afs/athena.mit.edu/astaff/project/emacs/beta/src/emacs/configure CC=gcc CPPFLAGS=-I/usr/athena/include LDFLAGS="-L/usr/athena/lib -Wl,-R /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/sun4x_510 --enable-asserts --with-x-toolkit=gtk

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

# On sun4x_59, you must omit the toolkit=gtk

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