commit ee835173a241055761945fd3f30c886bffb88f1c from: Benjamin Stürz date: Sat Nov 16 20:14:59 2024 UTC make: implement "normal" include commit - 1b3014243e2252993d1a7dc4fa55cca8e36782a1 commit + ee835173a241055761945fd3f30c886bffb88f1c blob - 242c3a778f41dc2423a249d69e6160f4e73f4870 blob + f58fe287f5a03c63cca850d61f608f9272a7b4ca --- make/TODO.md +++ make/TODO.md @@ -55,9 +55,6 @@ -s silent, do not write commands to stdout -# "normal" `include file` - - # Macro Definition Operators ## `+=`: Append Assignment ### MyMakefile blob - 4c0063b2d7535ecd383791f284409a160048c0bf blob + ee99ac0e60d9e8e5f30827586ee5d40dd6b065c3 --- make/make.c +++ make/make.c @@ -767,7 +767,7 @@ char *path; struct macro *m, *m2; struct rule *r = NULL; size_t len, cap; - char *s, *t, *help = NULL; + char *s, *t, *u, *help = NULL; FILE *file; int ln = 0; @@ -787,6 +787,17 @@ char *path; continue; } else if (s[0] == '#' || *trim (s) == '\0') { continue; + } else if (starts_with (s, "include ")) { + t = strdup (trim (expand (sc, s + 8, NULL))); + if (*t == '/') { + u = t; + } else { + asprintf (&u, "%s/%s", path_to_str (dir), t); + } + parse (sc, dir, u); + if (u != t) + free (u); + free (t); } else if (starts_with (s, ".include ")) { if (parse_include (sc, dir, s + 9) == -1) errx (1, "%s:%d: syntax error", path, ln);