Re: [PATCH 1/2] Fix Makefile to delete objects from the library on make clean

Eric Biggers
2020-05-20T02:42:45Z

On Fri, May 15, 2020 at 04:56:48PM -0400, Jes Sorensen wrote:
> From: Jes Sorensen <jsorensen@fb.com>
>
> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
> ---
> Makefile | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Makefile b/Makefile
> index 1a7be53..c5f46f4 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -81,6 +81,7 @@ LIB_SRC := $(wildcard lib/*.c)
> LIB_HEADERS := $(wildcard lib/*.h) $(COMMON_HEADERS)
> STATIC_LIB_OBJ := $(LIB_SRC:.c=.o)
> SHARED_LIB_OBJ := $(LIB_SRC:.c=.shlib.o)
> +LIB_OBJS := $(SHARED_LIB_OBJ) $(STATIC_LIB_OBJ)
>
> # Compile static library object files
> $(STATIC_LIB_OBJ): %.o: %.c $(LIB_HEADERS) .build-config
> --

Thanks for pointing this out. I think it would be a bit easier to just use a
wildcard in the clean target, though.

diff --git a/Makefile b/Makefile
index 1a7be53..e7fb5cf 100644
--- a/Makefile
+++ b/Makefile
@@ -180,8 +180,8 @@ help:
done

clean:
- rm -f $(DEFAULT_TARGETS) $(TEST_PROGRAMS) $(LIB_OBJS) $(ALL_PROG_OBJ) \
- .build-config
+ rm -f $(DEFAULT_TARGETS) $(TEST_PROGRAMS) \
+ lib/*.o programs/*.o .build-config