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)