##################################################
###                                            ###
### Makefile for LCLint                        ###
###                                            ### 
### designed for use with gmake (GNU make)     ### 
###                                            ###  
### original version based on LCL Makefile     ###
### completely revised December 1993           ###   
###                                            ###
### All system dependant information is in     ###
### Makefile.sys.   This file should not need  ###
### to be edited.                              ###
###                                            ###
##################################################

.SUFFIXES : .lcl .lcs .lh .h .c .o .check
.PHONY : all dorerelease retest rerelease homeversion
.IGNORE: dorerelease retest rerelease

CHECK = FALSE

include ../Makefile.decmips.sys
include ../Makefile.sources

###
### top level
### 

all : homeversion lclint

quick: lclint

lclint : $(OBJ) 
	@echo '<<< Linking >>>'
	@cd /u/evs/lclint/src ; $(GCC) $(DEBUGFLAGS) -o lclint -g $(OBJ) -ll -lgc

###
### grammars
###

# -p yl flag to bison renames yyparse ==> ylparse, yllex ==> yllex
# this is probably NOT compatible with yacc.

Headers/signature2.h : signature.c
Headers/cgrammar2.h : cgrammar.c
Headers/llgrammar.h : llgrammar.c

signature.o : signature.y
	$(YACC) $(LSLYFLAGS) signature.y
	@$(MV) signature.tab.c signature.c
	@$(MV) signature.tab.h Headers/signature2.h
	$(GCC) $(CNWFLAGS) -c signature.c

cgrammar.o : cgrammar.y
	$(YACC) $(YFLAGS) cgrammar.y
	@$(MV) y.tab.c cgrammar.c
	@$(MV) y.tab.h Headers/cgrammar2.h
	$(GCC) $(CNWFLAGS) -Wimplicit -c cgrammar.c

llgrammar.o  : llgrammar.y
	$(YACC) $(YFLAGS) -p yl llgrammar.y
	@$(MV) y.tab.c llgrammar.c
	@cp y.tab.h Headers/llgrammar2.h
	@$(MV) y.tab.h Headers/llgrammar.h
	$(GCC) $(CNWFLAGS) -c llgrammar.c

###
### scanner
###

lex.yy.c : cgrammar.l
	$(LEX) $(LFLAGS) cgrammar.l

###
### defaults
###

# .lcl.lh:
#	$(LCL) -h $*

.lcl.lcs:
	$(LCLINT) $*

.l.c:
	cd /u/evs/lclint/src ; $(LEX) $(LFLAGS) $*.l

message.o:
	@echo 'Compiling 'message.c'...'
	@cd /u/evs/lclint/src ; $(GCC) $(CNCFLAGS) -c message.c

simp_message.o:
	@echo 'Compiling 'simp_message.c'...'
	@cd /u/evs/lclint/src ; $(GCC) $(CNCFLAGS) -c simp_message.c

$(CHECKS): lclint.lldmp

.c.check: 
	lclint $(LINTFLAGS) $*.c -load lclint.lldmp

.c.o:
	@echo 'Compiling '$*.c'...'
	@cd /u/evs/lclint/src ; $(GCC) $(CFLAGS) -c $*.c

lex.yy.o: lex.yy.c
	@echo 'Compiling '$*.c'...'
	@cd /u/evs/lclint/src ; $(GCC) $(YYUSEPROTOS) $(CFLAGS) -c $*.c 

# -DYY_USE_PROTOS
#   needed for cc on alpha

###
### checking
###

lclint.lldmp: $(LCLSPECS)
	@echo 'Making lclint.lldmp library file'
	@lclint $(LINTFLAGS) $(LCLSPECS) -dump lclint.lldmp 

lint: lclint.lldmp
	lclint $(LINTFLAGS) +singleinclude $(SRC) -load lclint.lldmp

plainLint: 
	lint -IHeaders $(SRC)

lintStrict: lclint.lldmp
	lclint $(LINTSTRICTFLAGS) +singleinclude $(SRC) -load lclint.lldmp

###
### misc
###

indent:
	$(INDENT) $(SRC) 

###
### alternatives (tests, releases, backups, etc.)
###

        ### -e option makes environment variables take precedence

.PHONY : test quicktest opt backup

test: 
	cd $(TESTDIR) ; setenv $(LCLINT) $(WORKDIR)/$(LCLINT) ; $(MAKE) -e fulltest

quicktest: lclint
	cd $(TESTDIR) ; setenv $(LCLINT) $(WORKDIR)/$(LCLINT) ; $(MAKE) -e quicktest

opt :
	cd /u/evs/lclint/src ; $(MAKE) opt ; \

contopt :
	setenv GCC '$(GCCOPT)' ; \
	$(MAKE) -e lclint

prof : 
	$(GCC) $(DEBUGFLAGS) -pg -o lclint.prof -g $(OBJ) -ll


dorelease: 
	@cd /u/evs/lclint/src ; $(MAKE) dorelease

###
### cleaning
###
### Standard entries to remove files from the directories
###    up       --- remove .o files and grammar derivatives
###    tidy     --- eliminate unwanted files
###    clean    --- delete derived files, except for spec-derived files
###    pristine --- delete all derived files
###

.PHONY .IGNORE : up tidy clean pristine

pristine: clean
	-rm -f *.lcs *.lslo

clean: tidy
	-rm -f core
	-rm -f *.bib *.dvi *.idx  *.log *.o *.ps *.toc
	-rm -f cgrammar.c lex.yy.c

tidy:
	-rm -f ,* .,* *.CKP *.BAK .emacs_[0-9]* core a.out *.*~

up: 
	cd /u/evs/lclint/src ; $(MAKE) up
