#! /bin/sh
#
# Mastodon build for the mastodon tools
#

# define and generate our target directories
#

. ./Mastodon.inc

exedir CORE
supdir Compilers DEVEL
supdir Xfree
supdir Games
supdir Boot

# clean, build, and install the product
#
make clean
make CC="$SYSCC" || exit 1

install -d -m 755 -o root -g root $CORE/usr/ia32-linuxaout/lib
install -d -m 755 -o root -g root $CORE/usr/lib
install -d -m 755 -o root -g root $CORE/usr/include
install -d -m 755 -o root -g root $DEVEL/usr/ia32-linuxaout
install -d -m 755 -o root -g root $DEVEL/usr
install -d -m 755 -o root -g root $GAMES/usr/bin
install -d -m 755 -o man -g man   $GAMES/usr/man/man1
install -d -m 755 -o root -g root $CORE/etc/rc.d/net.cf

make CC="$SYSCC" DESTDIR=$CORE \
     INSTALL_LIB=$CORE/usr/ia32-linuxaout/lib install || exit 1
DESTDIR=$XFREE make -C admin Xinstall || exit 1

install -d -m 755 -o man -g man $DEVEL/usr/man
mv $CORE/usr/man/man3 $DEVEL/usr/man
mv $CORE/usr/ia32-linuxaout/lib $DEVEL/usr/ia32-linuxaout
mv $CORE/usr/include $DEVEL/usr

mv $CORE/usr/bin/play $GAMES/usr/bin/play
mv $CORE/usr/man/man1/play.1 $GAMES/usr/man/man1/play.1

for service in console serial inet yellowpages nfs tuneide; do
    ln -s ../init.d/$service $CORE/etc/rc.d/rc.m/$service
done

ln -s ../init.d/shutoff $CORE/etc/rc.d/rc.h/shutoff
ln -s ../init.d/shutoff $CORE/etc/rc.d/rc.r/shutoff
ln -s ../init.d/single $CORE/etc/rc.d/rc.s/single

echo "order hosts,bind" > $CORE/etc/host.conf

mkdir -p $CORE/etc/rc.d/net.cf
mkdir -p $CORE/tmp $XFREE/tmp $XFREE/usr/X11R6/bin
chmod 1777 $CORE/tmp $XFREE/tmp
cp admin/bin/stage2 $CORE/tmp/Config                ; touch $CORE
cp admin/bin/Xsetup $XFREE/tmp/Xsetup               ; touch $XFREE
cp admin/bin/xf86config $XFREE/usr/X11R6/bin/Xconfig
						      touch $GAMES

exit 0
