SHELL         = /bin/sh
DEST          = /mit/sipb/bin
MANDEST       = /mit/sipb/man/man1
EXTHDRS	      =
HDRS          = bitio.h\
		compat.h\
		freeze.h\
		huf.h\
		lz.h\
		patchlevel.h
LDFLAGS       =

#ifdef ibm032
MACH_DEP_FLAGS = -DFAST -U__STDC__ -DSIGTYPE=int -DUTIMES
#endif
#ifdef vax
MACH_DEP_FLAGS = -DFAST -DSIGTYPE=int -DUTIMES
#endif
#ifdef mips
MACH_DEP_FLAGS = -DFAST
#endif
#ifdef sparc
MACH_DEP_FLAGS = -DFAST -DSOLARIS
#endif

CFLAGS        = -DBITS=16 -O -DBSD $(MACH_DEP_FLAGS)

LINTFLAGS     = -DBITS=15 -DCOMPAT -DDEBUG -DGATHER_STAT -x -DFAST

MAKEFILE      = makefile

OBJS          = bitio.o\
		debug.o\
		decode.o\
		default.o\
		encode.o\
		freeze.o\
		huf.o\
		lz.o

PROGRAM       = freeze

CATMAN        = freeze.man

MAN           = freeze.1

SRCS          = bitio.c\
		debug.c\
		decode.c\
		default.c\
		encode.c\
		freeze.c\
		huf.c\
		lz.c

all::            $(PROGRAM) statist freeze.1 statist.1

.SUFFIXES:       .man .1

.1.man:
		nroff -man < $< > $@

.c.o:
		$(CC) -c $(CFLAGS) $(OPTIONS) $<

prog:            $(PROGRAM) statist

man:            $(CATMAN)

lint:           $(SRCS)
		lint $(LINTFLAGS) $(SRCS) > lint.out

$(PROGRAM):     $(OBJS) 
		$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)

statist: statist.o lz.o
		$(CC) $(CFLAGS) $(LDFLAGS) -o statist statist.o lz.o $(LIBS)

clobber:        clean
		rm -f $(PROGRAM) statist *.man \#* *~

install::        all
		install -c -s statist $(DESTDIR)$(DEST)
		install -c -s freeze $(DESTDIR)$(DEST)
		-ln -s freeze $(DESTDIR)$(DEST)/melt
		-ln -s freeze $(DESTDIR)$(DEST)/fcat
		-ln -s freeze $(DESTDIR)$(DEST)/unfreeze
		install -c -m 0444 freeze.1 $(DESTDIR)$(MANDEST)/freeze.1
		-rm -f $(DESTDIR)$(MANDEST)/melt.1 $(DESTDIR)$(MANDEST)/fcat.1
		for i in melt.1 fcat.1 unfreeze.1; do \
			echo ".so man1/freeze.1" > $(DESTDIR)$(MANDEST)/$$i; \
		done
		install -c -m 0444 statist.1 $(DESTDIR)$(MANDEST)/statist.1
clean::;         rm -f *.o *.b .,* core *.out

patch:;         rm -f patch.out
		-for i in ../distribution//**/* ; do \
		(diff -c $$i `basename $$i` >> patch.out); \
		done

$(CATMAN):      $(MAN)
		nroff -man < $(MAN) > $(CATMAN)

/* ### */
bitio.o: freeze.h compat.h bitio.h
debug.o: freeze.h compat.h huf.h bitio.h
decode.o: freeze.h compat.h huf.h bitio.h
default.o: freeze.h compat.h
encode.o: freeze.h compat.h lz.h huf.h bitio.h
freeze.o: freeze.h compat.h lz.h huf.h patchlevel.h
huf.o: freeze.h compat.h huf.h bitio.h
lz.o: freeze.h compat.h lz.h
statist.o: freeze.h compat.h lz.h
