#!gmake
#
# Copyright (C) 2000 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.
#

include /etc/pcp.conf

DOMAIN	= LOCKSTAT
CMDTARGET = pmdalockstat
CFILES	= pmda_lockstat.c
OBJECTS = pmda_lockstat.o
SCRIPTS	= Install Remove
LSRCFILES= $(SCRIPTS) pmns help root

PMDADIR	= .
PMCHART	= $(PCP_VAR_DIR)/config/pmchart

LDIRT	= *.o lockstat.log pmdalockstat help.pag help.dir

LOCKSTAT_OBJS = ../getsetdata.o ../symbols.o

CFLAGS = -g -I.. -I$(LINUX_INC_ROOT)
LDLIBS	= $(LOCKSTAT_OBJS) -lpcp_pmda -lpcp

default: $(CMDTARGET) domain.h

$(CMDTARGET) : $(OBJECTS) $(LOCKSTAT_OBJS) /usr/include/pcp/pmda.h
	cc -o $(CMDTARGET) $(CFLAGS) $(OBJECTS) $(LDLIBS)

pmda_lockstat.o: domain.h pmda_lockstat.h

domain.h: $(PCP_VAR_DIR)/pmns/stdpmid
	rm -f domain.h
	echo "/*" >domain.h
	echo " * built from $(PCP_VAR_DIR)/pmns/stdpmid" >>domain.h
	echo " */" >>domain.h
	$(PCP_AWK_PROG) < $< >> $@ '$$1=="#define" && $$2=="$(DOMAIN)" { print "#define $(DOMAIN) " $$3 }'

install: $(CMDTARGET)
	install -m 755 -d $(PCP_PMDAS_DIR)/lockstat
	install -m 0755 pmdalockstat Install Remove $(PCP_PMDAS_DIR)/lockstat
	install -m 0644 domain.h README help pmns root $(PCP_PMDAS_DIR)/lockstat
	install -m 0644 pmda_lockstat.c pmda_lockstat.h $(PCP_PMDAS_DIR)/lockstat
	install -m 0644  $(LOCKSTAT_OBJS) $(PCP_PMDAS_DIR)/lockstat
	install -m 0644 Makefile.install $(PCP_PMDAS_DIR)/lockstat/Makefile
	install -m 0644 ../lockstat.h ../lockmeter.h $(PCP_PMDAS_DIR)/lockstat
	
clean clobber :
	rm -f $(LDIRT)
