Commit Diff


commit - c029c51da1e88462de3ff3d8da9cd8d24ff983ff
commit + 3cae9670974e97af67a91b0ae22a538f3815d1c1
blob - 191613a70e7e3a0338a31946fde0c12c4ec5bd98
blob + 87a91dad57bd7d5c20ddc9ac0f61330455d9664a
--- make/TODO.md
+++ make/TODO.md
@@ -152,6 +152,9 @@ $ make sub/print
 TOP: ./..
 ```
 
+## Rename `$*` to something different
+POSIX specifies, that `$*` evaluates to the current target's basename, without the suffix.
+
 ## `${.SUBDIRS}`
 Useful for this:
 ```make
@@ -166,8 +169,6 @@ all: ${.SUBDIRS}
 clean: ${.SUBDIRS/clean}
 ```
 
-## `${MAKE}`, `${.MAKE}`, `${MAKEFLAGS}` and `${.MAKEFLAGS}`
-
 ## `${name:subst1=subst2}`: Macro Substitution
 Substitute all occurences of `subst1` with `subst2` in macro `name`.
 
blob - 85cd67900fe13f3370fd526c22746bd89bc84121
blob + 7a2154a4ca0432bc375fe247e7968b72e0ebd837
--- make/make.c
+++ make/make.c
@@ -33,9 +33,27 @@ static struct macro m_shell = {
 	.name = "MAKE",
 	.value = NULL,
 	.lazy = 0,
+}, m_dmake = {
+	.next = &m_make,
+	.enext = &m_make,
+	.name = ".MAKE",
+	.value = NULL,
+	.lazy = 0,
+}, m_makeflags = {
+	.next = &m_dmake,
+	.enext = &m_dmake,
+	.name = "MAKEFLAGS",
+	.value = NULL,
+	.lazy = 0,
+}, m_dmakeflags = {
+	.next = &m_makeflags,
+	.enext = &m_makeflags,
+	.name = ".MAKEFLAGS",
+	.value = NULL,
+	.lazy = 0,
 };
 
-static struct macro *globals = &m_make;
+static struct macro *globals = &m_dmakeflags;
 static int verbose = 0;
 
 /* MISC */
@@ -1369,9 +1387,13 @@ char **argv;
 	char *s;
 	int i, option, pr = 0, n = 0;
 
-	m_make.value = argv[0];
+	m_dmake.value = m_make.value = argv[0];
 
+	str_reset ();
 	while ((option = getopt (argc, argv, "pv")) != -1) {
+		str_push (' ');
+		str_push ('-');
+		str_push (option);
 		switch (option) {
 		case 'p':
 			pr = 1;
@@ -1394,6 +1416,9 @@ char **argv;
 		if (s == NULL)
 			continue;
 
+		str_push (' ');
+		str_push_str (argv[i]);
+
 		*s = '\0';
 		m = new (struct macro);
 		m->next = globals;
@@ -1404,6 +1429,8 @@ char **argv;
 		argv[i] = NULL;
 	}
 
+	m_dmakeflags.value = m_makeflags.value = strdup (trim (str_get ()));
+
 	path = parse_path (".");
 	sc = parse_recursive (path);