tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
make: ensure ${.MAKE} works
This came up in a recent thread.
Anyone object?
--------------------8<--------------------
If argv[0] contains '/' but is not an absolute path,
use realpath() to resolve it for setting .MAKE
Index: main.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/main.c,v
retrieving revision 1.177
diff -u -p -r1.177 main.c
--- main.c 8 Apr 2010 17:41:29 -0000 1.177
+++ main.c 13 Apr 2010 20:59:35 -0000
@@ -895,8 +895,14 @@ main(int argc, char **argv)
* MFLAGS also gets initialized empty, for compatibility.
*/
Parse_Init();
- Var_Set("MAKE", argv[0], VAR_GLOBAL, 0);
- Var_Set(".MAKE", argv[0], VAR_GLOBAL, 0);
+ if ((p1 = strchr(argv[0], '/')) && p1 != argv[0]) {
+ /* resolve to an absolute path */
+ p1 = realpath(argv[0], mdpath);
+ }
+ if (!p1)
+ p1 = argv[0];
+ Var_Set("MAKE", p1, VAR_GLOBAL, 0);
+ Var_Set(".MAKE", p1, VAR_GLOBAL, 0);
Var_Set(MAKEFLAGS, "", VAR_GLOBAL, 0);
Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL, 0);
Var_Set("MFLAGS", "", VAR_GLOBAL, 0);
Home |
Main Index |
Thread Index |
Old Index