 ############################################################################
#                                                                            #
#                       Makefile for Implementation of                       #
#                       RRC2 - Ron Rivest Cipher Nr. 2                       #
#                                                                            #
#       Implementation done on 13/15.02.96 by Daniel Vogelheim.              #
#                                                                            #
#       This document is placed into the public domain.                      #
#                                                                            #
#                                                                            #
#       compile all files with:         make all                             #
#       test with:                      make test                            #
#       make source archive with:       make archive                         #
#       clean directory with:           make clean                           #
#                                                                            #
 ############################################################################

EXEC = rrc2_test rrc2_encrypt rrc2_decrypt
SOURCE = rrc2.c rrc2.h rrc2_consts.c rrc2_test.c makefile rrc2_crypt.c rrc2spec.txt readme

all: $(EXEC)
archive: rrc2.tar.gz

CFLAGS = -Wall -ansi
CC = gcc $(CFLAGS)

rrc2.o: rrc2.c rrc2.h rrc2_consts.c
	$(CC) -c rrc2.c

rrc2_test: rrc2_test.c rrc2.o rrc2.h
	$(CC) -o rrc2_test rrc2_test.c rrc2.o

rrc2_encrypt: rrc2_crypt.c rrc2.h rrc2.o
	$(CC) -o rrc2_encrypt rrc2_crypt.c rrc2.o

rrc2_decrypt: rrc2_crypt.c rrc2.h rrc2.o
	$(CC) -o rrc2_decrypt rrc2_crypt.c rrc2.o -DDECRYPT

rrc2.tar.gz:  $(SOURCE)
	@echo "Packing source files into archive:"
	@rm -f rrc2.tar.gz
	@tar cvf - $(SOURCE) | gzip >rrc2.tar.gz

test: rrc2_test rrc2_encrypt rrc2_decrypt
	rrc2_test
	cp rrc2spec.txt test.file
	echo "abc" >>test.file
	echo "test.file" >test.cmd
	echo "This is a test-password." >>test.cmd
	cp test.file test.file.org
	rrc2_encrypt < test.cmd
	rm -f test.file
	rrc2_decrypt < test.cmd
	cmp test.file test.file.org
	rm -f test.file test.file.rrc2 test.file.org test.cmd
	@echo
	@echo
	@echo "RRC2 test passed!"
	
clean:
	rm -f *.o *~ $(EXEC)

# FINI: makefile
