# makefile

VERSION = 1

DOC	=

TEST =

PROGS   = discev

SKELFILES = make.local

MAKEFILE = Makefile

LINKER = cc

TM = tm

JUNK = tmp core makelog tags lint \
       testout

DISTOTHERS = 

DISTFILES = $(DISTSRCS) $(DISTHDRS) $(DOC) $(MAKEFILE) $(TMFILES) \
	    $(DISTOTHERS) $(TEST)

CFLAGS = -I$(IDIR) -D$(SYS) $(SYSCFLAGS) -g

LINTFLAGS = -I$(IDIR) -D$(SYS)

LIBS = $(LDIR)/libcvr.a $(LDIR)/libtmc.a $(CLIBLOC)

.SUFFIXES:
.SUFFIXES: .out .o .c .h .e .r .f .y .l .s .p .ht .ct

#when entering make do a make all 
default: all

#++ 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. ++

LINTLIBS =  $(LDIR)/llib-lcvr.ln $(LDIR)/llib-ltmc.ln $(LINTLIBLOC)

# .h files generated from tm modules
TMHDRS	      = tmcode.h 

HDRS	      = tmcode.h \
		discevconfig.h \
		discevconst.h \
		utils.h

OBJS         = tmcode.o utils.o discev.o

# .c files generated from tm modules
TMSRCS        = tmcode.c

SRCS          = discev.c tmcode.c utils.c

# distributed tm source files
TMFILES = discevconfig.t tmcode.ct tmcode.ht

# distributed .h files
DISTHDRS      = discevconfig.h \
		discevconst.h \
                utils.h
# distributed .c files
DISTSRCS      = discev.c utils.c

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."

all	: $(PROGS)

discev: $(OBJS)
	$(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o discev

# make rules for testing
test:
	@echo 'Sorry no testing available'

# run program and check output

install:  discev
	make bininstall 'MODULE=discev'
	make includeinstall 'MODULE=DiscEvents.c'
	make includeinstall 'MODULE=DiscEvMain.c'

clean:
	rm -f $(OBJS) $(TMSRCS) $(TMHDRS) $(JUNK) $(PROGS)

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

setup:
	modmake local ../make.local $(MAKEFILE)

# Non-standard make rules

index:
	ctags -wx $(HDRS) $(SRCS)

tags: $(HDRS) $(SRCS)
	ctags $(HDRS) $(SRCS)

depend: $(TMSRCS) $(TMHDRS)
	mkmf -I$(IDIR) -f $(MAKEFILE)

.ht.h:
	$(TM) discev.ds $< > $*.h

.ct.c:
	$(TM) discev.ds $< > $*.c

lint: $(SRCS) $(HDRS)
	lint $(LINTFLAGS) $(SRCS) $(LINTLIBS) > lint

# Dependencies not detected by 'mkmf'
$(TMHDRS) : discev.ds discevconfig.t
$(TMSRCS) : discev.ds discevconfig.t
###
discev.o: discevconst.h tmcode.h utils.h
tmcode.o: discevconfig.h tmcode.h discevconst.h
utils.o: discevconst.h tmcode.h utils.h
