123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- ---
- conf.c | 1
- confdata.c | 65 +++++++++++++++++++++++++++++++++++++++++++++----------------
- util.c | 16 +++++++++++++--
- 3 files changed, 62 insertions(+), 20 deletions(-)
- Index: config/conf.c
- ===================================================================
- --- config.orig/conf.c
- +++ config/conf.c
- @@ -503,7 +503,6 @@
- }
- name = av[optind];
- conf_parse(name);
- - //zconfdump(stdout);
- if (sync_kconfig) {
- name = conf_get_configname();
- if (stat(name, &tmpstat)) {
- Index: config/confdata.c
- ===================================================================
- --- config.orig/confdata.c
- +++ config/confdata.c
- @@ -44,9 +44,7 @@
-
- const char *conf_get_autoconfig_name(void)
- {
- - char *name = getenv("KCONFIG_AUTOCONFIG");
- -
- - return name ? name : "include/config/auto.conf";
- + return getenv("KCONFIG_AUTOCONFIG");
- }
-
- static char *conf_expand_value(const char *in)
- @@ -542,6 +540,9 @@
- int use_timestamp = 1;
- char *env;
-
- + if (!name)
- + name = conf_get_configname();
- +
- dirname[0] = 0;
- if (name && name[0]) {
- struct stat st;
- @@ -658,6 +659,7 @@
- {
- const char *name;
- char path[128];
- + char *opwd, *dir, *_name;
- char *s, *d, c;
- struct symbol *sym;
- struct stat sb;
- @@ -666,8 +668,20 @@
- name = conf_get_autoconfig_name();
- conf_read_simple(name, S_DEF_AUTO);
-
- - if (chdir("include/config"))
- - return 1;
- + opwd = malloc(256);
- + _name = strdup(name);
- + if (opwd == NULL || _name == NULL)
- + return 1;
- + opwd = getcwd(opwd, 256);
- + dir = dirname(_name);
- + if (dir == NULL) {
- + res = 1;
- + goto err;
- + }
- + if (chdir(dir)) {
- + res = 1;
- + goto err;
- + }
-
- res = 0;
- for_all_symbols(i, sym) {
- @@ -760,9 +774,11 @@
- close(fd);
- }
- out:
- - if (chdir("../.."))
- - return 1;
- -
- + if (chdir(opwd))
- + res = 1;
- +err:
- + free(opwd);
- + free(_name);
- return res;
- }
-
- @@ -774,25 +790,38 @@
- FILE *out, *tristate, *out_h;
- time_t now;
- int i;
- + char dir[PATH_MAX+1], buf[PATH_MAX+1];
- + char *s;
- +
- + strcpy(dir, conf_get_configname());
- + s = strrchr(dir, '/');
- + if (s)
- + s[1] = 0;
- + else
- + dir[0] = 0;
-
- sym_clear_all_valid();
-
- - file_write_dep("include/config/auto.conf.cmd");
- + sprintf(buf, "%s.config.cmd", dir);
- + file_write_dep(buf);
-
- if (conf_split_config())
- return 1;
-
- - out = fopen(".tmpconfig", "w");
- + sprintf(buf, "%s.tmpconfig", dir);
- + out = fopen(buf, "w");
- if (!out)
- return 1;
-
- - tristate = fopen(".tmpconfig_tristate", "w");
- + sprintf(buf, "%s.tmpconfig_tristate", dir);
- + tristate = fopen(buf, "w");
- if (!tristate) {
- fclose(out);
- return 1;
- }
-
- - out_h = fopen(".tmpconfig.h", "w");
- + sprintf(buf, "%s.tmpconfig.h", dir);
- + out_h = fopen(buf, "w");
- if (!out_h) {
- fclose(out);
- fclose(tristate);
- @@ -815,8 +844,7 @@
- fprintf(out_h, "/*\n"
- " * Automatically generated C config: don't edit\n"
- " * %s"
- - " */\n"
- - "#define AUTOCONF_INCLUDED\n",
- + " */\n",
- ctime(&now));
-
- for_all_symbols(i, sym) {
- @@ -870,19 +898,22 @@
- name = getenv("KCONFIG_AUTOHEADER");
- if (!name)
- name = "include/generated/autoconf.h";
- - if (rename(".tmpconfig.h", name))
- + sprintf(buf, "%s.tmpconfig.h", dir);
- + if (rename(buf, name))
- return 1;
- name = getenv("KCONFIG_TRISTATE");
- if (!name)
- name = "include/config/tristate.conf";
- - if (rename(".tmpconfig_tristate", name))
- + sprintf(buf, "%s.tmpconfig_tristate", dir);
- + if (rename(buf, name))
- return 1;
- name = conf_get_autoconfig_name();
- /*
- * This must be the last step, kbuild has a dependency on auto.conf
- * and this marks the successful completion of the previous steps.
- */
- - if (rename(".tmpconfig", name))
- + sprintf(buf, "%s.tmpconfig", dir);
- + if (rename(buf, name))
- return 1;
-
- return 0;
- Index: config/util.c
- ===================================================================
- --- config.orig/util.c
- +++ config/util.c
- @@ -144,6 +144,8 @@
- /* write a dependency file as used by kbuild to track dependencies */
- int file_write_dep(const char *name)
- {
- + char *str;
- + char buf[PATH_MAX+1], buf2[PATH_MAX+1], dir[PATH_MAX+1];
- struct symbol *sym, *env_sym;
- struct expr *e;
- struct file *file;
- @@ -151,7 +153,16 @@
-
- if (!name)
- name = ".kconfig.d";
- - out = fopen("..config.tmp", "w");
- +
- + strcpy(dir, conf_get_configname());
- + str = strrchr(dir, '/');
- + if (str)
- + str[1] = 0;
- + else
- + dir[0] = 0;
- +
- + sprintf(buf, "%s..config.tmp", dir);
- + out = fopen(buf, "w");
- if (!out)
- return 1;
- fprintf(out, "deps_config := \\\n");
- @@ -182,7 +193,8 @@
-
- fprintf(out, "\n$(deps_config): ;\n");
- fclose(out);
- - rename("..config.tmp", name);
- + sprintf(buf2, "%s%s", dir, name);
- + rename(buf, buf2);
- return write_make_deps(NULL);
- }
-
|