On 18.01.2022 17:21, Anthony PERARD wrote: > 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 > .. .. .. > ../../..
Looks good to me. > The added "source/" depends on whether we do out-of-tree build or not. Well, I guess we're free to add a "source => ." symlink even in the in-tree build case, deviating slightly from what Linux does? That would then slightly simplify your construct. Jan
