# RCSID $Id: Makefile,v 1.3 1996/06/19 09:02:29 ae59 Exp ae59 $
######################################################################
#|Readme
#|------
#|Version $Id: Makefile,v 1.3 1996/06/19 09:02:29 ae59 Exp ae59 $
#|
#|Description : This is the makefile for building a simple (and possibly) 
#|              incorrect software measurement tool for programs
#|              written in Pascal-XSC. It is called pmetric.
#|              It is based on a flex/bison compatible grammar and parser 
#|              description adapted from the common BSI Pascal version.
#|              It calculates and displays all functions, procedures 
#|              and operators of a pxsc program. It determines
#|              several software metrics like SLOC, ELOC, CCM (Mccabe)
#|              It determines number of real and interval data
#|              (with some limitations!)
#|              Metrics per routine (-a) follow (CCM=Mccabes,BB=basic blocks
#|              REC= No. simple recursion, SLOC=source lines, ELOC=exec lines
#|              EXOP= exact dot operations, REAL=real data, 
#|              INV=interval date, ARIOP=arithmetic operations
#|              Name of subroutines are separated
#|              by F(unction) P(rocedure) O(operator)| 
#|              Note that only non-aliases arithmetic data is traced and
#|              static values do not represent actual dynamic occurrence!
#|
#|Disclaimer:
#|              This software does not grant for anything and you can't make
#|              the autor responsible for any possible damages or errors!
#|
#|Ackowledgement: The BSI version comes from a friendly person 
#|              that did not stored his name somewhere. I guess
#|              he has been from Finnland. Thank you very much.
#|
#|              Also thanks to Michael Neaga from Numerik Software GmbH
#|              for the free available version of Pascal-XSC.
#|              (ftp iamk4515.mathematik.uni-karlsruhe.de/pub/pascal-xsc)
#|
#|Copyright:    This package is proprietary of the author. It may be 
#|              freely distributed but must not be changed or used for 
#|              commercial purposes without permission of the author.
#|
#|Availability: This package is available at:
#|              http://www.uni-karlsruhe.de/~ae59/pmetric0-0.Z
#|
#|Author   :    Heinrich Berlejung
#|              Institut fuer Angewandte Mathematik
#|              Universitaet Karlsruhe
#|              Email:Heiner.Berlejung@math.uni-karlsruhe.de
#|
#|Tests :       It was tested on :
#|              Sun Solaris 2.3 with gcc 2.6.7, bison 1.22, flex 2.4.7. 
#|              HPUX with lex,gcc (make LEX=lex)
#|              
#|              I tested pmetric on the toolbox programs and
#|              pxsc's standard libraries and parsing works right.
#|              It will only works on a UNIX system (at the moment)
#|
#|Usage and building:        
#|              make run # should build and run a demo.
#|              pmetric -h prints out all options. For example:
#|              pmetric -a nlss.p produced:
#|               F| nlss F| AllNLSSErrMsg : CCM = 7 BB = 8 REC = 0 
#|                  SLOC = 15 ELOC = 15 EXOP = 0 REAL = 0 INTV = 0 ARIOP = 2
#|              408 lines of nlss.p parsed
#|              pmetric -t nlss.p adds begin/end to control flow.
#|              pmetric -m nlss.p provide summary of metrics.
#|
#|Future Development:
#|              - correction of many many errors 
#|              - documentation
#|              - change control
#|              - increase number of metrics
#|              - PC porting   
#|              - a graphical environment (tk based) which already works, 
#|                but can't be given away  at the moment.
#|Comments:
#|              - Any comments are appreciated, send them to the author.
#|              - I am willing to add all meaningfull extensions that
#|                might be proposed from potential users.
#|
#| Files:
#| Makefile  
#| config.h     - simple configuration
#| misc.c       - string routines
#| mktoken_name - script to generate token names
#| nlss.p       - demo pxsc program (cant be compiled as it is)
#| pxsc.l       - parser for pxsc
#| pxsc.y       - grammar for pxsc
#| readme       - documentation file
#| utils.c      - misc routines
#| utils.h
#| version.h    - version info 
#|
#| Start:       1995-01-28
#|
######################################################################
PASCAL=pxsc
YACC=bison
LEX=flex
PREF=pxsc
OPTIONS= -vldt
CC=gcc
COPTS=-g
OBJECTS = pxsc_tab.o misc.o pxsc_yy.o token_name.o utils.o
RELEASE=`grep RELEASE version.h| sed -e "s/^.*RELEASE[ ]*\"//g" \
-e 's/\"//g' -e 's/\./-/g'`
zname="pmetric$(RELEASE).Z"

.SUFFIXES: .c .o

#
all:		pmetric

pmetric:	$(OBJECTS)
		$(CC) $(COPTS) -o pmetric $(OBJECTS) -ly -ll
.c.o :
		$(CC) -c $(COPTS) $*.c

utils.o: utils.c utils.h version.h

pxsc_tab.c pxsc_tab.h:	$(PASCAL).y
	$(YACC) $(OPTIONS) $(PASCAL).y
	-if [ -s pxsc.tab.c ] ; then \
		mv pxsc.tab.h pxsc_tab.h;mv pxsc.tab.c  pxsc_tab.c; fi
	-if [ -s y.tab.c ] ; then \
		mv y.tab.h pxsc_tab.h;mv y.tab.c  pxsc_tab.c; fi

pxsc_yy.c:	$(PASCAL).l
	$(LEX) $(PASCAL).l
	-if [ -s lex.yy.c ] ; then mv lex.yy.c pxsc_yy.c; fi

pxsc_yy.o:	tokens.h

tokens.h:	$(PREF)_tab.h
	-cmp -s pxsc_tab.h tokens.h || cat pxsc_tab.h |sed 's/^# /#/'>tokens.h

token_name.c:	mktoken_name tokens.h
	sh mktoken_name

install:	pmetric
	if [ -d "$(BIN)" ] ; then cp pmetric $(BIN)/ ; \
		     chmod 755 $(BIN)/pmetric ; fi
		
clean:
	rm -f *.o pxsc_yy.c pxsc_tab.h 
	rm -f pxsc_tab.c token_name.c tokens.h
	rm -f *.output pmetric

tar: 
	@$(MAKE) doc
	@tar cf - pxsc.y pxsc.l utils.c utils.h misc.c Makefile readme \
	mktoken_name config.h version.h nlss.p| compress  >pmetric$(RELEASE).Z
doc:
	@sed "/^#|[ ]*ftp:/s/pmetric.*\.Z/$(zname)/g" Makefile >Makefile.new
	@mv Makefile.new Makefile
	@grep '^#|' Makefile | sed "s/^#|//g" > readme

help:
	@grep '^#|' Makefile | sed "s/^#|//g" 


run : pmetric
	pmetric -m <nlss.p
	
