For kbuild to properly clean up these build artifacts in the subdirectory, even after CONFIG_KUNIT changed do disabled, the directory needs to be processed always. Pushing the special logic for hook.o into the kunit Makefile also makes the logic easier to understand.
Unified · Split
| @@ -109,11 +109,7 @@ test_fpu-y := test_fpu_glue.o test_fpu_impl.o · 108 unmodified lines | |||
| 109 | CFLAGS_test_fpu_impl.o += $(CC_FLAGS_FPU) | 109 | CFLAGS_test_fpu_impl.o += $(CC_FLAGS_FPU) |
| 110 | CFLAGS_REMOVE_test_fpu_impl.o += $(CC_FLAGS_NO_FPU) | 110 | CFLAGS_REMOVE_test_fpu_impl.o += $(CC_FLAGS_NO_FPU) |
| 111 | 111 | ||
| 112 | # Some KUnit files (hooks.o) need to be built-in even when KUnit is a module, | ||
| 113 | # so we can't just use obj-$(CONFIG_KUNIT). | ||
| 114 | ifdef CONFIG_KUNIT | ||
| 115 | obj-y += kunit/ | 112 | obj-y += kunit/ |
| 116 | endif | ||
| 117 | 113 | ||
| 118 | ifeq ($(CONFIG_DEBUG_KOBJECT),y) | 114 | ifeq ($(CONFIG_DEBUG_KOBJECT),y) |
| 119 | CFLAGS_kobject.o += -DDEBUG | 115 | CFLAGS_kobject.o += -DDEBUG |
| @@ -17,7 +17,7 @@ kunit-objs += debugfs.o · 16 unmodified lines | |||
| 17 | endif | 17 | endif |
| 18 | 18 | ||
| 19 | # KUnit 'hooks' are built-in even when KUnit is built as a module. | 19 | # KUnit 'hooks' are built-in even when KUnit is built as a module. |
| 20 | obj-y += hooks.o | 20 | obj-$(if $(CONFIG_KUNIT),y) += hooks.o |
| 21 | 21 | ||
| 22 | obj-$(CONFIG_KUNIT_TEST) += kunit-test.o | 22 | obj-$(CONFIG_KUNIT_TEST) += kunit-test.o |
| 23 | obj-$(CONFIG_KUNIT_TEST) += platform-test.o | 23 | obj-$(CONFIG_KUNIT_TEST) += platform-test.o |