.SUFFIXES: .c .o
BOBJS = mkbshift.o
COBJS = exit.o array.o Sulawalaw.o
SOBJS = main.o shorten.o fixio.o vario.o poly.o lpc.o hsgetopt.o dupfinfo.o license.o
CC    = cc
CFLAGS= -O

prefix = /usr/local
manext = 1

.c:	; $(CC) $(CFLAGS) -o $* $*.c
.c.o:	; $(CC) $(CFLAGS) -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) -o shorten $(COBJS) $(SOBJS) -lm

bitshift.h: mkbshift
	mkbshift

mkbshift: $(COBJS) $(BOBJS)
	$(CC) $(CFLAGS) -o mkbshift $(COBJS) $(BOBJS) -lm

license.c: LICENSE
	awk -f license.awk < LICENSE > license.c

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
	shntest

release: test spotless shorten.man
	release

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

spotless: clean
	rm -f shorten mkbshift mkbshift.exe tmp.s16 *~
