#!/bin/sh
if test "$1" = "-help"
then
	echo "purpose: make symbolic links for all header files";
	echo "         used in the application modules";
	exit 1;
fi


# test for /bin/test  :-)
if test -x /bin/test
then
	echo "ugmakelinks will use /bin/test for testing symbolic links"
	TEST_WITH_LINKS=/bin/test
else
	echo "ugmakelinks will use test for testing symbolic links"
	TEST_WITH_LINKS=test
fi


if test "x$UGROOT" = "x"
then
	echo "$0: to use $0 set shell environment variable UGROOT!";
	exit 1;
fi


cd $UGROOT;

# clear include-directory
if test -d include
then
	rm -f -r include;
fi	
mkdir include.tmp;

if test -x /bin/uname
then
case `/bin/uname | cut -f1 -d' ' ` in
	AIX | Paragon | HI-UX/MPP)
		FOLLOW_LINKS=
		echo "not following symbolic links"
		;;
	*)
		FOLLOW_LINKS=-follow
		;;
esac;
else
	FOLLOW_LINKS=
	echo "not following symbolic links"
fi

find ${UGROOT} \
	-type d -name include.tmp -prune -o \
	-type d -name doc -prune -o \
	-type d -name man -prune -o \
	-name '*.h' \
	${FOLLOW_LINKS} -exec ln -s {} $UGROOT/include.tmp \; -print

mv include.tmp include

# devices.h was renamed to ugdevices.h. For compatibility reasons:
ln -s $UGROOT/dev/ugdevices.h $UGROOT/include/devices.h

exit 0

