[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNU Make parser and dependency generation.

From: Tim Murphy
Subject: Re: GNU Make parser and dependency generation.
Date: Fri, 18 Mar 2016 11:42:13 +0000

On 18 March 2016 at 06:38, Hemant Bhagat <address@hidden> wrote:

> Hello,
> Hope You are doing well!
> My problem statement is, I need to get all the rules information from
> Makefile in a separate data structure which will be latter used by our
> program.
> I don't need to execute the project and create any executables. I just
> need Target, Dependency, Command information which will involve parsing
> Makefile, expanding all variables and predefined Makefile patterns.
> How can I use the GNU make source code to get that data structure OR build
> one else where to start.
> GNU make has  a --print-database option which could be what you need or

Quite a lot of the information it prints may be uninteresting to you but in
the middle it lists all the targets and commands to make them.  This is
relatively easy to parse and variables etc have been expanded already so
you don't have to do anything complicated to read it all.

If the makefile contains side effects such as $(shell) or $(file) then that
might cause some annoying problems.

This only helps you with explicitly mentioned dependencies.  If your build
also uses generated dependencies then you probably have to do 1 build
before using the print-database option to ensure that all your generated
dependency files have been created.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]