1# This Makefile is designed to be simple and readable.  It does not
2# aim at portability.  It requires GNU Make.
3
4BASE = bistromathic
5BISON = bison
6XSLTPROC = xsltproc
7
8# We need to find the headers and libs for readline (and possibly intl).
9# You probably need to customize this for your own environment.
10CPPFLAGS = -I/opt/local/include
11LDFLAGS = -L/opt/local/lib
12
13# Find the translation catalogue for Bison's generated messagess.
14BISON_LOCALEDIR = $(shell $(BISON) $(BISON_FLAGS) --print-localedir)
15CPPFLAGS += -DENABLE_NLS -DBISON_LOCALEDIR='"$(BISON_LOCALEDIR)"'
16
17LIBS = -lreadline -lm # In some environments, -lintl is needed.
18
19all: $(BASE)
20
21%.c %.h %.xml %.gv: %.y
22	$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
23
24$(BASE): parse.o
25	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
26
27run: $(BASE)
28	@echo "Type bistromathic expressions.  Quit with ctrl-d."
29	./$<
30
31html: $(BASE).html
32%.html: %.xml
33	$(XSLTPROC) $(XSLTPROCFLAGS) -o $@ $$($(BISON) --print-datadir)/xslt/xml2xhtml.xsl $<
34
35CLEANFILES =						\
36  $(BASE) *.o						\
37  parse.[ch] parse.output parse.xml parse.html parse.gv
38
39clean:
40	rm -f $(CLEANFILES)
41