# ======================================================================
# Makefile for checksum program
#
# Targets:
#	all		make everything
#	checksum	checksum program
#	clean		remove object files and other temporary files
#	clobber		remove all reconstructable files
#	crc.tab		output of polynom
#	polynom		generator of polynomial coefficients used by
#			checksum
#	test.new	simple test of checksum and its status codes
#
# [14-Mar-1994]
# ======================================================================

# These two values may need to be changed for your local conventions
BINDIR        =
MANDIR        =

CC            = sc
LN            = slink

CFLAGS        = IGNORE=304 NOICONS OPTIMIZE
LFLAGS        = NOICONS

CHECKSUM      = checksum

# Use -p to preserve time stamps where available
# HPUX and AT&T System V lack it however
CP          = copy clone
INSTALL       = copy clone

CWEAVE        = cweave
WFLAGS        = -fg

CTANGLE       = ctangle

RM            = delete

SEP           = "============================================================"

TARFILES      = Makefile README checksum.c checksum.txt \
		checksum.tex checksum.toc checksum.w \
		index polynom.c polynom.tex polynom.toc \
		polynom.w test.org test.new
 
#=======================================================================
# the remaining lines should not need changes

.SUFFIXES: .tex .dvi .w

.w.tex:
	$(CWEAVE) $(WFLAGS) $* $*

.tex.dvi:
	etex $*

.w.c:
	$(CTANGLE) $* $*

.c.o:
	$(CC) $(CFLAGS) $*

#=======================================================================

all:	checksum polynom crc.tab test.new checksum.dvi polynom.dvi

checksum.tex:	checksum.w checksum.ch
checksum.dvi:	checksum.tex
checksum.c:	checksum.w checksum.ch
checksum.o:	checksum.c
checksum:	checksum.o
	$(LN) $(LFLAGS) FROM lib:c.o checksum.o TO checksum LIB lib:sc.lib

clean:
	-$(RM) \#?.(bak|dvi|log|o|idx|scn|toc|c|tex|info)

clobber:	clean
	-$(RM) checksum polynom crc.tab

crc.tab:	polynom
	polynom

polynom.tex:	polynom.w polynom.ch
polynom.dvi:	polynom.tex
polynom.c:	polynom.w polynom.ch
polynom.o:	polynom.c
polynom:	polynom.o
	$(LN) $(LFLAGS) FROM lib:c.o polynom.o TO polynom LIB lib:sc.lib

test.new:	checksum
#	$(CHECKSUM) -c test.org test.new
	$(CHECKSUM) test.org test.new
	@echo $(SEP)
	@echo "The following lines should show the old and new checksums:"
	@diff test.org test.new
#	@echo $(SEP)
#	@echo "The following test should return a NON-ZERO status code:"
#	@if $(CHECKSUM) -v test.org  >/dev/null ;\
#	then	echo "	checksum INCORRECTLY returns a zero status code" ;\
#	else	echo "	checksum correctly returns a NON-ZERO status code" ;\
#	fi
#	@echo $(SEP)
#	@echo "The following test should return a ZERO status code:"
#	@if $(CHECKSUM) -v test.new >/dev/null ;\
#	then	echo "	checksum correctly returns a ZERO status code" ;\
#	else	echo "	checksum INCORRECTLY returns a non-zero status code" ;\
#	fi
	@echo $(SEP)
