#VERBOSE=-v
VERBOSE=

go:
	./this-pylint --which-2 None --to-pylint pnetcat
	pep8 --max-line-length 132 pnetcat
	ctags-exuberant pnetcat
	./pnetcat -h > /dev/null
	! ./pnetcat --bogus-option 2> /dev/null
	! ./pnetcat 2> /dev/null
	dd if=/dev/random bs=9999999 count=1 of=real-random
	/usr/local/cpython-3.4/bin/python3 pnetcat -t 9999999 -i -o $(VERBOSE) < real-random > test-random
	cmp real-random test-random
	@echo
	/usr/local/cpython-2.7/bin/python pnetcat -t 9999999 -i -o $(VERBOSE) < real-random > test-random
	cmp real-random test-random
	@echo
	/usr/local/cpython-3.4/bin/python3 pnetcat -t 9999999 -I 12345 -o > test-random &
	sleep 1
	/usr/local/cpython-3.4/bin/python3 pnetcat -t 9999999 -i -O localhost 12345 $(VERBOSE) < real-random
	cmp real-random test-random
	@echo
	/usr/local/cpython-2.7/bin/python pnetcat -t 9999999 -I 12345 -o > /dev/null > test-random &
	sleep 1
	/usr/local/cpython-2.7/bin/python pnetcat -t 9999999 -i -O localhost 12345 $(VERBOSE) < real-random
	cmp real-random test-random
	@echo
	# Note that UDP is unreliable, so a count that isn't correct may not be an actual error
	/usr/local/cpython-3.4/bin/python3 pnetcat -t 9999999 -b 1024 -I 54321 -o -u > test-random &
	sleep 1
	/usr/local/cpython-3.4/bin/python3 pnetcat -t 9999999 -b 1024 -i -O localhost 54321 -u $(VERBOSE) < real-random
	cmp real-random test-random
	@echo
	/usr/local/cpython-2.7/bin/python pnetcat -t 9999999 -b 1024 -I 54321 -o -u > test-random &
	sleep 1
	/usr/local/cpython-2.7/bin/python pnetcat -t 9999999 -b 1024 -i -O localhost 54321 -u $(VERBOSE) < real-random
	cmp real-random test-random
	rm test-random real-random

clean:
	rm -f pnetcatc tags
	rm -f test-random real-random

install:
	./install-file --file pnetcat --directory /usr/local/bin/.