[1/4] Makefile: export a few variables to help support scripts

Submitted by Yann E. MORIN on Jan. 13, 2013, 9:52 p.m.

Details

Message ID d9e98990b22abeb96d52d72687ccf52883521e69.1358113846.git.yann.morin.1998@free.fr
State Accepted
Headers show

Commit Message

Yann E. MORIN Jan. 13, 2013, 9:52 p.m.
Support scripts (in support/) may need to parse the .config file, so give
them an easy access to it, by exporting BUILDROOT_CONFIG with the fully-
qualified path to .config.

Also, post-build scripts may need to reference a few locations, so export
those, too.

Note: we export both O and BASE_DIR. Although they are the same, BASE_DIR
is used internally, while O is used on the command line, which makes it a
bit ambiguous to know which to use. As users use O= on the command line,
they will probably tend to use that in their post-build scripts.

Update doc accordingly.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Arnout Vandecappelle <arnout@mind.be>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
cc: Peter Korsgaard <jacmet@uclibc.org>
---
 Makefile                         |   11 +++++++++++
 docs/manual/customize-rootfs.txt |    7 +++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

Comments

Peter Korsgaard Jan. 13, 2013, 10:15 p.m.
>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

 Yann> Support scripts (in support/) may need to parse the .config file, so give
 Yann> them an easy access to it, by exporting BUILDROOT_CONFIG with the fully-
 Yann> qualified path to .config.

 Yann> Also, post-build scripts may need to reference a few locations, so export
 Yann> those, too.

 Yann> Note: we export both O and BASE_DIR. Although they are the same,
 Yann> BASE_DIR is used internally, while O is used on the command line,
 Yann> which makes it a bit ambiguous to know which to use. As users use
 Yann> O= on the command line, they will probably tend to use that in
 Yann> their post-build scripts.

Ok. I guess most people don't need the upper O/BASE_DIR variables, but
lets add the for completeness.

 Yann> +++ b/docs/manual/customize-rootfs.txt
 Yann> @@ -37,6 +37,13 @@ there are a few ways to customize the resulting target filesystem.
 Yann>    certain package generates wrong or unneeded files, you should fix
 Yann>    that package rather than work around it with a post-build cleanup
 Yann>    script. _Among these first 3 methods, this one should be preferred_.
 Yann> +  You may also use these variables in your post-build script:
 Yann> +    - +BUILDROOT_CONFIG+: the path to the Buildroot .config file
 Yann> +    - +HOST_DIR+, +STAGING_DIR+, +TARGET_DIR+: see
 Yann> +      xref:generic-package-reference[]
 Yann> +    - +BINARIES_DIR+: the place were all binary files (aka images) are

s/were/where/

Committed with the typo fixed, thanks.
Peter Korsgaard Jan. 14, 2013, 8:52 a.m.
>>>>> "Peter" == Peter Korsgaard <jacmet@uclibc.org> writes:

>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:
 Yann> Support scripts (in support/) may need to parse the .config file, so give
 Yann> them an easy access to it, by exporting BUILDROOT_CONFIG with the fully-
 Yann> qualified path to .config.

 Yann> Also, post-build scripts may need to reference a few locations, so export
 Yann> those, too.

 Yann> Note: we export both O and BASE_DIR. Although they are the same,
 Yann> BASE_DIR is used internally, while O is used on the command line,
 Yann> which makes it a bit ambiguous to know which to use. As users use
 Yann> O= on the command line, they will probably tend to use that in
 Yann> their post-build scripts.

 Peter> Ok. I guess most people don't need the upper O/BASE_DIR variables, but
 Peter> lets add the for completeness.

And even worse, other projects also use the O=<dir> syntax for out of
tree, and atleast uClibc doesn't check that it gets explictly passed on
the command line, breaking the build.

So I'll remove the O.
Yann E. MORIN Jan. 14, 2013, 5:38 p.m.
Peter, All,

On Monday 14 January 2013 Peter Korsgaard wrote:
[--SNIP--]
> And even worse, other projects also use the O=<dir> syntax for out of
> tree, and atleast uClibc doesn't check that it gets explictly passed on
> the command line, breaking the build.
> 
> So I'll remove the O.

Yes, as an afterthought, exporting $(O) was bad.

I was able to build both busybox and the Linux kernel with $(O), and I did
not think about uClibc. Ough... :-( And yesterday was too late for me to
spend more time on it, and removing $(O) would have been the first thing I
would have tried tonight. Sorry for the mess...

Thanks for the quick fix!

Regards,
Yann E. MORIN.
Peter Korsgaard Jan. 14, 2013, 6:34 p.m.
>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

Hi,

 Yann> Yes, as an afterthought, exporting $(O) was bad.

 Yann> I was able to build both busybox and the Linux kernel with $(O),
 Yann> and I did not think about uClibc. Ough... :-( And yesterday was
 Yann> too late for me to spend more time on it, and removing $(O) would
 Yann> have been the first thing I would have tried tonight. Sorry for
 Yann> the mess...

No problem...

Patch hide | download patch | download mbox

diff --git a/Makefile b/Makefile
index 074674a..5a83251 100644
--- a/Makefile
+++ b/Makefile
@@ -91,6 +91,8 @@  EXTRAMAKEARGS = O=$(O)
 NEED_WRAPPER=y
 endif
 
+BUILDROOT_CONFIG=$(CONFIG_DIR)/.config
+
 # Pull in the user's configuration file
 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
 -include $(CONFIG_DIR)/.config
@@ -282,6 +284,15 @@  HOSTCC  := $(CCACHE) $(HOSTCC)
 HOSTCXX := $(CCACHE) $(HOSTCXX)
 endif
 
+# Scripts in support/ or post-build scripts may need to reference
+# these locations, so export them so it is easier to use
+export BUILDROOT_CONFIG
+export TARGET_DIR
+export STAGING_DIR
+export HOST_DIR
+export BINARIES_DIR
+export BASE_DIR O   # O and BASE_DIR are the same
+
 #############################################################
 #
 # You should probably leave this stuff alone unless you know
diff --git a/docs/manual/customize-rootfs.txt b/docs/manual/customize-rootfs.txt
index a1a556b..fe3ea7e 100644
--- a/docs/manual/customize-rootfs.txt
+++ b/docs/manual/customize-rootfs.txt
@@ -37,6 +37,13 @@  there are a few ways to customize the resulting target filesystem.
   certain package generates wrong or unneeded files, you should fix
   that package rather than work around it with a post-build cleanup
   script. _Among these first 3 methods, this one should be preferred_.
+  You may also use these variables in your post-build script:
+    - +BUILDROOT_CONFIG+: the path to the Buildroot .config file
+    - +HOST_DIR+, +STAGING_DIR+, +TARGET_DIR+: see
+      xref:generic-package-reference[]
+    - +BINARIES_DIR+: the place were all binary files (aka images) are
+      stored
+    - +BASE_DIR+ (or +O+): the base output directory
 
 * A special package, 'customize', stored in +package/customize+ can be
   used. You can put all the files that you want to see in the final