#!/bin/sh

# This is used to include machine specific
# headers in the Makefiles.

HEADER=$NNTOOLS/param/$MACHTYPE.param

cd $1;
echo Makify: `pwd`;

if test -s Makefile.am
then
	echo Creating $MACHTYPE.mk from Makefile.am

	# where is NNTOOLS installed?
	echo "NNTOOLS=$NNTOOLS" > $MACHTYPE.mk;

	# add in local customizations
	if test -s "local.am"
	then
		echo "" >> $MACHTYPE.mk
		echo "# -------- local.am --------" >> $MACHTYPE.mk
		cat local.am >> $MACHTYPE.mk;
	fi

	# add machine dependent info
	echo "" >> $MACHTYPE.mk
	echo "# -------- $MACHTYPE.param  --------" >> $MACHTYPE.mk
	cat $HEADER >> $MACHTYPE.mk;

	# concat the base makefile to the end
	echo "" >> $MACHTYPE.mk
	echo "# -------- Makefile.am --------" >> $MACHTYPE.mk
	cat Makefile.am >> $MACHTYPE.mk;

fi

# bpmake makefiles
if test -s Makefile.bp
then
	echo Creating $MACHTYPE.bp.mk from Makefile.bp

	# where is NNTOOLS installed?
	echo "NNTOOLS=$NNTOOLS" > $MACHTYPE.bp.mk;

	# add machine dependent info
	cat $HEADER >> $MACHTYPE.bp.mk;


	# concat the base makefile to the end
	cat Makefile.bp | sed 's/^include/#include/' >> $MACHTYPE.bp.mk;
fi

for f in *
do
if test -d $f
then
	$NNTOOLS/Makify $f
fi
done