[Buildroot] *Tons* of BR warnings like "package/Makefile.autotools.in:179: warning: overriding commands for target `/home/bjornfor/raid/forks/buildroot/output'"

Peter Korsgaard jacmet at uclibc.org
Sun Dec 13 21:28:56 UTC 2009


>>>>> "Bjørn" == Bjørn Forsman <bjorn.forsman at gmail.com> writes:

Hi,

 Bjørn> I finally found the bug. (Thanks a lot for the hint, Peter.)
 Bjørn> BASE_DIR ends up containing the Buildroot output directory *two*
 Bjørn> times (separated by a space). And it happends because I use the
 Bjørn> CDPATH environment variable.

 Bjørn> Let me demonstrate:

 Bjørn> $ mkdir dir
 Bjørn> $ (CDPATH= cd dir/)      # no output
 Bjørn> $ (CDPATH=.:.. cd dir/)  # output!
 Bjørn> /tmp/directory/dir

Ahh - I use zsh dir hashes for that kind of stuff instead.

 Bjørn> This means that when the top Makefile in BR says:

 Bjørn>   BASE_DIR := $(shell mkdir -p $(O) && cd $(O) && pwd)

 Bjørn> both 'cd' and 'pwd' will print out the same path (when CDPATH is
 Bjørn> non-empty), BASE_DIR will be containing two identical paths. Make freaks
 Bjørn> out and BR fails.

 Bjørn> So to fix this issue I thought it would be easy to remove CDPATH from
 Bjørn> the Buildroot environment. But how? I tried:

 Bjørn> export CDPATH:=
 Bjørn> unexport CDPATH

 Bjørn> in the top Makefile but neither worked.

It does work, but only for stuff running inside the make rules:

cat Makefile
export CDPATH:=
all:
        set|grep CDPATH

export CDPATH=.:~
make
set|grep CDPATH
BASH_EXECUTION_STRING='set|grep CDPATH'
CDPATH=

sed -i 's/export/#export/' Makefile
make
set|grep CDPATH
BASH_EXECUTION_STRING='set|grep CDPATH'
CDPATH=.:/home/peko

But if you instead have something using $(shell ) it won't work:

cat Makefile
export CDPATH:=
DUMMY:=$(shell set|grep CDPATH >&2)
all:
        set|grep CDPATH

make
BASH_EXECUTION_STRING='set|grep CDPATH >&2'
CDPATH=.:/home/peko
set|grep CDPATH
BASH_EXECUTION_STRING='set|grep CDPATH'
CDPATH=

E.G. the export doesn't effect the environment of $(shell ).

So the proper fix is to do:

unset CDPATH:=
and explicitly work around if for BASE_DIR, E.G.:

BASE_DIR := $(shell mkdir -p $(O) && cd $(O) >/dev/null && pwd)

I'll fix that in git.

 Bjørn> It is also possible to use absolute paths when defining BASE_DIR. But I
 Bjørn> don't know how to do that when the output variable O can be relative or
 Bjørn> absolute:

 Bjørn>   $ make O=/tmp/output
 Bjørn>   $ make O=output

Well, that's the point of the 'cd $(O) >/dev/null && pwd' part (convert
to absolute path).

-- 
Bye, Peter Korsgaard


More information about the buildroot mailing list