prefix = $(PWD)/test-tree
bindir = $(prefix)/bin
libdir = $(prefix)/lib
sharedir = $(prefix)/share
mandir = $(prefix)/share/man
man1dir = $(mandir)/man1

all: check

check: _lodju.so
	python testrun.py

_lodju.so: _lodjumodule.c
	python setup.py build
	cp build/lib.*/_lodju.so .

install: _lodju.so
	install -d $(bindir)
	install -d $(libdir)
	install -d $(sharedir)
	install -d $(man1dir)
	sed 's#^SHAREDIR.*#SHAREDIR = "$(sharedir)"#' lodju.py | \
	    sed 's#^LIBDIR.*#LIBDIR = "$(libdir)"#;' > $(bindir)/lodju
	chmod 755 $(bindir)/lodju
	install convert-lodju1-to-lodju2.sh $(bindir)/convert-lodju1-to-lodju2
	install _lodju.so $(libdir)
	install -m 0644 lodju.dtd lodju.glade *.png *.py $(sharedir)
	cp -a templates $(sharedir)
	install -m 0644 *.1 $(man1dir)
	rm $(sharedir)/lodju.py

clean:
	rm -rf *.pyc *.pyo _lodju.so build
