INSTALL_DIR := /usr/local/django/prefetch-bug-test/

define header
	@tput setaf 6
	@echo "* $1"
	@tput sgr0
endef

install: $(INSTALL_DIR)
	$(call header,"Installing")
	@. $(INSTALL_DIR)/bin/activate; python setup.py -q install

# Install/update dependencies
# Runs whenever any requirements file changes.
$(INSTALL_DIR): $(INSTALL_DIR)/bin/activate
$(INSTALL_DIR)/bin/activate: requirements.txt
	$(call header,"Updating dependencies")
	@test -d $(INSTALL_DIR) || virtualenv $(INSTALL_DIR)
	@. $(INSTALL_DIR)/bin/activate; pip install -q --upgrade pip
	@. $(INSTALL_DIR)/bin/activate; pip install -r requirements.txt
	@touch $(INSTALL_DIR)/bin/activate

test: install
	$(call header,"Running unit tests")
	@. $(INSTALL_DIR)/bin/activate; python manage.py test

migrations: install
	@. $(INSTALL_DIR)/bin/activate; python manage.py makemigrations
