commit - 3c12f67d765d9fd0ee94e3dee7ed65e8fa2765a8
commit + f629615182e2c7fdb39ef1cb453a80a034eb0f37
blob - 3ffee0beee1663f6c8a6433dfe4a5f0bb8c68d68
blob + 0f054e8453b1acec8bdfaeb083b90a715bb9e6fa
--- make/TODO.md
+++ make/TODO.md
-s silent, do not write commands to stdout
-# Macro Definition Operators
-## `+=`: Append Assignment
-### MyMakefile
-```make
-CFLAGS = -ansi
-.export CFLAGS
-```
-### sub/MyMakefile
-```
-CFLAGS += -Wall
-```
-
# Templates
## MyMakefile
```make
blob - cc694d669c9d7bfe6c8b778df8d0e882ec1264be
blob + b36e5d8963bad822dcc39dc2c6accd1f1f4dbf23
--- make/make.c
+++ make/make.c
static struct macro m_shell = {
.next = NULL,
.enext = NULL,
+ .prepend = NULL,
.name = "SHELL",
.value = SHELL,
.lazy = 0,
}, m_make = {
.next = &m_shell,
.enext = &m_shell,
+ .prepend = NULL,
.name = "MAKE",
.value = NULL,
.lazy = 0,
}, m_dmake = {
.next = &m_make,
.enext = &m_make,
+ .prepend = NULL,
.name = ".MAKE",
.value = NULL,
.lazy = 0,
}, m_makeflags = {
.next = &m_dmake,
.enext = &m_dmake,
+ .prepend = NULL,
.name = "MAKEFLAGS",
.value = NULL,
.lazy = 0,
}, m_dmakeflags = {
.next = &m_makeflags,
.enext = &m_makeflags,
+ .prepend = NULL,
.name = ".MAKEFLAGS",
.value = NULL,
.lazy = 0,
struct scope *sc;
struct macro *m;
{
+ if (m->prepend != NULL) {
+ expand_macro (sc, m->prepend);
+ str_push (' ');
+ }
+
if (m->lazy) {
expand_into (sc, m->value, NULL);
} else {
m = new (struct macro);
m->next = sc->dir->macros;
+ m->enext = NULL;
m->help = help;
+ m->prepend = NULL;
if (t[-1] == '!') {
t[-1] = '\0';
t[t[-2] == ':' ? -2 : -1] = '\0';
m->lazy = 0;
m->value = strdup (trim (expand (sc, trim (t + 1), NULL)));
+ } else if (t[-1] == '+') {
+ t[-1] = '\0';
+ m->value = strdup (trim (t + 1));
+ m->prepend = find_macro (sc, trim (s));
+ m->lazy = 1;
} else {
m->lazy = 1;
m->value = strdup (trim (t + 1));
for (m = sc->dir->macros; m != NULL; m = m->next) {
if (m->help != NULL)
printf ("\n## %s\n", m->help);
- printf ("%s = %s\n", m->name, m->value);
+ printf ("%s %s= %s\n", m->name, m->prepend != NULL ? "+" : "", m->value);
}
printf ("\n");
blob - a541402897a1d3a09bcd5962f1577a6c923952f8
blob + 1633f42f1d844ff4030d29d1875de920f48a6758
--- make/make.h
+++ make/make.h
};
struct macro {
- struct macro *next, *enext;
+ struct macro *next, *enext, *prepend;
char *name;
char *value;
char *help;