#
VERSION = 0.96

## CHANGE HERE ##
BINDIR=/usr/local/bin
DOCDIR=/usr/doc/webtex
NETPBMDIR=/usr/local/netpbm
STYLEDIR=/usr/local/lib/tex/macros
MANDIR=/usr/man
JMANDIR=ja_JP.ujis

# cc
#CC     = cc
CC     = gcc
CFLAGS = -DBINDIR=\"$(BINDIR)\" \
         -DNETPBMDIR=\"$(NETPBMDIR)\" \
         -DVERSION=$(VERSION) # -Wall -g -DDEBUG

# yacc & lex
YACC   = yacc         ## use 'berkeley' yacc
#YACC   = bison -y
#LEX    = lex
LEX    = flex

#
OBJS   = main.o \
         y.tab.o lex.yy.o \
		 lexlib.o hashlib.o latex.o \
		 http.o 

all:		webtex gethtml

install:	webtex gethtml w2t webtex.sty
	cp webtex gethtml w2t  $(BINDIR)/
	cp webtex.sty          $(STYLEDIR)/

install.man:	webtex.man README-$(VERSION) HISTORY-$(VERSION) \
				webtex.jman README-$(VERSION).eucj HISTORY-$(VERSION).eucj
	cp webtex.man $(MANDIR)/man1/webtex.1
	cp webtex.jman $(MANDIR)/$(JMANDIR)/man1/webtex.1
	mkdir -p $(DOCDIR)
	cp README-$(VERSION) README-$(VERSION).eucj \
	   HISTORY-$(VERSION) HISTORY-$(VERSION).eucj $(DOCDIR)/

webtex:		$(OBJS)
	$(CC) $(CFLAGS) -o webtex $(OBJS)

gethtml:	gethtml.o http.o
	$(CC) $(CFLAGS) -o gethtml gethtml.o http.o

y.tab.c:	html.y
#	$(YACC) -d html.y
	$(YACC) -v -d html.y  # -d for y.tab.h (needed), -v for y.output (optional)

lex.yy.c:	html.l
	$(LEX) -I html.l

y.tab.o:	y.tab.c  lexlib.h latex.h   # y.tab.h
	$(CC) -c $(CFLAGS) y.tab.c	

lex.yy.o:	lex.yy.c  y.tab.h  lexlib.h
	$(CC) -c $(CFLAGS) lex.yy.c	


main.o:		main.c     hashlib.h latex.h Makefile

lexlib.o:	lexlib.c   lexlib.h

hashlib.o:	hashlib.c  hashlib.h

latex.o:	latex.c    latex.h hashlib.h

http.o:		http.c     http.h

.c.o:  y.tab.h
	$(CC) -c $(CFLAGS) $*.c	

clean:
	rm -f webtex $(OBJS) y.tab.c y.tab.h lex.yy.c y.output \
              *~ core scaletmp.ps w2t.* gethtml gethtml.o

zap:
	rm -f core *~
 


