#
# vtk library makefile
#

#
# Makefile for Visualization Toolkit sources. 
# 
#------------------------------------------------------------------------------
#

SHELL = /bin/sh
.SUFFIXES: .cxx

srcdir        = @srcdir@
VPATH         = @srcdir@

#------------------------------------------------------------------------------
# Autoconfig defines that can be overridden in user.make

@MAKEINCLUDE@ @MAKEQUOTE@../system.make@MAKEQUOTE@

#------------------------------------------------------------------------------
# Include user-editable defines.

@MAKEINCLUDE@ @MAKEQUOTE@../user.make@MAKEQUOTE@

#------------------------------------------------------------------------------
LDLIBS =  \
	${USE_LOCAL_PYTHON}	\
	${USE_CONTRIB_PYTHON}	\
	${USE_PATENTED_PYTHON}	\
	${USE_IMAGING_PYTHON}	\
	${USE_GRAPHICS_PYTHON}	\
        -L../common -lVTKCommonPython -lVTKCommon \
	${XLIBS} ${GRAPHICS_API_LIBS} \
	${DL_LIBS} \
	${THREAD_LIBS}

CXX_FLAGS = ${USER_CXXFLAGS} ${CPPFLAGS} ${CXXFLAGS} -I${srcdir} \
	-I${srcdir}/../common ${PYTHON_INCLUDES} ${TK_INCLUDE} \
	-DVTK_USE_TKWIDGET ${GRAPHICS_API_FLAGS} ${TCL_INCLUDE} \
	${USE_TOOLKIT_FLAGS}

C_FLAGS = ${USER_CFLAGS} ${CPPFLAGS} ${CFLAGS} -I${srcdir} \
	${PYTHON_INCLUDES} -DVTK_USE_TKWIDGET \
	${GRAPHICS_API_FLAGS} ${USE_TOOLKIT_FLAGS}

all: vtkpython @TKWIDGET_TARGETS@

vtkpython: vtkpython$(SHLIB_SUFFIX)
	@echo ""

vtkpython.o: vtkpython.c Makefile
	$(CC) $(C_FLAGS) -c -o vtkpython.o $(srcdir)/vtkpython.c

vtkTkRenderWidget: ${srcdir}/../graphics/vtkTkRenderWidget.cxx ${TOOLKIT_DEPENDS}
	${CXX} -o vtkTkRenderWidget -DVTK_PYTHON_BUILD \
	${srcdir}/../graphics/vtkTkRenderWidget.cxx ${TK_LIB} ${TCL_LIB} \
	-L. ${CXX_FLAGS} ${VTK_SHLIB_BUILD_FLAGS} ${XLDFLAGS} ${LDLIBS} \
	${XLIBS} -lXext -lXt ${X_PRE_LIBS} -lX11 ${X_EXTRA_LIBS} -lm

vtkTkImageViewerWidget: ${srcdir}/../imaging/vtkTkImageViewerWidget.cxx ${TOOLKIT_DEPENDS}
	${CXX} -o vtkTkImageViewerWidget -DVTK_PYTHON_BUILD \
	${srcdir}/../imaging/vtkTkImageViewerWidget.cxx ${TK_LIB} ${TCL_LIB} \
	-L. ${CXX_FLAGS} ${VTK_SHLIB_BUILD_FLAGS} ${XLDFLAGS} ${LDLIBS} \
	${XLIBS} -lXext -lXt ${X_PRE_LIBS} -lX11 ${X_EXTRA_LIBS} -lm

vtkTkImageWindowWidget: ${srcdir}/../imaging/vtkTkImageWindowWidget.cxx ${TOOLKIT_DEPENDS}
	${CXX} -o vtkTkImageWindowWidget -DVTK_PYTHON_BUILD \
	${srcdir}/../imaging/vtkTkImageWindowWidget.cxx ${TK_LIB} ${TCL_LIB} \
	-L. ${CXX_FLAGS} ${VTK_SHLIB_BUILD_FLAGS} ${XLDFLAGS} ${LDLIBS} \
	${XLIBS} -lXext -lXt ${X_PRE_LIBS} -lX11 ${X_EXTRA_LIBS} -lm

#------------------------------------------------------------------------------
# build the vtkpython module 
#
vtkpython${SHLIB_SUFFIX}: Makefile vtkpython.o ${TOOLKIT_DEPENDS}
	${CXX} -o vtkpython${SHLIB_SUFFIX} vtkpython.o \
	-L. ${CXX_FLAGS} ${VTK_SHLIB_BUILD_FLAGS} ${XLDFLAGS} ${LDLIBS} \
	${XLIBS} -lXext -lXt ${X_PRE_LIBS} -lX11 ${X_EXTRA_LIBS} -lm

#------------------------------------------------------------------------------
# build vtkpython.pth
vtkpython.pth: Makefile
	-rm -f vtkpython.pth
	echo $(exec_prefix)/lib/vtk/python/ > vtkpython.pth

#------------------------------------------------------------------------------
# Install the python files and libraries
# Note: install can only handle one file at a time, so if a new *.py file
#       is added, it must be installed explicitly!
install: all
	${INSTALL} -m 755 -d $(PY_SITE_DIR)
	echo "${PY_PKG_NAME}" > $(PY_SITE_DIR)/../${PY_PKG_NAME}.pth
	${INSTALL} -m 644 ${srcdir}/VTK.py                      $(PY_SITE_DIR)
	${INSTALL} -m 644 ${srcdir}/libVTKCommonPython.py       $(PY_SITE_DIR)
	${INSTALL} -m 644 ${srcdir}/libVTKContribPython.py      $(PY_SITE_DIR)
	${INSTALL} -m 644 ${srcdir}/libVTKGraphicsPython.py     $(PY_SITE_DIR)
	${INSTALL} -m 644 ${srcdir}/libVTKImagingPython.py      $(PY_SITE_DIR)
	${INSTALL} -m 644 ${srcdir}/libVTKLocalPython.py        $(PY_SITE_DIR)
	${INSTALL} -m 644 ${srcdir}/libVTKPatentedPython.py     $(PY_SITE_DIR)
	${INSTALL} -m 644 ${srcdir}/vtkConstants.py             $(PY_SITE_DIR)
	${INSTALL} -m 644 ${srcdir}/vtkImageExportToArray.py    $(PY_SITE_DIR)
	${INSTALL} -m 644 ${srcdir}/vtkImageImportFromArray.py  $(PY_SITE_DIR)
	${INSTALL} -m 644 ${srcdir}/vtkImageViewerWidget.py     $(PY_SITE_DIR)
	${INSTALL} -m 644 ${srcdir}/vtkImageWindowWidget.py     $(PY_SITE_DIR)
	${INSTALL} -m 644 ${srcdir}/vtkRenderWidget.py          $(PY_SITE_DIR)
	${INSTALL} -m 755 vtkpython.so                          $(PY_SITE_DIR)
	${INSTALL} -m 755 vtkTkImageViewerWidget                $(LIB_INSTALL_DIR)
	${INSTALL} -m 755 vtkTkImageWindowWidget                $(LIB_INSTALL_DIR)
	${INSTALL} -m 755 vtkTkRenderWidget                     $(LIB_INSTALL_DIR)

#------------------------------------------------------------------------------
clean: 
	-rm -f *.so *.o *.a *.pyc Makefile vtkTk*Widget


