###########################################################################
#
# FairCom Corporation makefile for c-treeACE Python Tutorials
#
###########################################################################

# Directory in which tutorial source code is located
SRCDIR=..
PYEXE=python3
LIBDIR=../../ctree.drivers/lib
CPAPI=
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
	CPAPI=cd $(SRCDIR)/;cp $(LIBDIR)/libctsqlapi.dylib .
endif
ifeq (, $(shell which $(PYEXE)))
	PYEXE=python
endif
ifeq (, $(shell which $(PYEXE)))
$(error Error. Could not find suitable $(PYEXE). Aborting.)
endif


ALL:
	cd $(SRCDIR)/;cp ../pyctree.py .;cp ../pyctsqlapi.py .
	$(CPAPI)
	@echo "The python tutorials are ready to run."
	@echo Make sure your Python and FairCom runtimes match. Both must be 32-bit or 64-bit\; otherwise, you will get the wrong ELF class Error
	@echo "Type 'make run' to run the tutorials."
run:
	cd $(SRCDIR)/;LD_LIBRARY_PATH=$(LIBDIR) $(PYEXE) PY_tutorial2.py;
	cd $(SRCDIR)/;LD_LIBRARY_PATH=$(LIBDIR) $(PYEXE) PY_tutorial4.py

clean:
	rm -f $(SRCDIR)/*.pyc
	rm -f $(SRCDIR)/pyctree.py
	rm -f $(SRCDIR)/pyctsqlapi.py

