# Build a dictionary using hashpw and the dicts.rules file.

all: bigdict

CRACKSRC=/mcs/source/crack/v4.1/Sources
CC=cc
CFLAGS=-O
TMPDIR=/tmp
DICTDIR=/mcs/source/DICTIONARIES/RAW

bigdict: hashpw dicts.rules
	/bin/rm -f bigdict.new
	(cd $(DICTDIR); grep -hv '^# ' *) | sort -T $(TMPDIR) -u - | \
	./hashpw dicts.rules | sort -T $(TMPDIR) - | cut -c1-8 | \
	uniq > bigdict.new
	/bin/rm -f bigdict
	/bin/mv -f bigdict.new bigdict
	
hashpw: hashpw.o crack-lib.o
	$(CC) $(CFLAGS) hashpw.o crack-lib.o -o hashpw

crack-lib.o: $(CRACKSRC)/crack-lib.c
	$(CC) $(CFLAGS) -I$(CRACKSRC) \
		-c $(CRACKSRC)/crack-lib.c

hashpw.o: hashpw.c
	$(CC) $(CFLAGS) -I$(CRACKSRC) -c hashpw.c

smallbigdict: hashpw dicts.rules
	/bin/rm -f bigdict.new
	(cd $(DICTDIR); grep -hv '^# ' *) | sort -T $(TMPDIR) -u - | \
	./hashpw dicts.rules | cut -c1-8 | ./strip.pl | \
	sort -u -T $(TMPDIR) > bigdict.new
	/bin/rm -f bigdict
	/bin/mv -f bigdict.new bigdict

clean: 
	/bin/rm -f *.o hashpw 
