aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Zippel <zippel@linux-m68k.org>2006-06-09 01:12:51 -0400
committerSam Ravnborg <sam@mars.ravnborg.org>2006-06-09 10:28:07 -0400
commit14cdd3c402bf7c66f0bcd76e290f0770a54a4b21 (patch)
tree1a58bdd177f1d5723a1a695e6165c5904c641c55
parent250725aa13f5c9595e5bc265ebed8471e816d8b4 (diff)
kconfig: KCONFIG_OVERWRITECONFIG
If you set KCONFIG_OVERWRITECONFIG in environment, Kconfig will not break symlinks when .config is a symlink to somewhere else. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
-rw-r--r--Makefile6
-rw-r--r--scripts/kconfig/confdata.c46
-rw-r--r--scripts/kconfig/lkc.h2
3 files changed, 33 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 3c55de99ed31..3cb9270c584d 100644
--- a/Makefile
+++ b/Makefile
@@ -178,6 +178,8 @@ CROSS_COMPILE ?=
178# Architecture as present in compile.h 178# Architecture as present in compile.h
179UTS_MACHINE := $(ARCH) 179UTS_MACHINE := $(ARCH)
180 180
181KCONFIG_CONFIG ?= .config
182
181# SHELL used by kbuild 183# SHELL used by kbuild
182CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ 184CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
183 else if [ -x /bin/bash ]; then echo /bin/bash; \ 185 else if [ -x /bin/bash ]; then echo /bin/bash; \
@@ -437,13 +439,13 @@ ifeq ($(dot-config),1)
437-include include/config/auto.conf 439-include include/config/auto.conf
438 440
439# To avoid any implicit rule to kick in, define an empty command 441# To avoid any implicit rule to kick in, define an empty command
440.config include/config/auto.conf.cmd: ; 442$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
441 443
442# If .config is newer than include/config/auto.conf, someone tinkered 444# If .config is newer than include/config/auto.conf, someone tinkered
443# with it and forgot to run make oldconfig. 445# with it and forgot to run make oldconfig.
444# if auto.conf.cmd is missing then we are probarly in a cleaned tree so 446# if auto.conf.cmd is missing then we are probarly in a cleaned tree so
445# we execute the config step to be sure to catch updated Kconfig files 447# we execute the config step to be sure to catch updated Kconfig files
446include/config/auto.conf: .config include/config/auto.conf.cmd 448include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
447 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig 449 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
448 450
449else 451else
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 5bd66f451189..2ee48c377b66 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -21,8 +21,6 @@ static void conf_warning(const char *fmt, ...)
21static const char *conf_filename; 21static const char *conf_filename;
22static int conf_lineno, conf_warnings, conf_unsaved; 22static int conf_lineno, conf_warnings, conf_unsaved;
23 23
24const char conf_def_filename[] = ".config";
25
26const char conf_defname[] = "arch/$ARCH/defconfig"; 24const char conf_defname[] = "arch/$ARCH/defconfig";
27 25
28static void conf_warning(const char *fmt, ...) 26static void conf_warning(const char *fmt, ...)
@@ -36,6 +34,13 @@ static void conf_warning(const char *fmt, ...)
36 conf_warnings++; 34 conf_warnings++;
37} 35}
38 36
37const char *conf_get_configname(void)
38{
39 char *name = getenv("KCONFIG_CONFIG");
40
41 return name ? name : ".config";
42}
43
39static char *conf_expand_value(const char *in) 44static char *conf_expand_value(const char *in)
40{ 45{
41 struct symbol *sym; 46 struct symbol *sym;
@@ -91,7 +96,7 @@ int conf_read_simple(const char *name, int def)
91 } else { 96 } else {
92 struct property *prop; 97 struct property *prop;
93 98
94 name = conf_def_filename; 99 name = conf_get_configname();
95 in = zconf_fopen(name); 100 in = zconf_fopen(name);
96 if (in) 101 if (in)
97 goto load; 102 goto load;
@@ -381,7 +386,7 @@ int conf_write(const char *name)
381 if (!stat(name, &st) && S_ISDIR(st.st_mode)) { 386 if (!stat(name, &st) && S_ISDIR(st.st_mode)) {
382 strcpy(dirname, name); 387 strcpy(dirname, name);
383 strcat(dirname, "/"); 388 strcat(dirname, "/");
384 basename = conf_def_filename; 389 basename = conf_get_configname();
385 } else if ((slash = strrchr(name, '/'))) { 390 } else if ((slash = strrchr(name, '/'))) {
386 int size = slash - name + 1; 391 int size = slash - name + 1;
387 memcpy(dirname, name, size); 392 memcpy(dirname, name, size);
@@ -389,16 +394,24 @@ int conf_write(const char *name)
389 if (slash[1]) 394 if (slash[1])
390 basename = slash + 1; 395 basename = slash + 1;
391 else 396 else
392 basename = conf_def_filename; 397 basename = conf_get_configname();
393 } else 398 } else
394 basename = name; 399 basename = name;
395 } else 400 } else
396 basename = conf_def_filename; 401 basename = conf_get_configname();
397 402
398 sprintf(newname, "%s.tmpconfig.%d", dirname, (int)getpid()); 403 sprintf(newname, "%s%s", dirname, basename);
399 out = fopen(newname, "w"); 404 env = getenv("KCONFIG_OVERWRITECONFIG");
405 if (!env || !*env) {
406 sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
407 out = fopen(tmpname, "w");
408 } else {
409 *tmpname = 0;
410 out = fopen(newname, "w");
411 }
400 if (!out) 412 if (!out)
401 return 1; 413 return 1;
414
402 sym = sym_lookup("KERNELVERSION", 0); 415 sym = sym_lookup("KERNELVERSION", 0);
403 sym_calc_value(sym); 416 sym_calc_value(sym);
404 time(&now); 417 time(&now);
@@ -498,19 +511,18 @@ int conf_write(const char *name)
498 } 511 }
499 } 512 }
500 fclose(out); 513 fclose(out);
501 if (!name || basename != conf_def_filename) { 514
502 if (!name) 515 if (*tmpname) {
503 name = conf_def_filename; 516 strcat(dirname, name ? name : conf_get_configname());
504 sprintf(tmpname, "%s.old", name); 517 strcat(dirname, ".old");
505 rename(name, tmpname); 518 rename(newname, dirname);
519 if (rename(tmpname, newname))
520 return 1;
506 } 521 }
507 sprintf(tmpname, "%s%s", dirname, basename);
508 if (rename(newname, tmpname))
509 return 1;
510 522
511 printf(_("#\n" 523 printf(_("#\n"
512 "# configuration written to %s\n" 524 "# configuration written to %s\n"
513 "#\n"), tmpname); 525 "#\n"), newname);
514 526
515 sym_change_count = 0; 527 sym_change_count = 0;
516 528
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 2d3d4ed3c9f2..2628023a1fe1 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -64,8 +64,6 @@ int zconf_lineno(void);
64char *zconf_curname(void); 64char *zconf_curname(void);
65 65
66/* confdata.c */ 66/* confdata.c */
67extern const char conf_def_filename[];
68
69char *conf_get_default_confname(void); 67char *conf_get_default_confname(void);
70 68
71/* kconfig_load.c */ 69/* kconfig_load.c */