# Top-level Makefile – delegates build/clean/test to subdirectories

CC ?= gcc

SUBDIRS = engine client

.PHONY: all build clean test check format orchestrator run $(SUBDIRS)

all: build orchestrator

build: $(SUBDIRS)
	@echo "Build complete."

orchestrator: orchestrator.c
	$(CC) -Wall -Wextra -std=c11 -o looper orchestrator.c

$(SUBDIRS):
	$(MAKE) -C $@

run: orchestrator
	./looper

test:
#	$(MAKE) -C engine test
	$(MAKE) -C client test

clean:
	rm -f looper
	@for dir in $(SUBDIRS); do \
	    echo "Cleaning $$dir..."; \
	    $(MAKE) -C $$dir clean; \
	done

check:
	$(MAKE) -C engine check

format:
	$(MAKE) -C engine format
