SHELL         = /bin/sh
DEST          = /usr/local/bin
MANDEST       = /usr/local/man/man1
EXTHDRS	      =
HDRS          = bitio.h\
		compat.h\
		freeze.h\
		huf.h\
		lz.h\
		patchlevel.h
LDFLAGS       =
LIBS          = #-lc_s   # shared library

CC            = cc -D_BSD_COMPAT -DJHU

#CFLAGS        = -DBITS=16 -O4 -DCOMPAT -DFAST -fstrength-reduce -DBSD42 #-DSUN4
CFLAGS        = -DBITS=16 -O3 -DCOMPAT -DFAST -DBSD42 #-DSUN4

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

MAKEFILE      = makefile

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

PROGRAM       = freeze

CATMAN        = freeze.man statist.man

MAN           = freeze.1 statist.1

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

.SUFFIXES:       .1 .man

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

all:            $(PROGRAM) statist man

man:            $(CATMAN)

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

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

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

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

clean:;         rm -f *.u *.b .,* core *.out

install:        $(DEST)/$(PROGRAM) $(MANDEST)/freeze.1 $(MANDEST)/statist.1

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

$(DEST)/$(PROGRAM): $(PROGRAM)
		-strip $(PROGRAM)
#		-mcs -d $(PROGRAM)
		bsdinst.sh -m 755 $(PROGRAM) $(DEST)
		-ln -f $@ $(DEST)/melt
		-ln -f $@ $(DEST)/fcat

$(MANDEST)/freeze.1: freeze.man
		cp freeze.man $@
		chmod +r $@
		-ln -f $@ $(MANDEST)/melt.1
		-ln -f $@ $(MANDEST)/fcat.1

$(MANDEST)/statist.1: statist.man
		cp statist.man $@
		chmod +r $@

###
bitio.u: freeze.h compat.h bitio.h
debug.u: freeze.h compat.h huf.h bitio.h
decode.u: freeze.h compat.h huf.h bitio.h
default.u: freeze.h compat.h
encode.u: freeze.h compat.h lz.h huf.h bitio.h
freeze.u: freeze.h compat.h lz.h huf.h patchlevel.h
huf.u: freeze.h compat.h huf.h bitio.h
lz.u: freeze.h compat.h lz.h
statist.u: freeze.h compat.h lz.h
