# personal utilities library makefile

# (base) Name of ar and lint library for this library
LIBID = cvr
ARLIB = $(LIBID)
LINTLIB = $(LIBID)

LDFLAGS =

LIBS = $(CLIBLOC) $(LDIR)/libtmc.a
LINTLIBS = $(LINTLIBLOC) $(LDIR)/llib-ltmc.ln

LINTFLAGS = -I$(IDIR) $(DBUG) -D$(SYS)
CFLAGS = $(SYSCFLAGS) -I$(IDIR) $(DBUG) -D$(SYS)

# Version number of this libary
VERSION = 1

LINKER        = cc

INSTHFILES    = cvr.h

TESTSRCS = testprog.c

TESTFILES = testin goodout gooderr $(TESTSRCS)

JUNK  = testprog testerr testout tmp core mon.out gmon.out $(ARLIBNAME) \
	$(LINTLIBNAME) lint libcvr.lint cvr.aux cvr.dvi cvr.log \
        lib$(LIBID)_p.a lib$(LIBID)_g.a profilelib debuglib

# filled in by mkmf
SRCS	= 

# filled in by mkmf
HDRS = config.h cvr.h all.h

# filled in by mkmf
OBJS	= 

LIBSRCS = \
    ckmalloc.c ckcalloc.c ckreallc.c \
    symbol.c fscsym.c \
    flagfind.c flagset.c flaghelp.c

LIBOBJS = \
    ckmalloc.o ckcalloc.o ckreallc.o \
    symbol.o fscsym.o \
    flagfind.o flagset.o flaghelp.o

# standard variables of modmake modules
AROBJS = $(LIBOBJS)
LINTLIBSRCS = $(LIBSRCS)

TESTOBJS = testprog.o

DOC = README CHANGELOG cvr.tex

PROGS =

MAKEFILE = Makefile

DISTFILES = $(LIBSRCS) $(HDRS) $(DOC) $(MAKEFILE) $(TESTFILES)

#++ make module lintlib start, do NOT touch this line. ++
### lintlib ###
# LINTLIBSRCS	- list of source files for this lint lib
# LINTFLAGS	- additional lint flags
# LINTLIB	- base name of lint library to create
LINTLIBNAME = llib-l$(LINTLIB).ln
$(LINTLIBNAME): $(LINTLIBSRCS)
	lint -o $(LINTLIB) $(SYSLINTFLAGS) $(LINTFLAGS) $(LINTLIBSRCS)
#++ make module lintlib end, do NOT touch this line. ++

#++ make module arlib start, do NOT touch this line. ++
### arlib ###
# AROBJS	- list of source files for ar
# ADDITIONALarFLAGS	- additional ar flags
# ARLIB		- base name of ar library to create
ARFLAGS   = rv
ARLIBNAME = lib$(ARLIB).a
$(ARLIBNAME): $(AROBJS)
	ar $(ARFLAGS) $(ARLIBNAME) $(ADDITIONALarFLAGS) $(AROBJS)
#ranlib $(ARLIBNAME)
#++ make module arlib end, do NOT touch this line. ++

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

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

profilelib: $(LIBSRCS)
	rm -f $(LIBOBJS)
	make 'ARLIB=$(LIBID)_p' 'SYSCFLAGS=$(SYSCPROFFLAGS)' lib$(LIBID)_p.a
	rm -f $(LIBOBJS)
	touch $@

debuglib: $(LIBSRCS)
	rm -f $(LIBOBJS)
	make 'ARLIB=$(LIBID)_g' 'SYSCCFLAGS=$(SYSCDBUGFLAGS)' lib$(LIBID)_g.a
	rm -f $(LIBOBJS)
	touch $@

all: lib$(LIBID).a

# Add rules for the programs themselves here.

testprog: $(TESTOBJS) $(ARLIBNAME)
	$(LINKER) $(LDFLAGS) $(TESTOBJS) $(ARLIBNAME) $(LIBS) -o testprog

test: testprog testin
	./testprog > testout
	diff testout goodout

install:  $(ARLIBNAME)
	make 'MODULE=$(ARLIBNAME)' arlibinstall
	make 'MODULE=$(INSTHFILES)' includeinstall

clean:
	rm -f $(LIBOBJS) $(JUNK)

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

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

lint: $(TESTSRCS) $(LINTLIBNAME)
	lint $(SYSLINTFLAGS) $(LINTFLAGS) $(TESTSRCS) $(LINTLIBNAME) $(LINTLIBS) >& lintout

# Non-standard make rules

version.tex : $(MAKEFILE)
	echo $(VERSION) > version.tex

doc: version.tex
	latex cvr

depend:
	mkmf -f $(MAKEFILE)

$(LINTLIBNAME): $(HDRS)
###
ckcalloc.c ckmalloc.c ckreallc.c : cvr.h all.h
symbol.c fscsym.c : cvr.h all.h
flagfind.c flagset.c flaghelp.c : cvr.h all.h
testprog.c: cvr.h
