aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kconfig/confdata.c71
1 files changed, 14 insertions, 57 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index df629ecb4fdf..59b667cae5f3 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -495,15 +495,25 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
495 495
496 switch (*value) { 496 switch (*value) {
497 case 'n': 497 case 'n':
498 return; 498 break;
499 case 'm': 499 case 'm':
500 suffix = "_MODULE"; 500 suffix = "_MODULE";
501 /* fall through */ 501 /* fall through */
502 default: 502 default:
503 value = "1"; 503 fprintf(fp, "#define %s%s%s 1\n",
504 CONFIG_, sym->name, suffix);
504 } 505 }
505 fprintf(fp, "#define %s%s%s %s\n", 506 /*
506 CONFIG_, sym->name, suffix, value); 507 * Generate the __enabled_CONFIG_* and
508 * __enabled_CONFIG_*_MODULE macros for use by the
509 * IS_{ENABLED,BUILTIN,MODULE} macros. The _MODULE variant is
510 * generated even for booleans so that the IS_ENABLED() macro
511 * works.
512 */
513 fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n",
514 sym->name, (*value == 'y'));
515 fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n",
516 sym->name, (*value == 'm'));
507 break; 517 break;
508 } 518 }
509 case S_HEX: { 519 case S_HEX: {
@@ -555,58 +565,6 @@ static struct conf_printer header_printer_cb =
555}; 565};
556 566
557/* 567/*
558 * Function-style header printer
559 *
560 * This printer is used to generate the config_is_xxx() function-style macros
561 * in `include/generated/autoconf.h'
562 */
563static void
564header_function_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
565{
566 int val = 0;
567 char c;
568 char *tmp, *d;
569
570 switch (sym->type) {
571 case S_BOOLEAN:
572 case S_TRISTATE:
573 break;
574 default:
575 return;
576 }
577 if (*value == 'm')
578 val = 2;
579 else if (*value == 'y')
580 val = 1;
581
582 d = strdup(CONFIG_);
583 tmp = d;
584 while ((c = *d)) {
585 *d = tolower(c);
586 d++;
587 }
588
589 fprintf(fp, "#define %sis_", tmp);
590 free(tmp);
591
592 d = strdup(sym->name);
593 tmp = d;
594 while ((c = *d)) {
595 *d = tolower(c);
596 d++;
597 }
598 fprintf(fp, "%s%s() %d\n", tmp, (val > 1) ? "_module" : "",
599 val ? 1 : 0);
600 free(tmp);
601}
602
603static struct conf_printer header_function_printer_cb =
604{
605 .print_symbol = header_function_print_symbol,
606};
607
608
609/*
610 * Tristate printer 568 * Tristate printer
611 * 569 *
612 * This printer is used when generating the `include/config/tristate.conf' file. 570 * This printer is used when generating the `include/config/tristate.conf' file.
@@ -997,7 +955,6 @@ int conf_write_autoconf(void)
997 conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1); 955 conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);
998 956
999 conf_write_symbol(out_h, sym, &header_printer_cb, NULL); 957 conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
1000 conf_write_symbol(out_h, sym, &header_function_printer_cb, NULL);
1001 } 958 }
1002 fclose(out); 959 fclose(out);
1003 fclose(tristate); 960 fclose(tristate);