summaryrefslogtreecommitdiff
path: root/Makefile.common
diff options
context:
space:
mode:
authorSébastien Hinderer <Sebastien.Hinderer@inria.fr>2021-03-02 12:21:28 +0100
committerSébastien Hinderer <Sebastien.Hinderer@inria.fr>2021-03-02 12:21:28 +0100
commitbe34be3af2f22f69140b344006b8edba480346f1 (patch)
treee171426d7736b69f6d36df0ed20d79f0d2a7f7be /Makefile.common
parent9fce0f6fc73b732e63f530047e26afa070ee8d7e (diff)
downloadocaml-be34be3af2f22f69140b344006b8edba480346f1.tar.gz
Build system: deduplicate the rules used to generate the lexers and parsers
Diffstat (limited to 'Makefile.common')
-rw-r--r--Makefile.common24
1 files changed, 22 insertions, 2 deletions
diff --git a/Makefile.common b/Makefile.common
index af979b789f..1e0486615f 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -66,8 +66,6 @@ OPTCOMPFLAGS=
ifeq "$(FUNCTION_SECTIONS)" "true"
OPTCOMPFLAGS += -function-sections
endif
-# By default, request ocamllex to be quiet
-OCAMLLEXFLAGS ?= -q
# Escape special characters in the argument string.
# There are four characters that need escaping:
@@ -120,3 +118,25 @@ ifneq ($(EXE),)
$(1): $(1)$(EXE)
endif
endef # PROGRAM_SYNONYM
+
+# Lexer generation
+
+BOOT_OCAMLLEX ?= $(CAMLRUN) $(ROOTDIR)/boot/ocamllex
+# The OCAMLLEX command used in the recipe below is defined in the individual
+# makefiles, because its default value is directory-specific.
+# By default, some directories use BOOT_OCAMLLEX while others use the
+# freshly compiled lexer generator.
+
+OCAMLLEXFLAGS ?= -q
+
+%.ml: %.mll
+ $(OCAMLLEX) $(OCAMLLEXFLAGS) $<
+
+# Parser generation
+
+OCAMLYACC ?= $(ROOTDIR)/yacc/ocamlyacc$(EXE)
+
+OCAMLYACCFLAGS ?=
+
+%.ml %.mli: %.mly
+ $(OCAMLYACC) $(OCAMLYACCFLAGS) $<