1 #**************************************************************************
2 #* *
3 #* OCaml *
4 #* *
5 #* Gabriel Scherer, projet Parsifal, INRIA Saclay *
6 #* *
7 #* Copyright 2018 Institut National de Recherche en Informatique et *
8 #* en Automatique. *
9 #* *
10 #* All rights reserved. This file is distributed under the terms of *
11 #* the GNU Lesser General Public License version 2.1, with the *
12 #* special exception on linking described in the file LICENSE. *
13 #* *
14 #**************************************************************************
15
16 # Developer-only rules, included in Makefile when a Git repository is detected.
17
18 # Testing the parser -- see parsing/HACKING.adoc
19
20 SOURCE_FILES=$(shell git ls-files '*.ml' '*.mli' | grep -v boot/menhir/parser)
21
22 AST_FILES=$(addsuffix .ast,$(SOURCE_FILES))
23
24 build-all-asts:
25 # Recursive invocation ensures that `git ls-files` is not executed on every
26 # invocation of make
27 @$(MAKE) --no-print-directory $(AST_FILES)
28
29 CAMLC_DPARSETREE := \
30 $(CAMLRUN) ./ocamlc -nostdlib -nopervasives \
31 -stop-after parsing -dparsetree
32
33 %.ml.ast: %.ml ocamlc
34 $(CAMLC_DPARSETREE) $< 2> $@ || exit 0
35 # `|| exit 0` : some source files will fail to parse
36 # (for example, they are meant as toplevel scripts
37 # rather than source files, or are parse-error tests),
38 # we ignore the failure in that case
39
40 %.mli.ast: %.mli ocamlc
41 $(CAMLC_DPARSETREE) $< 2> $@ || exit 0
42
43 .PHONY: list-all-asts
44 list-all-asts:
45 @for f in $(AST_FILES); do echo "'$$f'"; done
46
47 partialclean::
48 @rm -f $(AST_FILES)
49