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
COMPONENT_ADD_LDFLAGS := -lapp_trace
-ifdef CONFIG_SYSVIEW_ENABLE
+ifeq ("$(CONFIG_SYSVIEW_ENABLE)","y")
#COMPONENT_EXTRA_INCLUDES := freertos
COMPONENT_ADD_INCLUDEDIRS += \
# Component Makefile
#
-ifdef CONFIG_AWS_IOT_SDK
+ifeq ("$(CONFIG_AWS_IOT_SDK)","y")
COMPONENT_ADD_INCLUDEDIRS := include aws-iot-device-sdk-embedded-C/include
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
@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
$(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
#
# 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 $< $@
#
# Component Makefile
#
-ifdef CONFIG_BT_ENABLED
+ifneq ("$(CONFIG_BT_ENABLED)","")
COMPONENT_SRCDIRS := .
endif
-ifdef CONFIG_BLUEDROID_ENABLED
+ifeq ("$(CONFIG_BLUEDROID_ENABLED)","y")
COMPONENT_ADD_INCLUDEDIRS += bluedroid/bta/include \
bluedroid/bta/sys/include \
endmenu # Wi-Fi
-menu Phy
+menu PHY
config ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
bool "Do phy calibration and store calibration data in NVS"
#
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.
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
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
COMPONENT_ADD_INCLUDEDIRS := include
COMPONENT_PRIV_INCLUDEDIRS := include/freertos
-#ifdef CONFIG_SYSVIEW_ENABLE
+#ifeq ("$(CONFIG_SYSVIEW_ENABLE)","y")
#COMPONENT_ADD_INCLUDEDIRS += app_trace
#endif
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 := \
-
ifeq ("$(CONFIG_SPIRAM_CACHE_WORKAROUND)","y")
LIBC_PATH := $(COMPONENT_PATH)/lib/libc-psram-workaround.a
LIBM_PATH := $(COMPONENT_PATH)/lib/libm-psram-workaround.a
LIBM_PATH := $(COMPONENT_PATH)/lib/libm.a
-endif
+endif # CONFIG_SPIRAM_CACHE_WORKAROUND
COMPONENT_ADD_LDFLAGS := $(LIBC_PATH) $(LIBM_PATH) -lnewlib
# 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
# 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
#
# 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
details := @true
# disable echoing of commands, directory names
-MAKEFLAGS += --silent
+MAKEFLAGS += --silent --warn-undefined-variables
endif
# General make utilities
$(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
# 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))
# 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)))' >> $@
rm -f $(CLEAN_FILES)
endif
+DEBUG_FLAGS ?= -ggdb
+
# Include all dependency files already generated
-include $(COMPONENT_OBJS:.o=.d)
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.
# 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
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.
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)"
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) \
# 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++
# 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) \
# 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 \
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
#
# 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)
$(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)
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))","")
$(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
.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
# Generated files
#
config*
+*.d
*.lex.c
*.tab.c
*.tab.h
# 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:
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)
clean:
rm -f $(clean-files)
+
+-include $(wildcard *.d)
+-include $(wildcard lxdialog/*.d)
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;
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:
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);