Pull Kconfig updates from Masahiro Yamada: - show clearer error messages where pkg-config is needed, but not installed - rename SYMBOL_AUTO to SYMBOL_NO_WRITE to reflect its semantics - create all necessary directories by Kconfig tool itself instead of Makefile - update the .config unconditionally when syncconfig is invoked - use 'include' directive instead of '-include' where include/config/{auto,tristate}.conf is mandatory - do not try to update the .config when running install targets - add .DELETE_ON_ERROR to delete partially updated files - misc cleanups and fixes * tag 'kconfig-v4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: kconfig: remove P_ENV property type kconfig: remove unused sym_get_env_prop() function kconfig: fix the rule of mainmenu_stmt symbol init/Kconfig: Use short unix-style option instead of --longname Kbuild: Makefile.modbuiltin: include auto.conf and tristate.conf mandatory kbuild: remove auto.conf from prerequisite of phony targets kbuild: do not update config for 'make kernelrelease' kbuild: do not update config when running install targets kbuild: add .DELETE_ON_ERROR special target kbuild: use 'include' directive to load auto.conf from top Makefile kconfig: allow all config targets to write auto.conf if missing kconfig: make syncconfig update .config regardless of sym_change_count kconfig: create directories needed for syncconfig by itself kconfig: remove unneeded directory generation from local*config kconfig: split out useful helpers in confdata.c kconfig: rename file_write_dep and move it to confdata.c kconfig: fix typos in description of "choice" in kconfig-language.txt kconfig: handle format string before calling conf_message_callback() kconfig: rename SYMBOL_AUTO to SYMBOL_NO_WRITE kconfig: check for pkg-config on make {menu,n,g,x}config
Unified · Split
| @@ -370,7 +370,7 @@ choices: · 369 unmodified lines | ||
| 370 | 370 | |
| 371 | 371 | This defines a choice group and accepts any of the above attributes as |
| 372 | 372 | options. A choice can only be of type bool or tristate. If no type is |
| 373 | −specified for a choice, it's type will be determined by the type of | |
| 373 | +specified for a choice, its type will be determined by the type of | |
| 374 | 374 | the first choice element in the group or remain unknown if none of the |
| 375 | 375 | choice elements have a type specified, as well. |
| 376 | 376 | |
| @@ -384,7 +384,7 @@ A choice accepts another option "optional", which allows to set the · 7 unmodified lines | ||
| 384 | 384 | choice to 'n' and no entry needs to be selected. |
| 385 | 385 | If no [symbol] is associated with a choice, then you can not have multiple |
| 386 | 386 | definitions of that choice. If a [symbol] is associated to the choice, |
| 387 | −then you may define the same choice (ie. with the same entries) in another | |
| 387 | +then you may define the same choice (i.e. with the same entries) in another | |
| 388 | 388 | place. |
| 389 | 389 | |
| 390 | 390 | comment: |
| @@ -81,6 +81,14 @@ The build system has, as of 4.13, switched to using thin archives (`ar T`) · 80 unmodified lines | ||
| 81 | 81 | rather than incremental linking (`ld -r`) for built-in.a intermediate steps. |
| 82 | 82 | This requires binutils 2.20 or newer. |
| 83 | 83 | |
| 84 | +pkg-config | |
| 85 | +---------- | |
| 86 | + | |
| 87 | +The build system, as of 4.18, requires pkg-config to check for installed | |
| 88 | +kconfig tools and to determine flags settings for use in | |
| 89 | +'make {menu,n,g,x}config'. Previously pkg-config was being used but not | |
| 90 | +verified or documented. | |
| 91 | + | |
| 84 | 92 | Flex |
| 85 | 93 | ---- |
| 86 | 94 | |
| @@ -225,10 +225,13 @@ no-dot-config-targets := $(clean-targets) \ · 224 unmodified lines | ||
| 225 | 225 | cscope gtags TAGS tags help% %docs check% coccicheck \ |
| 226 | 226 | $(version_h) headers_% archheaders archscripts \ |
| 227 | 227 | %asm-generic kernelversion %src-pkg |
| 228 | +no-sync-config-targets := $(no-dot-config-targets) install %install \ | |
| 229 | + kernelrelease | |
| 228 | 230 | |
| 229 | −config-targets := 0 | |
| 230 | −mixed-targets := 0 | |
| 231 | −dot-config := 1 | |
| 231 | +config-targets := 0 | |
| 232 | +mixed-targets := 0 | |
| 233 | +dot-config := 1 | |
| 234 | +may-sync-config := 1 | |
| 232 | 235 | |
| 233 | 236 | ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) |
| 234 | 237 | ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) |
| @@ -236,6 +239,16 @@ ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) · 1 unmodified line | ||
| 236 | 239 | endif |
| 237 | 240 | endif |
| 238 | 241 | |
| 242 | +ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),) | |
| 243 | + ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),) | |
| 244 | + may-sync-config := 0 | |
| 245 | + endif | |
| 246 | +endif | |
| 247 | + | |
| 248 | +ifneq ($(KBUILD_EXTMOD),) | |
| 249 | + may-sync-config := 0 | |
| 250 | +endif | |
| 251 | + | |
| 239 | 252 | ifeq ($(KBUILD_EXTMOD),) |
| 240 | 253 | ifneq ($(filter config %config,$(MAKECMDGOALS)),) |
| 241 | 254 | config-targets := 1 |
| @@ -585,7 +598,7 @@ virt-y := virt/ · 343 unmodified lines | ||
| 585 | 598 | endif # KBUILD_EXTMOD |
| 586 | 599 | |
| 587 | 600 | ifeq ($(dot-config),1) |
| 588 | −-include include/config/auto.conf | |
| 601 | +include include/config/auto.conf | |
| 589 | 602 | endif |
| 590 | 603 | |
| 591 | 604 | # The all: target is the default when no target is given on the |
| @@ -607,7 +620,7 @@ ARCH_CFLAGS := · 15 unmodified lines | ||
| 607 | 620 | include arch/$(SRCARCH)/Makefile |
| 608 | 621 | |
| 609 | 622 | ifeq ($(dot-config),1) |
| 610 | −ifeq ($(KBUILD_EXTMOD),) | |
| 623 | +ifeq ($(may-sync-config),1) | |
| 611 | 624 | # Read in dependencies to all Kconfig* files, make sure to run syncconfig if |
| 612 | 625 | # changes are detected. This should be included after arch/$(SRCARCH)/Makefile |
| 613 | 626 | # because some architectures define CROSS_COMPILE there. |
| @@ -622,8 +635,9 @@ $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; · 8 unmodified lines | ||
| 622 | 635 | include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd |
| 623 | 636 | $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig |
| 624 | 637 | else |
| 625 | −# external modules needs include/generated/autoconf.h and include/config/auto.conf | |
| 626 | −# but do not care if they are up-to-date. Use auto.conf to trigger the test | |
| 638 | +# External modules and some install targets need include/generated/autoconf.h | |
| 639 | +# and include/config/auto.conf but do not care if they are up-to-date. | |
| 640 | +# Use auto.conf to trigger the test | |
| 627 | 641 | PHONY += include/config/auto.conf |
| 628 | 642 | |
| 629 | 643 | include/config/auto.conf: |
| @@ -635,11 +649,7 @@ include/config/auto.conf: · 5 unmodified lines | ||
| 635 | 649 | echo >&2 ; \ |
| 636 | 650 | /bin/false) |
| 637 | 651 | |
| 638 | −endif # KBUILD_EXTMOD | |
| 639 | − | |
| 640 | −else | |
| 641 | −# Dummy target needed, because used as prerequisite | |
| 642 | −include/config/auto.conf: ; | |
| 652 | +endif # may-sync-config | |
| 643 | 653 | endif # $(dot-config) |
| 644 | 654 | |
| 645 | 655 | KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) |
| @@ -1035,15 +1045,14 @@ define filechk_kernel.release · 389 unmodified lines | ||
| 1035 | 1045 | endef |
| 1036 | 1046 | |
| 1037 | 1047 | # Store (new) KERNELRELEASE string in include/config/kernel.release |
| 1038 | −include/config/kernel.release: include/config/auto.conf FORCE | |
| 1048 | +include/config/kernel.release: $(srctree)/Makefile FORCE | |
| 1039 | 1049 | $(call filechk,kernel.release) |
| 1040 | 1050 | |
| 1041 | 1051 | # Additional helpers built in scripts/ |
| 1042 | 1052 | # Carefully list dependencies so we do not try to build scripts twice |
| 1043 | 1053 | # in parallel |
| 1044 | 1054 | PHONY += scripts |
| 1045 | −scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \ | |
| 1046 | − asm-generic gcc-plugins $(autoksyms_h) | |
| 1055 | +scripts: scripts_basic asm-generic gcc-plugins $(autoksyms_h) | |
| 1047 | 1056 | $(Q)$(MAKE) $(build)=$(@) |
| 1048 | 1057 | |
| 1049 | 1058 | # Things we need to do before we recursively start building the kernel |
| @@ -1073,8 +1082,7 @@ endif · 23 unmodified lines | ||
| 1073 | 1082 | # that need to depend on updated CONFIG_* values can be checked here. |
| 1074 | 1083 | prepare2: prepare3 outputmakefile asm-generic |
| 1075 | 1084 | |
| 1076 | −prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h \ | |
| 1077 | − include/config/auto.conf | |
| 1085 | +prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h | |
| 1078 | 1086 | $(cmd_crmodverdir) |
| 1079 | 1087 | |
| 1080 | 1088 | archprepare: archheaders archscripts prepare1 scripts_basic |
| @@ -1212,7 +1220,7 @@ modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin · 131 unmodified lines | ||
| 1212 | 1220 | modules.builtin: $(vmlinux-dirs:%=%/modules.builtin) |
| 1213 | 1221 | $(Q)$(AWK) '!x[$$0]++' $^ > $(objtree)/modules.builtin |
| 1214 | 1222 | |
| 1215 | −%/modules.builtin: include/config/auto.conf | |
| 1223 | +%/modules.builtin: include/config/auto.conf include/config/tristate.conf | |
| 1216 | 1224 | $(Q)$(MAKE) $(modbuiltin)=$* |
| 1217 | 1225 | |
| 1218 | 1226 | |
| @@ -2,9 +2,9 @@ config DEFCONFIG_LIST · 1 unmodified line | ||
| 2 | 2 | string |
| 3 | 3 | depends on !UML |
| 4 | 4 | option defconfig_list |
| 5 | − default "/lib/modules/$(shell,uname --release)/.config" | |
| 5 | + default "/lib/modules/$(shell,uname -r)/.config" | |
| 6 | 6 | default "/etc/kernel-config" |
| 7 | − default "/boot/config-$(shell,uname --release)" | |
| 7 | + default "/boot/config-$(shell,uname -r)" | |
| 8 | 8 | default ARCH_DEFCONFIG |
| 9 | 9 | default "arch/$(ARCH)/defconfig" |
| 10 | 10 | |
| @@ -400,3 +400,6 @@ endif · 399 unmodified lines | ||
| 400 | 400 | endef |
| 401 | 401 | # |
| 402 | 402 | ############################################################################### |
| 403 | + | |
| 404 | +# delete partially updated (i.e. corrupted) files on error | |
| 405 | +.DELETE_ON_ERROR: | |
| @@ -8,10 +8,10 @@ src := $(obj) · 7 unmodified lines | ||
| 8 | 8 | PHONY := __modbuiltin |
| 9 | 9 | __modbuiltin: |
| 10 | 10 | |
| 11 | −-include include/config/auto.conf | |
| 11 | +include include/config/auto.conf | |
| 12 | 12 | # tristate.conf sets tristate variables to uppercase 'Y' or 'M' |
| 13 | 13 | # That way, we get the list of built-in modules in obj-Y |
| 14 | −-include include/config/tristate.conf | |
| 14 | +include include/config/tristate.conf | |
| 15 | 15 | |
| 16 | 16 | include scripts/Kbuild.include |
| 17 | 17 | |
| @@ -3,8 +3,7 @@ · 2 unmodified lines | ||
| 3 | 3 | # Kernel configuration targets |
| 4 | 4 | # These targets are used from top-level makefile |
| 5 | 5 | |
| 6 | −PHONY += xconfig gconfig menuconfig config syncconfig \ | |
| 7 | − localmodconfig localyesconfig | |
| 6 | +PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig | |
| 8 | 7 | |
| 9 | 8 | ifdef KBUILD_KCONFIG |
| 10 | 9 | Kconfig := $(KBUILD_KCONFIG) |
| @@ -34,14 +33,7 @@ config: $(obj)/conf · 23 unmodified lines | ||
| 34 | 33 | nconfig: $(obj)/nconf |
| 35 | 34 | $< $(silent) $(Kconfig) |
| 36 | 35 | |
| 37 | −# This has become an internal implementation detail and is now deprecated | |
| 38 | −# for external use. | |
| 39 | −syncconfig: $(obj)/conf | |
| 40 | − $(Q)mkdir -p include/config include/generated | |
| 41 | − $< $(silent) --$@ $(Kconfig) | |
| 42 | − | |
| 43 | 36 | localyesconfig localmodconfig: $(obj)/conf |
| 44 | − $(Q)mkdir -p include/config include/generated | |
| 45 | 37 | $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config |
| 46 | 38 | $(Q)if [ -f .config ]; then \ |
| 47 | 39 | cmp -s .tmp.config .config || \ |
| @@ -56,8 +48,12 @@ localyesconfig localmodconfig: $(obj)/conf · 8 unmodified lines | ||
| 56 | 48 | $(Q)rm -f .tmp.config |
| 57 | 49 | |
| 58 | 50 | # These targets map 1:1 to the commandline options of 'conf' |
| 51 | +# | |
| 52 | +# Note: | |
| 53 | +# syncconfig has become an internal implementation detail and is now | |
| 54 | +# deprecated for external use | |
| 59 | 55 | simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \ |
| 60 | − alldefconfig randconfig listnewconfig olddefconfig | |
| 56 | + alldefconfig randconfig listnewconfig olddefconfig syncconfig | |
| 61 | 57 | PHONY += $(simple-targets) |
| 62 | 58 | |
| 63 | 59 | $(simple-targets): $(obj)/conf |
| @@ -215,6 +211,7 @@ $(obj)/zconf.tab.o: $(obj)/zconf.lex.c · 151 unmodified lines | ||
| 215 | 211 | |
| 216 | 212 | # check if necessary packages are available, and configure build flags |
| 217 | 213 | define filechk_conf_cfg |
| 214 | + $(CONFIG_SHELL) $(srctree)/scripts/kconfig/check-pkgconfig.sh; \ | |
| 218 | 215 | $(CONFIG_SHELL) $< |
| 219 | 216 | endef |
| 220 | 217 | |
| @@ -0,0 +1,8 @@ | ||
| 1 | +#!/bin/sh | |
| 2 | +# SPDX-License-Identifier: GPL-2.0 | |
| 3 | +# Check for pkg-config presence | |
| 4 | + | |
| 5 | +if [ -z $(command -v pkg-config) ]; then | |
| 6 | + echo "'make *config' requires 'pkg-config'. Please install it." 1>&2 | |
| 7 | + exit 1 | |
| 8 | +fi | |
| @@ -496,6 +496,7 @@ int main(int ac, char **av) · 495 unmodified lines | ||
| 496 | 496 | int opt; |
| 497 | 497 | const char *name, *defconfig_file = NULL /* gcc uninit */; |
| 498 | 498 | struct stat tmpstat; |
| 499 | + int no_conf_write = 0; | |
| 499 | 500 | |
| 500 | 501 | tty_stdio = isatty(0) && isatty(1); |
| 501 | 502 | |
| @@ -633,13 +634,14 @@ int main(int ac, char **av) · 131 unmodified lines | ||
| 633 | 634 | } |
| 634 | 635 | |
| 635 | 636 | if (sync_kconfig) { |
| 636 | − if (conf_get_changed()) { | |
| 637 | − name = getenv("KCONFIG_NOSILENTUPDATE"); | |
| 638 | − if (name && *name) { | |
| 637 | + name = getenv("KCONFIG_NOSILENTUPDATE"); | |
| 638 | + if (name && *name) { | |
| 639 | + if (conf_get_changed()) { | |
| 639 | 640 | fprintf(stderr, |
| 640 | 641 | "\n*** The configuration requires explicit update.\n\n"); |
| 641 | 642 | return 1; |
| 642 | 643 | } |
| 644 | + no_conf_write = 1; | |
| 643 | 645 | } |
| 644 | 646 | } |
| 645 | 647 | |
| @@ -684,29 +686,32 @@ int main(int ac, char **av) · 38 unmodified lines | ||
| 684 | 686 | break; |
| 685 | 687 | } |
| 686 | 688 | |
| 687 | − if (sync_kconfig) { | |
| 688 | − /* syncconfig is used during the build so we shall update autoconf. | |
| 689 | − * All other commands are only used to generate a config. | |
| 690 | − */ | |
| 691 | − if (conf_get_changed() && conf_write(NULL)) { | |
| 692 | − fprintf(stderr, "\n*** Error during writing of the configuration.\n\n"); | |
| 693 | − exit(1); | |
| 694 | − } | |
| 695 | − if (conf_write_autoconf()) { | |
| 696 | − fprintf(stderr, "\n*** Error during update of the configuration.\n\n"); | |
| 697 | − return 1; | |
| 698 | − } | |
| 699 | − } else if (input_mode == savedefconfig) { | |
| 689 | + if (input_mode == savedefconfig) { | |
| 700 | 690 | if (conf_write_defconfig(defconfig_file)) { |
| 701 | 691 | fprintf(stderr, "n*** Error while saving defconfig to: %s\n\n", |
| 702 | 692 | defconfig_file); |
| 703 | 693 | return 1; |
| 704 | 694 | } |
| 705 | 695 | } else if (input_mode != listnewconfig) { |
| 706 | − if (conf_write(NULL)) { | |
| 696 | + if (!no_conf_write && conf_write(NULL)) { | |
| 707 | 697 | fprintf(stderr, "\n*** Error during writing of the configuration.\n\n"); |
| 708 | 698 | exit(1); |
| 709 | 699 | } |
| 700 | + | |
| 701 | + /* | |
| 702 | + * Create auto.conf if it does not exist. | |
| 703 | + * This prevents GNU Make 4.1 or older from emitting | |
| 704 | + * "include/config/auto.conf: No such file or directory" | |
| 705 | + * in the top-level Makefile | |
| 706 | + * | |
| 707 | + * syncconfig always creates or updates auto.conf because it is | |
| 708 | + * used during the build. | |
| 709 | + */ | |
| 710 | + if (conf_write_autoconf(sync_kconfig) && sync_kconfig) { | |
| 711 | + fprintf(stderr, | |
| 712 | + "\n*** Error during sync of the configuration.\n\n"); | |
| 713 | + return 1; | |
| 714 | + } | |
| 710 | 715 | } |
| 711 | 716 | return 0; |
| 712 | 717 | } |
| @@ -16,6 +16,64 @@ · 15 unmodified lines | ||
| 16 | 16 | |
| 17 | 17 | #include "lkc.h" |
| 18 | 18 | |
| 19 | +/* return true if 'path' exists, false otherwise */ | |
| 20 | +static bool is_present(const char *path) | |
| 21 | +{ | |
| 22 | + struct stat st; | |
| 23 | + | |
| 24 | + return !stat(path, &st); | |
| 25 | +} | |
| 26 | + | |
| 27 | +/* return true if 'path' exists and it is a directory, false otherwise */ | |
| 28 | +static bool is_dir(const char *path) | |
| 29 | +{ | |
| 30 | + struct stat st; | |
| 31 | + | |
| 32 | + if (stat(path, &st)) | |
| 33 | + return 0; | |
| 34 | + | |
| 35 | + return S_ISDIR(st.st_mode); | |
| 36 | +} | |
| 37 | + | |
| 38 | +/* | |
| 39 | + * Create the parent directory of the given path. | |
| 40 | + * | |
| 41 | + * For example, if 'include/config/auto.conf' is given, create 'include/config'. | |
| 42 | + */ | |
| 43 | +static int make_parent_dir(const char *path) | |
| 44 | +{ | |
| 45 | + char tmp[PATH_MAX + 1]; | |
| 46 | + char *p; | |
| 47 | + | |
| 48 | + strncpy(tmp, path, sizeof(tmp)); | |
| 49 | + tmp[sizeof(tmp) - 1] = 0; | |
| 50 | + | |
| 51 | + /* Remove the base name. Just return if nothing is left */ | |
| 52 | + p = strrchr(tmp, '/'); | |
| 53 | + if (!p) | |
| 54 | + return 0; | |
| 55 | + *(p + 1) = 0; | |
| 56 | + | |
| 57 | + /* Just in case it is an absolute path */ | |
| 58 | + p = tmp; | |
| 59 | + while (*p == '/') | |
| 60 | + p++; | |
| 61 | + | |
| 62 | + while ((p = strchr(p, '/'))) { | |
| 63 | + *p = 0; | |
| 64 | + | |
| 65 | + /* skip if the directory exists */ | |
| 66 | + if (!is_dir(tmp) && mkdir(tmp, 0755)) | |
| 67 | + return -1; | |
| 68 | + | |
| 69 | + *p = '/'; | |
| 70 | + while (*p == '/') | |
| 71 | + p++; | |
| 72 | + } | |
| 73 | + | |
| 74 | + return 0; | |
| 75 | +} | |
| 76 | + | |
| 19 | 77 | struct conf_printer { |
| 20 | 78 | void (*print_symbol)(FILE *, struct symbol *, const char *, void *); |
| 21 | 79 | void (*print_comment)(FILE *, const char *, void *); |
| @@ -43,16 +101,16 @@ static void conf_warning(const char *fmt, ...) · 21 unmodified lines | ||
| 43 | 101 | conf_warnings++; |
| 44 | 102 | } |
| 45 | 103 | |
| 46 | −static void conf_default_message_callback(const char *fmt, va_list ap) | |
| 104 | +static void conf_default_message_callback(const char *s) | |
| 47 | 105 | { |
| 48 | 106 | printf("#\n# "); |
| 49 | − vprintf(fmt, ap); | |
| 107 | + printf("%s", s); | |
| 50 | 108 | printf("\n#\n"); |
| 51 | 109 | } |
| 52 | 110 | |
| 53 | −static void (*conf_message_callback) (const char *fmt, va_list ap) = | |
| 111 | +static void (*conf_message_callback)(const char *s) = | |
| 54 | 112 | conf_default_message_callback; |
| 55 | −void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap)) | |
| 113 | +void conf_set_message_callback(void (*fn)(const char *s)) | |
| 56 | 114 | { |
| 57 | 115 | conf_message_callback = fn; |
| 58 | 116 | } |
| @@ -60,10 +118,15 @@ void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap)) · 1 unmodified line | ||
| 60 | 118 | static void conf_message(const char *fmt, ...) |
| 61 | 119 | { |
| 62 | 120 | va_list ap; |
| 121 | + char buf[4096]; | |
| 122 | + | |
| 123 | + if (!conf_message_callback) | |
| 124 | + return; | |
| 63 | 125 | |
| 64 | 126 | va_start(ap, fmt); |
| 65 | − if (conf_message_callback) | |
| 66 | − conf_message_callback(fmt, ap); | |
| 127 | + | |
| 128 | + vsnprintf(buf, sizeof(buf), fmt, ap); | |
| 129 | + conf_message_callback(buf); | |
| 67 | 130 | va_end(ap); |
| 68 | 131 | } |
| 69 | 132 | |
| @@ -83,7 +146,6 @@ const char *conf_get_autoconfig_name(void) · 13 unmodified lines | ||
| 83 | 146 | |
| 84 | 147 | char *conf_get_default_confname(void) |
| 85 | 148 | { |
| 86 | − struct stat buf; | |
| 87 | 149 | static char fullname[PATH_MAX+1]; |
| 88 | 150 | char *env, *name; |
| 89 | 151 | |
| @@ -91,7 +153,7 @@ char *conf_get_default_confname(void) · 1 unmodified line | ||
| 91 | 153 | env = getenv(SRCTREE); |
| 92 | 154 | if (env) { |
| 93 | 155 | sprintf(fullname, "%s/%s", env, name); |
| 94 | − if (!stat(fullname, &buf)) | |
| 156 | + if (is_present(fullname)) | |
| 95 | 157 | return fullname; |
| 96 | 158 | } |
| 97 | 159 | return name; |
| @@ -397,7 +459,7 @@ int conf_read(const char *name) · 299 unmodified lines | ||
| 397 | 459 | |
| 398 | 460 | for_all_symbols(i, sym) { |
| 399 | 461 | sym_calc_value(sym); |
| 400 | − if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO)) | |
| 462 | + if (sym_is_choice(sym) || (sym->flags & SYMBOL_NO_WRITE)) | |
| 401 | 463 | continue; |
| 402 | 464 | if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) { |
| 403 | 465 | /* check that calculated value agrees with saved value */ |
| @@ -725,10 +787,9 @@ int conf_write(const char *name) · 321 unmodified lines | ||
| 725 | 787 | |
| 726 | 788 | dirname[0] = 0; |
| 727 | 789 | if (name && name[0]) { |
| 728 | − struct stat st; | |
| 729 | 790 | char *slash; |
| 730 | 791 | |
| 731 | − if (!stat(name, &st) && S_ISDIR(st.st_mode)) { | |
| 792 | + if (is_dir(name)) { | |
| 732 | 793 | strcpy(dirname, name); |
| 733 | 794 | strcat(dirname, "/"); |
| 734 | 795 | basename = conf_get_configname(); |
| @@ -813,26 +874,59 @@ next: · 78 unmodified lines | ||
| 813 | 874 | return 0; |
| 814 | 875 | } |
| 815 | 876 | |
| 877 | +/* write a dependency file as used by kbuild to track dependencies */ | |
| 878 | +static int conf_write_dep(const char *name) | |
| 879 | +{ | |
| 880 | + struct file *file; | |
| 881 | + FILE *out; | |
| 882 | + | |
| 883 | + if (!name) | |
| 884 | + name = ".kconfig.d"; | |
| 885 | + out = fopen("..config.tmp", "w"); | |
| 886 | + if (!out) | |
| 887 | + return 1; | |
| 888 | + fprintf(out, "deps_config := \\\n"); | |
| 889 | + for (file = file_list; file; file = file->next) { | |
| 890 | + if (file->next) | |
| 891 | + fprintf(out, "\t%s \\\n", file->name); | |
| 892 | + else | |
| 893 | + fprintf(out, "\t%s\n", file->name); | |
| 894 | + } | |
| 895 | + fprintf(out, "\n%s: \\\n" | |
| 896 | + "\t$(deps_config)\n\n", conf_get_autoconfig_name()); | |
| 897 | + | |
| 898 | + env_write_dep(out, conf_get_autoconfig_name()); | |
| 899 | + | |
| 900 | + fprintf(out, "\n$(deps_config): ;\n"); | |
| 901 | + fclose(out); | |
| 902 | + | |
| 903 | + if (make_parent_dir(name)) | |
| 904 | + return 1; | |
| 905 | + rename("..config.tmp", name); | |
| 906 | + return 0; | |
| 907 | +} | |
| 908 | + | |
| 816 | 909 | static int conf_split_config(void) |
| 817 | 910 | { |
| 818 | 911 | const char *name; |
| 819 | 912 | char path[PATH_MAX+1]; |
| 820 | 913 | char *s, *d, c; |
| 821 | 914 | struct symbol *sym; |
| 822 | − struct stat sb; | |
| 823 | 915 | int res, i, fd; |
| 824 | 916 | |
| 825 | 917 | name = conf_get_autoconfig_name(); |
| 826 | 918 | conf_read_simple(name, S_DEF_AUTO); |
| 827 | 919 | sym_calc_value(modules_sym); |
| 828 | 920 | |
| 921 | + if (make_parent_dir("include/config/foo.h")) | |
| 922 | + return 1; | |
| 829 | 923 | if (chdir("include/config")) |
| 830 | 924 | return 1; |
| 831 | 925 | |
| 832 | 926 | res = 0; |
| 833 | 927 | for_all_symbols(i, sym) { |
| 834 | 928 | sym_calc_value(sym); |
| 835 | − if ((sym->flags & SYMBOL_AUTO) || !sym->name) | |
| 929 | + if ((sym->flags & SYMBOL_NO_WRITE) || !sym->name) | |
| 836 | 930 | continue; |
| 837 | 931 | if (sym->flags & SYMBOL_WRITE) { |
| 838 | 932 | if (sym->flags & SYMBOL_DEF_AUTO) { |
| @@ -897,19 +991,12 @@ static int conf_split_config(void) · 58 unmodified lines | ||
| 897 | 991 | res = 1; |
| 898 | 992 | break; |
| 899 | 993 | } |
| 900 | − /* | |
| 901 | − * Create directory components, | |
| 902 | − * unless they exist already. | |
| 903 | − */ | |
| 904 | − d = path; | |
| 905 | − while ((d = strchr(d, '/'))) { | |
| 906 | − *d = 0; | |
| 907 | − if (stat(path, &sb) && mkdir(path, 0755)) { | |
| 908 | − res = 1; | |
| 909 | − goto out; | |
| 910 | − } | |
| 911 | − *d++ = '/'; | |
| 994 | + | |
| 995 | + if (make_parent_dir(path)) { | |
| 996 | + res = 1; | |
| 997 | + goto out; | |
| 912 | 998 | } |
| 999 | + | |
| 913 | 1000 | /* Try it again. */ |
| 914 | 1001 | fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); |
| 915 | 1002 | if (fd == -1) { |
| @@ -926,16 +1013,20 @@ out: · 10 unmodified lines | ||
| 926 | 1013 | return res; |
| 927 | 1014 | } |
| 928 | 1015 | |
| 929 | −int conf_write_autoconf(void) | |
| 1016 | +int conf_write_autoconf(int overwrite) | |
| 930 | 1017 | { |
| 931 | 1018 | struct symbol *sym; |
| 932 | 1019 | const char *name; |
| 1020 | + const char *autoconf_name = conf_get_autoconfig_name(); | |
| 933 | 1021 | FILE *out, *tristate, *out_h; |
| 934 | 1022 | int i; |
| 935 | 1023 | |
| 1024 | + if (!overwrite && is_present(autoconf_name)) | |
| 1025 | + return 0; | |
| 1026 | + | |
| 936 | 1027 | sym_clear_all_valid(); |
| 937 | 1028 | |
| 938 | − file_write_dep("include/config/auto.conf.cmd"); | |
| 1029 | + conf_write_dep("include/config/auto.conf.cmd"); | |
| 939 | 1030 | |
| 940 | 1031 | if (conf_split_config()) |
| 941 | 1032 | return 1; |
| @@ -982,19 +1073,26 @@ int conf_write_autoconf(void) · 40 unmodified lines | ||
| 982 | 1073 | name = getenv("KCONFIG_AUTOHEADER"); |
| 983 | 1074 | if (!name) |
| 984 | 1075 | name = "include/generated/autoconf.h"; |
| 1076 | + if (make_parent_dir(name)) | |
| 1077 | + return 1; | |
| 985 | 1078 | if (rename(".tmpconfig.h", name)) |
| 986 | 1079 | return 1; |
| 1080 | + | |
| 987 | 1081 | name = getenv("KCONFIG_TRISTATE"); |
| 988 | 1082 | if (!name) |
| 989 | 1083 | name = "include/config/tristate.conf"; |
| 1084 | + if (make_parent_dir(name)) | |
| 1085 | + return 1; | |
| 990 | 1086 | if (rename(".tmpconfig_tristate", name)) |
| 991 | 1087 | return 1; |
| 992 | − name = conf_get_autoconfig_name(); | |
| 1088 | + | |
| 1089 | + if (make_parent_dir(autoconf_name)) | |
| 1090 | + return 1; | |
| 993 | 1091 | /* |
| 994 | 1092 | * This must be the last step, kbuild has a dependency on auto.conf |
| 995 | 1093 | * and this marks the successful completion of the previous steps. |
| 996 | 1094 | */ |
| 997 | − if (rename(".tmpconfig", name)) | |
| 1095 | + if (rename(".tmpconfig", autoconf_name)) | |
| 998 | 1096 | return 1; |
| 999 | 1097 | |
| 1000 | 1098 | return 0; |
| @@ -141,7 +141,7 @@ struct symbol { · 140 unmodified lines | ||
| 141 | 141 | #define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */ |
| 142 | 142 | #define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */ |
| 143 | 143 | #define SYMBOL_CHANGED 0x0400 /* ? */ |
| 144 | −#define SYMBOL_AUTO 0x1000 /* value from environment variable */ | |
| 144 | +#define SYMBOL_NO_WRITE 0x1000 /* Symbol for internal use only; it will not be written */ | |
| 145 | 145 | #define SYMBOL_CHECKED 0x2000 /* used during dependency checking */ |
| 146 | 146 | #define SYMBOL_WARNED 0x8000 /* warning has been issued */ |
| 147 | 147 | |
| @@ -185,7 +185,6 @@ enum prop_type { · 37 unmodified lines | ||
| 185 | 185 | P_SELECT, /* select BAR */ |
| 186 | 186 | P_IMPLY, /* imply BAR */ |
| 187 | 187 | P_RANGE, /* range 7..100 (for a symbol) */ |
| 188 | − P_ENV, /* value from environment variable */ | |
| 189 | 188 | P_SYMBOL, /* where a symbol is defined */ |
| 190 | 189 | }; |
| 191 | 190 | |
| @@ -101,8 +101,8 @@ const char *dbg_sym_flags(int val) · 100 unmodified lines | ||
| 101 | 101 | strcat(buf, "write/"); |
| 102 | 102 | if (val & SYMBOL_CHANGED) |
| 103 | 103 | strcat(buf, "changed/"); |
| 104 | − if (val & SYMBOL_AUTO) | |
| 105 | − strcat(buf, "auto/"); | |
| 104 | + if (val & SYMBOL_NO_WRITE) | |
| 105 | + strcat(buf, "no_write/"); | |
| 106 | 106 | |
| 107 | 107 | buf[strlen(buf) - 1] = '\0'; |
| 108 | 108 | |
| @@ -525,6 +525,7 @@ void on_save_activate(GtkMenuItem * menuitem, gpointer user_data) · 416 unmodified lines | ||
| 525 | 525 | { |
| 526 | 526 | if (conf_write(NULL)) |
| 527 | 527 | text_insert_msg("Error", "Unable to save configuration !"); |
| 528 | + conf_write_autoconf(0); | |
| 528 | 529 | } |
| 529 | 530 | |
| 530 | 531 | |
| @@ -97,7 +97,6 @@ void menu_set_type(int type); · 96 unmodified lines | ||
| 97 | 97 | |
| 98 | 98 | /* util.c */ |
| 99 | 99 | struct file *file_lookup(const char *name); |
| 100 | −int file_write_dep(const char *name); | |
| 101 | 100 | void *xmalloc(size_t size); |
| 102 | 101 | void *xcalloc(size_t nmemb, size_t size); |
| 103 | 102 | void *xrealloc(void *p, size_t size); |
| @@ -126,7 +125,6 @@ const char *sym_get_string_default(struct symbol *sym); · 22 unmodified lines | ||
| 126 | 125 | struct symbol *sym_check_deps(struct symbol *sym); |
| 127 | 126 | struct property *prop_alloc(enum prop_type type, struct symbol *sym); |
| 128 | 127 | struct symbol *prop_get_symbol(struct property *prop); |
| 129 | −struct property *sym_get_env_prop(struct symbol *sym); | |
| 130 | 128 | |
| 131 | 129 | static inline tristate sym_get_tristate_value(struct symbol *sym) |
| 132 | 130 | { |
| @@ -7,10 +7,10 @@ int conf_read(const char *name); · 6 unmodified lines | ||
| 7 | 7 | int conf_read_simple(const char *name, int); |
| 8 | 8 | int conf_write_defconfig(const char *name); |
| 9 | 9 | int conf_write(const char *name); |
| 10 | −int conf_write_autoconf(void); | |
| 10 | +int conf_write_autoconf(int overwrite); | |
| 11 | 11 | bool conf_get_changed(void); |
| 12 | 12 | void conf_set_changed_callback(void (*fn)(void)); |
| 13 | −void conf_set_message_callback(void (*fn)(const char *fmt, va_list ap)); | |
| 13 | +void conf_set_message_callback(void (*fn)(const char *s)); | |
| 14 | 14 | |
| 15 | 15 | /* menu.c */ |
| 16 | 16 | extern struct menu rootmenu; |
| @@ -772,16 +772,13 @@ static void show_helptext(const char *title, const char *text) · 771 unmodified lines | ||
| 772 | 772 | show_textbox(title, text, 0, 0); |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | −static void conf_message_callback(const char *fmt, va_list ap) | |
| 775 | +static void conf_message_callback(const char *s) | |
| 776 | 776 | { |
| 777 | − char buf[PATH_MAX+1]; | |
| 778 | − | |
| 779 | − vsnprintf(buf, sizeof(buf), fmt, ap); | |
| 780 | 777 | if (save_and_exit) { |
| 781 | 778 | if (!silent) |
| 782 | − printf("%s", buf); | |
| 779 | + printf("%s", s); | |
| 783 | 780 | } else { |
| 784 | − show_textbox(NULL, buf, 6, 60); | |
| 781 | + show_textbox(NULL, s, 6, 60); | |
| 785 | 782 | } |
| 786 | 783 | } |
| 787 | 784 | |
| @@ -977,6 +974,7 @@ static int handle_exit(void) · 189 unmodified lines | ||
| 977 | 974 | "\n\n"); |
| 978 | 975 | return 1; |
| 979 | 976 | } |
| 977 | + conf_write_autoconf(0); | |
| 980 | 978 | /* fall through */ |
| 981 | 979 | case -1: |
| 982 | 980 | if (!silent) |
| @@ -212,7 +212,7 @@ void menu_add_option(int token, char *arg) · 211 unmodified lines | ||
| 212 | 212 | sym_defconfig_list = current_entry->sym; |
| 213 | 213 | else if (sym_defconfig_list != current_entry->sym) |
| 214 | 214 | zconf_error("trying to redefine defconfig symbol"); |
| 215 | − sym_defconfig_list->flags |= SYMBOL_AUTO; | |
| 215 | + sym_defconfig_list->flags |= SYMBOL_NO_WRITE; | |
| 216 | 216 | break; |
| 217 | 217 | case T_OPT_ALLNOCONFIG_Y: |
| 218 | 218 | current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y; |
| @@ -674,6 +674,7 @@ static int do_exit(void) · 673 unmodified lines | ||
| 674 | 674 | "Your configuration changes were NOT saved.", |
| 675 | 675 | 1, |
| 676 | 676 | "<OK>"); |
| 677 | + conf_write_autoconf(0); | |
| 677 | 678 | break; |
| 678 | 679 | default: |
| 679 | 680 | btn_dialog( |
| @@ -1210,12 +1211,9 @@ static void conf(struct menu *menu) · 530 unmodified lines | ||
| 1210 | 1211 | } |
| 1211 | 1212 | } |
| 1212 | 1213 | |
| 1213 | −static void conf_message_callback(const char *fmt, va_list ap) | |
| 1214 | +static void conf_message_callback(const char *s) | |
| 1214 | 1215 | { |
| 1215 | − char buf[1024]; | |
| 1216 | − | |
| 1217 | − vsnprintf(buf, sizeof(buf), fmt, ap); | |
| 1218 | − btn_dialog(main_window, buf, 1, "<OK>"); | |
| 1216 | + btn_dialog(main_window, s, 1, "<OK>"); | |
| 1219 | 1217 | } |
| 1220 | 1218 | |
| 1221 | 1219 | static void show_help(struct menu *menu) |
| @@ -1149,7 +1149,6 @@ QString ConfigInfoView::debug_info(struct symbol *sym) · 1148 unmodified lines | ||
| 1149 | 1149 | case P_DEFAULT: |
| 1150 | 1150 | case P_SELECT: |
| 1151 | 1151 | case P_RANGE: |
| 1152 | − case P_ENV: | |
| 1153 | 1152 | debug += prop_get_type_name(prop->type); |
| 1154 | 1153 | debug += ": "; |
| 1155 | 1154 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); |
| @@ -1535,6 +1534,8 @@ bool ConfigMainWindow::saveConfig(void) · 379 unmodified lines | ||
| 1535 | 1534 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); |
| 1536 | 1535 | return false; |
| 1537 | 1536 | } |
| 1537 | + conf_write_autoconf(0); | |
| 1538 | + | |
| 1538 | 1539 | return true; |
| 1539 | 1540 | } |
| 1540 | 1541 | |
| @@ -76,15 +76,6 @@ struct property *sym_get_choice_prop(struct symbol *sym) · 75 unmodified lines | ||
| 76 | 76 | return NULL; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | −struct property *sym_get_env_prop(struct symbol *sym) | |
| 80 | −{ | |
| 81 | − struct property *prop; | |
| 82 | − | |
| 83 | − for_all_properties(sym, prop, P_ENV) | |
| 84 | − return prop; | |
| 85 | − return NULL; | |
| 86 | −} | |
| 87 | − | |
| 88 | 79 | static struct property *sym_get_default_prop(struct symbol *sym) |
| 89 | 80 | { |
| 90 | 81 | struct property *prop; |
| @@ -463,7 +454,7 @@ void sym_calc_value(struct symbol *sym) · 372 unmodified lines | ||
| 463 | 454 | } |
| 464 | 455 | } |
| 465 | 456 | |
| 466 | − if (sym->flags & SYMBOL_AUTO) | |
| 457 | + if (sym->flags & SYMBOL_NO_WRITE) | |
| 467 | 458 | sym->flags &= ~SYMBOL_WRITE; |
| 468 | 459 | |
| 469 | 460 | if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) |
| @@ -1298,8 +1289,6 @@ const char *prop_get_type_name(enum prop_type type) · 828 unmodified lines | ||
| 1298 | 1289 | switch (type) { |
| 1299 | 1290 | case P_PROMPT: |
| 1300 | 1291 | return "prompt"; |
| 1301 | − case P_ENV: | |
| 1302 | − return "env"; | |
| 1303 | 1292 | case P_COMMENT: |
| 1304 | 1293 | return "comment"; |
| 1305 | 1294 | case P_MENU: |
| @@ -29,36 +29,6 @@ struct file *file_lookup(const char *name) · 28 unmodified lines | ||
| 29 | 29 | return file; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | −/* write a dependency file as used by kbuild to track dependencies */ | |
| 33 | −int file_write_dep(const char *name) | |
| 34 | −{ | |
| 35 | − struct file *file; | |
| 36 | − FILE *out; | |
| 37 | − | |
| 38 | − if (!name) | |
| 39 | − name = ".kconfig.d"; | |
| 40 | − out = fopen("..config.tmp", "w"); | |
| 41 | − if (!out) | |
| 42 | − return 1; | |
| 43 | − fprintf(out, "deps_config := \\\n"); | |
| 44 | − for (file = file_list; file; file = file->next) { | |
| 45 | − if (file->next) | |
| 46 | − fprintf(out, "\t%s \\\n", file->name); | |
| 47 | − else | |
| 48 | − fprintf(out, "\t%s\n", file->name); | |
| 49 | − } | |
| 50 | − fprintf(out, "\n%s: \\\n" | |
| 51 | − "\t$(deps_config)\n\n", conf_get_autoconfig_name()); | |
| 52 | − | |
| 53 | − env_write_dep(out, conf_get_autoconfig_name()); | |
| 54 | − | |
| 55 | − fprintf(out, "\n$(deps_config): ;\n"); | |
| 56 | − fclose(out); | |
| 57 | − rename("..config.tmp", name); | |
| 58 | − return 0; | |
| 59 | −} | |
| 60 | − | |
| 61 | − | |
| 62 | 32 | /* Allocate initial growable string */ |
| 63 | 33 | struct gstr str_new(void) |
| 64 | 34 | { |
| @@ -31,7 +31,7 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE]; · 30 unmodified lines | ||
| 31 | 31 | static struct menu *current_menu, *current_entry; |
| 32 | 32 | |
| 33 | 33 | %} |
| 34 | −%expect 31 | |
| 34 | +%expect 30 | |
| 35 | 35 | |
| 36 | 36 | %union |
| 37 | 37 | { |
| @@ -117,7 +117,7 @@ start: mainmenu_stmt stmt_list | stmt_list; · 79 unmodified lines | ||
| 117 | 117 | |
| 118 | 118 | /* mainmenu entry */ |
| 119 | 119 | |
| 120 | −mainmenu_stmt: T_MAINMENU prompt nl | |
| 120 | +mainmenu_stmt: T_MAINMENU prompt T_EOL | |
| 121 | 121 | { |
| 122 | 122 | menu_add_prompt(P_MENU, $2, NULL); |
| 123 | 123 | }; |
| @@ -265,7 +265,7 @@ symbol_option_arg: · 141 unmodified lines | ||
| 265 | 265 | choice: T_CHOICE word_opt T_EOL |
| 266 | 266 | { |
| 267 | 267 | struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE); |
| 268 | − sym->flags |= SYMBOL_AUTO; | |
| 268 | + sym->flags |= SYMBOL_NO_WRITE; | |
| 269 | 269 | menu_add_entry(sym); |
| 270 | 270 | menu_add_expr(P_CHOICE, NULL, NULL); |
| 271 | 271 | free($2); |