CFLAGS= -n -O
#	make file for STYLE and DICTION
#
#	BIN is the directory for storing the object code
#		for the 3 programs that make up style
#	DICT is the full pathname of the file dict.d, the
#		dictionary file used by DICTION
#
BIN = /usr/lib
DICT= -DDICT=\"/usr/lib/dict.d\"

all: diction style explain deroff
style: style1 style2 style3

cp: all
	cp style1 /usr/lib
	cp style2 /usr/lib
	cp style3 /usr/lib
	cp dprog /usr/lib
	cp deroff /usr/lib
	rm -f /usr/bin/deroff
	ln /usr/lib/deroff ${DESTDIR}/usr/bin/deroff
	cp style /usr/bin
	cp diction /usr/bin
	cp explain /usr/bin
	cp dict.d /usr/lib
	cp explain.d /usr/lib

clean:
	rm -f prtlex.c wdslex.c endlex.c
	rm -f *.o style1 style2 style3 dprog

style3: prtlex.o pscan.o outp.o
	$(CC) prtlex.o pscan.o outp.o -ll  -o style3

prtlex.c: part.l
	lex part.l
	mv lex.yy.c prtlex.c

prtlex.o: names.h prtlex.c
pscan.o: names.h conp.h
outp.o: names.h conp.h style.h 
wdslex.o: wdslex.c nhash.c dict.c ydict.c names.h
endlex.o: names.h endlex.c ehash.c edict.c
diction: dprog

style1: wdslex.o
	$(CC) $(CFLAGS) wdslex.o -ll  -o style1


wdslex.c: nwords.l
	lex nwords.l
	mv lex.yy.c wdslex.c

style2: endlex.o
	$(CC) $(CFLAGS) endlex.o -ll  -o style2


endlex.c: end.l
	lex end.l
	mv lex.yy.c endlex.c


dprog: diction.c
	$(CC)  $(CFLAGS) $(DICT) diction.c -o dprog

deroff:	deroff.c
	$(CC) $(CFLAGS) deroff.c -o deroff
