BUGFIX_RELEASE=03

.SUFFIXES: .c .o
OBJS = main.o shorten.o fixio.o vario.o lpc.o exit.o getopt.o
CC = cc
DEFS = -DBUGFIX_RELEASE=\"${BUGFIX_RELEASE}\"
CFLAGS = -O 

.c:	; $(CC) $(CFLAGS) $(DEFS) -o $* $*.c
.c.o:	; $(CC) $(CFLAGS) $(DEFS) -c $*.c

all: shorten shorten.man

shorten: bitshift.h $(OBJS)
	$(CC) $(CFLAGS) $(DEFS) -o shorten $(OBJS) -lm

bitshift.h: bitshift.c ulaw.c
	$(CC) $(CFLAGS) $(DEFS) -o bitshift bitshift.c ulaw.c -lm
	bitshift > bitshift.h

shorten.man: shorten.1
	nroff -man shorten.1 | col -b > shorten.man

test: shorten
	./shorten -a1 -tau	shorten.c | ./shorten -x | cmp - shorten.c
	./shorten -a1024 -ts8	shorten.c | ./shorten -x | cmp - shorten.c
	./shorten -b1 -tu8	shorten.c | ./shorten -x | cmp - shorten.c
	./shorten -b1024 -tau	shorten.c | ./shorten -x | cmp - shorten.c
	./shorten -p1 -tau	shorten.c | ./shorten -x | cmp - shorten.c
	./shorten -p16 -ts8	shorten.c | ./shorten -x | cmp - shorten.c
	./shorten -v0 -tau	shorten.c | ./shorten -x | cmp - shorten.c
	./shorten -t au	test.txt | ./shorten -x | cmp - test.txt
	./shorten -t s8	test.txt | ./shorten -x | cmp - test.txt
	./shorten -t u8	test.txt | ./shorten -x | cmp - test.txt
	./shorten -t s16	test.txt | ./shorten -x | cmp - test.txt
	./shorten -t u16	test.txt | ./shorten -x | cmp - test.txt
	./shorten -t u16x	test.txt | ./shorten -x | cmp - test.txt
	./shorten -ts16hl	test.txt | ./shorten -x | cmp - test.txt
	./shorten -tu16hl	test.txt | ./shorten -x | cmp - test.txt
	./shorten -ts16lh	test.txt | ./shorten -x | cmp - test.txt
	./shorten -tu16lh	test.txt | ./shorten -x | cmp - test.txt
	./shorten -c2 -tau	test.txt | ./shorten -x | cmp - test.txt
	./shorten -c21 -tu8	test.txt | ./shorten -x | cmp - test.txt
	./shorten -c7 -ts16 test.txt | ./shorten -x | cmp - test.txt
	./shorten -m4 -ts16 test.txt | ./shorten -x | cmp - test.txt
	./shorten -m4 -p4 -tu16 -b5 test.txt | ./shorten -x | cmp - test.txt

shar: shorten.man bitshift.h
	shar -c -v shorten.man shorten.1 Makefile main.c shorten.c \
	fixio.c vario.c lpc.c exit.c shorten.h bitshift.c ulaw.c \
	bitshift.h getopt.c test.txt laplacian.tex change.log > \
		shorten-1.${BUGFIX_RELEASE}.shar

clean:
	rm -f $(OBJS) bitshift.o ulaw.o

spotless: clean
	rm -f shorten sizech bitshift bitshift.h shorten.man
