#!/bin/sh
# Build and install GNU emacs for Slackware.
# Before starting, you might want to reduce dependancies in the
# .tgz packages by doing this (no, you really don't want to do this):
#                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#removepkg xaw3d
#rm /usr/lib/libjpeg.so
#rm /usr/lib/libpng.so
#rm /usr/lib/libtiff.so
#rm /usr/lib/libungif.so
# and then replace these things after the build.
CWD=`pwd`
VERSION=21.3
cd /tmp
rm -rf emacs-$VERSION
tar xjvf $CWD/emacs-$VERSION.tar.bz2
tar xjvf $CWD/leim-$VERSION.tar.bz2
cd emacs-$VERSION
chown -R root.root .
find . -perm 664 -exec chmod 644 {} \;
# Save some docs:
rm -rf /usr/doc/emacs-$VERSION
mkdir -p /usr/doc/emacs-$VERSION
cp -a BUGS FTP INSTALL README /usr/doc/emacs-$VERSION
chmod 644 /usr/doc/emacs-$VERSION/*
( cd /usr/doc/emacs-$VERSION ; ln -sf /usr/share/emacs/$VERSION/etc . )
# Build a version of emacs that is not linked to the X11 libraries:
CFLAGS=-O2 LDFLAGS=-s ./configure i486-slackware-linux \
            --prefix=/usr \
            --with-x=no \
            --with-pop
make
make install
( cd /usr/bin ; mv emacs-$VERSION emacs-$VERSION-no-x11 )
# OK, now we start over building the full X11 emacs:
CFLAGS=-O2 LDFLAGS=-s ./configure i486-slackware-linux \
            --prefix=/usr \
            --with-x11 \
            --with-x-toolkit \
            --with-pop
make
make install
( cd /usr/bin
  mv emacs-$VERSION emacs-$VERSION-with-x11 
  ln -sf emacs-$VERSION-with-x11 emacs
)
# You'll get to sort through these later:
mkdir -p /install
cp -a $CWD/slack-desc* /install