From 5e0ee893cdb9e42d7454624fd46fd6979688ba90 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Mon, 30 Jul 2018 21:30:31 +0000 Subject: [PATCH] Tag each .c file with the options that might have brought it in. --- usr.bin/config/mkmakefile.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/usr.bin/config/mkmakefile.c b/usr.bin/config/mkmakefile.c index eebc5086b4b5..63e773363b4b 100644 --- a/usr.bin/config/mkmakefile.c +++ b/usr.bin/config/mkmakefile.c @@ -584,6 +584,36 @@ emitincludes(FILE *fp) } /* + * Emit all options included in a conditional expression + */ +static void +emitopts(FILE *fp, struct condexpr *cond, int include) +{ + +again: switch (cond->cx_type) { + case CX_ATOM: + if (include) { + fprintf(fp, " %s", cond->cx_u.atom); + } + break; + case CX_NOT: + cond = cond->cx_u.not; + include = !include; + goto again; + case CX_AND: + emitopts(fp, cond->cx_u.and.left, include); + cond = cond->cx_u.and.right; + goto again; + case CX_OR: + emitopts(fp, cond->cx_u.and.left, include); + cond = cond->cx_u.and.right; + goto again; + default: + cfgerror("bug"); + } +} + +/* * Emit appending makeoptions. */ static void @@ -591,6 +621,17 @@ emitappmkoptions(FILE *fp) { struct nvlist *nv; struct condexpr *cond; + size_t i; + + for (i = 0; i < nselfiles; i++) { + struct files *const fi = selfiles[i]; + + if (fi->fi_optx) { + fprintf(fp, "OPT.%s.c+=", fi->fi_base); + emitopts(fp, fi->fi_optx, 1); + fprintf(fp, "\n"); + } + } for (nv = appmkoptions; nv != NULL; nv = nv->nv_next) fprintf(fp, "%s+=%s\n", nv->nv_name, nv->nv_str); -- 2.11.0