TIMESTAMP := $(shell date +%Y%m%d%H%M%S)
TWITTER := https://api.twitter.com/oauth
AUTHORIZE_URL := $(TWITTER)/authorize
APP_ID := com.jcomeau.test
# use a line like the following in your ~/.netrc file:
# machine api.twitter.com login c0nsUm3rK3y password KonSum3rS3kr3t
# recommended to put www-data homedir in /etc/apache2 on Debian
OAUTH_CONSUMER_KEY ?= $(shell awk '/^machine api.twitter.com/ \
	{print $$4}' ~/.netrc)
OAUTH_CONSUMER_SECRET ?= $(shell awk '/^machine api.twitter.com/ \
	{print $$6}' ~/.netrc)
# now erase the above definitions so the Python script can find them
OAUTH_CONSUMER_KEY :=
OAUTH_CONSUMER_SECRET :=
HTTP_HOST ?= twitter
#OAUTH_CALLBACK ?= http://$(HTTP_HOST)/
REQUEST_TOKEN_URL := $(TWITTER)/request_token
ACCESS_TOKEN_URL := $(TWITTER)/access_token
#OAUTH_VERSION := 1.0
#OAUTH_SIGNATURE_METHOD := HMAC-SHA1
WWWSERVERS := www tek
export
set:
	set
shell:
	/bin/bash  # shell with all the environment variables set
check:
	@echo ensure that OAUTH_SIGNATURE=F1Li3tvehgcraF8DMJ7OyxO4w9Y%3D
	$(MAKE) \
	 OAUTH_CONSUMER_SECRET=L8qq9PZyRg6ieKGEKhZolGC0vJWLw8iEJ88DRdyOg \
	 OAUTH_CALLBACK=http://localhost/sign-in-with-twitter/ \
	 OAUTH_CONSUMER_KEY=cChZNFj6T5R0TigYB9yd1w \
	 OAUTH_NONCE=ea9ec8429b68d6b77cd5600adbbb0456 \
	 OAUTH_TIMESTAMP=1318467427 \
	 get_request_token.test
check2:
	@echo ensure that OAUTH_SIGNATURE=39cipBtIOHEEnybAR4sATQTpl2I%3D
	$(MAKE) \
	 OAUTH_CONSUMER_SECRET=L8qq9PZyRg6ieKGEKhZolGC0vJWLw8iEJ88DRdyOg \
	 OAUTH_CALLBACK=http://localhost/sign-in-with-twitter/ \
	 OAUTH_CONSUMER_KEY=cChZNFj6T5R0TigYB9yd1w \
	 OAUTH_NONCE=a9900fe68e2573b27a37f10fbad6a755 \
	 OAUTH_TOKEN=NPcudxy0yU5T3tBzho7iCotZ3cnetKwcTIRlX0iwRl0 \
	 OAUTH_TOKEN_SECRET=veNRnAWe6inFuo8o2u8SLLZLjolYDmDP7SzL0YfYI \
	 OAUTH_VERIFIER=uw7NjWHT6OJ1MpJOXsHfNxoAhPKpgI8BlYDhxEjIBY \
	 OAUTH_TIMESTAMP=1318467427 \
	 get_access_token.test
%.py:
	[ "$@" != "twitter_oauth.py" ] && ln -s twitter_oauth.py $@
webtest:
	firefox http://twitter/
swebtest:
	firefox https://twitter/
wwwtest:
	firefox http://unternet.net/twitter/twitter_oauth.cgi
swwwtest:
	firefox https://unternet.net/twitter/twitter_oauth.cgi
%.test:	%.py
	@./$<
log:
	tail -n 100 /var/log/apache2/error.log
userlog:
	grep python /var/log/user.log | tail -n 100
checkupload:
	$(MAKE) DRYRUN=--dry-run upload
upload: clean
	for remote in $(WWWSERVERS); do \
	 rsync -avuz $(DRYRUN) \
	 --exclude=.bzr \
	 --exclude=members \
	 --exclude=index.cgi \
	 --delete \
	 . $$remote:/var/www/unternet.net/twitter/; \
	done
clean:
	for file in *.py; do \
	 if [ -d $$(basename $$file .py) ]; then \
	  fusermount -u $$(basename $$file .py); \
	 fi; \
	done
	rm -f *.pyc
sigtest:
	$(MAKE) hmac_sha1_test.test
backup:
	cd ~/rentacoder && make upload
