BUGFIX_RELEASE=13

.SUFFIXES: .c .o
COBJS = exit.o array.o
BOBJS = bitshift.o ulaw.o
SOBJS = main.o shorten.o fixio.o vario.o lpc.o hsgetopt.o dupfinfo.o
CC    = cc
DEFS  = -DBUGFIX_RELEASE=\"${BUGFIX_RELEASE}\"
CFLAGS= -O

prefix = /usr/local
manext = 1

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

all: shorten shorten.man

install: shorten
	cp shorten $(prefix)/bin
	cp shorten.1 $(prefix)/man/man$(manext)/shorten.$(manext)

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

bitshift.h: $(COBJS) $(BOBJS)
	$(CC) $(CFLAGS) $(DEFS) -o bitshift $(COBJS) $(BOBJS) -lm
	./bitshift > bitshift.h

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

test: shorten
	./shorten -x mvs.s16.shn tmp.s16
	if [ `wc -lc tmp.s16 | sed 's/ //g'` != "17032596tmp.s16" ]; then exit 1; fi
	./shorten -t s16hl	tmp.s16 - | cmp - mvs.s16.shn
	./shorten -a1 -tau	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -a1024 -ts8	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -b1 -tu8	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -b1024 -tau	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -p1 -tau	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -p16 -ts8	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -v0 -t s16hl	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -v1 -t s16hl	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -tau		tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -ts8		tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -tu8		tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -ts16		tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -tu16		tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -tu16x	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -ts16hl	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -tu16hl	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -ts16lh	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -tu16lh	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -c2 -tau	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -a340 -c256	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -m4 -ts16	tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -m4 -p4 -tu16 -b5 tmp.s16 - | ./shorten -x | cmp - tmp.s16
	./shorten -q3 -ts16hl	tmp.s16 tmp.s16.shn
	./shorten -x tmp.s16.shn - | ./shorten     -ts16hl | cmp - tmp.s16.shn
	./shorten -x tmp.s16.shn - | ./shorten -q3 -ts16hl | cmp - tmp.s16.shn
	rm tmp.s16.shn
	./shorten -r3 -ts16hl tmp.s16 tmp.s16.shn
	rm tmp.s16.shn
	./shorten tmp.s16
	./shorten -x tmp.s16.shn
	rm tmp.s16

release: test spotless shorten.man
	NAME=shorten-1.${BUGFIX_RELEASE} ; \
	cd .. ; \
	tar cvf $$NAME.tar $$NAME ; \
	cp -p $$NAME.tar $$NAME.tmp ; \
	compress $$NAME.tar ; \
	gzip -9 $$NAME.tmp ; \
	mv $$NAME.tmp.gz $$NAME.tar.gz ; \
	rm /home/psf/ftp/pub/comp.speech/sources/shorten-?.*.tar.* ; \
	cp -p $$NAME.tar.Z /home/psf/ftp/pub/comp.speech/sources ; \
	cp -p $$NAME.tar.gz /home/psf/ftp/pub/comp.speech/sources ; \
	mv $$NAME.tar.gz src

clean:
	rm -f $(COBJS) $(BOBJS) $(SOBJS)

spotless: clean
	rm -f shorten bitshift bitshift.h shorten.man tmp.s16 *~
