CC ?= cc
CFLAGS ?= -O2 -g
CFLAGS += -std=c23 -Wall -Wextra -Wpedantic -Wno-unused-function -Wno-logical-op-parentheses
LDLIBS += -lm

COMMON_OBJECTS = parser.o typecheck.o probe.o compiler.o

.PHONY: all test clean debug

all: vedit

vedit: main.o $(COMMON_OBJECTS)
	$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)

tests: tests.o $(COMMON_OBJECTS)
	$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)

test: tests
	./tests

debug: CFLAGS := -std=c23 -O0 -g3 -Wall -Wextra -Wpedantic -Wno-unused-function \
	-Wno-logical-op-parentheses -fsanitize=address,undefined
debug: clean tests
	./tests

clean:
	rm -f vedit tests *.o