VERSION = 2.3

MYDOTC	=   check.afuncs.c contsens.c errorenv.c \
	    mainf.c mainsk.c unification.c size.c
SRCS	=   ${MYDOTC} \
	    check.afuncs.h contsens.h errorenv.h \
	    unification.h check.ds.h check.var.h\
	    size.h \
	    testcsfin goodcsfout goodcsferr\
	    testskin goodskout goodskerr\
	    cpdif\
	    kex.ds\
	    p2c.h p2clib.c\
	    handlefull.ht handlefull.ct fullconf.t\
	    handlekex.ht handlekex.ct kexconf.t\
	    handcom.h handcom.c

OBJS	=   check.afuncs.o contsens.o size.o errorenv.o \
	    mainf.o mainsk.o handleds.o unification.o p2clib.o

DOC	=   Readme

SKELFILES = 

MAKEFILE = Makefile

JUNK = tmp core makelog skeleton.log skeleton.aux skeleton.dvi \
       testcsfout testcsferr testskout testskerr\
       handlefull.h handlefull.c handlekex.h handlekex.c\
       handleds.h handleds.c

DISTFILES = ${SRCS} ${DOC} ${MAKEFILE} ${SKELFILES}

#++ make module local start, do NOT touch this line. ++
# Installation dependent make variables for ericv on HERMES 

# full path of the ESPRIT environment
ESPRITDIR = /home1/forfun

#  BDIR     : bin directory
BDIR = $(ESPRITDIR)/binA

#  IDIR     : include directory
IDIR = $(ESPRITDIR)/include

#  LDIR     : library directory
LDIR = $(ESPRITDIR)/libA


NFULLDS = $(ESPRITDIR)/ds/nfullgl.ds
NKERNDS = $(ESPRITDIR)/ds/nkerngl.ds

#  HOSTNAME : name of installation machine.
HOSTNAME=hermes

# SYS     : name of operating system or machine type
#     BSD	For generic BSD systems
#     AVIION	For generic DG_UX systems
#     HPUX	For all HP-UX systems
#     SUN	For all SUN systems
#     APOLLO	For all Apollo systems
SYS = AVIION

# CLIBLOC : required C libraries
CLIBLOC =

LINTLIBLOC =

PASLIBLOC =

# CBADADR : address that will cause a core-dump if read or written.
CBADADR = 0

SYSLINTFLAGS = -hpac
SYSCFLAGS = 
SYSCPROFFLAGS =
SYSCDBUGFLAGS =
SYSPFLAGS =
OFLAG= -O
# Collection of host dependent make rules.

### libinstall ###
# MODULE	- module to install
libinstall:
	cp $(MODULE) $(LDIR)/$(MODULE)

### includeinstall ###
# MODULE	- module to install
includeinstall:
	cp $(MODULE) $(IDIR)/$(MODULE)

### maninstall ###
# MAN		- manual page to install
maninstall:
	cp $(MAN) /usr/man/manl

### bininstall ###
# MODULE	- module to install
bininstall:
	cp $(MODULE) $(BDIR)/$(MODULE)
	strip $(BDIR)/$(MODULE)

### arlibinstall ###
# MODULE	- module to install
arlibinstall:
	cp $(MODULE) $(LDIR)/$(MODULE)

LINK.c=$(CC) 
#++ make module local end, do NOT touch this line. ++

CFLAGS = $(SYSCFLAGS) -I$(IDIR) $(DBUG) -D$(SYS)
help :
	@echo " Possible make targets:"
	@echo "all		Create local running programs."
	@echo "clean		Free disk space."
	@echo "distfiles	List distribution files."
	@echo "install		Install relevant files."
	@echo "setup		Adapt sources to local situation."
	@echo "test		Run tests."
version :
	@echo "version of context-sensitive checks: $(VERSION)"

PROGS   = csf sk

all: 	$(PROGS)

# Add rules for the programs themselves here.
#; lint -I$(IDIR) $*.c

