# Makefile for TeX-project WEB sources to C conversion programs.

# These get expanded from the parent directory, not this one.
ac_include ../make/common.make
ac_include ../make/programs.make
ac_include ../make/paths.make
ac_include kpathsea.make

LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
YACC = @YACC@

proglib = ../lib/lib.a
programs = otp2ocp outocp
scripts = mkocp mkofm

otp2ocp_objects = otp2ocp.o routines.o y_tab.o $(LEX_OUTPUT_ROOT).o
all: $(programs)
otp2ocp: $(otp2ocp_objects)
	$(kpathsea_link) $(otp2ocp_objects) $(LEXLIB) $(LOADLIBES) 

otp2ocp.o: otp2ocp.c y_tab.h
y_tab.c y_tab.h: otp.y
	$(YACC) -d -v $(srcdir)/otp.y
	-test -f y.tab.c && mv -f y.tab.c y_tab.c
	-test -f y.tab.h && mv -f y.tab.h y_tab.h
$(LEX_OUTPUT_ROOT).o: otp.h
$(LEX_OUTPUT_ROOT).c: otp.l
	$(LEX) $(srcdir)/otp.l

outocp: outocp.o
	$(kpathsea_link) outocp.o $(LOADLIBES)

$(programs): $(proglib) $(kpathsea)

install-programs: $(programs)
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(bindir) 
	for p in $(programs); do $(INSTALL_LIBTOOL_PROG) $(bindir) $$p; done
	for p in $(scripts); do $(INSTALL_SCRIPT) $(srcdir)/$$p $(scriptdir); done

Makefile: Makefile.in ../config.status
	cd .. && $(SHELL) config.status

ac_include ../make/tkpathsea.make
ac_include ../make/clean.make

clean::
	rm -f y_tab.c y_tab.h y.out* yacc.* $(LEX_OUTPUT_ROOT).c

ac_include ../make/rdepend.make
ac_include otps/depend.make
