build: build everything from the root dir, use obj=$subdir
authorAnthony PERARD <anthony.perard@citrix.com>
Fri, 25 Feb 2022 10:01:15 +0000 (11:01 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 25 Feb 2022 10:01:15 +0000 (11:01 +0100)
commit7a3bcd2babcc7d9952bcf174f3705ebd9290671a
tree4d4ebb68c4df149e2134ed2b29d0b585ee8bef9a
parent27060920a79be3a12628e91212d6e21a9b4a2b76
build: build everything from the root dir, use obj=$subdir

A subdirectory is now built by setting "$(obj)" instead of changing
directory. "$(obj)" should always be set when using "Rules.mk" and
thus a shortcut "$(build)" is introduced and should be used.

A new variable "$(need-builtin)" is introduce. It is to be used
whenever a "built_in.o" is wanted from a subdirectory. "built_in.o"
isn't the main target anymore, and thus only needs to depends on the
objects that should be part of "built_in.o".

Introduce $(srctree) and $(objtree) to replace $(BASEDIR) in cases a
relative path is better, and $(abs_srctree) and $(abs_objtree) which
have an absolute path.

DEPS is updated as the existing macro to deal with it doesn't know
about $(obj).

There's some changes in "Rules.mk" which in addition to deal with
"$(obj)" also make it's looks more like "Makefile.build" from Linux
v5.12.

test/Makefile doesn't need special handling in order to build
everything under test/, Rules.mk will visit test/livepatch via
$(subdir-y), thus "tests" "all" and "build" target are removed.
"subtree-force-update" target isn't useful so it is removed as well.

test/livepatch/Makefile doesn't need default target anymore, Rules.mk
will build everything in $(extra-y) and thus all *.livepatch.

Adjust cloc recipe: dependency files generated by CC will now have the
full path to the source file, so we don't need to prepend the
subdirectory. This fix some issue with source not been parsed by cloc
before. Also source from tools/kconfig would be listed with changes in
this patch so adjust the find command to stop listing the "tools"
directory and thus kconfig. With a default build of Xen on X86, they
are a few new files parsed by cloc:
    arch/x86/x86_64/compat/mm.c
    arch/x86/x86_64/mm.c
    common/compat/domain.c
    common/compat/memory.c
    common/compat/xlat.c

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Bob Eshleman <bobbyeshleman@gmail.com>
Acked-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Daniel P. Smith <dpsmith@apertussolutions.com> # XSM
17 files changed:
xen/Makefile
xen/Rules.mk
xen/arch/arm/Makefile
xen/arch/arm/Rules.mk
xen/arch/arm/arch.mk
xen/arch/riscv/arch.mk
xen/arch/x86/Makefile
xen/arch/x86/Rules.mk
xen/arch/x86/arch.mk
xen/arch/x86/boot/Makefile
xen/build.mk
xen/include/Makefile
xen/scripts/Kbuild.include
xen/test/Makefile
xen/test/livepatch/Makefile
xen/xsm/flask/Makefile
xen/xsm/flask/ss/Makefile