Am 26.07.2017 um 09:24 schrieb Sébastien Hinderer:
Dear all,
OCaml's parser generator, ocamlyacc, produces two files simultaneously.
For example, the command
ocamlyacc parsermly
will produce both parser.ml (the code of the parser) and parser.mli (the
interface of the parsing module, descrbing which symbols it exports).
I am wondering what's the best way to let make know about this.
From what I understand, a rule like
parser.mli parser.ml: parser.mly
ocaplyacc $<
does nos say exactly this but is rather an abbreviation for
parser.mli: parser.mly
ocamlyacc $<
parser.ml: parser.mly
ocamlyacc $<
which is not what I'd like to express
I have been told that one way to make things work could be the two
following rules:
parser.mli parser.ml: parser.mly
ocamlyacc $<
parser.mli: parser.ml
Is this the commonly used way to achieve the expected result?
I find it a bit tricky because "parser.mli: parser.ml" looks like a hack
to me, there is no real dependency.
Even if that is what is commonly used, I am wondering how this would
generalize to a command that would produce n files where n>2.
Many thanks for any comment,
Sébastien.
Use pattern rules for this. As a special behavior they run the command
only once if multiple targets match the pattern:
%.mli %.ml: %.mly
ocaplyacc $<
This behavior is different from normal, multi-target rules, and is
implement for this very case. See
https://www.gnu.org/software/make/manual/make.html#Pattern-Examples
Best gerads.
_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make