buildroot

How are configuration options for Buildroot generated dynamically?


If I download the fresh buildroot (as of 2024), I can see that when I don't explicitly select the option to build with u-boot, on running make help I will not see anything related to u-boot. On the other hand, if I run menuconfig and select u-boot, I will see the u-boot related configuration options. How does this mechanism work?

P. S.: I see the if/endif part in Config.in located at /boot/uboot. But how does the Makefile include a new dynamic target for this package? It is still not known to me..

P. P. S.: I would ideally like to study how it is done with u-boot so I can do the same thing for my packages.


Solution

  • When you run make help, Make simply runs the commands for the help target which is defined in the top-level Makefile:

    help:
            @echo 'Cleaning:'
            @echo '  clean                  - delete all files created by build'
            @echo '  distclean              - delete all non-source files (including .config)'
            @echo
            @echo 'Build:'
    ...
    

    In the middle of that very long text is the dynamic part:

            $(foreach p,$(HELP_PACKAGES), \
                    @echo $(sep) \
                    @echo '$($(p)_NAME):' $(sep) \
                    $($(p)_HELP_CMDS)$(sep))
    

    sep is a newline - we can't use an actual newline there because we're within the foreach command.

    HELP_PACKAGES is set in the huge inner-generic-package macro in package/pkg-generic.mk. It adds the name of the package to that list if the package is enabled and it defines FOO_HELP_CMDS.

    $(p)_NAME and $(p)_HELP_CMDS expand to UBOOT_NAME and UBOOT_HELP_CMDS. UBOOT_NAME is also set by inner-generic-package. UBOOT_HELP_CMDS is set in package/pkg-kconfig.mk