Re: [PATCH] Makefile: Fix separate output directory build of kselftests
From: Muhammad Usama Anjum
Date: Mon Apr 04 2022 - 07:10:13 EST
>From [Makefile](https://elixir.bootlin.com/linux/latest/source/Makefile):
```
ifeq ($(abs_srctree),$(abs_objtree))
# building in the source tree
srctree := .
building_out_of_srctree :=
else
ifeq ($(abs_srctree)/,$(dir $(abs_objtree)))
# building in a subdirectory of the source tree
srctree := ..
else
srctree := $(abs_srctree)
endif
building_out_of_srctree := 1
endif
```
`ifeq ($(abs_srctree)/,$(dir $(abs_objtree)))` condition is setting
`srctree` to `..`. This is wrong. This condition isn't considering that
`header_install` doesn't depend on `abs_srctree and abs_objtree`. This
condition needs to be tweaked or removed for the `install_headers` to
work fine and fix this issue. I've added `KBUILD_ABS_SRCTREE=1` to the
kselftest target which sets the `srctree` to `abs_srctree` and thus
forcefully affecting only kselftest targets. This seems like the clean
fix. Alternatively we should remove this condition `ifeq
($(abs_srctree)/,$(dir $(abs_objtree)))` but it'll affect other targets
as well.
Complete details of investigation can be found here:
https://github.com/kernelci/kernelci-project/issues/92#issuecomment-1087406222
On 3/17/22 11:08 PM, Masahiro Yamada wrote:
> On Thu, Mar 17, 2022 at 7:49 PM Muhammad Usama Anjum
> <usama.anjum@xxxxxxxxxxxxx> wrote:
>>
>> Reminder. Shuah is okay with this patch. Any thoughts?
>
> I do not think this is the right fix,
> but something you just happen to find working.
>
>
> The Make is working in a wrong directory, that is why
> the relative path does not work
> (and you use the absolute path to work around it)
>
`ifeq ($(abs_srctree)/,$(dir $(abs_objtree))) \ srctree := ..` has
broken the `make headers_install` when called through
selftests/Makefile. We can remove it or use the absolute path each time.
--
Muhammad Usama Anjum