#! /bin/sh
#
# Copyright (C) 1999 Silicon Graphics, Inc.  All Rights Reserved.
# 
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Fondation.
# 
# This program is distributed in the hope that it would be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  Further, any license provided herein,
# whether implied or otherwise, is limited to this program in accordance with
# the express provisions of the GNU General Public License.  Patent licenses,
# if any, provided herein do not apply to combinations of this program with
# other product or programs, or any other product whatsoever.  This program is
# distributed without any warranty that the program is delivered free of the
# rightful claim of any third person by way of infringement or the like.  See
# the GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along with
# this program; if not, write the Free Software Foundation, Inc., 59 Temple
# Place - Suite 330, Boston MA 02111-1307, USA.
#
# Install the lockstat PMDA and/or PMNS
#
# $Id: Install,v 1.2 2000/11/01 04:34:55 markgw Exp $
#

# Get standard environment
. /etc/pcp.env

# The name of the PMDA
#
iam=lockstat

if [ `pwd` != "$PCP_PMDAS_DIR/$iam" ]
then
    echo
    echo "Error: you must run \"make install\" to install the"
    echo "lockstat PMDA into $PCP_PMDAS_DIR/lockstat directory"
    echo "and then run this script in that directory."
    echo

    exit 1
fi

# Get the common procedures and variable assignments
#
. $PCP_SHARE_DIR/lib/pmdaproc.sh

# Using libpcp_pmda.so.2 and PMDA_INTERFACE_3
#
pmda_interface=3

echo "The lockstat PMDA requires access to the System.map that matches the"
echo "running kernel. This is required in order to resolve lock names from"
echo "lock addresses and caller names from caller return addresses. This is"
echo "usually found in the top level directory of the linux kernel source"
echo "used to compile the running kernel."
echo

defaultsysmap=`pwd`/System.map
while true
do
    $ECHONL "Enter path to \"System.map\" [$defaultsysmap]"
    read answer
    [ -z "$answer" ] && answer="$defaultsysmap"
    [ ! -f "$answer" -a -f "$answer/System.map" ] && answer=$answer/System.map
    if [ -f "$answer" ]
    then
	sysmap="$answer"
	break
    fi
    echo "Error: \"$answer\" not found. Try again."
done
args="-s $sysmap"

# Do it
#
pmdaSetup

pmda_dir=`pwd`
make pmdalockstat

pmdaInstall

exit 0
