[question] how is include path selected when compiling a .c file?

Chan Kim ckim at etri.re.kr
Thu Dec 16 03:51:47 CET 2021


Hello,

For example In file arch/arm/cpu/arm1136/mx31/timer.c, I see

#include <common.h>

#include <init.h>

#include <asm/arch/imx-regs.h>

#include <asm/io.h>

There are 13 files named common.h files and 4405 files doing '#include
<common.h>'. 

I can guess what file it is including but can't figure out exactly how the
default include path (-I cflag ) is set for each .c file.

I know the top Makefile has this line. 

UBOOTINCLUDE    := \

    -Iinclude \

    $(if $(KBUILD_SRC), -I$(srctree)/include) \

    $(if $(CONFIG_$(SPL_)SYS_THUMB_BUILD), \

        $(if $(CONFIG_HAS_THUMB2), \

            $(if $(CONFIG_CPU_V7M), \

                -I$(srctree)/arch/arm/thumb1/include), \

            -I$(srctree)/arch/arm/thumb1/include)) \

    -I$(srctree)/arch/$(ARCH)/include \

    -include $(srctree)/include/linux/kconfig.h

And some other lower Makefiles additively add -I option according to the
configuration.

But still can't figure it out.

For example in the above arch/arm/cpu/arm1136/mx31/timer.c file, I guess the
#include <asm/arch/imx-regs.h>

Is including ./arch/arm/include/asm/arch-mx31/imx-regs.h. Could anyone
explain it to me?

Thank you!

Chan Kim

 

 



More information about the U-Boot mailing list