version=\"$(shell cat .version)\"
CFLAGS := $(shell pkg-config --cflags ncursesw)
CFLAGS += -DLSP_VERSION=$(version)
LDFLAGS := $(shell pkg-config --libs ncursesw)

ifeq ($(prefix),)
	prefix := /usr
endif

lsp: lsp.c
	gcc $(CFLAGS) $(LDFLAGS) -o $@ $<

doc/lsp.1: doc/lsp.adoc
	a2x --doctype manpage --format manpage -a lsp-version=$(version) $<

.PHONY: uninstall install

install: lsp doc/lsp.1 doc/lsp-help.1
	install lsp $(prefix)/bin
	install doc/lsp.1 doc/lsp-help.1 $(prefix)/share/man/man1/

uninstall:
	rm $(prefix)/bin/lsp
	rm $(prefix)/share/man/man1/lsp{,-help}.1
