Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Makefile Grammar

Tags:

Is there anywhere a precise makefile grammar definition? Or at least some common subset since I guess that there are some flavors. Such a grammar that could be used for writing a parser.

GNU Make manual doesn't seem to be that precise. It would require some guessing and trial-and-error to write a parser for makefile based on that document.

I also found a similar question on ANTLR mail list. But it remained unanswered which kind of suggests the answer...

like image 989
Adam Badura Avatar asked Aug 28 '13 13:08

Adam Badura


People also ask

What is := in makefile?

= defines a recursively-expanded variable. := defines a simply-expanded variable.

How do you write if condition in makefile?

Syntax of ConditionalsThe text-if-true may be any lines of text, to be considered as part of the makefile if the condition is true. If the condition is false, no text is used instead. If the condition is true, text-if-true is used; otherwise, text-if-false is used instead.

What is IFEQ in makefile?

The ifeq directive begins the conditional, and specifies the condition. It contains two arguments, separated by a comma and surrounded by parentheses. Variable substitution is performed on both arguments and then they are compared.


1 Answers

It seems there is no official grammar for gnu make, and ...

It would be tricky to write a grammar for make, since the grammar is extremely context-dependent.

As said by Paul D. Smith in a message in the gnu make mailing list. Paul D. Smith is the official maintainer of gnu make.

like image 54
Lesmana Avatar answered Oct 01 '22 10:10

Lesmana