CC ?= cc
CPPFLAGS += $(shell pkg-config --cflags libcurl json-c libxxhash)
CFLAGS ?= -O2 -g
CFLAGS += -std=c17 -Wall -Wextra -Wpedantic -Werror -Wconversion -Wshadow \
          -Wstrict-prototypes -Wmissing-prototypes -Wformat=2 -fstack-protector-strong
LDLIBS += $(shell pkg-config --libs libcurl json-c libxxhash)

.PHONY: all clean check

all: pretranscode

pretranscode: pretranscode.c
	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)

tests/test_core: tests/test_core.c pretranscode.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused-function $(LDFLAGS) -o $@ $< $(LDLIBS)

check: pretranscode tests/test_core
	./pretranscode --version
	./tests/test_core

clean:
	rm -f pretranscode tests/test_core
