1.. _Header_configuration:
2
3#############################
4The Header File Config System
5#############################
6
7The header file configurations system is used to fine-tune component options.
8
9The following diagram shows how the system works.
10
11.. figure:: header_file_config_diagram.svg
12  :align: center
13
14Source files shall include ``config_tfm.h`` when necessary to fetch Component option settings.
15It is expected that all Component options are included in ``config_tfm.h`` to explicitly set values
16for each option.
17
18
19The ``config_tfm.h`` includes base configuration ``config_base.h``. Refer to
20:ref:`Base_configuration` for details of the base configurations.
21
22The ``config_tfm.h`` includes a customized project config file provided via compile definition
23``PROJECT_CONFIG_HEADER_FILE``. Customized Component options in the project config file overrides
24those configured in ``config_base.h``.
25The project config header file can be
26
27- Generated by the TF-M Kconfig system <kconfig_system>
28- One of the header files of Profiles <tf-m_profiles>, set via the ``TFM_PROFILE`` build option.
29- Manually customized profile based on pre-set profiles.
30
31Users set CMake variable ``PROJECT_CONFIG_HEADER_FILE`` with the full path of the configuration
32header file.
33
34A platform can adjust or place restriction on config options by providing a ``config_tfm_target.h``
35under the root folder of their platforms.
36If the build system finds the file, it sets the ``TARGET_CONFIG_HEADER_FILE`` compile definition.
37Platform specific option settings in ``TARGET_CONFIG_HEADER_FILE`` overrides those configured in
38``config_base.h``.
39
40.. code-block:: c
41
42    #ifdef PROJECT_CONFIG_HEADER_FILE
43    #include PROJECT_CONFIG_HEADER_FILE
44    #endif
45
46    #ifdef TARGET_CONFIG_HEADER_FILE
47    #include TARGET_CONFIG_HEADER_FILE
48    #endif
49
50    #include "config_base.h"
51
52Each component can implement a ``config_<comp_name>_check.h`` to validate component specific config
53dependencies. ``config_<comp_name>_check.h`` shall include ``config_tfm.h``
54
55--------------
56
57*Copyright (c) 2022, Arm Limited. All rights reserved.*
58