# rt16-heif — see src/rt16-heif.c for what it is and why it exists. Linked with the C++ driver: libheif is C++ and its
# runtime goes in statically (-static-libstdc++ comes in LDFLAGS); pkg-config's own -lstdc++ would pull the shared one.
CC         ?= cc
CXX        ?= c++
CFLAGS     ?= -O2 -Wall -Wextra
LDFLAGS    ?=
PKG_CONFIG ?= pkg-config --static
OUT        ?= build
HEIF_CFLAGS = $(shell $(PKG_CONFIG) --cflags libheif libpng16)
HEIF_LIBS   = $(filter-out -lstdc++,$(shell $(PKG_CONFIG) --libs libheif libpng16))

$(OUT)/rt16-heif: $(OUT)/rt16-heif.o
	$(CXX) -o $@ $< $(HEIF_LIBS) $(LDFLAGS) -lpthread -lm

$(OUT)/rt16-heif.o: src/rt16-heif.c src/display-p3.h | $(OUT)
	$(CC) $(CFLAGS) $(HEIF_CFLAGS) -c -o $@ $<

$(OUT):
	mkdir -p $(OUT)

clean:
	rm -rf $(OUT)

.PHONY: clean
