From be34be3af2f22f69140b344006b8edba480346f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Hinderer?= Date: Tue, 2 Mar 2021 12:21:28 +0100 Subject: Build system: deduplicate the rules used to generate the lexers and parsers --- Makefile.common | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'Makefile.common') 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) $< -- cgit v1.2.1