?RCS: $Id: d_havetlib.U 1 2006-08-24 12:32:52Z rmanfredi $
?RCS:
?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
?RCS:
?RCS: You may redistribute only under the terms of the Artistic Licence,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic Licence; a copy of which may be found at the root
?RCS: of the source tree for dist 4.0.
?RCS:
?RCS: $Log: d_havetlib.U,v $
?RCS: Revision 3.0.1.2  1997/02/28  15:36:31  ram
?RCS: patch61: replaced .a with $_a all over the place
?RCS: patch61: likewise for .o replaced by $_o
?RCS:
?RCS: Revision 3.0.1.1  1994/05/06  14:44:06  ram
?RCS: patch23: added AIX support to accept shared lib stub as termlib (WED)
?RCS:
?RCS: Revision 3.0  1993/08/18  12:06:19  ram
?RCS: Baseline for dist 3.0 netwide release.
?RCS:
?MAKE:d_havetlib termlib: cat contains Myread Loc Filexp Oldconfig libpth \
	test uname _a _o
?MAKE:	-pick add $@ %<
?S:d_havetlib:
?S:	This variable conditionally defines the HAS_TERMLIB symbol, which
?S:	indicates to the C program that termlib-style routines are available.
?S:.
?S:termlib:
?S:	This variable contains the argument to pass to the loader to get
?S:	termlib-style routines.  It is up to the Makefile.SH to make sure
?S:	the value gets to the right command.  Note that on many systems the
?S:	termlib routines are emulated by the curses or terminfo library.
?S:.
?C:HAS_TERMLIB (HAVETERMLIB):
?C:	This symbol, when defined, indicates that termlib-style routines
?C:	are available.  There is nothing to include.
?C:.
?H:#$d_havetlib	HAS_TERMLIB	/**/
?H:.
?T:xxx
: where do we get termlib routines from
echo " "
xxx=`./loc libcurses$_a x $libpth`
case "$xxx" in
/*)
	ar t $xxx >grimble
	if $contains tputs$_o grimble >/dev/null 2>&1; then
		termlib='-lcurses'
		d_havetlib="$define"
		echo "Terminfo library found." >&4
	elif $test "x`$uname 2>/dev/null`" = xAIX; then
		# Ok, do the AIX shr.o fun thing
		/usr/ccs/bin/nm -en $xxx 2>/dev/null >grimble
		if $contains '^tputs .*|extern|' grimble >/dev/null 2>&1; then
			termlib='-lcurses'
			d_havetlib="$define"
			echo "AIX Terminfo library found." >&4
		else
			xxx=x
		fi
	else
		xxx=x
	fi
	rm -f grimble
	;;
esac
case "$xxx" in
x)
	xxx=`./loc libtermlib$_a x $libpth`
	case "$xxx" in
	/usr/lib*|/lib*)
		termlib='-ltermlib'
		d_havetlib="$define"
		echo "Termlib library found." >&4
		;;
	/*)
		termlib="$xxx"
		d_havetlib="$define"
		echo "Termlib library found." >&4
		;;
	*)
		xxx=`./loc libtermcap$_a x $libpth`
		case "$xxx" in
		/usr/lib*|/lib*)
			termlib='-ltermcap'
			d_havetlib="$define"
			echo "Termcap library found." >&4
			;;
		/*)
			termlib="$xxx"
			d_havetlib="$define"
			echo "Termcap library found." >&4
			;;
		*)
			case "$termlib" in
			'')
				dflt=y
rp="Your system appears to NOT have termlib-style routines. Is this true?"
				. ./myread
				case "$ans" in
				n*|f*) d_havetlib="$define"
					$cat <<'EOM'
Then where are the termlib-style routines kept? Specify either -llibname
or a full pathname (~name ok).

EOM
					dflt=''
					rp='Specify termlib path:'
					. ./myread
					termlib=`./filexp $ans`
					;;
				*)
					d_havetlib="$undef"
					termlib=''
					echo "You will have to play around with term.c then." >&4
					;;
				esac
			echo " ";;
			*)  echo "You said termlib was $termlib before." >&4;;
			esac;;
		esac;;
	esac;;
esac

