CC = gcc
CFLAGS = -O -DETAGS
LDFLAGS = -s
YACC = yacc
YFLAGS = 
LEX = lex
LFLAGS =

all : etags$E
.PHONY: all

debugetags$E : etags.c parser.c
	$(CC) -g -DETAGS -DDEBUG etags.c parser.c $(LDFLAGS) -o $@

etags$E : etags.c parser.c
	$(CC) $(CFLAGS) etags.c parser.c $(LDFLAGS) -o $@

parser.c : parser.y lexer.c
	$(YACC) $(YFLAGS) parser.y
	mv -f y.tab.c $@

lexer.c : lexer.l
	$(LEX) $(LFLAGS) -t lexer.l >$@

clean :
	rm -f *~ \#* *.aux *.cp *.dvi *.fn *.ky *.log *.pg *.toc *.tp *.vr *.o TAGS
.PHONY: clean

realclean : clean
	rm -f *.ps *.Z debugetags etags lexer.c parser.c y.output c++-browse
.PHONY: realclean

# Version number.
VERS = 2

# The name of the directory that the tar file unpacks into.
DISTDIR = c++-browse-$(VERS)

# The name of the distribution archive.
TARFILE = $(DISTDIR).tar.Z

DISTFILES = \
ANNOUNCE	    THESIS		lexer.l \
ChangeLog	    c++-browse.el	parser.y \
Makefile	    c++-browse.texinfo \
README		    etags.c


dist:
	rm -rf $(DISTDIR)
	mkdir $(DISTDIR)
	ln $(DISTFILES) $(DISTDIR)
	tar chZf $(TARFILE) $(DISTDIR)
	rm -rf $(DISTDIR)
.PHONY: dist

c++-browse.info : c++-browse.texinfo
	makeinfo c++-browse.texinfo

c++-browse.dvi : c++-browse.texinfo
	tex c++-browse.texinfo
	texindex c++-browse.??
	tex c++-browse.texinfo

c++-browse.ps : c++-browse.dvi
	dvips c++-browse -o c++-browse.ps
