This module serves as a parser for GNU makefiles. However, it does not parse user's original makefile directly. Instead it uses Makefile::DOM to parse the "data base output listing" produced by GNU make (via its --print-data-base option). So essentially it reuses the C implementation of GNU make.

This parser has been tested as a component of the pgmake-db utility and has successfully passed 51% of GNU make 3.81's official test suite.

The "data base output listing" generated by make --print-data-base is a detailed listing for GNU make's internal data structures, which is essentially the AST used by make. According to GNU make's current maintainer, Paul Smith, this feature is provided primarily for debuging the user's own makefiles, and it also helps the GNU make developer team to diagnose the flaws in make itself. Incidentally this output is conformed to the GNU makefile syntax, and a lot of important information is provided in the form of makefile comments. Therefore, my GmakeDB parser is able to reuse the Makefile::DOM module to parse this output listing.

The data base output from GNU make can be divided into several clearly-separated segments. They're file header, "Variables", "Files", "VPATH Search Paths", as well as the last resource stats information.

The contents of these segments are mostly obvious. The Files segment may deserve some explanation. It is the place for explict rules.

Now let's take the Variables segment as an example to demonstrate the format of the data base listing:

From the previous two data base listing snippets, it's not hard to see that the variable references in rule commands and recursively-expanded variables's values are not expanded.

Experiments have shown that GNU make will do implicit rule search for the first rule that needs to, but no more. This behavior means testing our own implicit rule searching algorithm requires specifying at least two goals that require matching.

GNU make does not escape meta characters appeared in rule targes and prerequisites in its data base listing. Examples are :, \, and #. This bug has been reported to the GNU make team as Savannah bug #20067.

This bug has not yet been fixed on the make side, so I have to work around this issue by preprocessing the data base listing in the makesimple script.

The data base listing produced by GNU make lacks the information regarding the export and unexport directives. It gives rise to the lack of information in the resulting AST structures constructed by this module. Hence the current AST and runtime do not implement the export and unexport directives.

To make it even worse, there's no known way to work around it.

I've already reported this issue to the GNU make team as Savannah bug #20069.