?RCS: $Id: usedtrace.U,v $
?RCS:
?RCS: Copyright (c) 2008 H.Merijn Brand
?RCS:
?RCS: You may distribute under the terms of either the GNU General Public
?RCS: License or the Artistic License, as specified in the README file.
?RCS:
?RCS: $Log: usedtrace.U,v $
?RCS:
?MAKE:usedtrace dtrace: Myread Oldconfig Setvar Getfile test
?MAKE:	-pick add $@ %<
?Y:TOP
?S:usedtrace:
?S:	This variable indicates whether we are compiling with dtrace
?S:	support. See also dtrace.
?S:.
?S:dtrace:
?S:	This variable holds the location of the dtrace executable.
?S:.
?C:USE_DTRACE:
?C:	This symbol, if defined, indicates that Perl should
?C:	be built with support for DTrace.
?C:.
?H:#$usedtrace USE_DTRACE		/**/
?H:.
?T:dflt_dtrace
?LINT:set usedtrace
?LINT:set dtrace
: DTrace support
dflt_dtrace='/usr/sbin/dtrace'
$test -x /usr/bin/dtrace && dflt_dtrace='/usr/bin/dtrace'

cat <<EOM

Perl can be built to support DTrace on platforms that support it.
DTrace is a diagnosis and performance analysis tool from Sun.

If this doesn't make any sense to you, just accept the default.
EOM

while $test 1 ; do
	case "$usedtrace" in
	$define|true|[yY]*)
		dflt='y'
		;;
	$undef|false|[nN]*)
		dflt='n'
		dflt_dtrace=""
		;;
	?*)
		dflt='y'
		dflt_dtrace=$usedtrace
		;;
	*)
		dflt='n'
		;;
	esac

	rp='Support DTrace if available?'
	. ./myread
	case "$ans" in
	y|Y)	val="$define" ;;
	*)      val="$undef" ;;
	esac
	set usedtrace
	eval $setvar

	test "X$usedtrace" != "X$define" && break

	echo " "
	rp='Where is the dtrace executable?'
	dflt=$dflt_dtrace
	. ./getfile
	val="$ans"
	set dtrace
	eval $setvar

	if $test -f $dtrace
	then
		if $dtrace -h -s ../perldtrace.d \
			-o perldtrace.tmp >/dev/null 2>&1 \
			&& rm -f perldtrace.tmp
		then
			echo " "
			echo "Good: your $dtrace knows about the -h flag."
		else
			cat >&2 <<EOM

*** $me:  Fatal Error:  $dtrace doesn't support -h flag
***
*** Your installed dtrace doesn't support the -h switch to compile a D
*** program into a C header. Can't continue.

EOM
			exit 1
		fi
		break;
	fi

	case "$fastread" in
	yes)
		cat >&2 <<EOM

*** $me:  Fatal Error:  $dtrace not found.
*** Can't continue.

EOM
		exit 1
		;;
	*)
		echo "*** $dtrace was not found."
		echo " "
		;;
	esac
done

