#
# vtk library makefile
#

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

SHELL = /bin/sh
.SUFFIXES: .cxx .java


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 = -L../common \
        ${USE_CONTRIB_JAVA}	\
        ${USE_PATENTED_JAVA}		\
	${USE_IMAGING_JAVA}	\
	${USE_GRAPHICS_JAVA}	\
        -lVTKCommonJava -lVTKCommon \
        ${XLIBS} ${GRAPHICS_API_LIBS} ${DL_LIBS} ${THREAD_LIBS}

C_FLAGS = ${CPPFLAGS} ${XCFLAGS} ${CFLAGS} -I${srcdir} 

all:  vtk

#------------------------------------------------------------------------------
# build the vtk java library
#
vtk: libvtkJava$(SHLIB_SUFFIX)
	# Make a jar file
	cd ${JAVA_CLASS_HOME}; ${JAR} -fc vtk.jar vtk/*.class

# special hack for sgi compilers, uncomment out the following target 
# and comment out the normal one
#libvtkJava$(SHLIB_SUFFIX): 
#	touch empty.c; $(CXX) $(CXX_FLAGS) $(USER_CXXFLAGS)
#	${VTK_SHLIB_BUILD_FLAGS} -c -o empty.o empty.c
#	$(CXX) ${CXX_FLAGS} ${VTK_SHLIB_BUILD_FLAGS} empty.o \
#	-o libvtkJava$(SHLIB_SUFFIX) -L. ${XLDFLAGS} ${LDLIBS} \
#	${XLIBS} -lXext ${X_PRE_LIBS} -lX11 ${X_EXTRA_LIBS} ${JAVA_CXX_LIB}
#	rm -f empty.c empty.o

libvtkJava$(SHLIB_SUFFIX): 
	$(CXX) ${CXX_FLAGS} ${VTK_SHLIB_BUILD_FLAGS} \
	-o libvtkJava$(SHLIB_SUFFIX) -L. ${XLDFLAGS} ${LDLIBS} \
	${XLIBS} -lXext ${X_PRE_LIBS} -lX11 ${X_EXTRA_LIBS} ${JAVA_CXX_LIB}

install:  vtk
	@echo "Installing libvtkJava$(SHLIB_SUFFIX)"
	${INSTALL} libvtkJava$(SHLIB_SUFFIX) $(LIB_INSTALL_DIR)/libvtkJava$(SHLIB_SUFFIX)
	if [ ! -d $(JAVA_INSTALL_DIR) ] ; then \
	    ${INSTALL} -m 755 -d $(JAVA_INSTALL_DIR) ; \
	fi;
	${INSTALL} -m 644 $(JAVA_CLASS_HOME)/vtk.jar $(JAVA_INSTALL_DIR)/vtk.jar
	@chmod 755 $(LIB_INSTALL_DIR)/libvtkJava$(SHLIB_SUFFIX)

#------------------------------------------------------------------------------
clean: 
	-rm -f *.o *.a Makefile


