#
# Cryptographic support routines for knfsd
#

include $(TOP)/config.mk

SHAFLAGS= -DUNROLL_LOOPS
OBJS	= md5.o sha.o randomkey.o weakrandomkey.o
LIB	= libcrypt.a

all::	$(LIB)
	@echo "Done."

$(LIB):	$(OBJS)
	rm -f $@
	ar cr $@ $(OBJS)

sha.o:	sha.c
	$(CC) $(CFLAGS) $(SHAFLAGS) -c $< -o $@

clean distclean::
	rm -f *.o sha appgen sha.outputs

distclean::
	rm -f $(LIB) .depend

test:	shatest

shatest:sha appgen
	rm -f sha.outputs
	appgen 1 | sha >> sha.outputs
	appgen 2 | sha >> sha.outputs
	appgen 3 | sha >> sha.outputs
	@if diff sha.good.outputs sha.outputs > /dev/null; then \
		echo "SHA module seems to work."; \
	else \
		echo "SHA module is broken."; \
		echo "Correct results should be:"; cat sha.good.outputs; \
		echo "Test binary produced:"; cat sha.outputs; \
	fi

sha:	sha_driver.o sha_test.o
	$(CC) $(CFLAGS) -o $@ sha_driver.o sha_test.o

sha_test.o: sha.c
	$(CC) $(CFLAGS) -O2 $(SHAFLAGS) -c -o $@ $<

dep::
	$(CC) $(CFLAGS) -M $(OBJS:.o=.c) > .depend

install::

ifeq (.depend,$(wildcard .depend))
include .depend
endif
