.PHONY: all clean test test-unattended

GTK_CFLAGS=$(shell pkg-config --cflags gtk+-2.0)
GTK_LIBS=$(shell pkg-config --libs gtk+-2.0)

DEBUG=-O0 -g
CFLAGS=$(GTK_CFLAGS) $(DEBUG)
LIBS=$(GTK_LIBS)

# disable GTypeDebugFlags and GTimeVal deprecations, might be overkill
CFLAGS+=-DGTK_DISABLE_DEPRECATED

# Define this macro to make code blocks end with an empty line according to
# the CommonMark 0.30 specification. The default value below does not create
# the empty line because I think the output block looks better without.
CFLAGS+=-UCOMMONMARK_FENCED_CODEBLOCK_LINE_ENDING

all: mdview

mdview: *.c *.h
	$(CC) *.c -o mdview $(CFLAGS) $(LIBS)

clean:
	rm -f mdview

test: all test-unattended
	./mdview examples

test-unattended: all
	@test/run_unattended_tests.sh

### build distribution package
package: clean
	-rm -rf /tmp/mdview-fossil
	-mkdir -p /tmp/mdview-fossil
	-cp  -a * /tmp/mdview-fossil
	-fossil info > /tmp/mdview-fossil/fossil-version
	-echo Version $(shell date +%F) > /tmp/mdview-fossil/VERSION
	-rm -f /tmp/mdview-fossil/auth*
	-tar -C /tmp -cjvf ../mdview-$(shell date +%F).tar.bz2 mdview-fossil
	-rm -rf /tmp/mdview-fossil

