#!/usr/bin/make -f

PACKAGE = colortest-python
PKGDIR	= $(shell pwd)/debian/$(PACKAGE)
BINDIR	= $(PKGDIR)/usr/bin

ORIG	= terminal-colors
URL	= http://zhar.net/projects/shell/$(ORIG)
DIR	= ../tmp
SAVE	= $(DIR)/$(ORIG)

get-orig-source:
	install -d -m 755 $(DIR)
	rm -f $(SAVE)

	wget -q -O $(SAVE) http://zhar.net/projects/shell/terminal-colors

	@cmp $(SAVE) $(ORIG); \
	status=$$? ; \
	if [ "$$status" = "1" ] ; then \
	    echo "New upstream release downloaded: $(SAVE)"; \
	    ver=$$(python $(SAVE) --version | awk '{print $$1}') ; \
	    rm -vrf $(DIR)/$(PACKAGE)-$$ver && \
	    mkdir -v $(DIR)/$(PACKAGE)-$$ver && \
	    cp -v $(SAVE) $(DIR)/$(PACKAGE)-$$ver && \
	    (cd $(DIR) && tar -zcvf $(PACKAGE)-$$ver.tar.gz $(PACKAGE)-$$ver ); \
	    echo "Done $(DIR)/$(PACKAGE)-$$ver.tar.gz"; \
	else \
	    echo "Up to date"; \
	fi

man:
	$(MAKE) -C debian -f pod2man.mk PACKAGE=$(PACKAGE) makeman

override_dh_auto_install: man
	install -m 755 -D $(ORIG) $(BINDIR)/$(PACKAGE)

%:
	dh  $@ --with python2

.PHONY: man get-orig-source

# End of file
