#!/bin/sh

export NOSDIR=/nos
if [ -n "$1" ]; then
	echo "Using TNOS installation directory of '$1'"
	NOSDIR=$1
fi

echo "Preparing your TNOS source tree for initial 'make'...."
echo

echo "First step: remove any files that need to be customized for your site"
echo "	Deleting 'config.h', just in case it exists"
rm -f config.h
echo "	Deleting 'catalog.h', just in case it exists"
rm -f catalog.h
echo "	Deleting 'hardware.h', just in case it exists"
rm -f hardware.h
echo

echo "Second step: setup OS-dependent Makefile for Unix"
echo "	Creating Makefile from makefile.unx"
rm -f Makefile
ln -s makefile.unx Makefile
echo

echo "Third step: create initial 'config.h' and 'make.inc' files"
rm -f make.inc config.h
MAKE=make
export MAKE
if ( make -v >/dev/null 2>&1 );
then
	:
else
	MAKE=gmake
	if ( gmake -v >/dev/null 2>&1 );
	then
		:
	else
		echo "	Sorry, but GNU make not found!"
		echo "	You will need to do a 'make make.inc config.h' with GNU make.!"
		exit 1
	fi
fi
${MAKE} NOSDIR=$NOSDIR initial config.h 2>/dev/null
${MAKE} NOSDIR=$NOSDIR make.inc 2>/dev/null
echo

echo "Fourth step: create catalog and dependencies files"
${MAKE} NOSDIR=$NOSDIR mostlyclean dep 2>/dev/null
echo

echo "Configuration complete!"
echo

echo To complete building TNOS, do the following commands:
echo
echo "       make"
echo "       make install"
echo

