PYINTERP=/usr/local/cpython-3.7/bin/python3

#SSH=-ssh-read-write
SSH=

moviedir:=$(shell if [ -d /mymount/movie/ ]; then echo /mymount/movie; elif [ -d /mymount/movie-ssh-read-write/ ]; then echo /mymount/movie-ssh-read-write/; fi)
INSTALL_DIR=/usr/local/bin/.

default: go5

types:
	monkeytype run mplay.t --timestamps '../../../../../../${moviedir}/Avatar - The Last Airbender/'
	LC_ALL=C.UTF-8 LANG=C.UTF-8 monkeytype apply mplay
	
go5: lints
	# ${PYINTERP} -m mypy --disallow-untyped-calls mnext
	[ "`./mnext test-data-for-mnext/bad-file-extension 2>&1; exit 0`" = "Unknown whether pathname test-data-for-mnext/bad-file-extension/2.foo! is a media file or not" ]
	[ "`./mnext test-data-for-mnext/empty-dir 2>&1; exit 0`" = "./mnext: no media files found" ]
	[ "`./mnext test-data-for-mnext/finished-show 2>&1; exit 0`" = "You have reached the end of this show. mplay the first if you wish to start over." ]
	[ "`./mnext test-data-for-mnext/in-the-middle-show`" = "test-data-for-mnext/in-the-middle-show/3.mp4" ]
	[ "`./mnext test-data-for-mnext/one-media-file-unwatched`" = "test-data-for-mnext/one-media-file-unwatched/file.mp4" ]
	[ "`./mnext test-data-for-mnext/one-media-file-watched 2>&1; exit 0`" = "You have reached the end of this show. mplay the first if you wish to start over." ]
	# ./mnext /mymount/movie/Big\ Bang\ Theory,\ The

go4: lints
	./mplay --timestamps ${moviedir}/Stranger\ Things/Season\ 1/Disc\ 1\ of\ 2/handbrake/

go3: lints
	./mreport --list-unfinished
	./mreport --views-timestamps
	./mreport --no-views

go2: lints
	# /usr/local/cpython-3.4/bin/pudb3 msync source_dir dest_dir
	./msync $$(pwd)/source_dir $$(pwd)/dest_dir

go: lints
	(cd ~/movie${SSH}/Little\ Movies && ~/src/home-svn/mplay/trunk/mplay --temp 'Ugachaka Baby/UGACHAKA.AVI')
	(cd ~/movie${SSH}/Little\ Movies && ~/src/home-svn/mplay/trunk/mplay --timestamps)
	(~/src/home-svn/mplay/trunk/mplay --timestamps ~/movie${SSH}/Little\ Movies ~/movie${SSH}/Rush)
	./mplay ~/movie${SSH}/"Little Movies/Ugachaka Baby/UGACHAKA.AVI"

lints:
	ctags-exuberant --language-force=Python mplay mreport msync
	python3 -m mypy --disallow-untyped-calls --ignore-missing-imports mplay
	# ./this-pylint --which-2 None --to-pylint mplay
	${PYINTERP} -m mypy --disallow-untyped-calls mplay
	./this-pylint --which-2 None --to-pylint msync
	${PYINTERP} -m mypy --disallow-untyped-calls msync
	${PYINTERP} -m mypy --disallow-untyped-calls mreport
	${PYINTERP} -m mypy --disallow-untyped-calls mnext

install:
	./install-file --file mreport --directory ${INSTALL_DIR}
	./install-file --file mplay --directory ${INSTALL_DIR}
	./install-file --file mmv --directory ${INSTALL_DIR}
	./install-file --file mrm --directory ${INSTALL_DIR}
	./install-file --file msync --directory ${INSTALL_DIR}
	./install-file --file msyncs --directory ${INSTALL_DIR}
	./install-file --file mlink --directory ${INSTALL_DIR}
	./install-file --file munfail --directory ${INSTALL_DIR}
	./install-file --file mexts --directory ${INSTALL_DIR}
	./install-file --file mnext --directory ${INSTALL_DIR}
	./install-file --file mp --directory ${INSTALL_DIR}
	./install-file --file input.conf --directory ~/.mplayer/.
	./install-file --file config --directory ~/.mplayer/.
	./install-package --deb-packages mplayer --rpm-packages mplayer
	./install-package --deb-packages vlc --rpm-packages vlc

clean:
	rm -f *.pyc
	rm -rf __pycache__ .mypy_cache
	rm -rf dest_dir/*
	rm -f tags
	rm -f monkeytype.sqlite3