---------------
An example project directory tree might look like this::
+
- myProject/
- Makefile
- sdkconfig
- component2/ - component.mk
- Kconfig
- src1.c
- - include/
- - component2.h
+ - include/ - component2.h
- main/ - src1.c
- src2.c
- component.mk
+
- build/
This example "myProject" contains the following elements:
^^^^^^^^^^^^^^^^^^^^^^^^
::
+
PROJECT_NAME := myProject
include $(IDF_PATH)/make/project.mk
^^^^^^^^^^^^^^^^^^^^^^^^^^
The minimal ``component.mk`` file is an empty file(!). If the file is empty, the default component behaviour is set:
-- All source files in the same directory as the makefile (*.c, *.cpp, *.S) will be compiled into the component library
+
+- All source files in the same directory as the makefile (``*.c``, ``*.cpp``, ``*.S``) will be compiled into the component library
- A sub-directory "include" will be added to the global include search path for all other components.
- The component library will be linked into the project app.
are available at all times. It is necessary if one component
generates an include file which you then want to include in another
component. Most components do not need to set this variable.
+- ``COMPONENT_ADD_LINKER_DEPS``: Optional list of component-relative paths
+ to files which should trigger a re-link of the ELF file if they change.
+ Typically used for linker script files and binary libraries. Most components do
+ not need to set this variable.
The following variable only works for components that are part of esp-idf itself:
``COMPONENT_PRIV_INCLUDEDIRS`` variable, except these paths are not
expanded relative to the component directory.
- ``COMPONENT_SRCDIRS``: Directory paths, must be relative to the
- component directory, which will be searched for source files (*.cpp,
- *.c, *.S). Defaults to '.', ie the component directory
+ component directory, which will be searched for source files (``*.cpp``,
+ ``*.c``, ``*.S``). Defaults to '.', ie the component directory
itself. Override this to specify a different list of directories
which contain source files.
- ``COMPONENT_OBJS``: Object files to compile. Default value is a .o
+=``. It is also possible (although not recommended) to override
this variable completely for a component.
+To apply compilation flags to a single source file, you can add a variable override as a target, ie::
+
+ apps/dhcpserver.o: CFLAGS += -Wno-unused-variable
+
+This can be useful if there is upstream code that emits warnings.
+
Component Configuration
-----------------------
depending on the options selected in ``make menuconfig``:
``Kconfig``::
+
config FOO_ENABLE_BAR
bool "Enable the BAR feature."
help
This enables the BAR feature of the FOO component.
``component.mk``::
+
COMPONENT_OBJS := foo_a.o foo_b.o
ifdef CONFIG_FOO_BAR