all: installed

INSTALL_DIR = ${CURDIR}
GIT_DIR = build/python-twitter
GIT_URL = https://github.com/bear/python-twitter
GIT_REVISION = 61bca7f6764ed5090aebf8043993c30186152697

PYTHONBIN   = python2
PYTHONDIR   = $(shell $(PYTHONBIN) -c 'import sys; print "python%s"%sys.version[:3]')
SETUPTOOLS_ARG_EXTRA = "--install-layout=deb"
DIST_DIR    = $(INSTALL_DIR)/lib/$(PYTHONDIR)/dist-packages

MK_DIR      = $(shell rospack find mk)

include $(MK_DIR)/git_checkout.mk

disable_ssl:
	git config --global http.sslVerify false

installed: disable_ssl $(GIT_DIR)
	mkdir -p $(DIST_DIR)
	cd $(GIT_DIR) && pip install --user -r requirements.txt || echo ";; apt-get install python-pip"
	cd $(GIT_DIR) && $(PYTHONBIN) ./setup.py build
	cd $(GIT_DIR) && PYTHONPATH=$(DIST_DIR) $(PYTHONBIN) ./setup.py install --prefix=$(INSTALL_DIR) $(SETUPTOOLS_ARG_EXTRA) --record installed_files.txt
	mkdir -p ${INSTALL_DIR}/bin
	cp $(GIT_DIR)/get_access_token.py ${INSTALL_DIR}/bin
	touch installed

clean:
	(cd $(GIT_DIR) && cat installed_files.txt | xargs rm -rvf )
	rm -fr $(DIST_DIR)




