confdata.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. /*
  2. * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
  3. * Released under the terms of the GNU GPL v2.0.
  4. */
  5. #include <sys/stat.h>
  6. #include <ctype.h>
  7. #include <fcntl.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <time.h>
  12. #include <unistd.h>
  13. #define LKC_DIRECT_LINK
  14. #include "lkc.h"
  15. static void conf_warning(const char *fmt, ...)
  16. __attribute__ ((format (printf, 1, 2)));
  17. static const char *conf_filename;
  18. static int conf_lineno, conf_warnings, conf_unsaved;
  19. const char conf_defname[] = "extra/Configs/defconfigs/$ARCH";
  20. static void conf_warning(const char *fmt, ...)
  21. {
  22. va_list ap;
  23. va_start(ap, fmt);
  24. fprintf(stderr, "%s:%d:warning: ", conf_filename, conf_lineno);
  25. vfprintf(stderr, fmt, ap);
  26. fprintf(stderr, "\n");
  27. va_end(ap);
  28. conf_warnings++;
  29. }
  30. const char *conf_get_configname(void)
  31. {
  32. char *name = getenv("KCONFIG_CONFIG");
  33. return name ? name : ".config";
  34. }
  35. static char *conf_expand_value(const char *in)
  36. {
  37. struct symbol *sym;
  38. const char *src;
  39. static char res_value[SYMBOL_MAXLENGTH];
  40. char *dst, name[SYMBOL_MAXLENGTH];
  41. res_value[0] = 0;
  42. dst = name;
  43. while ((src = strchr(in, '$'))) {
  44. strncat(res_value, in, src - in);
  45. src++;
  46. dst = name;
  47. while (isalnum(*src) || *src == '_')
  48. *dst++ = *src++;
  49. *dst = 0;
  50. sym = sym_lookup(name, 0);
  51. sym_calc_value(sym);
  52. strcat(res_value, sym_get_string_value(sym));
  53. in = src;
  54. }
  55. strcat(res_value, in);
  56. return res_value;
  57. }
  58. char *conf_get_default_confname(void)
  59. {
  60. struct stat buf;
  61. static char fullname[PATH_MAX+1];
  62. char *env, *name;
  63. name = conf_expand_value(conf_defname);
  64. env = getenv(SRCTREE);
  65. if (env) {
  66. sprintf(fullname, "%s/%s", env, name);
  67. if (!stat(fullname, &buf))
  68. return fullname;
  69. }
  70. return name;
  71. }
  72. int conf_read_simple(const char *name, int def)
  73. {
  74. FILE *in = NULL;
  75. char line[1024];
  76. char *p, *p2;
  77. struct symbol *sym;
  78. int i, def_flags;
  79. if (name) {
  80. in = zconf_fopen(name);
  81. } else {
  82. struct property *prop;
  83. name = conf_get_configname();
  84. in = zconf_fopen(name);
  85. if (in)
  86. goto load;
  87. sym_add_change_count(1);
  88. if (!sym_defconfig_list)
  89. return 1;
  90. for_all_defaults(sym_defconfig_list, prop) {
  91. if (expr_calc_value(prop->visible.expr) == no ||
  92. prop->expr->type != E_SYMBOL)
  93. continue;
  94. name = conf_expand_value(prop->expr->left.sym->name);
  95. in = zconf_fopen(name);
  96. if (in) {
  97. printf(_("#\n"
  98. "# using defaults found in %s\n"
  99. "#\n"), name);
  100. goto load;
  101. }
  102. }
  103. }
  104. if (!in)
  105. return 1;
  106. load:
  107. conf_filename = name;
  108. conf_lineno = 0;
  109. conf_warnings = 0;
  110. conf_unsaved = 0;
  111. def_flags = SYMBOL_DEF << def;
  112. for_all_symbols(i, sym) {
  113. sym->flags |= SYMBOL_CHANGED;
  114. sym->flags &= ~(def_flags|SYMBOL_VALID);
  115. if (sym_is_choice(sym))
  116. sym->flags |= def_flags;
  117. switch (sym->type) {
  118. case S_INT:
  119. case S_HEX:
  120. case S_STRING:
  121. if (sym->def[def].val)
  122. free(sym->def[def].val);
  123. default:
  124. sym->def[def].val = NULL;
  125. sym->def[def].tri = no;
  126. }
  127. }
  128. while (fgets(line, sizeof(line), in)) {
  129. conf_lineno++;
  130. sym = NULL;
  131. switch (line[0]) {
  132. case '#':
  133. if (line[1]!=' ')
  134. continue;
  135. p = strchr(line + 2, ' ');
  136. if (!p)
  137. continue;
  138. *p++ = 0;
  139. if (strncmp(p, "is not set", 10))
  140. continue;
  141. if (def == S_DEF_USER) {
  142. sym = sym_find(line + 2);
  143. if (!sym) {
  144. conf_warning("trying to assign nonexistent symbol %s", line + 2);
  145. break;
  146. }
  147. } else {
  148. sym = sym_lookup(line + 2, 0);
  149. if (sym->type == S_UNKNOWN)
  150. sym->type = S_BOOLEAN;
  151. }
  152. if (sym->flags & def_flags) {
  153. conf_warning("trying to reassign symbol %s", sym->name);
  154. break;
  155. }
  156. switch (sym->type) {
  157. case S_BOOLEAN:
  158. case S_TRISTATE:
  159. sym->def[def].tri = no;
  160. sym->flags |= def_flags;
  161. break;
  162. default:
  163. ;
  164. }
  165. break;
  166. case 'A' ... 'Z':
  167. p = strchr(line, '=');
  168. if (!p)
  169. continue;
  170. *p++ = 0;
  171. p2 = strchr(p, '\n');
  172. if (p2) {
  173. *p2-- = 0;
  174. if (*p2 == '\r')
  175. *p2 = 0;
  176. }
  177. if (def == S_DEF_USER) {
  178. sym = sym_find(line);
  179. if (!sym) {
  180. conf_warning("trying to assign nonexistent symbol %s", line);
  181. break;
  182. }
  183. } else {
  184. sym = sym_lookup(line, 0);
  185. if (sym->type == S_UNKNOWN)
  186. sym->type = S_OTHER;
  187. }
  188. if (sym->flags & def_flags) {
  189. conf_warning("trying to reassign symbol %s", sym->name);
  190. break;
  191. }
  192. switch (sym->type) {
  193. case S_TRISTATE:
  194. if (p[0] == 'm') {
  195. sym->def[def].tri = mod;
  196. sym->flags |= def_flags;
  197. break;
  198. }
  199. case S_BOOLEAN:
  200. if (p[0] == 'y') {
  201. sym->def[def].tri = yes;
  202. sym->flags |= def_flags;
  203. break;
  204. }
  205. if (p[0] == 'n') {
  206. sym->def[def].tri = no;
  207. sym->flags |= def_flags;
  208. break;
  209. }
  210. conf_warning("symbol value '%s' invalid for %s", p, sym->name);
  211. break;
  212. case S_OTHER:
  213. if (*p != '"') {
  214. for (p2 = p; *p2 && !isspace(*p2); p2++)
  215. ;
  216. sym->type = S_STRING;
  217. goto done;
  218. }
  219. case S_STRING:
  220. if (*p++ != '"')
  221. break;
  222. for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) {
  223. if (*p2 == '"') {
  224. *p2 = 0;
  225. break;
  226. }
  227. memmove(p2, p2 + 1, strlen(p2));
  228. }
  229. if (!p2) {
  230. conf_warning("invalid string found");
  231. continue;
  232. }
  233. case S_INT:
  234. case S_HEX:
  235. done:
  236. if (sym_string_valid(sym, p)) {
  237. sym->def[def].val = strdup(p);
  238. sym->flags |= def_flags;
  239. } else {
  240. conf_warning("symbol value '%s' invalid for %s", p, sym->name);
  241. continue;
  242. }
  243. break;
  244. default:
  245. ;
  246. }
  247. break;
  248. case '\r':
  249. case '\n':
  250. break;
  251. default:
  252. conf_warning("unexpected data");
  253. continue;
  254. }
  255. if (sym && sym_is_choice_value(sym)) {
  256. struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
  257. switch (sym->def[def].tri) {
  258. case no:
  259. break;
  260. case mod:
  261. if (cs->def[def].tri == yes) {
  262. conf_warning("%s creates inconsistent choice state", sym->name);
  263. cs->flags &= ~def_flags;
  264. }
  265. break;
  266. case yes:
  267. if (cs->def[def].tri != no) {
  268. conf_warning("%s creates inconsistent choice state", sym->name);
  269. cs->flags &= ~def_flags;
  270. } else
  271. cs->def[def].val = sym;
  272. break;
  273. }
  274. cs->def[def].tri = E_OR(cs->def[def].tri, sym->def[def].tri);
  275. }
  276. }
  277. fclose(in);
  278. if (modules_sym)
  279. sym_calc_value(modules_sym);
  280. return 0;
  281. }
  282. int conf_read(const char *name)
  283. {
  284. struct symbol *sym;
  285. struct property *prop;
  286. struct expr *e;
  287. int i, flags;
  288. sym_set_change_count(0);
  289. if (conf_read_simple(name, S_DEF_USER))
  290. return 1;
  291. for_all_symbols(i, sym) {
  292. sym_calc_value(sym);
  293. if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO))
  294. goto sym_ok;
  295. if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) {
  296. /* check that calculated value agrees with saved value */
  297. switch (sym->type) {
  298. case S_BOOLEAN:
  299. case S_TRISTATE:
  300. if (sym->def[S_DEF_USER].tri != sym_get_tristate_value(sym))
  301. break;
  302. if (!sym_is_choice(sym))
  303. goto sym_ok;
  304. default:
  305. if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val))
  306. goto sym_ok;
  307. break;
  308. }
  309. } else if (!sym_has_value(sym) && !(sym->flags & SYMBOL_WRITE))
  310. /* no previous value and not saved */
  311. goto sym_ok;
  312. conf_unsaved++;
  313. /* maybe print value in verbose mode... */
  314. sym_ok:
  315. if (sym_has_value(sym) && !sym_is_choice_value(sym)) {
  316. if (sym->visible == no)
  317. sym->flags &= ~SYMBOL_DEF_USER;
  318. switch (sym->type) {
  319. case S_STRING:
  320. case S_INT:
  321. case S_HEX:
  322. if (!sym_string_within_range(sym, sym->def[S_DEF_USER].val))
  323. sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER);
  324. default:
  325. break;
  326. }
  327. }
  328. if (!sym_is_choice(sym))
  329. continue;
  330. prop = sym_get_choice_prop(sym);
  331. flags = sym->flags;
  332. for (e = prop->expr; e; e = e->left.expr)
  333. if (e->right.sym->visible != no)
  334. flags &= e->right.sym->flags;
  335. sym->flags &= flags | ~SYMBOL_DEF_USER;
  336. }
  337. sym_add_change_count(conf_warnings || conf_unsaved);
  338. return 0;
  339. }
  340. int conf_write(const char *name)
  341. {
  342. FILE *out;
  343. struct symbol *sym;
  344. struct menu *menu;
  345. const char *basename;
  346. char dirname[128], tmpname[128], newname[128];
  347. int type, l;
  348. const char *str;
  349. time_t now;
  350. int use_timestamp = 1;
  351. char *env;
  352. dirname[0] = 0;
  353. if (name && name[0]) {
  354. struct stat st;
  355. char *slash;
  356. if (!stat(name, &st) && S_ISDIR(st.st_mode)) {
  357. strcpy(dirname, name);
  358. strcat(dirname, "/");
  359. basename = conf_get_configname();
  360. } else if ((slash = strrchr(name, '/'))) {
  361. int size = slash - name + 1;
  362. memcpy(dirname, name, size);
  363. dirname[size] = 0;
  364. if (slash[1])
  365. basename = slash + 1;
  366. else
  367. basename = conf_get_configname();
  368. } else
  369. basename = name;
  370. } else
  371. basename = conf_get_configname();
  372. sprintf(newname, "%s%s", dirname, basename);
  373. env = getenv("KCONFIG_OVERWRITECONFIG");
  374. if (!env || !*env) {
  375. sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
  376. out = fopen(tmpname, "w");
  377. } else {
  378. *tmpname = 0;
  379. out = fopen(newname, "w");
  380. }
  381. if (!out)
  382. return 1;
  383. sym = sym_lookup("VERSION", 0);
  384. sym_calc_value(sym);
  385. time(&now);
  386. env = getenv("KCONFIG_NOTIMESTAMP");
  387. if (env && *env)
  388. use_timestamp = 0;
  389. fprintf(out, _("#\n"
  390. "# Automatically generated make config: don't edit\n"
  391. "%s%s"
  392. "#\n"),
  393. use_timestamp ? "# " : "",
  394. use_timestamp ? ctime(&now) : "");
  395. if (!conf_get_changed())
  396. sym_clear_all_valid();
  397. menu = rootmenu.list;
  398. while (menu) {
  399. sym = menu->sym;
  400. if (!sym) {
  401. if (!menu_is_visible(menu))
  402. goto next;
  403. str = menu_get_prompt(menu);
  404. fprintf(out, "\n"
  405. "#\n"
  406. "# %s\n"
  407. "#\n", str);
  408. } else if (!(sym->flags & SYMBOL_CHOICE)) {
  409. sym_calc_value(sym);
  410. if (!(sym->flags & SYMBOL_WRITE))
  411. goto next;
  412. sym->flags &= ~SYMBOL_WRITE;
  413. type = sym->type;
  414. if (type == S_TRISTATE) {
  415. sym_calc_value(modules_sym);
  416. if (modules_sym->curr.tri == no)
  417. type = S_BOOLEAN;
  418. }
  419. switch (type) {
  420. case S_BOOLEAN:
  421. case S_TRISTATE:
  422. switch (sym_get_tristate_value(sym)) {
  423. case no:
  424. fprintf(out, "# %s is not set\n", sym->name);
  425. break;
  426. case mod:
  427. fprintf(out, "%s=m\n", sym->name);
  428. break;
  429. case yes:
  430. fprintf(out, "%s=y\n", sym->name);
  431. break;
  432. }
  433. break;
  434. case S_STRING:
  435. str = sym_get_string_value(sym);
  436. fprintf(out, "%s=\"", sym->name);
  437. while (1) {
  438. l = strcspn(str, "\"\\");
  439. if (l) {
  440. fwrite(str, l, 1, out);
  441. str += l;
  442. }
  443. if (!*str)
  444. break;
  445. fprintf(out, "\\%c", *str++);
  446. }
  447. fputs("\"\n", out);
  448. break;
  449. case S_HEX:
  450. str = sym_get_string_value(sym);
  451. if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
  452. fprintf(out, "%s=%s\n", sym->name, str);
  453. break;
  454. }
  455. case S_INT:
  456. str = sym_get_string_value(sym);
  457. fprintf(out, "%s=%s\n", sym->name, str);
  458. break;
  459. }
  460. }
  461. next:
  462. if (menu->list) {
  463. menu = menu->list;
  464. continue;
  465. }
  466. if (menu->next)
  467. menu = menu->next;
  468. else while ((menu = menu->parent)) {
  469. if (menu->next) {
  470. menu = menu->next;
  471. break;
  472. }
  473. }
  474. }
  475. fclose(out);
  476. if (*tmpname) {
  477. strcat(dirname, basename);
  478. strcat(dirname, ".old");
  479. rename(newname, dirname);
  480. if (rename(tmpname, newname))
  481. return 1;
  482. }
  483. printf(_("#\n"
  484. "# configuration written to %s\n"
  485. "#\n"), newname);
  486. sym_set_change_count(0);
  487. return 0;
  488. }
  489. int conf_split_config(void)
  490. {
  491. char *name, path[128];
  492. char *s, *d, c;
  493. struct symbol *sym;
  494. struct stat sb;
  495. int res, i, fd;
  496. name = getenv("KCONFIG_AUTOCONFIG");
  497. if (!name)
  498. name = "include/config/auto.conf";
  499. conf_read_simple(name, S_DEF_AUTO);
  500. if (chdir("include/config"))
  501. return 1;
  502. res = 0;
  503. for_all_symbols(i, sym) {
  504. sym_calc_value(sym);
  505. if ((sym->flags & SYMBOL_AUTO) || !sym->name)
  506. continue;
  507. if (sym->flags & SYMBOL_WRITE) {
  508. if (sym->flags & SYMBOL_DEF_AUTO) {
  509. /*
  510. * symbol has old and new value,
  511. * so compare them...
  512. */
  513. switch (sym->type) {
  514. case S_BOOLEAN:
  515. case S_TRISTATE:
  516. if (sym_get_tristate_value(sym) ==
  517. sym->def[S_DEF_AUTO].tri)
  518. continue;
  519. break;
  520. case S_STRING:
  521. case S_HEX:
  522. case S_INT:
  523. if (!strcmp(sym_get_string_value(sym),
  524. sym->def[S_DEF_AUTO].val))
  525. continue;
  526. break;
  527. default:
  528. break;
  529. }
  530. } else {
  531. /*
  532. * If there is no old value, only 'no' (unset)
  533. * is allowed as new value.
  534. */
  535. switch (sym->type) {
  536. case S_BOOLEAN:
  537. case S_TRISTATE:
  538. if (sym_get_tristate_value(sym) == no)
  539. continue;
  540. break;
  541. default:
  542. break;
  543. }
  544. }
  545. } else if (!(sym->flags & SYMBOL_DEF_AUTO))
  546. /* There is neither an old nor a new value. */
  547. continue;
  548. /* else
  549. * There is an old value, but no new value ('no' (unset)
  550. * isn't saved in auto.conf, so the old value is always
  551. * different from 'no').
  552. */
  553. /* Replace all '_' and append ".h" */
  554. s = sym->name;
  555. d = path;
  556. while ((c = *s++)) {
  557. c = tolower(c);
  558. *d++ = (c == '_') ? '/' : c;
  559. }
  560. strcpy(d, ".h");
  561. /* Assume directory path already exists. */
  562. fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
  563. if (fd == -1) {
  564. if (errno != ENOENT) {
  565. res = 1;
  566. break;
  567. }
  568. /*
  569. * Create directory components,
  570. * unless they exist already.
  571. */
  572. d = path;
  573. while ((d = strchr(d, '/'))) {
  574. *d = 0;
  575. if (stat(path, &sb) && mkdir(path, 0755)) {
  576. res = 1;
  577. goto out;
  578. }
  579. *d++ = '/';
  580. }
  581. /* Try it again. */
  582. fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
  583. if (fd == -1) {
  584. res = 1;
  585. break;
  586. }
  587. }
  588. close(fd);
  589. }
  590. out:
  591. if (chdir("../.."))
  592. return 1;
  593. return res;
  594. }
  595. int conf_write_autoconf(void)
  596. {
  597. struct symbol *sym;
  598. const char *str;
  599. char *name;
  600. FILE *out, *out_h;
  601. time_t now;
  602. int i, l;
  603. return system("./extra/config/conf-header.sh .config > include/bits/uClibc_config.h");
  604. sym_clear_all_valid();
  605. file_write_dep("include/config/auto.conf.cmd");
  606. if (conf_split_config())
  607. return 1;
  608. out = fopen(".tmpconfig", "w");
  609. if (!out)
  610. return 1;
  611. out_h = fopen(".tmpconfig.h", "w");
  612. if (!out_h) {
  613. fclose(out);
  614. return 1;
  615. }
  616. sym = sym_lookup("VERSION", 0);
  617. sym_calc_value(sym);
  618. time(&now);
  619. fprintf(out, "#\n"
  620. "# Automatically generated make config: don't edit\n"
  621. "# %s"
  622. "#\n",
  623. ctime(&now));
  624. fprintf(out_h, "/*\n"
  625. " * Automatically generated C config: don't edit\n"
  626. " * %s"
  627. " */\n",
  628. ctime(&now));
  629. for_all_symbols(i, sym) {
  630. sym_calc_value(sym);
  631. if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
  632. continue;
  633. switch (sym->type) {
  634. case S_BOOLEAN:
  635. case S_TRISTATE:
  636. switch (sym_get_tristate_value(sym)) {
  637. case no:
  638. break;
  639. case mod:
  640. fprintf(out, "%s=m\n", sym->name);
  641. fprintf(out_h, "#define %s_MODULE 1\n", sym->name);
  642. break;
  643. case yes:
  644. fprintf(out, "%s=y\n", sym->name);
  645. fprintf(out_h, "#define %s 1\n", sym->name);
  646. break;
  647. }
  648. break;
  649. case S_STRING:
  650. str = sym_get_string_value(sym);
  651. fprintf(out, "%s=\"", sym->name);
  652. fprintf(out_h, "#define %s \"", sym->name);
  653. while (1) {
  654. l = strcspn(str, "\"\\");
  655. if (l) {
  656. fwrite(str, l, 1, out);
  657. fwrite(str, l, 1, out_h);
  658. str += l;
  659. }
  660. if (!*str)
  661. break;
  662. fprintf(out, "\\%c", *str);
  663. fprintf(out_h, "\\%c", *str);
  664. str++;
  665. }
  666. fputs("\"\n", out);
  667. fputs("\"\n", out_h);
  668. break;
  669. case S_HEX:
  670. str = sym_get_string_value(sym);
  671. if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
  672. fprintf(out, "%s=%s\n", sym->name, str);
  673. fprintf(out_h, "#define %s 0x%s\n", sym->name, str);
  674. break;
  675. }
  676. case S_INT:
  677. str = sym_get_string_value(sym);
  678. fprintf(out, "%s=%s\n", sym->name, str);
  679. fprintf(out_h, "#define %s %s\n", sym->name, str);
  680. break;
  681. default:
  682. break;
  683. }
  684. }
  685. fclose(out);
  686. fclose(out_h);
  687. name = getenv("KCONFIG_AUTOHEADER");
  688. if (!name)
  689. name = "include/linux/autoconf.h";
  690. if (rename(".tmpconfig.h", name))
  691. return 1;
  692. name = getenv("KCONFIG_AUTOCONFIG");
  693. if (!name)
  694. name = "include/config/auto.conf";
  695. /*
  696. * This must be the last step, kbuild has a dependency on auto.conf
  697. * and this marks the successful completion of the previous steps.
  698. */
  699. if (rename(".tmpconfig", name))
  700. return 1;
  701. return 0;
  702. }
  703. static int sym_change_count;
  704. static void (*conf_changed_callback)(void);
  705. void sym_set_change_count(int count)
  706. {
  707. int _sym_change_count = sym_change_count;
  708. sym_change_count = count;
  709. if (conf_changed_callback &&
  710. (bool)_sym_change_count != (bool)count)
  711. conf_changed_callback();
  712. }
  713. void sym_add_change_count(int count)
  714. {
  715. sym_set_change_count(count + sym_change_count);
  716. }
  717. bool conf_get_changed(void)
  718. {
  719. return sym_change_count;
  720. }
  721. void conf_set_changed_callback(void (*fn)(void))
  722. {
  723. conf_changed_callback = fn;
  724. }