From 7f5ceeb24fb1ebd77e3904d1ad2d1922289e6358 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 10 Nov 2025 18:12:30 +0000 Subject: [PATCH] Add build target for libmousefs_client.a static library - Add CLIENT_CFILES and CLIENT_OFILES variables to Makefile - Add rules to build object files and create static library - Include libmousefs_client.a in the 'all' target - Update clean target to remove library and object files - Update .gitignore to ignore *.o and *.a build artifacts The library includes: client.c, basic.c, tcp.c, message.c --- .gitignore | 2 ++ Makefile | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 512eab8..2b915ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.exe *.out +*.o +*.a chunk_server_data_* diff --git a/Makefile b/Makefile index b0658cb..e40185f 100644 --- a/Makefile +++ b/Makefile @@ -12,9 +12,13 @@ endif CFILES = $(shell find src -name '*.c') HFILES = $(shell find src -name '*.h') +# Client library source files +CLIENT_CFILES = src/client.c src/basic.c src/tcp.c src/message.c +CLIENT_OFILES = $(CLIENT_CFILES:.c=.o) + .PHONY: all clean -all: mousefs_server$(EXT) mousefs_test$(EXT) example_client$(EXT) +all: mousefs_server$(EXT) mousefs_test$(EXT) example_client$(EXT) libmousefs_client.a mousefs_server$(EXT): $(CFILES) $(HFILES) gcc -o $@ $(CFILES) $(CFLAGS) $(LFLAGS) -Iinc -DBUILD_SERVER @@ -25,11 +29,20 @@ mousefs_test$(EXT): $(CFILES) $(HFILES) example_client$(EXT): examples/main.c $(CFILES) $(HFILES) gcc -o $@ examples/main.c $(CFILES) $(CFLAGS) $(LFLAGS) -Iinc +# Client library build rules +%.o: %.c $(HFILES) + gcc -c -o $@ $< $(CFLAGS) -Iinc + +libmousefs_client.a: $(CLIENT_OFILES) + ar rcs $@ $^ + clean: - rm \ + rm -f \ mousefs_server.exe \ mousefs_server.out \ mousefs_test.exe \ mousefs_test.out \ example_client.exe \ - example_client.out + example_client.out \ + libmousefs_client.a \ + $(CLIENT_OFILES)