# -*-mode: makefile; fill-column: 75; tab-width: 8; coding: utf-8-unix -*-

PROG=gridfire
BOX_OS_FLAVOR=`cat /etc/hostname`

pex:: gridfire.py Makefile
	$(MAKE) $(MFLAGS) -f Makefile.pex dist/dist-$(BOX_OS_FLAVOR)/gridfire.pex

# No bundling of so's - not a freezer
dist/dist-Windows/gridfire.pex:: gridfire.py Makefile
	[ -d dist/dist-$(BOX_OS_FLAVOR) ] ||mkdir -p dist/dist-$(BOX_OS_FLAVOR)
	/usr/local/bin/pex3.bash -D $(PWD) -m gridfire:main -o $@ \
                --no-index --ignore-errors  --inherit-path=prefer \
		-r gridfire.reqs --no-index \
		--platform windows_x86_64-cp-37-cp37mu	
	zip -d $@ build/build-\*/\* dist/dist-\*/\* cxFreeze-$(BOX_OS_FLAVOR)\* \
		\*/.git/\* \*.log __pycache__/\* >/dev/null

dist/dist-Kick150154/gridfire.pex:: gridfire.py Makefile
	/usr/local/bin/python3.sh -c 'import pex' || \
		apt-get install python3-pex || \
		/usr/local/bin/pip3.sh install pex
	[ -d dist/dist-Kick150154/ ]||mkdir -p dist/dist-Kick150154
	/usr/local/bin/pex3.bash -D $(PWD) -m gridfire:main -o $@ \
		-f /usr/lib/python3/dist-packages/ \
                --no-index --ignore-errors  --inherit-path=prefer \
		--platform linux_x86_64-cp-27-cp27mu \
		--platform linux_x86_64-cp-37-cp37mu
	zip -d $@ build/build-\*/\* dist/dist-\*/\* cxFreeze-Kick150154\* \
		\*/.git/\* \*.log __pycache__/\* >/dev/null

dist/dist-pentoo/gridfire.pex:: gridfire.py Makefile
	/usr/local/bin/python3.sh -c 'import pex' || /usr/local/bin/pip3.sh install pex
	[ -d dist/dist-pentoo/ ]||mkdir -p dist/dist-pentoo
	PYTHONPATH=${PWD} /usr/local/bin/pex3.bash -D $(PWD) -m gridfire:iMain -o $@ \
                --no-index --ignore-errors  --inherit-path=prefer \
		--platform linux_x86_64-cp-27-cp27mu \
		--platform linux_x86_64-cp-38-cp38mu	
	zip -d $@ build/build-\*/\* dist/dist-\*/\* cxFreeze-pentoo\* \
		\*/.git/\* \*.log __pycache__/\* >/dev/null

dist/dist-devuan/gridfire.pex:: gridfire.py Makefile
	/usr/local/bin/python3.sh -c 'import pex' || apt-get install python3-pex
	[ -d dist/dist-devuan/ ]||mkdir -p dist/dist-devuan
	/usr/local/bin/pex3.bash -D $(PWD) -m gridfire:main -o $@ \
                --no-index --ignore-errors  --inherit-path=prefer \
		--platform linux_x86_64-cp-39-cp39mu	
	zip -d $@ build/build-\*/\* dist/dist-\*/\* cxFreeze-devuan\* \
		\*/.git/\* \*.log __pycache__/\* >/dev/null

clean::
	rm *~

veryclean:: clean
	rm -f dist/dist-`cat /etc/hostname`/gridfire.pex
