Emit unwritten symbols in Kconfig so we don't have to do constructs like
[coreboot.git] / util / kconfig / confdata.c
index 05c260161ed7955efed93eec546d871c85b232df..946b8a9c0b476f45dd62a8a2d445ab40afda8705 100644 (file)
 #define LKC_DIRECT_LINK
 #include "lkc.h"
 
+#ifdef WIN32
+#define mkdir(x,y) mkdir(x)
+#define UNLINK_IF_NECESSARY(x) unlink(x)
+#else
+#define UNLINK_IF_NECESSARY(X)
+#endif
+
 static void conf_warning(const char *fmt, ...)
        __attribute__ ((format (printf, 1, 2)));
 
@@ -539,6 +546,7 @@ int conf_write(const char *name)
        if (*tmpname) {
                strcat(dirname, basename);
                strcat(dirname, ".old");
+               UNLINK_IF_NECESSARY(dirname);
                rename(newname, dirname);
                if (rename(tmpname, newname))
                        return 1;
@@ -713,8 +721,15 @@ int conf_write_autoconf(void)
 
        for_all_symbols(i, sym) {
                sym_calc_value(sym);
-               if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
+               if (!sym->name)
                        continue;
+               if (!(sym->flags & SYMBOL_WRITE)) {
+                       if (sym->type == S_BOOLEAN || sym->type == S_HEX
+                           || sym->type == S_INT)
+                               fprintf(out_h, "#define CONFIG_%s 0\n",
+                                       sym->name);
+                       continue;
+               }
                switch (sym->type) {
                case S_BOOLEAN:
                case S_TRISTATE:
@@ -775,6 +790,7 @@ int conf_write_autoconf(void)
        name = getenv("KCONFIG_AUTOHEADER");
        if (!name)
                name = "include/linux/autoconf.h";
+       UNLINK_IF_NECESSARY(name);
        if (rename(".tmpconfig.h", name))
                return 1;
        name = getenv("KCONFIG_AUTOCONFIG");
@@ -784,6 +800,7 @@ int conf_write_autoconf(void)
         * This must be the last step, kbuild has a dependency on auto.conf
         * and this marks the successful completion of the previous steps.
         */
+       UNLINK_IF_NECESSARY(name);
        if (rename(".tmpconfig", name))
                return 1;