# Makefile - Don Yang (uguu.org)
#
# Build script for easier file management.  Lots of manual intervention is
# still required to produce the final output.
#
# 11/28/01


all:

template: txt dejiko.enc puchiko.enc

dejiko.enc: template/dejiko.txt rlfreq rlhoptimize huffman encode
	./rlfreq $< | ./huffman > $@.dict
	./huffopt $@.hint $@.dict
	./encode $@.dict $@.hint $< $@

puchiko.enc: template/puchiko.txt rlfreq rlhoptimize huffman encode
	./rlfreq $< | ./huffman > $@.dict
	./huffopt $@.hint $@.dict
	./encode $@.dict $@.hint $< $@

txt:
	make -C template

rlfreq: rlfreq.c
	gcc -Wall -ansi $< -o $@

rlhoptimize: rlhoptimize.c
	gcc -Wall -ansi $< -o $@

huffman: huffman.c
	gcc -Wall -ansi $< -o $@

huffsize: huffsize.c
	gcc -Wall -ansi $< -o $@

encode: encode.c
	gcc -Wall -ansi $< -o $@


data.txt: code.txt xor nospace
	./nospace < code.txt | ./xor 3 > data.txt

xor: xor.c
	gcc $< -o $@

nospace: nospace.c
	gcc $< -o $@



clean:
	make -C template clean
	-rm -f data.txt nospace xor
	-rm -f *.enc* rlfreq rlhoptimize huffman huffsize encode

backup:
	make -C template backup
	-rm -f backup.tar.gz
	tar cf backup.tar *.c *.txt huffopt Makefile
	gzip -9 backup.tar
