[Buildroot] Example of running a host-autotools-package several times with different configs

Frager, Neal neal.frager at amd.com
Fri Feb 14 15:38:07 UTC 2025


Hi Arnout,

> Hi Arnout,
> 
>> Hello everyone,
>>
>> I am looking into expanding the toolchain-bare-metal-buildroot package to
>> define multiple bare-metal architectures in a list and build several
>> bare-metal toolchains with the single set of packages.
>>
>> Since binutils and gcc are host-autotools packages, I am wondering if
>> we have any examples for a single host-autotools package being used
>> several times with different configure options.  Is there already another
>> package which does this?
> 
>>   No, there isn't, and the Buildroot infra is actively hostile against such a
>> concept due to the splitting of configure, build and install steps.
> 
>>   You would have to define custom commands for each step and then run them in a
>> loop with a different output directory. I.e. something like
> 
>> 	mkdir ${$(PKG)_BUILD_DIR)/build-$(arch)
>>          cd ${$(PKG)_BUILD_DIR)/build-$(arch)
>> 	$($(PKG)_SRC_DIR)/configure --etc
> 
> Thank you for the rapid feedback!
> 
> Regarding the custom commands, I see how I could do this with using
> host-generic packages because I can define my own configure, build and
> install commands.  Is it possible to re-define binutils-bare-metal and
> gcc-bare-metal as host-generic packages instead of host-autotools?

>  Yes it is. However, it starts to diverge so much from normal autotools that it 
> doesn't make a lot o sense to keep using host-autotoos-package.

I see what you mean.

> 
> With host-autotools, it is not clear to me how I can implement my own
> commands since the commands come from the infrastructure itself.

> ifndef $(2)_BUILD_CMDS
> ifeq ($(4),target)
> define $(2)_BUILD_CMDS
>         $$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) 
> $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCDIR)
> endef
> else
> define $(2)_BUILD_CMDS
>         $$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) 
> $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCDIR)
> endef
> endif
> endif

> i.e. if you define _CMDS in the package.mk file, that will take precedence over 
> the "predefined" commands in autotools-package.

This was very helpful!  Actually, implementing multiple tuple support for
the buildroot-bare-metal-buildroot toolchain was much easier than I thought!

As long as separate build directories are used, we can easily configure and
build a single package multiple times.  We just configure several times in
a row, then build several times in a row, and then install several times.

Thank you for your support!  I look forward to your review of my solution.

Best regards,
Neal Frager
AMD


More information about the buildroot mailing list