[Top][All Lists]

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

Import statement - non-recursive make implementation

From: Kamil Mierzejewski
Subject: Import statement - non-recursive make implementation
Date: Fri, 3 Sep 2010 17:45:51 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; pl; rv: Gecko/20100825 Lightning/1.0b2 Thunderbird/3.1.3


I came up with a solution to this long-lasting, largely-talked problem of recursive make invocation. I also have a patched GNU make build that can be a live proof that it actually works.

First I thought of a smart "include" directive, that would isolate the included makefile's variable space, I called it "import". The isolation is acomplished with the use of global stack of variable_sets. I had to modify variable.c a little bit in order to facilitate global variable stack.

The second issue I had to bare with was working directory. If one imports another makefile that is in another directory, the directory is pushed to a stack and all filenames defined in the imported makefile are prefixed with the directory name, in order to make the DAG coherent. Some tweaks in read.c made it possible.

This solution enables definition of full DAG across multiple makefiles and 

When recipes are executed, actions are taken to ensure that they start in the right working directory and automatic file variables are defined as they should (relative to the right dir).

After a few more tweaks here and there I made it work.

The imported makefiles don't have to be designed specially to work with this solution. If you have a running project with recursive make invocations, just replace them with import directives and the DAG will get stitched altogether.

I think this solution is worth to incorporate into GNU make main codeline. I'm sure it needs some fixes around the edges, but it works as a proof of concept.

Paul, if you are interested I would be happy to share the code.


reply via email to

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