URL: <http://savannah.gnu.org/bugs/?35485>
Summary: New $(.MFDIR) built-in variable Project: make Submitted by: boyski Submitted on: Wed 08 Feb 2012 06:30:41 PM GMT Severity: 3 - Normal Item Group: Enhancement Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any Component Version: CVS Operating System: Any Fixed Release: None Triage Status: None _______________________________________________________ Details: The attached one-line (plus docs) patch adds a .MFDIR variable which evaluates to the directory of the containing makefile, more or less. It's actually just shorthand: diff -u -r1.60 default.c --- default.c 16 Jan 2012 02:29:22 -0000 1.60 +++ default.c 8 Feb 2012 17:45:49 -0000 @@ -527,6 +527,7 @@ #endif #endif /* !VMS */ + ".MFDIR", "$(abspath $(dir $(lastword $(MAKEFILE_LIST))))", 0, 0 }; Justification: though this adds no new functionality, I think it's important for support of non-recursive build styles. Given a build tree with many directories containing source files and makefiles, in a recursive model the tendency is to cd into each directory and invoke make locally, and thus the important relative directory is the cwd aka $(CURDIR). But in a flat build model those sub-makefiles tend to be included into a single make process and CURDIR doesn't change. In this case the important relationship is with the directory containing the controlling sub-makefile. Currently the playing field is tilted towards cwd-centric builds by the support for CURDIR. Having .MFDIR would even that out by making it easier to think in terms of a makefile-relative directory. Expecting naive (or even expert) developers to qualify paths with "$(abspath $(dir $(lastword $(MAKEFILE_LIST))))" is a nonstarter. This could be made more verbose as MAKEFILE_DIR or less as MWD. The leading "." is just my guess as to what would be most compatible. Also, it's arguable whether this is better handled as a regular predefined variable, subject to removal with -R, or a hard-wired variable analogous to CURDIR. _______________________________________________________ File Attachments: ------------------------------------------------------- Date: Wed 08 Feb 2012 06:30:41 PM GMT Name: mfdir.diff Size: 2kB By: boyski <http://savannah.gnu.org/bugs/download.php?file_id=25027> _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?35485> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make