mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Build system: Allow components to add to the global CFLAGS via Makefile.projbuild
Used by mbedTLS to set MBEDTLS_CONFIG_FILE in all components. This change sets CFLAGS/etc at the project level and then exports those variables for components, rather than setting them independently each time a component Makefile is invoked.
This commit is contained in:
parent
31e6b2cdb4
commit
7c58c1e06b
@ -17,15 +17,11 @@ BOOTLOADER_BIN=$(BOOTLOADER_BUILD_DIR)/bootloader.bin
|
|||||||
|
|
||||||
$(BOOTLOADER_BIN): $(COMPONENT_PATH)/src/sdkconfig
|
$(BOOTLOADER_BIN): $(COMPONENT_PATH)/src/sdkconfig
|
||||||
$(Q) PROJECT_PATH= \
|
$(Q) PROJECT_PATH= \
|
||||||
LDFLAGS= \
|
|
||||||
CFLAGS= \
|
|
||||||
BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
|
BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
|
||||||
$(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src MAKEFLAGS= V=$(V) TARGET_BIN_LAYOUT="$(BOOTLOADER_TARGET_BIN_LAYOUT)" $(BOOTLOADER_BIN)
|
$(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src MAKEFLAGS= V=$(V) TARGET_BIN_LAYOUT="$(BOOTLOADER_TARGET_BIN_LAYOUT)" $(BOOTLOADER_BIN)
|
||||||
|
|
||||||
bootloader-clean:
|
bootloader-clean:
|
||||||
$(Q) PROJECT_PATH= \
|
$(Q) PROJECT_PATH= \
|
||||||
LDFLAGS= \
|
|
||||||
CFLAGS= \
|
|
||||||
BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
|
BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
|
||||||
$(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src app-clean MAKEFLAGS= V=$(V)
|
$(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src app-clean MAKEFLAGS= V=$(V)
|
||||||
|
|
||||||
|
@ -10,6 +10,6 @@ COMPONENT_ADD_INCLUDEDIRS := port/include include/expat
|
|||||||
|
|
||||||
COMPONENT_SRCDIRS := library port
|
COMPONENT_SRCDIRS := library port
|
||||||
|
|
||||||
EXTRA_CFLAGS := -Wno-error=address -Waddress -DHAVE_EXPAT_CONFIG_H
|
CFLAGS += -Wno-error=address -Waddress -DHAVE_EXPAT_CONFIG_H
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component.mk
|
include $(IDF_PATH)/make/component.mk
|
||||||
|
@ -6,6 +6,6 @@ COMPONENT_ADD_INCLUDEDIRS := include/lwip include/lwip/port include/lwip/posix
|
|||||||
|
|
||||||
COMPONENT_SRCDIRS := api apps/sntp apps core/ipv4 core/ipv6 core netif port/freertos port/netif port
|
COMPONENT_SRCDIRS := api apps/sntp apps core/ipv4 core/ipv6 core netif port/freertos port/netif port
|
||||||
|
|
||||||
EXTRA_CFLAGS := -Wno-error=address -Waddress -DLWIP_ESP8266
|
CFLAGS += -Wno-error=address -Waddress -DLWIP_ESP8266
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
include $(IDF_PATH)/make/component_common.mk
|
||||||
|
4
components/mbedtls/Makefile.projbuild
Normal file
4
components/mbedtls/Makefile.projbuild
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Anyone compiling mbedTLS code needs the name of the
|
||||||
|
# alternative config file
|
||||||
|
CFLAGS += -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"'
|
||||||
|
|
@ -6,6 +6,4 @@ COMPONENT_ADD_INCLUDEDIRS := port/include include
|
|||||||
|
|
||||||
COMPONENT_SRCDIRS := library port
|
COMPONENT_SRCDIRS := library port
|
||||||
|
|
||||||
EXTRA_CFLAGS += -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"'
|
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
include $(IDF_PATH)/make/component_common.mk
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
# Component Makefile
|
# Component Makefile
|
||||||
#
|
#
|
||||||
|
|
||||||
EXTRA_CFLAGS := -DLWIP_ESP8266
|
CFLAGS += -DLWIP_ESP8266
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
include $(IDF_PATH)/make/component_common.mk
|
||||||
|
@ -60,7 +60,7 @@ influencing the build process of the component as well as the project it's used
|
|||||||
in. Components may also include a Kconfig file defining the compile-time options that are
|
in. Components may also include a Kconfig file defining the compile-time options that are
|
||||||
settable by means of the menu system.
|
settable by means of the menu system.
|
||||||
|
|
||||||
Project makefile variables that can be set by the programmer::
|
Project Makefile variables that can be set by the programmer::
|
||||||
|
|
||||||
PROJECT_NAME: Mandatory. Name for the project
|
PROJECT_NAME: Mandatory. Name for the project
|
||||||
BUILD_DIR_BASE: Set the directory where all objects/libraries/binaries end up in.
|
BUILD_DIR_BASE: Set the directory where all objects/libraries/binaries end up in.
|
||||||
@ -76,17 +76,20 @@ Project makefile variables that can be set by the programmer::
|
|||||||
include directories that are passed to the compilation pass of all components and
|
include directories that are passed to the compilation pass of all components and
|
||||||
they do not have a Kconfig option.
|
they do not have a Kconfig option.
|
||||||
|
|
||||||
Component makefile variables that can be set by the programmer::
|
Component-specific component.mk variables that can be set by the programmer::
|
||||||
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS: Relative path to include directories to be added to
|
COMPONENT_ADD_INCLUDEDIRS: Relative path to include directories to be added to
|
||||||
the entire project
|
the entire project. If an include directory is only needed to compile this
|
||||||
|
specific component, don't add it here.
|
||||||
COMPONENT_PRIV_INCLUDEDIRS: Relative path to include directories that are only used
|
COMPONENT_PRIV_INCLUDEDIRS: Relative path to include directories that are only used
|
||||||
when compiling this specific component
|
when compiling this specific component.
|
||||||
COMPONENT_DEPENDS: Names of any components that need to be compiled before this component.
|
COMPONENT_DEPENDS: Names of any components that need to be compiled before this component.
|
||||||
COMPONENT_ADD_LDFLAGS: Ld flags to add for this project. Defaults to -l$(COMPONENT_NAME).
|
COMPONENT_ADD_LDFLAGS: LD flags to add for the entire project. Defaults to -l$(COMPONENT_NAME).
|
||||||
Add libraries etc in the current directory as $(abspath libwhatever.a)
|
Add libraries etc in the current directory as $(abspath libwhatever.a)
|
||||||
COMPONENT_EXTRA_INCLUDES: Any extra include paths. These will be prefixed with '-I' and
|
COMPONENT_EXTRA_INCLUDES: Any extra include paths used when compiling the component's
|
||||||
passed to the compiler; please put absolute paths here.
|
source files. These will be prefixed with '-I' and passed to the compiler.
|
||||||
|
Similar to COMPONENT_PRIV_INCLUDEDIRS, but these paths are passed as-is instead of
|
||||||
|
expanded relative to the component directory.
|
||||||
COMPONENT_SRCDIRS: Relative directories to look in for sources. Defaults to '.', the current
|
COMPONENT_SRCDIRS: Relative directories to look in for sources. Defaults to '.', the current
|
||||||
directory (the root of the component) only. Use this to specify any subdirectories. Note
|
directory (the root of the component) only. Use this to specify any subdirectories. Note
|
||||||
that specifying this overwrites the default action of compiling everything in the
|
that specifying this overwrites the default action of compiling everything in the
|
||||||
@ -114,6 +117,10 @@ be usable in component or project Makefiles::
|
|||||||
COMPONENTS: Name of the components to be included
|
COMPONENTS: Name of the components to be included
|
||||||
CONFIG_*: All values set by 'make menuconfig' have corresponding Makefile variables.
|
CONFIG_*: All values set by 'make menuconfig' have corresponding Makefile variables.
|
||||||
|
|
||||||
|
Inside your component's component.mk makefile, you can override or add to these variables
|
||||||
|
as necessary. The changes are isolated from other components (see Makefile.projbuild below
|
||||||
|
if you want to share these changes with all other components.)
|
||||||
|
|
||||||
For components, there also are these defines::
|
For components, there also are these defines::
|
||||||
|
|
||||||
COMPONENT_PATH: Absolute path to the root of the source tree of the component we're
|
COMPONENT_PATH: Absolute path to the root of the source tree of the component we're
|
||||||
@ -152,10 +159,16 @@ details to add to "menuconfig" for this component.
|
|||||||
Makefile.projbuild
|
Makefile.projbuild
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
For components that have parts that need to be run when building of the
|
For components that have parts that need to be evaluated in the top-level
|
||||||
project is done, you can create a file called Makefile.projbuild in the
|
project context, you can create a file called Makefile.projbuild in the
|
||||||
component root directory. This file will be included in the main
|
component root directory. These files is included into the project's
|
||||||
Makefile.
|
top-level Makefile.
|
||||||
|
|
||||||
|
For example, if your component needs to add to CFLAGS for the entire
|
||||||
|
project (not just for its own source files) then you can set
|
||||||
|
``CFLAGS +=`` in Makefile.projbuild. Note that this isn't necessary for
|
||||||
|
adding include directories to the project, you can set
|
||||||
|
``COMPONENT_ADD_INCLUDEDIRS`` (see above) in the component.mk.
|
||||||
|
|
||||||
|
|
||||||
KConfig.projbuild
|
KConfig.projbuild
|
||||||
|
@ -8,32 +8,6 @@
|
|||||||
# see project_config.mk for details.)
|
# see project_config.mk for details.)
|
||||||
-include $(PROJECT_PATH)/build/include/config/auto.conf
|
-include $(PROJECT_PATH)/build/include/config/auto.conf
|
||||||
|
|
||||||
ifeq ("$(LDFLAGS)","")
|
|
||||||
LDFLAGS = -nostdlib \
|
|
||||||
-L$(IDF_PATH)/lib \
|
|
||||||
-L$(IDF_PATH)/ld \
|
|
||||||
$(addprefix -L$(BUILD_DIR_BASE)/,$(COMPONENTS) $(SRCDIRS)) \
|
|
||||||
-u call_user_start_cpu0 \
|
|
||||||
-Wl,--gc-sections \
|
|
||||||
-Wl,-static \
|
|
||||||
-Wl,--start-group \
|
|
||||||
$(COMPONENT_LDFLAGS) \
|
|
||||||
-lgcc \
|
|
||||||
-Wl,--end-group
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ("$(CFLAGS)","")
|
|
||||||
CFLAGS = -DESP_PLATFORM -Og -std=gnu99 -g3 \
|
|
||||||
-Wpointer-arith -Werror -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable \
|
|
||||||
-Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -Wall -ffunction-sections -fdata-sections $(EXTRA_CFLAGS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ("$(CXXFLAGS)","")
|
|
||||||
CXXFLAGS = -DESP_PLATFORM -Og -std=gnu++11 -g3 \
|
|
||||||
-Wpointer-arith -Werror -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable \
|
|
||||||
-Wl,-EL -nostdlib -mlongcalls -Wall -ffunction-sections -fdata-sections $(EXTRA_CFLAGS) -fno-exceptions
|
|
||||||
endif
|
|
||||||
|
|
||||||
#Handling of V=1/VERBOSE=1 flag
|
#Handling of V=1/VERBOSE=1 flag
|
||||||
#
|
#
|
||||||
# if V=1, $(summary) does nothing and $(details) will echo extra details
|
# if V=1, $(summary) does nothing and $(details) will echo extra details
|
||||||
|
@ -25,7 +25,7 @@ export COMPONENT_PATH
|
|||||||
|
|
||||||
include $(IDF_PATH)/make/common.mk
|
include $(IDF_PATH)/make/common.mk
|
||||||
|
|
||||||
#Some of these options are overridable by the components Makefile.
|
#Some of these options are overridable by the component's component.mk Makefile
|
||||||
|
|
||||||
#Name of the component
|
#Name of the component
|
||||||
COMPONENT_NAME ?= $(lastword $(subst /, ,$(realpath $(COMPONENT_PATH))))
|
COMPONENT_NAME ?= $(lastword $(subst /, ,$(realpath $(COMPONENT_PATH))))
|
||||||
@ -58,7 +58,8 @@ COMPONENT_ADD_LDFLAGS ?= -l$(COMPONENT_NAME)
|
|||||||
OWN_INCLUDES:=$(abspath $(addprefix $(COMPONENT_PATH)/,$(COMPONENT_ADD_INCLUDEDIRS) $(COMPONENT_PRIV_INCLUDEDIRS)))
|
OWN_INCLUDES:=$(abspath $(addprefix $(COMPONENT_PATH)/,$(COMPONENT_ADD_INCLUDEDIRS) $(COMPONENT_PRIV_INCLUDEDIRS)))
|
||||||
COMPONENT_INCLUDES := $(OWN_INCLUDES) $(filter-out $(OWN_INCLUDES),$(COMPONENT_INCLUDES))
|
COMPONENT_INCLUDES := $(OWN_INCLUDES) $(filter-out $(OWN_INCLUDES),$(COMPONENT_INCLUDES))
|
||||||
|
|
||||||
#This target is used to collect variable values from inside the main makefile
|
#This target is used to collect variable values from inside project.mk
|
||||||
|
# see project.mk GetVariable macro for details.
|
||||||
get_variable:
|
get_variable:
|
||||||
@echo "$(GET_VARIABLE)=$(call $(GET_VARIABLE)) "
|
@echo "$(GET_VARIABLE)=$(call $(GET_VARIABLE)) "
|
||||||
|
|
||||||
@ -82,9 +83,6 @@ clean:
|
|||||||
$(Q) rm -f $(COMPONENT_LIBRARY) $(COMPONENT_OBJS) $(COMPONENT_OBJS:.o=.d) $(COMPONENT_EXTRA_CLEAN)
|
$(Q) rm -f $(COMPONENT_LIBRARY) $(COMPONENT_OBJS) $(COMPONENT_OBJS:.o=.d) $(COMPONENT_EXTRA_CLEAN)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#Also generate dependency files
|
|
||||||
CFLAGS+=-MMD -MP
|
|
||||||
CXXFLAGS+=-MMD -MP
|
|
||||||
#Include all dependency files already generated
|
#Include all dependency files already generated
|
||||||
-include $(COMPONENT_OBJS:.o=.d)
|
-include $(COMPONENT_OBJS:.o=.d)
|
||||||
|
|
||||||
|
@ -133,6 +133,41 @@ export PROJECT_PATH
|
|||||||
#Include functionality common to both project & component
|
#Include functionality common to both project & component
|
||||||
-include $(IDF_PATH)/make/common.mk
|
-include $(IDF_PATH)/make/common.mk
|
||||||
|
|
||||||
|
# Set default LDFLAGS
|
||||||
|
|
||||||
|
LDFLAGS ?= -nostdlib \
|
||||||
|
-L$(IDF_PATH)/lib \
|
||||||
|
-L$(IDF_PATH)/ld \
|
||||||
|
$(addprefix -L$(BUILD_DIR_BASE)/,$(COMPONENTS) $(SRCDIRS)) \
|
||||||
|
-u call_user_start_cpu0 \
|
||||||
|
-Wl,--gc-sections \
|
||||||
|
-Wl,-static \
|
||||||
|
-Wl,--start-group \
|
||||||
|
$(COMPONENT_LDFLAGS) \
|
||||||
|
-lgcc \
|
||||||
|
-Wl,--end-group \
|
||||||
|
-Wl,-EL
|
||||||
|
|
||||||
|
# Set default CPPFLAGS, CFLAGS, CXXFLAGS
|
||||||
|
#
|
||||||
|
# These are exported so that components can use them when compiling.
|
||||||
|
#
|
||||||
|
# If you need your component to add CFLAGS/etc for it's own source compilation only, set CFLAGS += in your component's Makefile.
|
||||||
|
#
|
||||||
|
# If you need your component to add CFLAGS/etc globally for all source
|
||||||
|
# files, set CFLAGS += in your component's Makefile.projbuild
|
||||||
|
|
||||||
|
# CPPFLAGS used by an compile pass that uses the C preprocessor
|
||||||
|
CPPFLAGS = -DESP_PLATFORM -Og -g3 -Wpointer-arith -Werror -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wall -ffunction-sections -fdata-sections -mlongcalls -nostdlib -MMD -MP
|
||||||
|
|
||||||
|
# C flags use by C only
|
||||||
|
CFLAGS = $(CPPFLAGS) -std=gnu99 -g3 -fno-inline-functions
|
||||||
|
|
||||||
|
# CXXFLAGS uses by C++ only
|
||||||
|
CXXFLAGS = $(CPPFLAGS) -Og -std=gnu++11 -g3 -fno-exceptions
|
||||||
|
|
||||||
|
export CFLAGS CPPFLAGS CXXFLAGS
|
||||||
|
|
||||||
#Set host compiler and binutils
|
#Set host compiler and binutils
|
||||||
HOSTCC := $(CC)
|
HOSTCC := $(CC)
|
||||||
HOSTLD := $(LD)
|
HOSTLD := $(LD)
|
||||||
|
@ -10,8 +10,6 @@ KCONFIG_TOOL_DIR=$(IDF_PATH)/tools/kconfig
|
|||||||
# clear MAKEFLAGS as the menuconfig makefile uses implicit compile rules
|
# clear MAKEFLAGS as the menuconfig makefile uses implicit compile rules
|
||||||
$(KCONFIG_TOOL_DIR)/mconf $(KCONFIG_TOOL_DIR)/conf:
|
$(KCONFIG_TOOL_DIR)/mconf $(KCONFIG_TOOL_DIR)/conf:
|
||||||
MAKEFLAGS="" \
|
MAKEFLAGS="" \
|
||||||
CFLAGS="" \
|
|
||||||
LDFLAGS="" \
|
|
||||||
CC=$(HOSTCC) LD=$(HOSTLD) \
|
CC=$(HOSTCC) LD=$(HOSTLD) \
|
||||||
$(MAKE) -C $(KCONFIG_TOOL_DIR)
|
$(MAKE) -C $(KCONFIG_TOOL_DIR)
|
||||||
|
|
||||||
|
@ -18,6 +18,10 @@ endif
|
|||||||
# We need this, in case the user has it in its environment
|
# We need this, in case the user has it in its environment
|
||||||
unexport CONFIG_
|
unexport CONFIG_
|
||||||
|
|
||||||
|
# Unset some environment variables set in the project environment
|
||||||
|
CFLAGS :=
|
||||||
|
CPPFLAGS :=
|
||||||
|
LDFLAGS :=
|
||||||
|
|
||||||
default: mconf conf
|
default: mconf conf
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user