# Makefile for Nock OCaml/C benchmark comparison VERE_ROOT = ../vere VERE_PKG = $(VERE_ROOT)/pkg/noun VERE_INCLUDES = -I$(VERE_ROOT)/pkg -I$(VERE_ROOT)/ext # Find the Vere build directory VERE_BUILD = $(VERE_ROOT)/build # Try to find the actual library paths VERE_LIBS = -L$(VERE_BUILD) -L$(VERE_ROOT)/build CC = gcc CFLAGS = -O3 -g $(VERE_INCLUDES) LDFLAGS = $(VERE_LIBS) .PHONY: all clean bench bench-c bench-ocaml test compare all: test bench # Build everything build: build-ocaml build-ocaml: @echo "Building OCaml implementation..." dune build # Note: C benchmark requires linking against libvere which may not be available # as a standalone library. We'll document this limitation. build-c: bench_nock_c @echo "C benchmark built (requires Vere libraries)" bench_nock_c: bench_nock.c @echo "Note: Building C benchmark requires Vere to be built first" @echo "This may fail if Vere libraries are not available" @echo "Attempting to compile..." -$(CC) $(CFLAGS) -o bench_nock_c bench_nock.c \ $(VERE_PKG)/allocate.c \ $(VERE_PKG)/nock.c \ $(VERE_PKG)/hashtable.c \ $(VERE_PKG)/imprison.c \ $(VERE_PKG)/jets.c \ $(VERE_PKG)/manage.c \ $(VERE_PKG)/retrieve.c \ $(VERE_PKG)/trace.c \ $(VERE_PKG)/xtract.c \ $(VERE_PKG)/events.c \ $(VERE_PKG)/zave.c \ $(LDFLAGS) -lm -lpthread -lgmp -lsigsegv -luv -lcrypto -lssl # Run tests test: @echo "Running OCaml tests..." dune exec ./test_nock.exe # Run benchmarks bench: bench-ocaml bench-ocaml: @echo "Running OCaml benchmark..." dune exec ./bench_nock.exe bench-c: bench_nock_c @echo "Running C benchmark..." ./bench_nock_c # Compare both implementations (if C benchmark is available) compare: bench-ocaml @echo "" @echo "==================================" @echo "Comparison (OCaml only)" @echo "==================================" @echo "Note: C benchmark requires full Vere build" @echo "To compare, build Vere first, then run 'make bench-c'" # Clean build artifacts clean: dune clean rm -f bench_nock_c rm -f *.o help: @echo "Nock OCaml/C Benchmark Makefile" @echo "" @echo "Targets:" @echo " make test - Run OCaml tests" @echo " make bench - Run OCaml benchmark" @echo " make bench-ocaml - Run OCaml benchmark" @echo " make bench-c - Run C benchmark (requires Vere build)" @echo " make compare - Run comparison" @echo " make clean - Clean build artifacts" @echo "" @echo "Note: C benchmarks require Vere to be fully built first."