#
# Makefile --
#
# Top-level makefile for the Visualization Toolkit
# 
#------------------------------------------------------------------------------
#
SHELL=/bin/sh

srcdir        = @srcdir@
VPATH         = @srcdir@

BUILD_TOOLKITS    = @BUILD_TOOLKITS@
DEPEND_TOOLKITS   = @DEPEND_TOOLKITS@
CLEAN_TOOLKITS    = @CLEAN_TOOLKITS@

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

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

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

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

#------------------------------------------------------------------------------

all: targets build_wrap build_common ${BUILD_TOOLKITS} \
    ${BUILD_TCL} ${BUILD_JAVA}

targets: ${srcdir}/targets.cxx ${srcdir}/makedepend.cxx
	${CXX} -o targets ${srcdir}/targets.cxx ${srcdir}/makedepend.cxx

build_common: targets build_wrap
	cd common;     ${MAKE} -${MAKEFLAGS} targets.make
	cd common;     ${MAKE} -${MAKEFLAGS} all

build_graphics: targets build_wrap
	cd graphics;   ${MAKE} -${MAKEFLAGS} targets.make
	cd graphics;   ${MAKE} -${MAKEFLAGS} all

build_imaging: targets build_wrap
	cd imaging;    ${MAKE} -${MAKEFLAGS} targets.make
	cd imaging;    ${MAKE} -${MAKEFLAGS} all

build_patented: targets build_wrap
	cd patented;    ${MAKE} -${MAKEFLAGS} targets.make
	cd patented;    ${MAKE} -${MAKEFLAGS} all

build_wrap: targets
	cd wrap;        ${MAKE} -${MAKEFLAGS} all

build_contrib: targets build_wrap
	cd contrib;     ${MAKE} -${MAKEFLAGS} targets.make
	cd contrib;     ${MAKE} -${MAKEFLAGS} all

build_tcl: build_common ${BUILD_TOOLKITS} 
	cd tcl;        ${MAKE} -${MAKEFLAGS} vtk

build_java: build_common ${BUILD_TOOLKITS}
	cd java;       ${MAKE} -${MAKEFLAGS} vtk

#------------------------------------------------------------------------------
# generate dpend.make files

depend: ${DEPEND_TCL} ${DEPEND_TOOLKITS} 
	cd common;    ${MAKE} -${MAKEFLAGS} depend

depend_tcl:
	cd tcl;       ${MAKE} -${MAKEFLAGS} depend

depend_graphics:
	cd graphics;  ${MAKE} -${MAKEFLAGS} depend

depend_imaging:
	cd imaging;   ${MAKE} -${MAKEFLAGS} depend

depend_patented:
	cd patented;    ${MAKE} -${MAKEFLAGS} depend

depend_contrib:
	cd contrib; ${MAKE} -${MAKEFLAGS} depend

#------------------------------------------------------------------------------
# Clean up all files that were built by make.
clean: ${CLEAN_TCL} ${CLEAN_JAVA} ${CLEAN_TOOLKITS}
	cd common;    ${MAKE} -${MAKEFLAGS} clean
	cd wrap;    ${MAKE} -${MAKEFLAGS} clean
	rm -f config.cache

clean_tcl:
	cd tcl;       ${MAKE} -${MAKEFLAGS} clean

clean_java:
	cd java;      ${MAKE} -${MAKEFLAGS} clean

clean_graphics:
	cd graphics;  ${MAKE} -${MAKEFLAGS} clean

clean_imaging:
	cd imaging;   ${MAKE} -${MAKEFLAGS} clean

clean_patented:
	cd patented;    ${MAKE} -${MAKEFLAGS} clean

clean_contrib:
	cd contrib;   ${MAKE} -${MAKEFLAGS} clean

#------------------------------------------------------------------------------
# Clean up all files that were built by make.
install: install-dirs install-libs do_@INSTALL_TARGET@

install-libs: @INSTALL_TOOLKITS@ 
	cd common; ${MAKE} -${MAKEFLAGS} @INSTALL_TARGET@

install_graphics:
	cd graphics;   ${MAKE} -${MAKEFLAGS} @INSTALL_TARGET@

install_imaging: 
	cd imaging;    ${MAKE} -${MAKEFLAGS} @INSTALL_TARGET@

install_patented: 
	cd patented;    ${MAKE} -${MAKEFLAGS} @INSTALL_TARGET@

install_contrib:
	cd contrib;     ${MAKE} -${MAKEFLAGS} @INSTALL_TARGET@

do_install_tcl_java: do_install_tcl

do_install_java:

do_install:

do_install_tcl:
	@echo "Installing vtk"
	@${srcdir}/$(INSTALL) tcl/vtk $(BIN_INSTALL_DIR)/vtk

install-dirs:
	@for i in $(LIB_INSTALL_DIR) $(BIN_INSTALL_DIR) ; \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir $$i; \
		chmod 755 $$i; \
		else true; \
		fi; \
	    done;


