PKG_CONFIG ?= pkg-config
CFLAGS = -std=c99 $(shell $(PKG_CONFIG) --cflags unibilium termkey tickit) -DHAVE_UNIBILIUM
LDFLAGS = $(shell $(PKG_CONFIG) --libs unibilium termkey tickit)
LIBTOOL = ./libtool
TESTSOURCES = $(sort $(wildcard t/[0-9]*.c))
TESTFILES = $(TESTSOURCES:.c=.t)

configure: configure.ac
	LIBTOOLIZE='libtoolize -i' autoreconf -f -i

libtool: configure
	./configure

t/%.lo: t/%.c | libtool
	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(CFLAGS) -o $@ -c $^

t/%.t: t/%.lo t/taplib.lo t/mockterm.lo t/taplib-tickit.lo | libtool
	$(LIBTOOL) --mode=link --tag=CC $(CC) -o $@ $^ $(LDFLAGS)

.PHONY: test
test: $(TESTFILES)
	$(LIBTOOL) --mode=execute prove -e ''
