scripts: Add support for variant and selinux defconfig
authordhacker29 <davidhackerdvm@gmail.com>
Fri, 23 Aug 2013 22:29:35 +0000 (17:29 -0500)
committerNolen Johnson <johnsonnolen@gmail.com>
Wed, 22 Dec 2021 02:21:17 +0000 (21:21 -0500)
scripts/kconfig/Makefile
scripts/kconfig/conf.c
scripts/kconfig/confdata.c
scripts/kconfig/lkc_proto.h

index 90a091b6ae4de74e6c070d77255b9f4b5655629a..abbca017f543a3b3e9245704fc38cbb7f26997c0 100644 (file)
@@ -87,6 +87,22 @@ $(simple-targets): $(obj)/conf
 
 PHONY += oldnoconfig savedefconfig defconfig
 
+ifneq ($(VARIANT_DEFCONFIG),)
+export KCONFIG_VARIANT := arch/$(SRCARCH)/configs/$(VARIANT_DEFCONFIG)
+endif
+
+ifneq ($(DEBUG_DEFCONFIG),)
+export KCONFIG_DEBUG := arch/$(SRCARCH)/configs/$(DEBUG_DEFCONFIG)
+endif
+
+ifneq ($(SELINUX_DEFCONFIG),)
+export KCONFIG_SELINUX := arch/$(SRCARCH)/configs/$(SELINUX_DEFCONFIG)
+endif
+
+ifneq ($(SELINUX_LOG_DEFCONFIG),)
+export KCONFIG_LOG_SELINUX := arch/$(SRCARCH)/configs/$(SELINUX_LOG_DEFCONFIG)
+endif
+
 # oldnoconfig is an alias of olddefconfig, because people already are dependent
 # on its behavior (sets new symbols to their default value but not 'n') with the
 # counter-intuitive name.
index 866369f10ff84f4d2cae14eb6dfbe7e353c08adf..418048b3353a255bef2d36d593b5f1a30103bebf 100644 (file)
@@ -587,6 +587,51 @@ int main(int ac, char **av)
                                "***\n"), defconfig_file);
                        exit(1);
                }
+               name = getenv("KCONFIG_SELINUX");
+               printf("KCONFIG_SELINUX(%s)\n", name);
+               if (name) {
+                       if (conf_read_simple(name, S_DEF_USER, false)) {
+                               printf(_("***\n"
+                                       "*** Can't find selinux configuration \"%s\"!\n"
+                                       "***\n"), name);
+                               exit(1);
+                       }
+               }
+               name = getenv("KCONFIG_LOG_SELINUX");
+               printf("KCONFIG_LOG_SELINUX(%s)\n", name);
+               if (name) {
+                       if (conf_read_simple(name, S_DEF_USER, false)) {
+                               printf(_("***\n"
+                                       "*** Can't find selinux log configuration \"%s\"!\n"
+                                       "***\n"), name);
+                               exit(1);
+                       }
+               }
+               name = getenv("KCONFIG_VARIANT");
+               printf("KCONFIG_VARIANT(%s)\n", name);
+               if (name) {
+                       if (conf_read_simple(name, S_DEF_USER, false)) {
+                               printf(_("***\n"
+                                       "*** Can't find variant configuration \"%s\"!\n"
+                                       "***\n"), name);
+                               exit(1);
+                       }
+               } else {
+                       printf(_("***\n"
+                               "***  You must specify VARIANT_DEFCONFIG !\n"
+                               "***\n"));
+                       exit(1);
+               }
+               name = getenv("KCONFIG_DEBUG");
+               printf("KCONFIG_DEBUG(%s)\n", name);
+               if (name) {
+                       if (conf_read_simple(name, S_DEF_USER, false)) {
+                               printf(_("***\n"
+                                       "*** Can't find debug configuration \"%s\"!\n"
+                                       "***\n"), name);
+                               exit(1);
+                       }
+               }
                break;
        case savedefconfig:
        case silentoldconfig:
@@ -605,7 +650,7 @@ int main(int ac, char **av)
                if (!name)
                        break;
                if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) {
-                       if (conf_read_simple(name, S_DEF_USER)) {
+                       if (conf_read_simple(name, S_DEF_USER, true)) {
                                fprintf(stderr,
                                        _("*** Can't read seed configuration \"%s\"!\n"),
                                        name);
@@ -621,8 +666,8 @@ int main(int ac, char **av)
                case randconfig:        name = "allrandom.config"; break;
                default: break;
                }
-               if (conf_read_simple(name, S_DEF_USER) &&
-                   conf_read_simple("all.config", S_DEF_USER)) {
+               if (conf_read_simple(name, S_DEF_USER, true) &&
+                   conf_read_simple("all.config", S_DEF_USER, true)) {
                        fprintf(stderr,
                                _("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"),
                                name);
index fa423fcd1a9285b12c024b8829f26ace0f2a99a0..7e03aee39473aaa480854d86d81763c0d69f7cb5 100644 (file)
@@ -248,7 +248,7 @@ e_out:
        return -1;
 }
 
-int conf_read_simple(const char *name, int def)
+int conf_read_simple(const char *name, int def, int sym_init)
 {
        FILE *in = NULL;
        char   *line = NULL;
@@ -293,6 +293,10 @@ load:
        conf_unsaved = 0;
 
        def_flags = SYMBOL_DEF << def;
+
+       if (!sym_init)
+               goto readsym;
+
        for_all_symbols(i, sym) {
                sym->flags |= SYMBOL_CHANGED;
                sym->flags &= ~(def_flags|SYMBOL_VALID);
@@ -311,6 +315,7 @@ load:
                }
        }
 
+readsym:
        while (compat_getline(&line, &line_asize, in) != -1) {
                conf_lineno++;
                sym = NULL;
@@ -413,7 +418,7 @@ int conf_read(const char *name)
 
        sym_set_change_count(0);
 
-       if (conf_read_simple(name, S_DEF_USER)) {
+       if (conf_read_simple(name, S_DEF_USER, true)) {
                sym_calc_value(modules_sym);
                return 1;
        }
@@ -848,7 +853,7 @@ static int conf_split_config(void)
        int res, i, fd;
 
        name = conf_get_autoconfig_name();
-       conf_read_simple(name, S_DEF_AUTO);
+       conf_read_simple(name, S_DEF_AUTO, true);
        sym_calc_value(modules_sym);
 
        if (chdir("include/config"))
index d5398718ec2ae3337dac3cb3d19654c8508c3007..376e4e12c30dbb3dbc8057caedc6b63a3958a537 100644 (file)
@@ -3,7 +3,7 @@
 /* confdata.c */
 void conf_parse(const char *name);
 int conf_read(const char *name);
-int conf_read_simple(const char *name, int);
+int conf_read_simple(const char *name, int, int);
 int conf_write_defconfig(const char *name);
 int conf_write(const char *name);
 int conf_write_autoconf(void);