file for "make menuconfig"

I was following example 2 of the OpenWRT examples ( and have a question about the in this example.

Contents of

menu "Configuration"
	depends on PACKAGE_example2a

	bool "Enable Feature Foo"
	depends on PACKAGE_example2a
	default y

	bool "Enable feature Bar"
	depends on PACKAGE_example2a
	default n


The application Example2 contains the following:

#include <stdio.h>

int main(int argc, char **argv)
	printf("Hi, this is example2.\n");

#if defined(FOO)
	printf("Feature foo was selected.\n");

#if defined(BAR)
	printf("Feature bar was selected.\n");

Based on the description in the example and what I see, this gives 2 sub-options Foo and Bar when running "make menuconfig" and select the Example2 package.

However, after selecting an option (either Foo or Bar), after "make" and run the program (in a VDI image running Virtual Box), it always prints only the first line ("this is example 2"), and none of the "Feature X was selected" lines was printed.

Am I correct in expecting that once you select an option (Foo or Bar), this would become a flag at compilation time so the compiled code would contain the corresponding "Feature X was selected" line ?

And why am I not seeing "Feature X was selected" regardless of the option I chose ?


That example is bad. MAKE_FLAGS is defined, sure, but then it's not actually used in Build/Compile - stage at all, so of course it's also not going to do anything. Besides that, -DFOO and -DBAR aren't make-flags to begin with; you don't supply defines to make, you supply them to gcc and should be using TARGET_CFLAGS or TARGET_CPPFLAGS instead.

Change MAKE_FLAGS += -DFOO to TARGET_CFLAGS += -DFOO and similarly for the other option and it should work.

Thanks WereCatf. I followed your suggestions and it worked.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.