lumbda/c/Makefile
russell@unturf.com fc9eb5350c Add C implementation: 7,429 lines, 58 tests, identical output
Complete C port of the Scheme interpreter. Same .lsp files run in
both Python and C with identical output.

Architecture:
- NaN-boxed 64-bit values (zero-alloc numbers)
- Hash-map environments with parent chain + global shortcut
- Interned symbols
- TCO via explicit loop (eval) and TAIL_CALL/SELF_TAIL_CALL (VM)
- Bytecode compiler with all opcodes including superinstructions
- 58 unit + integration tests

Makefile targets:
  make test-all    run Python (571) + C (58) tests
  make examples    run examples in both, compare output
  make friction    benchmark same .lsp in Python vs C
  make c-build     build C interpreter
  make c-test      run C tests
  make c-repl      C REPL
2026-04-14 14:55:17 -04:00

39 lines
874 B
Makefile

# Makefile for uncommonlisp C interpreter
# Targets: all, test, bench, clean
CC = gcc
CFLAGS = -O2 -Wall -Wextra -Wno-unused-parameter -std=c11 -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE
LDFLAGS = -lm
# Optional: Boehm GC support
# Uncomment the next two lines if libgc-dev is installed
# CFLAGS += -DUSE_BOEHM_GC
# LDFLAGS += -lgc
SRCS = types.c reader.c printer.c eval.c builtins.c vm.c
OBJS = $(SRCS:.c=.o)
.PHONY: all clean test bench
all: uncommonlisp
uncommonlisp: main.o $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
test: test_runner
./test_runner
test_runner: test.c $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
bench: bench_runner uncommonlisp
ulimit -s 65536 && ./bench_runner
bench_runner: bench.c $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
%.o: %.c uncommonlisp.h
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -f *.o uncommonlisp test_runner bench_runner