# Instructions for manual installation are in the file README.install.

# If fed to sh, this script *may* do everything automagically.

# Although I develop Siag under Linux, it should be pretty
# straightforward to port it to other Unices. I have successfully
# built Siag under Solaris and HP/UX with no modifications of the source.
# I have also had success reports from people running SCO and FreeBSD.

# A text version of Siag is available in the tsiag directory. It is
# not built unless told to.
# A Gtk version is in the gsiag directory.

echo "Please refer to the file README.install for detailed explanation"
echo "of the installation, along with a few hints how it can be done"
echo "manually if this script fails."
echo
echo "This is to set SIAGHOME, SIAGHELP and choose libraries"
echo "Press Return to edit"
read dummy
if [ "$EDITOR" = "" ]; then
	EDITOR=vi
fi
$EDITOR topdir.mk

if [ -d xc ]; then
	echo
	echo "This compiles and installs Xaw3d, the 3D Athena replacement widget set"
	(cd xc/lib/Xaw3d
	echo "Here you should uncomment the line"
	echo "#  EXTRA_DEFINES = -DARROW_SCROLLBAR -DUSEGRAY"
	echo "Press Return to edit"
	read dummy
	$EDITOR Imakefile
	xmkmf
	make depend
	make
	su root -c "make install")
fi

if [ -d guile-1.2 ]; then
	echo
	echo "This compiles the Scheme interpreter Guile."
	echo "Press Return to continue"
	read dummy
	(cd guile-1.2
	./configure
	make
	su root -c "make install")
fi

echo
echo "This compiles and installs SIAG, PW and Egon"
echo "Press Return to continue"
read dummy
(xmkmf
make Makefiles
make depend
make
su root -c "make install")

echo
if [ -d tsiag ]; then
	echo "Do you want to try installing the Curses version?"
	read answer
	while [ "$answer" != "yes" -a "$answer" != "no" ]; do
		echo "Please answer yes or no"
		read answer
	done
else
	answer=no
fi
if [ "$answer" = "yes" ]; then
	echo
	echo "The executable will be called tsiag"
	echo "Press Return to install"
	read dummy
	(cd tsiag
	xmkmf
	make depend
	make
	su root -c "make install")
fi

echo
if [ -d gsiag ]; then
	echo "Do you want to try installing the GTK version?"
	read answer
	while [ "$answer" != "yes" -a "$answer" != "no" ]; do
		echo "Please answer yes or no"
		read answer
	done
else
	answer=no
fi
if [ "$answer" = "yes" ]; then
	echo
	echo "The executable will be called gsiag"
	echo "Press Return to install"
	read dummy
	(cd gsiag
	xmkmf
	make depend
	make
	su root -c "make install")
fi

# After this point, everything is optional.

if [ -d netpbm ]; then
	echo
	echo "This compiles and installs netpbm"
	echo "Press Return to continue"
	read dummy
	(cd netpbm
	xmkmf
	make Makefiles
	make depend
	make
	su root -c "make install")
fi

if [ -d chimera-1.70 ]; then
	echo
	echo "This compiles and installs Chimera"
	echo "Press Return to continue"
	read dummy
	(cd chimera-1.70
	cp Common.tmpl.dist Common.tmpl
	cp options.h.dist options.h
	xmkmf
	make Makefiles
	make depend
	make
	su root -c "make install")
fi

if [ -d ghostview-1.5 ]; then
	echo
	echo "This compiles and installs Ghostview"
	echo "Ghostview is no longer used; it has been replaced by GV"
	echo "Press Return to continue"
	read dummy
	(cd ghostview-1.5
	xmkmf
	make Makefiles
	make depend
	make
	su root -c "make install")
fi

if [ -d gv-3.5.8 ]; then
	echo
	echo "This compiles and installs the Postscript viewer GV"
	echo "Press Return to continue"
	read dummy
	(cd gv-3.5.8
	xmkmf
	make Makefiles
	make depend
	make
	su root -c "make install")
fi

if [ -d gnuplot ]; then
	echo
	echo "This compiles and installs Gnuplot"
	echo "Press Return to continue"
	read dummy
	(cd gnuplot
	make All
	su root -c "make x11 TARGET=Install")
fi

