On Tue, Jan 18, 2022 at 11:06:38AM +0000, Anthony PERARD wrote:
> On Tue, Dec 21, 2021 at 02:53:49PM +0100, Jan Beulich wrote:
> > On 25.11.2021 14:39, Anthony PERARD wrote:
> > > +$(obj)/%.c: $(abs_srctree)/common/efi/%.c FORCE
> > > + $(Q)ln -nfs $< $@
> > 
> > Like was the case before, I think it would be better if the links were
> > relative ones, at least when srctree == objtree (but ideally always).
> 
> I can give it a try.

How about:
    ln -nfs $(subst $(space),/,$(patsubst %,..,$(subst /, ,$(obj))))/$(if 
$(building_out_of_srctree),source/)common/efi/$(<F) $@

This will result in the relative path "../../../common/efi/runtime.c"
for in-tree builds, and "../../../source/common/efi/runtime.c" for
out-of-tree builds. There's a "source" symlink that can be used which
point to the source tree when doing out-of-tree builds.

The part:
    $(subst $(space),/,$(patsubst %,..,$(subst /, ,$(obj))))
means that if $(obj) were to be something other than "arch/*/efi", the
command would still works and give the right number of "../".
It does this steps to "arch/x86/efi":
    arch x86 efi
    .. .. ..
    ../../..

The added "source/" depends on whether we do out-of-tree build or not.

-- 
Anthony PERARD

Reply via email to