## -------------------- ## ## Scanner generation. ## ## -------------------- ## # Definition of flags used by reflex REFLEX_HEADER = %D%/scantiger.hh REFLEX_FLAGS = -d --flex --header-file=$(REFLEX_HEADER) SOURCES_REFLEX = $(REFLEX_HEADER) %D%/scantiger.cc MAINTAINERCLEANFILES += %D%/scantiger.cc $(REFLEX_HEADER) EXTRA_DIST += %D%/scantiger.ll # Rule to generate all files with reflex %D%/scantiger.cc $(REFLEX_HEADER) : %D%/scantiger.ll $(AM_V_GEN)mkdir -p $(@D) $(AM_V_at)rm -f $@ # Generate scantiger.cc and scantiger.hh $(AM_V_at) $(REFLEX) $< -o %D%/scantiger.cc $(REFLEX_FLAGS) ## ------------------- ## ## Parser generation. ## ## ------------------- ## BISONXX = $(top_builddir)/build-aux/bin/bison++ BISONXX_IN = $(top_srcdir)/build-aux/bin/bison++.in BISONXXFLAGS = \ $(if $(V:0=),--verbose) AM_BISONFLAGS = \ --warnings=all,dangling-alias \ --report=all ## Use this additional bison flag to display counterexamples in the tty. #AM_BISONFLAGS += --warnings=counterexamples # We do not use Automake features here. SOURCES_PARSETIGER_YY = \ %D%/location.hh \ %D%/parsetiger.cc \ %D%/parsetiger.hh BUILT_SOURCES += $(SOURCES_PARSETIGER_YY) # Ship %D%/stack.hh only if GLR is disabled, as Bison does not # generate this file for GLR parsers. dist-hook: dist-hook-parse dist-hook-parse: @grep '%glr-parser' $(srcdir)/%D%/parsetiger.yy >/dev/null \ || cp -p $(srcdir)/%D%/stack.hh $(distdir)/src/parse/ # Compile the parser and save cycles. # This code comes from "Handling Tools that Produce Many Outputs", # from the Automake documentation. EXTRA_DIST += \ %D%/parsetiger.stamp \ %D%/parsetiger.yy # The dependency is on bison++.in and not bison++, since bison++ is # regenerated at distribution time, and voids the time stamps (which # we don't want!). %D%/parsetiger.stamp: %D%/parsetiger.yy $(BISONXX_IN) $(AM_V_GEN)mkdir -p $(@D) $(AM_V_at)rm -f $@ $@.tmp $(AM_V_at)echo '$@ rebuilt because of: $?' >$@.tmp $(AM_V_at)$(MAKE) $(BISONXX) $(AM_V_at)$(BISONXX) $(BISONXXFLAGS) \ -r $(srcdir)/src \ -- \ $< $(srcdir)/%D%/parsetiger.cc \ $(AM_BISONFLAGS) $(BISONFLAGS) $(AM_V_at)mv -f $@.tmp $@ ## If Make does not know it will generate in the srcdir, then when ## trying to compile from *.cc to *.lo, it will not apply VPATH ## lookup, since it expects the file to be in builddir. So *here*, ## make srcdir explicit. $(addprefix $(srcdir)/, $(SOURCES_PARSETIGER_YY)): %D%/parsetiger.stamp $(AM_V_GEN)if test -f $@; then :; else \ rm -f $<; \ $(MAKE) $(AM_MAKEFLAGS) $<; \ fi # We tried several times to run make from ast/ to build location.hh. # Unfortunately, because of different, but equivalent, paths, BSD Make # was unable to build them. The following hook is here to address this. .PHONY: generate-parser generate-parser: $(SOURCES_PARSETIGER_YY) PARSE_PRELUDE_GENERATION = %D%/generate-prelude.sh EXTRA_DIST += $(PARSE_PRELUDE_GENERATION) CLEANFILES += %D%/prelude.cc %D%/prelude.cc: $(top_srcdir)/data/prelude.tih $(AM_V_GEN)$(srcdir)/$(PARSE_PRELUDE_GENERATION) $< $@ ## ---------- ## ## libparse. ## ## ---------- ## src_libtc_la_SOURCES += \ $(SOURCES_REFLEX) \ $(SOURCES_PARSETIGER_YY) \ %D%/fwd.hh \ %D%/libparse.hh %D%/libparse.cc \ %D%/metavar-map.hh %D%/metavar-map.hxx \ %D%/tiger-driver.hh %D%/tiger-driver.cc \ %D%/tweast.hh %D%/tweast.cc %D%/tweast.hxx src_libtc_la_SOURCES += \ %D%/tiger-factory.hh %D%/tiger-factory.hxx FORMAT_IGNORE += $REFLEX_HEADER nodist_src_libtc_la_SOURCES += \ %D%/prelude.cc ## ------- ## ## Tests. ## ## ------- ## check_PROGRAMS += \ %D%/test-parse \ %D%/test-tweast # Find the prelude. %C%_test_parse_CPPFLAGS = $(AM_CPPFLAGS) -DPKGDATADIR=\"$(pkgdatadir)\" %C%_test_parse_LDADD = src/libtc.la %C%_test_tweast_LDADD = src/libtc.la TASKS += %D%/tasks.hh %D%/tasks.cc