SDLFLAGS_CC:=$(shell pkg-config sdl3 --cflags) $(shell pkg-config sdl3-ttf --cflags) $(shell pkg-config sdl3-image --cflags) $(shell pkg-config akgl --cflags) $(shell pkg-config akerror --cflags)
SDLFLAGS_LD:=$(shell pkg-config sdl3 --libs) $(shell pkg-config sdl3-ttf --libs) $(shell pkg-config sdl3-mixer --libs) $(shell pkg-config sdl3-image --libs) $(shell pkg-config akgl --libs) $(shell pkg-config akerror --libs) -lasound
CC:=$(shell which gcc)
LD:=$(shell which ld)

SRCFILES:=$(shell find src -type f -name '*.c')
OBJFILES:=$(patsubst %.c,%.o,$(SRCFILES))

LDFLAGS:=-L/home/andrew/local/lib -lsdlerror -lakgl -lgcov -lbox2d -ljansson
CFLAGS:=-I/home/andrew/local/include -g3 -gdwarf-2 -I./include/ -Wall -fstack-usage -Werror=analyzer-use-of-uninitialized-value -Werror=unused-result -Werror=multistatement-macros

DISTFILE:=dist/akgl-test

.PHONY: lib
.PHONY: clean

all: $(DISTFILE)

clean:
	rm -fr $(OBJFILES) ${DISTFILE}

src/%.o: src/%.c $(LIB_HEADERS)
	$(CC) -c -o $@ $(CFLAGS) $(SDLFLAGS_CC) $<

$(DISTFILE): $(OBJFILES)
	$(CC) -o $@ $^ $(LDFLAGS) $(SDLFLAGS_LD) -lm -lwayland-client
