#
# Set BINDIR to where you want the binaries to go.
#
BINDIR= ../../bin

#
# Set MANDIR to where you want the man pages to go.
#
MANDIR= .

#
# Select your favorite compiler and compilation flags here.
#
CC = cc
#CC = gcc
#CFLAGS= -I. -O2
#CFLAGS= +O3  -I.
#CFLAGS= -O2 -DDEBUG
CFLAGS= -O

#
#
#

ALL=util.o mcu.o predictor.o dpcmdecomp.o huffd.o read.o 

libdpcm.a: $(ALL) 
	ar rv libdpcm.a $(ALL)

test:	dpcmtopnm
	./dpcmtopnm dpcm12.jpg > temp.pnm || diff temp.pnm dpcm12.pnm
	rm -f temp.pnm

#
# You shouldn't have to modify anything below this point.
#

SRC= util.c mcu.c predictor.c\
     dpcmdecomp.c huffd.c read.c dpcmtopnm.c
DECODE_OBJ= util.o mcu.o predictor.o dpcmdecomp.o huffd.o read.o dpcmtopnm.c

default: dpcmtopnm

dpcmtopnm: $(DECODE_OBJ)
	$(CC) ${CFLAGS} -o $@ $(DECODE_OBJ)

install: dpcmtopnm 
	cp dpcmtopnm $(BINDIR)
	chmod 555 $(BINDIR)/dpcmtopnm
	chmod 444 $(MANDIR)/dpcmtopnm.1

clean:
	rm -f core *.o dpcmdecomp libdpcm.a *~

proto.h: $(SRC)
	mkproto $(SRC) > proto.h

tags: $(SRC)
	ctags $(SRC)

dpcmtopnm.o:	jpeg.h mcu.h 
dpcmdecomp.o:	jpeg.h mcu.h
huffd.o:	jpeg.h mcu.h io.h predictor.h
read.o:		jpeg.h mcu.h io.h
util.o:		jpeg.h mcu.h
mcu.o:		jpeg.h mcu.h
predictor.c:	mcu.h



