From 9903ea1c1102dc41f6bd765e12629d66f1e5d2f5 Mon Sep 17 00:00:00 2001 From: Deomid Ryabkov Date: Sat, 3 Dec 2016 22:11:22 +0000 Subject: [PATCH 1/4] Add --warn-undefined-variables to MAKEFLAGS Fix warnings where undefined vars are used. Make Kconfig emit "FOO=" for unset bool options To ensure make variables are always defined, even if empty. When writing auto.conf, include symbols disabled by dependency to make sure all make variables are always defined. Fixes espressif/esp-idf#137 Cherry-picked from https://github.com/espressif/esp-idf/pull/138 --- components/app_trace/component.mk | 2 +- components/aws_iot/component.mk | 2 +- components/bootloader/Makefile.projbuild | 3 +- .../bootloader/subproject/main/component.mk | 2 +- components/bootloader_support/component.mk | 4 +-- components/bt/component.mk | 4 +-- components/esp32/Kconfig | 2 +- components/esp32/component.mk | 7 ++-- components/esptool_py/Makefile.projbuild | 2 ++ components/freertos/component.mk | 2 +- components/lwip/component.mk | 4 ++- components/newlib/component.mk | 3 +- .../subscribe_publish/main/component.mk | 2 +- .../aws_iot/thing_shadow/main/component.mk | 2 +- make/common.mk | 3 +- make/component_wrapper.mk | 12 ++++++- make/project.mk | 31 ++++++++++++++--- make/project_config.mk | 10 +++--- tools/kconfig/.gitignore | 1 + tools/kconfig/Makefile | 7 ++-- tools/kconfig/confdata.c | 33 +++++++++---------- 21 files changed, 89 insertions(+), 49 deletions(-) diff --git a/components/app_trace/component.mk b/components/app_trace/component.mk index 235f19831..7a1f39759 100644 --- a/components/app_trace/component.mk +++ b/components/app_trace/component.mk @@ -8,7 +8,7 @@ COMPONENT_ADD_INCLUDEDIRS := include COMPONENT_ADD_LDFLAGS := -lapp_trace -ifdef CONFIG_SYSVIEW_ENABLE +ifeq ("$(CONFIG_SYSVIEW_ENABLE)","y") #COMPONENT_EXTRA_INCLUDES := freertos COMPONENT_ADD_INCLUDEDIRS += \ diff --git a/components/aws_iot/component.mk b/components/aws_iot/component.mk index cd1b15eee..aab25a71f 100644 --- a/components/aws_iot/component.mk +++ b/components/aws_iot/component.mk @@ -2,7 +2,7 @@ # Component Makefile # -ifdef CONFIG_AWS_IOT_SDK +ifeq ("$(CONFIG_AWS_IOT_SDK)","y") COMPONENT_ADD_INCLUDEDIRS := include aws-iot-device-sdk-embedded-C/include diff --git a/components/bootloader/Makefile.projbuild b/components/bootloader/Makefile.projbuild index 7a35dc8ad..db7f4f0a2 100644 --- a/components/bootloader/Makefile.projbuild +++ b/components/bootloader/Makefile.projbuild @@ -13,6 +13,7 @@ BOOTLOADER_BUILD_DIR=$(abspath $(BUILD_DIR_BASE)/bootloader) BOOTLOADER_BIN=$(BOOTLOADER_BUILD_DIR)/bootloader.bin # signing key path is resolved relative to the project directory +CONFIG_SECURE_BOOT_SIGNING_KEY ?= SECURE_BOOT_SIGNING_KEY=$(abspath $(call dequote,$(CONFIG_SECURE_BOOT_SIGNING_KEY))) export SECURE_BOOT_SIGNING_KEY # used by bootloader_support component @@ -107,7 +108,7 @@ $(BOOTLOADER_DIGEST_BIN): $(BOOTLOADER_BIN) $(SECURE_BOOTLOADER_KEY) @echo "DIGEST $(notdir $@)" $(Q) $(ESPSECUREPY) digest_secure_bootloader -k $(SECURE_BOOTLOADER_KEY) -o $@ $< -else +else # CONFIG_SECURE_BOOT_ENABLED && !CONFIG_SECURE_BOOTLOADER_REFLASHABLE && !CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH bootloader: @echo "Invalid bootloader target: bad sdkconfig?" @exit 1 diff --git a/components/bootloader/subproject/main/component.mk b/components/bootloader/subproject/main/component.mk index a54fe30a9..633051cb6 100644 --- a/components/bootloader/subproject/main/component.mk +++ b/components/bootloader/subproject/main/component.mk @@ -12,7 +12,7 @@ LINKER_SCRIPTS := \ $(IDF_PATH)/components/esp32/ld/esp32.peripherals.ld \ esp32.bootloader.rom.ld -ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH +ifneq ("$(CONFIG_SPI_FLASH_ROM_DRIVER_PATCH)","y") LINKER_SCRIPTS += $(IDF_PATH)/components/esp32/ld/esp32.rom.spiflash.ld endif diff --git a/components/bootloader_support/component.mk b/components/bootloader_support/component.mk index 6db815aff..8ad21d3b9 100755 --- a/components/bootloader_support/component.mk +++ b/components/bootloader_support/component.mk @@ -12,12 +12,12 @@ COMPONENT_SRCDIRS := src # # Secure boot signing key support # -ifdef CONFIG_SECURE_BOOT_ENABLED +ifneq ("$(CONFIG_SECURE_BOOT_ENABLED)","") # this path is created relative to the component build directory SECURE_BOOT_VERIFICATION_KEY := $(abspath signature_verification_key.bin) -ifdef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES +ifneq ("$(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)","") # verification key derived from signing key. $(SECURE_BOOT_VERIFICATION_KEY): $(SECURE_BOOT_SIGNING_KEY) $(SDKCONFIG_MAKEFILE) $(ESPSECUREPY) extract_public_key --keyfile $< $@ diff --git a/components/bt/component.mk b/components/bt/component.mk index 8f6ce29d5..86fddc8c1 100644 --- a/components/bt/component.mk +++ b/components/bt/component.mk @@ -1,7 +1,7 @@ # # Component Makefile # -ifdef CONFIG_BT_ENABLED +ifneq ("$(CONFIG_BT_ENABLED)","") COMPONENT_SRCDIRS := . @@ -20,7 +20,7 @@ COMPONENT_SUBMODULES += lib endif -ifdef CONFIG_BLUEDROID_ENABLED +ifeq ("$(CONFIG_BLUEDROID_ENABLED)","y") COMPONENT_ADD_INCLUDEDIRS += bluedroid/bta/include \ bluedroid/bta/sys/include \ diff --git a/components/esp32/Kconfig b/components/esp32/Kconfig index 86932c3bf..837a73afa 100644 --- a/components/esp32/Kconfig +++ b/components/esp32/Kconfig @@ -846,7 +846,7 @@ config ESP32_WIFI_NVS_ENABLED endmenu # Wi-Fi -menu Phy +menu PHY config ESP32_PHY_CALIBRATION_AND_DATA_STORAGE bool "Do phy calibration and store calibration data in NVS" diff --git a/components/esp32/component.mk b/components/esp32/component.mk index a8cd8606c..a151f8129 100644 --- a/components/esp32/component.mk +++ b/components/esp32/component.mk @@ -3,8 +3,9 @@ # COMPONENT_SRCDIRS := . hwcrypto -ifndef CONFIG_NO_BLOBS -LIBS := core rtc net80211 pp wpa smartconfig coexist wps wpa2 phy +LIBS ?= +ifneq ("$(CONFIG_NO_BLOBS)","y") +LIBS += core rtc net80211 pp wpa smartconfig coexist wps wpa2 phy endif #Linker scripts used to link the final application. @@ -22,7 +23,7 @@ ifeq ("$(CONFIG_NEWLIB_NANO_FORMAT)","y") LINKER_SCRIPTS += esp32.rom.nanofmt.ld endif -ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH +ifneq ("$(CONFIG_SPI_FLASH_ROM_DRIVER_PATCH)","y") LINKER_SCRIPTS += esp32.rom.spiflash.ld endif diff --git a/components/esptool_py/Makefile.projbuild b/components/esptool_py/Makefile.projbuild index b35dc1112..dce6b0af2 100644 --- a/components/esptool_py/Makefile.projbuild +++ b/components/esptool_py/Makefile.projbuild @@ -6,6 +6,8 @@ ESPFLASHMODE ?= $(CONFIG_ESPTOOLPY_FLASHMODE) ESPFLASHFREQ ?= $(CONFIG_ESPTOOLPY_FLASHFREQ) ESPFLASHSIZE ?= $(CONFIG_ESPTOOLPY_FLASHSIZE) +CONFIG_ESPTOOLPY_COMPRESSED ?= + PYTHON ?= $(call dequote,$(CONFIG_PYTHON)) # two commands that can be used from other components diff --git a/components/freertos/component.mk b/components/freertos/component.mk index 4496355a0..88be5b8f6 100644 --- a/components/freertos/component.mk +++ b/components/freertos/component.mk @@ -6,6 +6,6 @@ COMPONENT_ADD_LDFLAGS += -Wl,--undefined=uxTopUsedPriority COMPONENT_ADD_INCLUDEDIRS := include COMPONENT_PRIV_INCLUDEDIRS := include/freertos -#ifdef CONFIG_SYSVIEW_ENABLE +#ifeq ("$(CONFIG_SYSVIEW_ENABLE)","y") #COMPONENT_ADD_INCLUDEDIRS += app_trace #endif diff --git a/components/lwip/component.mk b/components/lwip/component.mk index 204e94fa7..921cc5916 100644 --- a/components/lwip/component.mk +++ b/components/lwip/component.mk @@ -8,8 +8,10 @@ COMPONENT_ADD_INCLUDEDIRS := \ include/lwip/posix \ apps/ping -ifdef CONFIG_PPP_SUPPORT +ifeq ("$(CONFIG_PPP_SUPPORT)","y") LWIP_PPP_DIRS := netif/ppp/polarssl netif/ppp +else +LWIP_PPP_DIRS := endif COMPONENT_SRCDIRS := \ diff --git a/components/newlib/component.mk b/components/newlib/component.mk index 0bf6275bf..ce5799dfb 100644 --- a/components/newlib/component.mk +++ b/components/newlib/component.mk @@ -1,5 +1,4 @@ - ifeq ("$(CONFIG_SPIRAM_CACHE_WORKAROUND)","y") LIBC_PATH := $(COMPONENT_PATH)/lib/libc-psram-workaround.a LIBM_PATH := $(COMPONENT_PATH)/lib/libm-psram-workaround.a @@ -14,7 +13,7 @@ endif LIBM_PATH := $(COMPONENT_PATH)/lib/libm.a -endif +endif # CONFIG_SPIRAM_CACHE_WORKAROUND COMPONENT_ADD_LDFLAGS := $(LIBC_PATH) $(LIBM_PATH) -lnewlib diff --git a/examples/protocols/aws_iot/subscribe_publish/main/component.mk b/examples/protocols/aws_iot/subscribe_publish/main/component.mk index bc11b6393..1ed56547c 100644 --- a/examples/protocols/aws_iot/subscribe_publish/main/component.mk +++ b/examples/protocols/aws_iot/subscribe_publish/main/component.mk @@ -2,7 +2,7 @@ # Main Makefile. This is basically the same as a component makefile. # -ifdef CONFIG_EXAMPLE_EMBEDDED_CERTS +ifeq ("$(CONFIG_EXAMPLE_EMBEDDED_CERTS)","y") # Certificate files. certificate.pem.crt & private.pem.key must be downloaded # from AWS, see README for details. COMPONENT_EMBED_TXTFILES := certs/aws-root-ca.pem certs/certificate.pem.crt certs/private.pem.key diff --git a/examples/protocols/aws_iot/thing_shadow/main/component.mk b/examples/protocols/aws_iot/thing_shadow/main/component.mk index bc11b6393..1ed56547c 100644 --- a/examples/protocols/aws_iot/thing_shadow/main/component.mk +++ b/examples/protocols/aws_iot/thing_shadow/main/component.mk @@ -2,7 +2,7 @@ # Main Makefile. This is basically the same as a component makefile. # -ifdef CONFIG_EXAMPLE_EMBEDDED_CERTS +ifeq ("$(CONFIG_EXAMPLE_EMBEDDED_CERTS)","y") # Certificate files. certificate.pem.crt & private.pem.key must be downloaded # from AWS, see README for details. COMPONENT_EMBED_TXTFILES := certs/aws-root-ca.pem certs/certificate.pem.crt certs/private.pem.key diff --git a/make/common.mk b/make/common.mk index 82652e63d..358c88088 100644 --- a/make/common.mk +++ b/make/common.mk @@ -19,6 +19,7 @@ endif # # if V=1, $(summary) does nothing and $(details) will echo extra details # if V is unset or not 1, $(summary) echoes a summary and $(details) does nothing +VERBOSE ?= V ?= $(VERBOSE) ifeq ("$(V)","1") summary := @true @@ -28,7 +29,7 @@ summary := @echo details := @true # disable echoing of commands, directory names -MAKEFLAGS += --silent +MAKEFLAGS += --silent --warn-undefined-variables endif # General make utilities diff --git a/make/component_wrapper.mk b/make/component_wrapper.mk index f9bdec672..618466877 100644 --- a/make/component_wrapper.mk +++ b/make/component_wrapper.mk @@ -63,6 +63,13 @@ define compile_only_if_not $(eval $(if $(1), $(call compile_exclude, $(2)), $(call compile_include, $(2)))) endef +COMPONENT_ADD_LINKER_DEPS ?= +COMPONENT_DEPENDS ?= +COMPONENT_EXTRA_CLEAN ?= +COMPONENT_EXTRA_INCLUDES ?= +COMPONENT_OBJEXCLUDE ?= +COMPONENT_OBJINCLUDE ?= +COMPONENT_SUBMODULES ?= ################################################################################ # 2) Include the component.mk for the specific component (COMPONENT_MAKEFILE) to @@ -105,6 +112,7 @@ COMPONENT_EMBED_OBJS ?= $(addsuffix .bin.o,$(notdir $(COMPONENT_EMBED_FILES))) $ # variable with all the include dirs from all the components in random order. This # means we can accidentally grab a header from another component before grabbing our own. # To make sure that does not happen, re-order the includes so ours come first. +COMPONENT_PRIV_INCLUDEDIRS ?= OWN_INCLUDES:=$(abspath $(addprefix $(COMPONENT_PATH)/,$(COMPONENT_PRIV_INCLUDEDIRS) $(COMPONENT_ADD_INCLUDEDIRS))) COMPONENT_INCLUDES := $(OWN_INCLUDES) $(filter-out $(OWN_INCLUDES),$(COMPONENT_INCLUDES)) @@ -139,7 +147,7 @@ endef # component-specific feature, please don't! What you want is a # Makefile.projbuild for your component (see docs/build-system.rst for # more.) -component_project_vars.mk:: +component_project_vars.mk: $(details) "Building component project variables list $(abspath $@)" @echo '# Automatically generated build file. Do not edit.' > $@ @echo 'COMPONENT_INCLUDES += $(call MakeVariablePath,$(addprefix $(COMPONENT_PATH)/,$(COMPONENT_ADD_INCLUDEDIRS)))' >> $@ @@ -178,6 +186,8 @@ clean: rm -f $(CLEAN_FILES) endif +DEBUG_FLAGS ?= -ggdb + # Include all dependency files already generated -include $(COMPONENT_OBJS:.o=.d) diff --git a/make/project.mk b/make/project.mk index d22a1b1dd..31635d41d 100644 --- a/make/project.mk +++ b/make/project.mk @@ -56,6 +56,7 @@ $(error esp-idf build system doesn't support running 'clean' targets along with endif endif +OS ?= # make IDF_PATH a "real" absolute path # * works around the case where a shell character is embedded in the environment variable value. @@ -113,6 +114,7 @@ export BUILD_DIR_BASE # or the directory contains subdirectories which are components.) # The project Makefile can override these component dirs, or add extras via EXTRA_COMPONENT_DIRS ifndef COMPONENT_DIRS +EXTRA_COMPONENT_DIRS ?= COMPONENT_DIRS := $(PROJECT_PATH)/components $(EXTRA_COMPONENT_DIRS) $(IDF_PATH)/components $(PROJECT_PATH)/main endif export COMPONENT_DIRS @@ -146,15 +148,18 @@ export COMPONENTS COMPONENT_PATHS := $(foreach comp,$(COMPONENTS),$(firstword $(foreach cd,$(COMPONENT_DIRS),$(wildcard $(dir $(cd))$(comp) $(cd)/$(comp))))) # If TESTS_ALL set to 1, set TEST_COMPONENTS_LIST to all components +ifdef TESTS_ALL ifeq ($(TESTS_ALL),1) TEST_COMPONENTS_LIST := $(COMPONENTS) else # otherwise, use TEST_COMPONENTS TEST_COMPONENTS_LIST := $(TEST_COMPONENTS) endif +else +TEST_COMPONENTS_LIST := +endif TEST_COMPONENT_PATHS := $(foreach comp,$(TEST_COMPONENTS_LIST),$(firstword $(foreach dir,$(COMPONENT_DIRS),$(wildcard $(dir)/$(comp)/test)))) -TEST_COMPONENT_NAMES := $(foreach comp,$(TEST_COMPONENT_PATHS),$(lastword $(subst /, ,$(dir $(comp))))_test) - +TEST_COMPONENT_NAMES := $(foreach comp,$(TEST_COMPONENT_PATHS),$(lastword $(subst /, ,$(dir $(comp))))_test) # Initialise project-wide variables which can be added to by # each component. @@ -189,9 +194,9 @@ export COMPONENT_INCLUDES include $(IDF_PATH)/make/common.mk all: -ifdef CONFIG_SECURE_BOOT_ENABLED +ifneq ("$(CONFIG_SECURE_BOOT_ENABLED)","") @echo "(Secure boot enabled, so bootloader not flashed automatically. See 'make bootloader' output)" -ifndef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES +ifeq ("$(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)","") @echo "App built but not signed. Sign app & partition data before flashing, via espsecure.py:" @echo "espsecure.py sign_data --keyfile KEYFILE $(APP_BIN)" @echo "espsecure.py sign_data --keyfile KEYFILE $(PARTITION_TABLE_BIN)" @@ -206,6 +211,7 @@ endif IDF_VER := $(shell cd ${IDF_PATH} && git describe --always --tags --dirty) # Set default LDFLAGS +EXTRA_LDFLAGS ?= LDFLAGS ?= -nostdlib \ -u call_user_start_cpu0 \ $(EXTRA_LDFLAGS) \ @@ -228,6 +234,8 @@ LDFLAGS ?= -nostdlib \ # CPPFLAGS used by C preprocessor # If any flags are defined in application Makefile, add them at the end. +CPPFLAGS ?= +EXTRA_CPPFLAGS ?= CPPFLAGS := -DESP_PLATFORM -D IDF_VER=\"$(IDF_VER)\" -MMD -MP $(CPPFLAGS) $(EXTRA_CPPFLAGS) # Warnings-related flags relevant both for C and C++ @@ -263,6 +271,8 @@ DEBUG_FLAGS ?= -ggdb # List of flags to pass to C compiler # If any flags are defined in application Makefile, add them at the end. +CFLAGS ?= +EXTRA_CFLAGS ?= CFLAGS := $(strip \ -std=gnu99 \ $(OPTIMIZATION_FLAGS) $(DEBUG_FLAGS) \ @@ -273,6 +283,8 @@ CFLAGS := $(strip \ # List of flags to pass to C++ compiler # If any flags are defined in application Makefile, add them at the end. +CXXFLAGS ?= +EXTRA_CXXFLAGS ?= CXXFLAGS := $(strip \ -std=gnu++11 \ -fno-exceptions \ @@ -289,8 +301,16 @@ export CFLAGS CPPFLAGS CXXFLAGS HOSTCC := $(CC) HOSTLD := $(LD) HOSTAR := $(AR) +ifdef OBJCOPY HOSTOBJCOPY := $(OBJCOPY) +else +HOSTOBJCOPY := objcopy +endif +ifdef SIZE HOSTSIZE := $(SIZE) +else +HOSTSIZE := size +endif export HOSTCC HOSTLD HOSTAR HOSTOBJCOPY SIZE # Set target compiler. Defaults to whatever the user has @@ -333,6 +353,7 @@ endif # # also depends on additional dependencies (linker scripts & binary libraries) # stored in COMPONENT_LINKER_DEPS, built via component.mk files' COMPONENT_ADD_LINKER_DEPS variable +COMPONENT_LINKER_DEPS ?= $(APP_ELF): $(foreach libcomp,$(COMPONENT_LIBRARIES),$(BUILD_DIR_BASE)/$(libcomp)/lib$(libcomp).a) $(COMPONENT_LINKER_DEPS) $(COMPONENT_PROJECT_VARS) $(summary) LD $(patsubst $(PWD)/%,%,$@) $(CC) $(LDFLAGS) -o $@ -Wl,-Map=$(APP_MAP) @@ -434,7 +455,7 @@ check-submodules: $(IDF_PATH)/$(1)/.git $(IDF_PATH)/$(1)/.git: @echo "WARNING: Missing submodule $(1)..." [ -e ${IDF_PATH}/.git ] || ( echo "ERROR: esp-idf must be cloned from git to work."; exit 1) - [ -x $(which git) ] || ( echo "ERROR: Need to run 'git submodule init $(1)' in esp-idf root directory."; exit 1) + [ -x $$(which git) ] || ( echo "ERROR: Need to run 'git submodule init $(1)' in esp-idf root directory."; exit 1) @echo "Attempting 'git submodule update --init $(1)' in esp-idf root directory..." cd ${IDF_PATH} && git submodule update --init $(1) diff --git a/make/project_config.mk b/make/project_config.mk index c92d5292e..0a212cd28 100644 --- a/make/project_config.mk +++ b/make/project_config.mk @@ -16,8 +16,8 @@ SDKCONFIG ?= $(PROJECT_PATH)/sdkconfig SDKCONFIG_DEFAULTS ?= $(PROJECT_PATH)/sdkconfig.defaults # reset MAKEFLAGS as the menuconfig makefile uses implicit compile rules -$(KCONFIG_TOOL_DIR)/mconf $(KCONFIG_TOOL_DIR)/conf: - MAKEFLAGS=$(ORIGINAL_MAKEFLAGS) CC=$(HOSTCC) LD=$(HOSTLD) \ +$(KCONFIG_TOOL_DIR)/mconf $(KCONFIG_TOOL_DIR)/conf: $(wildcard $(KCONFIG_TOOL_DIR)/*.c) + MAKEFLAGS="" CC=$(HOSTCC) LD=$(HOSTLD) \ $(MAKE) -C $(KCONFIG_TOOL_DIR) ifeq ("$(wildcard $(SDKCONFIG))","") @@ -42,7 +42,7 @@ define RunConf $(KCONFIG_TOOL_DIR)/$1 $(IDF_PATH)/Kconfig endef -ifeq ("$(MAKE_RESTARTS)","") +ifndef MAKE_RESTARTS # menuconfig, defconfig and "GENCONFIG" configuration generation only # ever run on the first make pass, subsequent passes don't run these # (make often wants to re-run them as the conf tool can regenerate the @@ -92,6 +92,6 @@ endif .PHONY: config-clean defconfig menuconfig config-clean: - $(summary RM CONFIG) - $(MAKE) -C $(KCONFIG_TOOL_DIR) clean + $(summary) RM CONFIG + MAKEFLAGS="" $(MAKE) -C $(KCONFIG_TOOL_DIR) clean rm -rf $(BUILD_DIR_BASE)/include/config $(BUILD_DIR_BASE)/include/sdkconfig.h diff --git a/tools/kconfig/.gitignore b/tools/kconfig/.gitignore index 977c274ce..1950c8cb1 100644 --- a/tools/kconfig/.gitignore +++ b/tools/kconfig/.gitignore @@ -2,6 +2,7 @@ # Generated files # config* +*.d *.lex.c *.tab.c *.tab.h diff --git a/tools/kconfig/Makefile b/tools/kconfig/Makefile index 9680b7410..c421365f2 100644 --- a/tools/kconfig/Makefile +++ b/tools/kconfig/Makefile @@ -145,7 +145,7 @@ check-lxdialog := lxdialog/check-lxdialog.sh # Use recursively expanded variables so we do not call gcc unless # we really need to do so. (Do not call gcc as part of make mrproper) CFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \ - -DLOCALE + -DLOCALE -MD # =========================================================================== # Shared Makefile for the various kconfig executables: @@ -173,7 +173,7 @@ gconf-objs := gconf.o zconf.tab.o hostprogs-y := conf nconf mconf kxgettext qconf gconf -clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck +clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck *.d clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h clean-files += $(conf-objs) $(mconf-objs) conf mconf $(lxdialog) @@ -309,3 +309,6 @@ zconf.tab.c: zconf.y clean: rm -f $(clean-files) + +-include $(wildcard *.d) +-include $(wildcard lxdialog/*.d) diff --git a/tools/kconfig/confdata.c b/tools/kconfig/confdata.c index 1e3d1f35b..2a8d5b54d 100644 --- a/tools/kconfig/confdata.c +++ b/tools/kconfig/confdata.c @@ -141,7 +141,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) sym->flags |= def_flags; break; } - if (p[0] == 'n') { + if (p[0] == 'n' || p[0] == '\0') { sym->def[def].tri = no; sym->flags |= def_flags; break; @@ -490,12 +490,7 @@ kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) case S_BOOLEAN: case S_TRISTATE: if (*value == 'n') { - bool skip_unset = (arg != NULL); - - if (!skip_unset) - fprintf(fp, "# %s%s is not set\n", - CONFIG_, sym->name); - return; + value = ""; } break; default: @@ -986,17 +981,21 @@ int conf_write_autoconf(void) conf_write_heading(out_h, &header_printer_cb, NULL); + /* write symbols to auto.conf, tristate and header files */ for_all_symbols(i, sym) { - sym_calc_value(sym); - if (!(sym->flags & SYMBOL_WRITE) || !sym->name) - continue; - - /* write symbol to auto.conf, tristate and header files */ - conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1); - - conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1); - - conf_write_symbol(out_h, sym, &header_printer_cb, NULL); + if (!sym->name) continue; + if ((sym->flags & SYMBOL_WRITE) || + /* + * If the symbol is disabled by dependency we still want it in auto.conf + * so that all possible variables are always defined. + */ + (sym->dir_dep.expr != NULL && sym->dir_dep.tri == no)) { + conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); + } + if (sym->flags & SYMBOL_WRITE) { + conf_write_symbol(tristate, sym, &tristate_printer_cb, NULL); + conf_write_symbol(out_h, sym, &header_printer_cb, NULL); + } } fclose(out); fclose(tristate); From 8670844acfb5fba680cb1ef91b04610fe7e6acb1 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 5 Sep 2017 15:50:31 +1000 Subject: [PATCH 2/4] build system: Restore ifdef/ifndef in Makefiles, clean up examples build --- components/app_trace/component.mk | 2 +- components/aws_iot/component.mk | 2 +- components/bootloader/subproject/main/component.mk | 2 +- components/bootloader_support/component.mk | 4 ++-- components/bt/component.mk | 4 ++-- components/esp32/component.mk | 6 +++--- components/freertos/component.mk | 4 ---- components/lwip/component.mk | 4 ++-- components/newlib/component.mk | 6 +++--- .../aws_iot/subscribe_publish/main/component.mk | 2 +- .../aws_iot/thing_shadow/main/component.mk | 2 +- make/project.mk | 13 +++++++------ 12 files changed, 24 insertions(+), 27 deletions(-) diff --git a/components/app_trace/component.mk b/components/app_trace/component.mk index 7a1f39759..235f19831 100644 --- a/components/app_trace/component.mk +++ b/components/app_trace/component.mk @@ -8,7 +8,7 @@ COMPONENT_ADD_INCLUDEDIRS := include COMPONENT_ADD_LDFLAGS := -lapp_trace -ifeq ("$(CONFIG_SYSVIEW_ENABLE)","y") +ifdef CONFIG_SYSVIEW_ENABLE #COMPONENT_EXTRA_INCLUDES := freertos COMPONENT_ADD_INCLUDEDIRS += \ diff --git a/components/aws_iot/component.mk b/components/aws_iot/component.mk index aab25a71f..cd1b15eee 100644 --- a/components/aws_iot/component.mk +++ b/components/aws_iot/component.mk @@ -2,7 +2,7 @@ # Component Makefile # -ifeq ("$(CONFIG_AWS_IOT_SDK)","y") +ifdef CONFIG_AWS_IOT_SDK COMPONENT_ADD_INCLUDEDIRS := include aws-iot-device-sdk-embedded-C/include diff --git a/components/bootloader/subproject/main/component.mk b/components/bootloader/subproject/main/component.mk index 633051cb6..a54fe30a9 100644 --- a/components/bootloader/subproject/main/component.mk +++ b/components/bootloader/subproject/main/component.mk @@ -12,7 +12,7 @@ LINKER_SCRIPTS := \ $(IDF_PATH)/components/esp32/ld/esp32.peripherals.ld \ esp32.bootloader.rom.ld -ifneq ("$(CONFIG_SPI_FLASH_ROM_DRIVER_PATCH)","y") +ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH LINKER_SCRIPTS += $(IDF_PATH)/components/esp32/ld/esp32.rom.spiflash.ld endif diff --git a/components/bootloader_support/component.mk b/components/bootloader_support/component.mk index 8ad21d3b9..6db815aff 100755 --- a/components/bootloader_support/component.mk +++ b/components/bootloader_support/component.mk @@ -12,12 +12,12 @@ COMPONENT_SRCDIRS := src # # Secure boot signing key support # -ifneq ("$(CONFIG_SECURE_BOOT_ENABLED)","") +ifdef CONFIG_SECURE_BOOT_ENABLED # this path is created relative to the component build directory SECURE_BOOT_VERIFICATION_KEY := $(abspath signature_verification_key.bin) -ifneq ("$(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)","") +ifdef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES # verification key derived from signing key. $(SECURE_BOOT_VERIFICATION_KEY): $(SECURE_BOOT_SIGNING_KEY) $(SDKCONFIG_MAKEFILE) $(ESPSECUREPY) extract_public_key --keyfile $< $@ diff --git a/components/bt/component.mk b/components/bt/component.mk index 86fddc8c1..8f6ce29d5 100644 --- a/components/bt/component.mk +++ b/components/bt/component.mk @@ -1,7 +1,7 @@ # # Component Makefile # -ifneq ("$(CONFIG_BT_ENABLED)","") +ifdef CONFIG_BT_ENABLED COMPONENT_SRCDIRS := . @@ -20,7 +20,7 @@ COMPONENT_SUBMODULES += lib endif -ifeq ("$(CONFIG_BLUEDROID_ENABLED)","y") +ifdef CONFIG_BLUEDROID_ENABLED COMPONENT_ADD_INCLUDEDIRS += bluedroid/bta/include \ bluedroid/bta/sys/include \ diff --git a/components/esp32/component.mk b/components/esp32/component.mk index a151f8129..2ed898052 100644 --- a/components/esp32/component.mk +++ b/components/esp32/component.mk @@ -4,7 +4,7 @@ COMPONENT_SRCDIRS := . hwcrypto LIBS ?= -ifneq ("$(CONFIG_NO_BLOBS)","y") +ifndef CONFIG_NO_BLOBS LIBS += core rtc net80211 pp wpa smartconfig coexist wps wpa2 phy endif @@ -19,11 +19,11 @@ ifndef CONFIG_SPIRAM_CACHE_WORKAROUND LINKER_SCRIPTS += esp32.rom.spiram_incompatible_fns.ld endif -ifeq ("$(CONFIG_NEWLIB_NANO_FORMAT)","y") +ifdef CONFIG_NEWLIB_NANO_FORMAT LINKER_SCRIPTS += esp32.rom.nanofmt.ld endif -ifneq ("$(CONFIG_SPI_FLASH_ROM_DRIVER_PATCH)","y") +ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH LINKER_SCRIPTS += esp32.rom.spiflash.ld endif diff --git a/components/freertos/component.mk b/components/freertos/component.mk index 88be5b8f6..7841d8f69 100644 --- a/components/freertos/component.mk +++ b/components/freertos/component.mk @@ -5,7 +5,3 @@ COMPONENT_ADD_LDFLAGS += -Wl,--undefined=uxTopUsedPriority COMPONENT_ADD_INCLUDEDIRS := include COMPONENT_PRIV_INCLUDEDIRS := include/freertos - -#ifeq ("$(CONFIG_SYSVIEW_ENABLE)","y") -#COMPONENT_ADD_INCLUDEDIRS += app_trace -#endif diff --git a/components/lwip/component.mk b/components/lwip/component.mk index 921cc5916..f85759bed 100644 --- a/components/lwip/component.mk +++ b/components/lwip/component.mk @@ -8,8 +8,8 @@ COMPONENT_ADD_INCLUDEDIRS := \ include/lwip/posix \ apps/ping -ifeq ("$(CONFIG_PPP_SUPPORT)","y") -LWIP_PPP_DIRS := netif/ppp/polarssl netif/ppp +ifdef CONFIG_PPP_SUPPORT +LWIP_PPP_DIRS := netif/ppp/polarssl netif/ppp else LWIP_PPP_DIRS := endif diff --git a/components/newlib/component.mk b/components/newlib/component.mk index ce5799dfb..05ef6bee8 100644 --- a/components/newlib/component.mk +++ b/components/newlib/component.mk @@ -1,15 +1,15 @@ -ifeq ("$(CONFIG_SPIRAM_CACHE_WORKAROUND)","y") +ifdef CONFIG_SPIRAM_CACHE_WORKAROUND LIBC_PATH := $(COMPONENT_PATH)/lib/libc-psram-workaround.a LIBM_PATH := $(COMPONENT_PATH)/lib/libm-psram-workaround.a else -ifeq ("$(CONFIG_NEWLIB_NANO_FORMAT)","y") +ifdef CONFIG_NEWLIB_NANO_FORMAT LIBC_PATH := $(COMPONENT_PATH)/lib/libc_nano.a else LIBC_PATH := $(COMPONENT_PATH)/lib/libc.a -endif +endif # CONFIG_NEWLIB_NANO_FORMAT LIBM_PATH := $(COMPONENT_PATH)/lib/libm.a diff --git a/examples/protocols/aws_iot/subscribe_publish/main/component.mk b/examples/protocols/aws_iot/subscribe_publish/main/component.mk index 1ed56547c..bc11b6393 100644 --- a/examples/protocols/aws_iot/subscribe_publish/main/component.mk +++ b/examples/protocols/aws_iot/subscribe_publish/main/component.mk @@ -2,7 +2,7 @@ # Main Makefile. This is basically the same as a component makefile. # -ifeq ("$(CONFIG_EXAMPLE_EMBEDDED_CERTS)","y") +ifdef CONFIG_EXAMPLE_EMBEDDED_CERTS # Certificate files. certificate.pem.crt & private.pem.key must be downloaded # from AWS, see README for details. COMPONENT_EMBED_TXTFILES := certs/aws-root-ca.pem certs/certificate.pem.crt certs/private.pem.key diff --git a/examples/protocols/aws_iot/thing_shadow/main/component.mk b/examples/protocols/aws_iot/thing_shadow/main/component.mk index 1ed56547c..bc11b6393 100644 --- a/examples/protocols/aws_iot/thing_shadow/main/component.mk +++ b/examples/protocols/aws_iot/thing_shadow/main/component.mk @@ -2,7 +2,7 @@ # Main Makefile. This is basically the same as a component makefile. # -ifeq ("$(CONFIG_EXAMPLE_EMBEDDED_CERTS)","y") +ifdef CONFIG_EXAMPLE_EMBEDDED_CERTS # Certificate files. certificate.pem.crt & private.pem.key must be downloaded # from AWS, see README for details. COMPONENT_EMBED_TXTFILES := certs/aws-root-ca.pem certs/certificate.pem.crt certs/private.pem.key diff --git a/make/project.mk b/make/project.mk index 31635d41d..9846872a2 100644 --- a/make/project.mk +++ b/make/project.mk @@ -151,11 +151,11 @@ COMPONENT_PATHS := $(foreach comp,$(COMPONENTS),$(firstword $(foreach cd,$(COMPO ifdef TESTS_ALL ifeq ($(TESTS_ALL),1) TEST_COMPONENTS_LIST := $(COMPONENTS) -else +else # TESTS_ALL not empty and not 1 # otherwise, use TEST_COMPONENTS TEST_COMPONENTS_LIST := $(TEST_COMPONENTS) endif -else +else # TESTS_ALL unset TEST_COMPONENTS_LIST := endif TEST_COMPONENT_PATHS := $(foreach comp,$(TEST_COMPONENTS_LIST),$(firstword $(foreach dir,$(COMPONENT_DIRS),$(wildcard $(dir)/$(comp)/test)))) @@ -171,6 +171,7 @@ TEST_COMPONENT_NAMES := $(foreach comp,$(TEST_COMPONENT_PATHS),$(lastword $(subs COMPONENT_INCLUDES := COMPONENT_LDFLAGS := COMPONENT_SUBMODULES := +COMPONENT_LIBRARIES := # COMPONENT_PROJECT_VARS is the list of component_project_vars.mk generated makefiles # for each component. @@ -194,9 +195,9 @@ export COMPONENT_INCLUDES include $(IDF_PATH)/make/common.mk all: -ifneq ("$(CONFIG_SECURE_BOOT_ENABLED)","") +ifdef CONFIG_SECURE_BOOT_ENABLED @echo "(Secure boot enabled, so bootloader not flashed automatically. See 'make bootloader' output)" -ifeq ("$(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)","") +ifndef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES @echo "App built but not signed. Sign app & partition data before flashing, via espsecure.py:" @echo "espsecure.py sign_data --keyfile KEYFILE $(APP_BIN)" @echo "espsecure.py sign_data --keyfile KEYFILE $(PARTITION_TABLE_BIN)" @@ -255,13 +256,13 @@ COMMON_FLAGS = \ -nostdlib # Optimization flags are set based on menuconfig choice -ifneq ("$(CONFIG_OPTIMIZATION_LEVEL_RELEASE)","") +ifdef CONFIG_OPTIMIZATION_LEVEL_RELEASE OPTIMIZATION_FLAGS = -Os else OPTIMIZATION_FLAGS = -Og endif -ifeq ("$(CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED)", "y") +ifdef CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED CPPFLAGS += -DNDEBUG endif From 5f3cb9f9dc84096562759ddb542f305dd1cb25de Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 5 Sep 2017 16:10:00 +1000 Subject: [PATCH 3/4] build system: Document --warn-undefined-variables and add a config item for it --- Kconfig | 14 +++++++++++++- docs/api-guides/build-system.rst | 11 +++++++++++ docs/api-reference/kconfig.rst | 11 ++++++++++- make/common.mk | 6 +++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/Kconfig b/Kconfig index 9611cf773..2cf242481 100644 --- a/Kconfig +++ b/Kconfig @@ -19,7 +19,19 @@ config PYTHON help The executable name/path that is used to run python. On some systems Python 2.x may need to be invoked as python2. -endmenu + +config MAKE_WARN_UNDEFINED_VARIABLES + bool "'make' warns on undefined variables" + default "y" + help + Adds --warn-undefined-variables to MAKEFLAGS. This causes make to + print a warning any time an undefined variable is referenced. + + This option helps find places where a variable reference is misspelled + or otherwise missing, but it can be unwanted if you have Makefiles which + depend on undefined variables expanding to an empty string. + +endmenu # SDK tool configuration source "$COMPONENT_KCONFIGS_PROJBUILD" diff --git a/docs/api-guides/build-system.rst b/docs/api-guides/build-system.rst index a86698e4c..34e35de3d 100644 --- a/docs/api-guides/build-system.rst +++ b/docs/api-guides/build-system.rst @@ -351,6 +351,17 @@ Some tips for debugging the esp-idf build system: For more debugging tips and general make information, see the `GNU Make Manual`. +.. _warn-undefined-variables: + +Warning On Undefined Variables +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +By default, the build process will print a warning if an undefined variable is referenced (like ``$(DOES_NOT_EXIST)``). This can be useful to find errors in variable names. + +If you don't want this behaviour, it can be disabled by disabling :ref:`CONFIG_MAKE_WARN_UNDEFINED_VARIABLES`. + +Note that this option doesn't trigger a warning if ``ifdef`` or ``ifndef`` are used in Makefiles. + Overriding Parts of the Project ------------------------------- diff --git a/docs/api-reference/kconfig.rst b/docs/api-reference/kconfig.rst index 21bcf6b38..28c4439aa 100644 --- a/docs/api-reference/kconfig.rst +++ b/docs/api-reference/kconfig.rst @@ -25,4 +25,13 @@ By convention, all option names are upper case with underscores. When Kconfig ge .. include:: /_build/inc/kconfig.inc -.. _Kconfig: https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt \ No newline at end of file +Customisations +============== + +Because IDF builds by default with :ref:`warn-undefined-variables`, when the Kconfig tool generates Makefiles (the ``auto.conf`` file) its behaviour has been customised. In normal Kconfig, a variable which is set to "no" is undefined. In IDF's version of Kconfig, this variable is defined in the Makefile but has an empty value. + +(Note that ``ifdef`` and ``ifndef`` can still be used in Makefiles, because they test if a variable is defined *and has a non-empty value*.) + +When generating header files for C & C++, the behaviour is not customised - so ``#ifdef`` can be used to test if a boolean config item is set or not. + +.. _Kconfig: https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt diff --git a/make/common.mk b/make/common.mk index 358c88088..ea39421cb 100644 --- a/make/common.mk +++ b/make/common.mk @@ -27,9 +27,13 @@ details := @echo else summary := @echo details := @true +endif # disable echoing of commands, directory names -MAKEFLAGS += --silent --warn-undefined-variables +MAKEFLAGS += --silent + +ifdef CONFIG_MAKE_WARN_UNDEFINED_VARIABLES +MAKEFLAGS += --warn-undefined-variables endif # General make utilities From 95c2aed1260cebbad8791a0ea58e8dfe181ec324 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 5 Sep 2017 16:28:42 +1000 Subject: [PATCH 4/4] build system: Remove obsolete GenerateBuildDirTarget macro eval --- make/component_wrapper.mk | 4 ---- 1 file changed, 4 deletions(-) diff --git a/make/component_wrapper.mk b/make/component_wrapper.mk index 618466877..751668d4b 100644 --- a/make/component_wrapper.mk +++ b/make/component_wrapper.mk @@ -276,10 +276,6 @@ $(foreach binfile,$(COMPONENT_EMBED_FILES), $(eval $(call GenerateEmbedTarget,$( $(foreach txtfile,$(COMPONENT_EMBED_TXTFILES), $(eval $(call GenerateEmbedTarget,$(txtfile),txt))) -# generate targets to create binary embed directories -$(foreach bindir,$(sort $(dir $(COMPONENT_EMBED_FILES))), $(eval $(call GenerateBuildDirTarget,$(bindir)))) - - else # COMPONENT_CONFIG_ONLY is set build: