
RELEASEFILES=	tentakel.1 \
		tentakel.1.html \
		INSTALL \
		README \
		TODO \
		PLUGINS \
		ChangeLog \
		tentakel.conf.example \
		Makefile \
		execwrapper.c \
		py/setup.py \
		py/tentakel \
		py/lekatnet/__init__.py \
		py/lekatnet/config.py \
		py/lekatnet/error.py \
		py/lekatnet/remote.py \
		py/lekatnet/shell.py \
		py/lekatnet/tpg.py \
		py/lekatnet/plugins/__init__.py \
		py/lekatnet/plugins/rsh.py \
		py/lekatnet/plugins/ssh.py

PYTHON?=	python
PREFIX?=	/usr/local
REL=		tentakel-2.2.1
CC?=		cc
CFLAGS?=

all: build

configure:
	cd py && $(PYTHON) setup.py config

build: configure execwrapper
	cd py && $(PYTHON) setup.py build

htmldoc: tentakel.1
	rm -f tentakel.1.html
	groff -Thtml -man tentakel.1 > tentakel.1.html

changelog:
	git log --pretty=format:"* %cd %cn%n%n%s%n%b" \
		| grep -v "git-svn-id" \
		| sed 's/^\([^*]\)/	\1/' \
		>ChangeLog

install: configure build
	cd py && $(PYTHON) setup.py install --prefix=$(PREFIX)

execwrapper: execwrapper.c
	$(CC) $(CFLAGS) -o execwrapper execwrapper.c

release: build
	rm -rf $(REL)
	mkdir $(REL)
	tar cf - $(RELEASEFILES) | ( cd $(REL) && tar xf - )
	tar czf $(REL).tgz $(REL)
	rm -rf $(REL)

regress: build
	cd py/lekatnet && $(PYTHON) config.py
	cd py/lekatnet && $(PYTHON) remote.py

clean:
	rm -f *~
	rm -f py/{,lekatnet/,lekatnet/plugins/}{*~,*.pyc,*.pyo}
	rm -rf py/build
	rm -f execwrapper
	rm -f $(REL).tgz

.PHONY: changelog
