
CC = acc

#   Default dictionary file
#   BSD and early systems
DEFAULTDICT = /usr/dict/words
#   System V uses this (at least on SGI)
#DEFAULTDICT = /usr/share/lib/dict/words

#   Set DEFAULTDICTMODE to 0 if the above file is in dictionary format
#   (-f mode) or 1 if the a text file is used (-t mode).
DEFAULTDICTMODE = 0

#   For debug
CCOPTS = -g
STRIP = true

#   For production
#CCOPTS = -O
#STRIP = strip

#   Other tools
LINT = alint
PAGER = less

#   Directories

SOURCE = stego.c iso8859.c
OBJS = stego.o iso8859.o
INCLUDES = iso8859.h
MAN = stego.1
MISC = Makefile
NOTES = README

RELEASE = $(NOTES) $(SOURCE) $(INCLUDES) $(MAN) $(MISC)

CFLAGS = $(CCOPTS) -DDEFAULT_DICT=\"$(DEFAULTDICT)\" \
		   -DDEFAULT_DICT_MODE=$(DEFAULTDICTMODE)

all:	stego

stego:	$(OBJS)
	$(CC) $(CFLAGS) $(OBJS) -o stego
	$(STRIP) stego

#   Run lint on source.  This program is not entirely lint free,
#   as I refuse to obfuscate the source to eliminate the last
#   few irrelevant natters.

lint:
	$(LINT) $(SOURCE)

#   Show manual page on terminal

manpage:
	nroff -man stego.1 | $(PAGER)

#   Print manual page

printman:
	ptroff -man stego.1

#   Create shell archive release file

shar:
	shar -a $(RELEASE) >stego.shar

#   Run tests

test:	diagnostic confidence

#   Diagnostic test

diagnostic: stego
	stego -e -v stego.c testfile.ste
	stego -d -v testfile.ste testfile.std
	@if cmp -s stego.c testfile.std ; \
	then \
	    echo "Passed diagnostic test." ; \
	    rm testfile.ste testfile.std ; \
	else \
	    echo "** Error: decoded file differs from source." ; \
	    ls -l stego.c testfile.std ; \
	    cmp stego.c testfile.std ; \
	fi

#   Full-on confidence test: Don't expect to understand the output if
#   something goes wrong here!	This takes a *long* time to run and
#   uses lots of memory.

confidence: stego
	stego -t stego.c -w testfile.dic
	time stego -e stego | stego -t stego.c -e | stego -e | compress -c | \
	    stego -e | stego -d | uncompress -c | stego -d | \
	    stego -d -f testfile.dic | stego -d >testfile.std
	@if cmp -s stego testfile.std ; \
	then \
	    echo "Passed confidence test." ; \
	    rm testfile.std testfile.dic ; \
	else \
	    echo "** Error: decoded file differs from source." ; \
	    ls -l stego testfile.std ; \
	    cmp stego testfile.std ; \
	fi

clean:
	rm -f *.bak *.o stego testfile.ste testfile.std core *.out *.shar
