Several things go wrong with this Makefile: 1) Using `test_srcs` to generate `test_objs`. 2) `test_objs` is an unused variable. So (1) is pointless. 3) `make clean` does not remove `ucontext-cp` binary. I assume (1) and (2) were blindly copied from the test Makefile. For 3, the `make clean` removes $(all_targets) and $(test_objs). But `ucontext-cp` only exists in $(all_targets) if we have `CONFIG_HAVE_UCONTEXT`. When the target goal is `clean`, we will not have any of `CONFIG_*` variables. Thus, `ucontext-cp` is not removed. Clean them up! Signed-off-by: Ammar Faizi <ammar.faizi@xxxxxxxxxxxxxxxxxxxxx> --- examples/Makefile | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index d3c5000..f966f94 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -10,20 +10,29 @@ ifneq ($(MAKECMDGOALS),clean) include ../config-host.mak endif -all_targets += io_uring-test io_uring-cp link-cp +example_srcs := \ + io_uring-cp.c \ + io_uring-test.c \ + link-cp.c + +all_targets := + ifdef CONFIG_HAVE_UCONTEXT -all_targets += ucontext-cp + example_srcs += ucontext-cp.c endif +all_targets += ucontext-cp -all: $(all_targets) +example_targets := $(patsubst %.c,%,$(patsubst %.cc,%,$(example_srcs))) +all_targets += $(example_targets) -test_srcs := io_uring-test.c io_uring-cp.c link-cp.c -test_objs := $(patsubst %.c,%.ol,$(test_srcs)) +all: $(example_targets) %: %.c $(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS) clean: - @rm -f $(all_targets) $(test_objs) + @rm -f $(all_targets) + +.PHONY: all clean -- 2.30.2