Files
ToastyFS/Makefile
T
Claude a57e713fda Add library build, Docker cluster, and example client
Introduce a Makefile that builds libtoastyfs.a and libtoastyfs.so from the
client-side sources (client, tcp, byte_queue, message, basic) so external
programs can link against the ToastyFS client API in include/toastyfs.h.

Add a Dockerfile and docker-compose.yml that spin up a 3-node ToastyFS
server cluster on a private bridge network with ports 8081-8083 exposed
on the host. Include cluster.sh as a convenience wrapper (up/down/status/
logs/run) — the "run" sub-command builds the library, compiles a user-
supplied C source against it, starts the cluster, and executes the binary.

Add examples/example.c demonstrating synchronous PUT, GET, DELETE, and a
NOT_FOUND verification.

https://claude.ai/code/session_019DVhmc25jfzcHnmdNxzib2
2026-02-21 14:30:58 +00:00

82 lines
2.3 KiB
Makefile

CC ?= gcc
CFLAGS ?= -Wall -Wextra -ggdb -O0
AR ?= ar
INCLUDES = -Iquakey/include -Iinclude -I.
# ---- Library (client-side only) ----
LIB_SRCS = src/client.c src/tcp.c src/byte_queue.c src/message.c src/basic.c
LIB_OBJS = $(LIB_SRCS:.c=.o)
STATIC_LIB = libtoastyfs.a
SHARED_LIB = libtoastyfs.so
# ---- Server binary ----
SERVER_SRCS = src/basic.c src/file_system.c src/byte_queue.c src/message.c \
src/tcp.c src/server.c src/main.c src/log.c src/client_table.c \
src/chunk_store.c src/metadata.c
# ---- Client binary (random test client) ----
CLIENT_SRCS = src/basic.c src/file_system.c src/byte_queue.c src/message.c \
src/tcp.c src/server.c src/client.c src/random_client.c src/main.c \
src/log.c src/client_table.c src/chunk_store.c src/metadata.c
# ---- Simulation binary ----
SIM_SRCS = src/basic.c src/file_system.c src/byte_queue.c src/message.c \
src/tcp.c src/server.c src/client.c src/random_client.c src/main.c \
src/log.c src/client_table.c src/invariant_checker.c src/chunk_store.c \
src/metadata.c quakey/src/mockfs.c quakey/src/quakey.c
# ---- Default target ----
all: $(STATIC_LIB) $(SHARED_LIB) toastyfs toastyfs_client toastyfs_simulation
# ---- Library targets ----
lib: $(STATIC_LIB) $(SHARED_LIB)
$(STATIC_LIB): $(LIB_OBJS)
$(AR) rcs $@ $^
$(SHARED_LIB): $(LIB_SRCS)
$(CC) $(CFLAGS) -shared -fPIC $(INCLUDES) $^ -o $@
src/%.o: src/%.c
$(CC) $(CFLAGS) $(INCLUDES) -fPIC -c $< -o $@
# ---- Binary targets ----
toastyfs: $(SERVER_SRCS)
$(CC) $(CFLAGS) $(INCLUDES) -DMAIN_SERVER $^ -o $@
toastyfs_client: $(CLIENT_SRCS)
$(CC) $(CFLAGS) $(INCLUDES) -DMAIN_CLIENT $^ -o $@
toastyfs_simulation: $(SIM_SRCS)
$(CC) $(CFLAGS) $(INCLUDES) -DMAIN_SIMULATION -DFAULT_INJECTION $^ -o $@
# ---- Install ----
PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib
INCLUDEDIR?= $(PREFIX)/include
install: $(STATIC_LIB) $(SHARED_LIB)
install -d $(DESTDIR)$(LIBDIR)
install -d $(DESTDIR)$(INCLUDEDIR)
install -m 644 $(STATIC_LIB) $(DESTDIR)$(LIBDIR)/
install -m 755 $(SHARED_LIB) $(DESTDIR)$(LIBDIR)/
install -m 644 include/toastyfs.h $(DESTDIR)$(INCLUDEDIR)/
# ---- Clean ----
clean:
rm -f $(LIB_OBJS) $(STATIC_LIB) $(SHARED_LIB)
rm -f toastyfs toastyfs_client toastyfs_simulation
.PHONY: all lib clean install