Question

I'm creating a Linux kernel module using buildroot to perform the cross-compile. I've created a Config.in file to create some optional bits like so:

config BR2_PACKAGE_MYPACKAGE_OPTION1
    bool "Option 1"

In my source code I would have:

#ifdef CONFIG_BR2_PACKAGE_MYPACKAGE_OPTION1
#error Testing if symbol defined 
#endif

This doesn't work, the symbol is not defined at compile time when the option is checked from menuconfig. The symbol does appear in the top-level .config file.

I guessed that mypackage.mk would have access to the symbol and it does. I've tried adding these to the .mk file, but although both TARGET_CFLAGS and EXTRA_CFLAGS get altered by the statements (confirmed with an @echo command), they don't get passed to the compiler.

ifeq ($(BR2_PACKAGE_MYPACKAGE_OPTION1),y)
    TARGET_CFLAGS += -DCONFIG_BR2_PACKAGE_MYPACKAGE_OPTION1
endif

ifeq ($(BR2_PACKAGE_MYPACKAGE_OPTION1),y)
    EXTRA_CFLAGS += -DCONFIG_BR2_PACKAGE_MYPACKAGE_OPTION1
endif

How does one get access to the configuration symbols in your source code?

Was it helpful?

Solution

I figured out one possible answer:

Pass the ones you are interested in to the $(MAKE) invocation in your mypackage.mk file, then you can pass them on to the compiler in your package Makefile/Kbuild file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top