08-make-write-deps.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. ---
  2. util.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
  3. 1 file changed, 116 insertions(+), 1 deletion(-)
  4. Index: kconfig/util.c
  5. ===================================================================
  6. --- kconfig.orig/util.c
  7. +++ kconfig/util.c
  8. @@ -29,6 +29,121 @@
  9. return file;
  10. }
  11. +static char* br2_symbol_printer(const char * const in)
  12. +{
  13. + ssize_t i, j, len = strlen(in);
  14. + char *ret;
  15. + if (len < 1)
  16. + return NULL;
  17. + ret = malloc(len+1);
  18. + if (!ret) {
  19. + printf("Out of memory!");
  20. + exit(1);
  21. + }
  22. + memset(ret, 0, len+1);
  23. + i = j = 0;
  24. + if (strncmp("BR2_", in, 4) == 0)
  25. + i += 4;
  26. + if (strncmp("PACKAGE_", in + i, 8) == 0)
  27. + i += 8;
  28. + else if (strncmp("TARGET_", in + i, 7) == 0)
  29. + i += 7;
  30. + while (i <= len)
  31. + ret[j++] = tolower(in[i++]);
  32. + return ret;
  33. +}
  34. +
  35. +/* write dependencies of the individual config-symbols */
  36. +static int write_make_deps(const char *name)
  37. +{
  38. + char *str;
  39. + char dir[PATH_MAX+1], buf[PATH_MAX+1], buf2[PATH_MAX+1];
  40. + struct menu *menu;
  41. + struct symbol *sym;
  42. + struct property *prop, *p;
  43. + unsigned done;
  44. + const char * const name_tmp = "..make.deps.tmp";
  45. + FILE *out;
  46. + if (!name)
  47. + name = ".auto.deps";
  48. +
  49. + strcpy(dir, conf_get_configname());
  50. + str = strrchr(dir, '/');
  51. + if (str)
  52. + str[1] = 0;
  53. + else
  54. + dir[0] = 0;
  55. +
  56. + sprintf(buf, "%s%s", dir, name_tmp);
  57. + out = fopen(buf, "w");
  58. + if (!out)
  59. + return 1;
  60. + fprintf(out, "# ATTENTION! This does not handle 'depends', just 'select'! \n"
  61. + "# See support/kconfig/util.c write_make_deps()\n#\n");
  62. + menu = &rootmenu;//rootmenu.list;
  63. + while (menu) {
  64. + sym = menu->sym;
  65. + if (!sym) {
  66. + if (!menu_is_visible(menu))
  67. + goto next;
  68. + } else if (!(sym->flags & SYMBOL_CHOICE)) {
  69. + sym_calc_value(sym);
  70. + if (sym->type == S_BOOLEAN
  71. + && sym_get_tristate_value(sym) != no) {
  72. + done = 0;
  73. + for_all_prompts(sym, prop) {
  74. + struct expr *e;
  75. +//printf("\nname=%s\n", sym->name);
  76. + for_all_properties(sym, p, P_SELECT) {
  77. + e = p->expr;
  78. + if (e && e->left.sym->name) {
  79. + if (!done) {
  80. + fprintf(out, "%s: $(BASE_TARGETS)", br2_symbol_printer(sym->name));
  81. + done = 1;
  82. + }
  83. +//printf("SELECTS %s\n",e->left.sym->name);
  84. + fprintf(out, " %s",br2_symbol_printer(e->left.sym->name));
  85. + }
  86. + }
  87. + if (done)
  88. + fprintf(out, "\n");
  89. +#if 0
  90. + e = sym->rev_dep.expr;
  91. + if (e && e->type == E_SYMBOL
  92. + && e->left.sym->name) {
  93. + fprintf(out, "%s: %s", br2_symbol_printer(e->left.sym->name),
  94. + br2_symbol_printer(sym->name));
  95. +printf("%s is Selected BY: %s", sym->name, e->left.sym->name);
  96. + }
  97. +#endif
  98. + }
  99. + }
  100. + }
  101. +next:
  102. + if (menu->list) {
  103. + menu = menu->list;
  104. + continue;
  105. + }
  106. + if (menu->next)
  107. + menu = menu->next;
  108. + else while ((menu = menu->parent)) {
  109. + if (menu->next) {
  110. + menu = menu->next;
  111. + break;
  112. + }
  113. + }
  114. + }
  115. + fclose(out);
  116. + sprintf(buf2, "%s%s", dir, name);
  117. + rename(buf, buf2);
  118. + printf(_("#\n"
  119. + "# make dependencies written to %s\n"
  120. + "# ATTENTION buildroot devels!\n"
  121. + "# See top of this file before playing with this auto-preprequisites!\n"
  122. + "#\n"), name);
  123. + return 0;
  124. +}
  125. +
  126. /* write a dependency file as used by kbuild to track dependencies */
  127. int file_write_dep(const char *name)
  128. {
  129. @@ -71,7 +186,7 @@
  130. fprintf(out, "\n$(deps_config): ;\n");
  131. fclose(out);
  132. rename("..config.tmp", name);
  133. - return 0;
  134. + return write_make_deps(NULL);
  135. }