# -*-makefile-*----------------------------------------------------------------
# $Id: pkg_python.in,v 1.7 1996/10/22 19:53:31 furnish Exp $
#
# Make assignments for PLplot/Python support.
#
# If Python doesn't support dynamically loaded modules on your system,
# you'll have to link plmodule.o with the Python library to build a
# new Python executable.  Copy plmodule.c into Python's Modules
# subdirectory, add something like the following to Modules/Setup,
#
# pl plmodule.c -I<PLplot include directory> -L<PLplot lib directory>
# -lplplotfX -L<X11 lib directory> -lX11
#
# and rebuild python.  If Python supports dynamically loaded modules,
# then all you have to worry about is passing the right flags to the
# compiler and linker to build a dynamically loaded module from
# plmodule.c (-I/usr/local/include/Py if the Python header files are
# installed, -I.../Python-VERSION/Include if not; Solaris 5.x requires
# ld -G while SunOS 4.x uses just ld, etc.).
# -----------------------------------------------------------------------------

SO		= @SO@
PYTHON_EXE	= plmodule$(SO)
PYTHON_INSTALL	= install_python
PYTHON_INC_DIR	= @PYTHON_INC_DIR@
PYTHON_MOD_DIR	= @PYTHON_MOD_DIR@
PYTHON_MACH_DIR	= @PYTHON_MACH_DIR@
PYTHON_CFG_DIR	= @PYTHON_CFG_DIR@
PYTHON_LIBS	= -L$(PYTHON_CFG_DIR) -lpython1.5
PYTHON_DIR	= @PYTHON_DIR@
LDSHARED	= @LDSHARED@

plmodule$O:	plmodule.c plmodule2.c plmodule.h
	$(CC) $(SHLIB_CCFLAGS) $(CC_FLAGS) \
		-I$(PYTHON_INC_DIR) -I$(PYTHON_CFG_DIR) \
		plmodule.c

$(PYTHON_EXE): plmodule$O
	@echo " "
	@echo "Building Python module."
	@echo " "
	$(LDSHARED) $(LDC_FLAGS) plmodule$O $(PYTHON_LIBS) $(PLLIB_LDC) \
		-o $(PYTHON_EXE) -lc $(LDC_LIBS)

install_python:
	$(LDSHARED) $(LDC_FLAGS) plmodule$O $(PYTHON_LIBS) $(LIB_INSTALL) \
		-o $(PYTHON_EXE) -lc $(LDC_LIBS)
	-if test ! -d $(PYTHON_DIR); then mkdir -p $(PYTHON_DIR); fi
	-cp $(PYTHON_EXE) $(PYTHON_DIR)
	-if test ! -d $(DEMOS_DIR)/python; then mkdir -p $(DEMOS_DIR)/python; fi
	-cd $(top_srcdir)/examples/python; cp * $(DEMOS_DIR)/python
	-if test ! -d $(PYTHON_MOD_DIR)/plplot; then \
		mkdir -p $(PYTHON_MOD_DIR)/plplot; fi
	-cd $(top_srcdir)/bindings/python; cp *.py $(PYTHON_MOD_DIR)/plplot

