m4-patches
[Top][All Lists]
Advanced

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

[PATCH] Support for GNU make dependency generation


From: Lorenzo Di Gregorio
Subject: [PATCH] Support for GNU make dependency generation
Date: Tue, 19 Oct 2010 14:52:40 +0200

Hello,

I'm following up on this (http://lists.gnu.org/archive/html/m4-discuss/2010-10/msg00003.html) post, because I've managed to find some time and write a patch for supporting dependency generation with M4, which is something I've been really missing for my makefiles.  You find the patch enclosed here as attachment.

To use the patched m4, you just call:

m4 -X depfile file1 file2 ...

this -X is equivalent to gcc's '-MD -MP -MF'.  -MT becomes unnecessary because m4 outputs on stdout and you must set a rule with target and prerequisites in the makefile.  If stdin is used, it does not get listed as dependency, of course.  Since multiple target files are processed, dependencies are listed for every target.  Only prerequisites which have not been listed as targets are listed as phony targets.

Internally, I've augmented m4* context with four lists: prereqs, targets, all_prereqs and all_targets.  They get allocated and filled by m4_add_dep(), dumped and freed in main().  I've extended m4_push_file() with a few flags to signal how to call m4_add_dep().

Hope the feature is ok and you like it: I'd be happy to see it within the tool.
Of course corrections/suggestions/changes/improvements are always welcome!

Best Regards,
Lorenzo

Attachment: 0001-Support-for-GNU-make-dependency-generation.patch
Description: Text Data


reply via email to

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