Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: buildroot@busybox.net
Subject: [Buildroot] How to include Buildroot defines?
Date: Thu, 23 May 2013 15:06:45 +0200	[thread overview]
Message-ID: <20130523150645.6efe2e15@skate> (raw)
In-Reply-To: <0855BDD4CF82174A8BE362DE9F27C3BF01E3FEC82D23@pche-exchange>

Dear Morten Kvistgaard,

On Thu, 23 May 2013 14:53:15 +0200, Morten Kvistgaard wrote:

> I'm currently converting my uClinux to Buildroot.

Nice. Which hardware platform are you working with?

> In my uClinux I could include the "KConfig result" in my programs.
> That way I could customize a program in the menuconfig. Eg. with
> extra options or by including apps etc. This could look something
> like:
> 
> #include <config/autoconf.h>
> 
> #ifdef CONFIG_USER_MYAPP_OPTION
>    //Menuconfig tells me to build featureX
> #endif
> 
> 
> This was an easy way to handle static options.
> I can see that Buildroot also has a autoconf.h. It's located in
> output/build/buildroot-config/.
> 
> How do I include this in a correct way? Or is this a bad way to do it?

Yes, I would say it's not how things should be done. Instead, your
package recipe maybe be passing different options to your program
configure or build process, depending on Buildroot Kconfig options.
That's what we do for all the packages.

For example in package/yourprog/Config.in:

config BR2_PACKAGE_YOURPROG
	bool "yourprog"
	help
	  This option enables the build of your program.

config BR2_PACKAGE_YOURPROG_OPTIONA
	bool "feature A"
	depends on BR2_PACKAGE_YOURPROG
	help
	  This option enables some feature A in your program

and then, in package/yourprog/yourprog.mk:

ifeq ($(BR2_PACKAGE_YOURPROG_OPTIONA),y)
YOURPROG_CONF_OPT += --enable-featurea
endif

if your package is autotools based. Or, if it's just a simple Makefile
that takes some environment variables:

ifeq ($(BR2_PACKAGE_YOURPROG_OPTIONA),y)
YOURPROG_MAKE_ENV += FEATUREA=YES
endif

define YOURPROG_BUILD_CMDS
	$(YOURPROG_MAKE_ENV) $(MAKE) -C $(@D)
endef

And that's it.

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

  reply	other threads:[~2013-05-23 13:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-23 12:53 [Buildroot] How to include Buildroot defines? Morten Kvistgaard
2013-05-23 13:06 ` Thomas Petazzoni [this message]
2013-05-23 13:33   ` Morten Kvistgaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130523150645.6efe2e15@skate \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox