Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] BR variable that points the built kernel
Date: Wed, 10 Jun 2015 19:15:32 +0200	[thread overview]
Message-ID: <20150610171532.GA3700@free.fr> (raw)
In-Reply-To: <CAFRxoJnZEi83_Zj45gAXMvwxZ5x=Cp1o-iMMhU9jVFHWArzbEw@mail.gmail.com>

Marco, All,

On 2015-06-10 12:06 +0200, Marco Pastorelli spake thusly:
> Thanks for your help, now it's more clear.
> Just to give more details I'm trying to write a post-build script in order
> to create a log file of the build. One information that is important for me
> is the kernel version, so I wrote the following line:
> 
> LINUX_VERSION=$(cat $(LINUX_DIR)/include/config/kernel.release)
> 
> That's where I run into the error.

That's because you're writting a shell script, not a Makefile. And in
shell script, $(foo) means running the command 'foo', not evaluating the
variable foo.

Besides, as Thomas said, not all variables are exported, and especially
the variables cotaining the packages build directories are not exported.
So, you can't refer to them from a post-build or post-image script.

However, there *is* a way to get them, which is asking Buildroot for
them. I have a similar need, and here's what I do:

    linux_dir_as_shell_variable=$(
        make printvars 2>/dev/null \
        |sed -r -e '/^LINUX_DIR=([^[:space:]]+)[[:space:]]+.*/!d; s//\1/;'
    )

    printf "LINUX_DIR from Buildroot is '%s'\n" "${linux_dir_as_shell_variable}"

And since you are only interested in the Linux version, you can replace
LINUX_DIR with LINUX_VERSION (or even LINUX_VERSION_PROBED).

However, it takes quite some time to run, because it is evaluating *all*
variables for *all* enabled packages, so it works OK if all you need is
only a few variable. If you need more, then you'd need a more complex
solution (or pay the price of calling make for each variable you need).

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

  reply	other threads:[~2015-06-10 17:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-09 11:41 [Buildroot] BR variable that points the built kernel Marco Pastorelli
2015-06-09 12:03 ` Thomas Petazzoni
2015-06-09 13:58   ` Marco Pastorelli
2015-06-09 14:03     ` Thomas Petazzoni
2015-06-10  8:29       ` Marco Pastorelli
2015-06-10  8:36         ` Thomas Petazzoni
2015-06-10 10:06           ` Marco Pastorelli
2015-06-10 17:15             ` Yann E. MORIN [this message]
2015-06-12  6:28               ` Marco Pastorelli

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=20150610171532.GA3700@free.fr \
    --to=yann.morin.1998@free.fr \
    --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