
PROGRAM = md5

CFLAGS = -O

RELFILES = Makefile index.html main.c md5.c md5.exe md5.gif md5.h rfc1321.html rfc1321.txt

all:	$(PROGRAM)

md5:	md5.o main.o
	$(CC) -o md5 md5.o main.o

zip:
	rm -f md5.zip
	zip md5.zip $(RELFILES)

lint:
	lint main.c md5.c

#	The silly stuff with "tr" is to allow directly cutting and
#	pasting the test cases from RFC 1321.
test:	$(PROGRAM)
	md5 -d"" >test.out
	md5 -d"a" >>test.out
	md5 -d"abc" >>test.out
	md5 -d"message digest" >>test.out
	md5 -d"abcdefghijklmnopqrstuvwxyz" >>test.out
	md5 -d"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" >>test.out
	md5 -d"12345678901234567890123456789012345678901234567890123456789012345678901234567890" >>test.out
	echo "d41d8cd98f00b204e9800998ecf8427e" | tr a-f A-F >expected.out
	echo "0cc175b9c0f1b6a831c399e269772661" | tr a-f A-F >>expected.out
	echo "900150983cd24fb0d6963f7d28e17f72" | tr a-f A-F >>expected.out
	echo "f96b697d7cb7938d525a2f31aaf161d0" | tr a-f A-F >>expected.out
	echo "c3fcd3d76192e4007dfb496cca67e13b" | tr a-f A-F >>expected.out
	echo "d174ab98d277d9f5a5611c2c9f419d9f" | tr a-f A-F >>expected.out
	echo "57edf4a22be3c955ac49da2e2107b67a" | tr a-f A-F >>expected.out
	diff test.out expected.out

clean:
	rm -f $(PROGRAM) *.bak *.o *.out core
