linuxcross-compilingautotoolsyoctorecipe

How to give options for "configure" using yocto recipes?


I'm writing a recipe in Yocto to build my custom component. In there, I would like to enable some flags according to the current machine.

For example, if machine is x86, my configure command should be:

./configure --enable-x86

If machine is x64:

./configure --enable-x64

I'm using auto tools for building. I seek help, writing a recipe and a "configure.ac" for achieving this.


Solution

  • You can provide the configure options using EXTRA_OECONF. Here, you can also append values to it based on your architecture.

    EXTRA_OECONF_append_x86="--enable-x86"
    EXTRA_OECONF_append_x64="--enable-x64"
    

    You can do this only if your architecture (x86/x64) is defined as part of the OVERRIDE value. Let us see what OVERRIDE value means:

    The Yocto bitbake configuration values are defined in poky/meta/conf/bitbake.conf. In that file, there is a variable called OVERRIDE. The sample value for OVERRIDE in bitbake configuration is shown below:

    OVERRIDES = "${TARGET_OS}:${TRANSLATED_TARGET_ARCH}:build-${BUILD_OS}:pn-${PN}:${MACHINEOVERRIDES}:${DISTROOVERRIDES}:${CLASSOVERRIDE}:forcevariable"
    

    Run bitbake -e and gather the output, to see the value OVERRIDE translates into, based on your configuration:

    $ bitbake -e
    [...]
    OVERRIDES="linux:i586:build-linux:pn-defaultpkgname:x86:qemuall:qemux86:poky:class-target:forcevariable:libc-glibc"
    

    In your setup, if you can see x86/x64 as part of the OVERRIDE value then you can define configure options as described earlier.