handlefull.h: handlefull.ht fullconf.t handcom.h
	tm $(NFULLDS) handlefull.ht > handlefull.h
handlefull.c: handlefull.ct fullconf.t  handcom.c
	tm  $(NFULLDS) handlefull.ct > handlefull.c
handlekex.c: kex.ds handlekex.ct kexconf.t  handcom.c
	tm kex.ds handlekex.ct > handlekex.c
handlekex.h: kex.ds handlekex.ht kexconf.t handcom.h
	tm kex.ds handlekex.ht > handlekex.h
handleds.h: trick $(HFK).h
	cpdif $(HFK).h handleds.h
handleds.c: trick $(HFK).c
	cpdif $(HFK).c handleds.c
trick:	

handleds.o: handleds.c handleds.h
p2clib.o: p2clib.c
errorenv.o: errorenv.c errorenv.h handleds.h check.ds.h check.var.h
check.afuncs.o: check.afuncs.c check.afuncs.h handleds.h check.ds.h check.var.h
contsens.o: contsens.c contsens.h handleds.h check.ds.h check.var.h\
	    check.afuncs.h unification.h errorenv.h
size.o: size.c size.h handleds.h check.ds.h check.var.h\
	    check.afuncs.h unification.h errorenv.h
mainf.o: mainf.c handleds.h check.ds.h check.var.h contsens.h
unification.o: unification.c unification.h handleds.h check.ds.h check.var.h\
	    check.afuncs.h errorenv.h
mainsk.o: mainsk.c handleds.h check.ds.h check.var.h size.h

csf: 	trick
	make 'HFK=handlefull' csf1

csf1: mainf.o contsens.o unification.o \
       check.afuncs.o errorenv.o handleds.o p2clib.o
	$(LINK.c)  -o csf p2clib.o handleds.o errorenv.o \
	check.afuncs.o unification.o contsens.o mainf.o $(LDIR)/libtmc.a -lm -lc 
sk:	trick
	make 'HFK=handlekex' sk1

sk1: mainsk.o size.o unification.o \
     check.afuncs.o errorenv.o handleds.o p2clib.o
	$(LINK.c)  -o sk \
	mainsk.o handleds.o p2clib.o unification.o size.o errorenv.o \
	check.afuncs.o $(LDIR)/libtmc.a -lm -lc
 
testPR: 
	sh -ce '$(PR) < $(TESTIN) > $(TESTOUT) 2> $(TESTERR)'
# in fact dependent on PR. This is not stated because this causes recompilation
# after make all (because of complicated definition of handleds).

test:
	make 'PR=csf' 'TESTIN=testcsfin' 'TESTOUT=testcsfout' 'TESTERR=testcsferr' testPR
	diff testcsfout goodcsfout
	diff testcsferr goodcsferr
	make 'PR=sk' 'TESTIN=testskin' 'TESTOUT=testskout' 'TESTERR=testskerr' testPR
	diff testskout goodskout
	diff testskerr goodskerr
#this test only tests if csf/sk work, not if the input they will actually get
#is as used in testcsfin/testskin.

install: 
	cp $(PROGS) $(BDIR)
# no check if PROGS up to date, because otherwise double work is done
# (because of different contents of handleds)

clean:
	rm -f ${JUNK} ${OBJS} ${PROGS}

distfiles:
	@echo $(DISTFILES) | tr ' ' '\012'

setup:
	modmake local ../make.local ${MAKEFILE}

# Non-standard make rules
###

#For use of the person making a (shar) package:

normaltestoutput: 
	make 'PR=csf' 'TESTIN=testcsfin' 'TESTOUT=goodcsfout' 'TESTERR=goodcsferr' testPR
	make 'PR=sk' 'TESTIN=testskin' 'TESTOUT=goodskout' 'TESTERR=goodskerr' testPR

sharit: normaltestoutput
	@echo 'now cd .. and shardir this directory'
dolint: 
	lint -I$(IDIR) ${MYDOTC} handleds.c
