#/****************************************************************************
#* Copyright by The HDF Group.                                               *
#* Copyright by the Board of Trustees of the University of Illinois.         *
#* All rights reserved.                                                      *
#*                                                                           *
#* This file is part of HDF Java Products. The full HDF Java copyright       *
#* notice, including terms governing use, modification, and redistribution,  *
#* is contained in the file, COPYING.  COPYING can be found at the root of   *
#* the source code distribution tree. You can also access it online  at      *
#* http://support.hdfgroup.org/products/licenses.html.  If you do not have   *
#* access to the file, you may request a copy from help@hdfgroup.org.        *
#****************************************************************************/
 
TOP = .
DIR	= . 

@VERSION@

JAVAC           = @JAVAC@
JAVADOC         = @JAVADOC@
JAR         	= @JAR@
FIND            = @FIND@
RM              = @RM@
JAVADOC_FLAGS   = -version -author
SLEXT=@SLEXT@
JSLEXT=@JSLEXT@

CLASSPATH=@CLASSPATH@
JH45INSTALLDIR=@JH45INST@
H45INC=@H45INC@
H4INC=@HDF4INC@
H5INC=@HDF5INC@

#make this relative to the source root...
LIBDIR=$(JH45INSTALLDIR)/lib
BINDIR=$(JH45INSTALLDIR)/bin
DOCDIR= $(JH45INSTALLDIR)/docs

CLASS_DIR=$(TOP)/lib
CP="$(CLASSPATH):$(CLASS_DIR):. "

CURRENTDIR = .
JAR_DIR=$(CLASS_DIR)
OUT_DIR=$(CLASS_DIR)/$(DIR)

JUNITSDISTJARFILE = $(CLASS_DIR)/junit.jar
LOGGINGDISTJARFILE = $(CLASS_DIR)/slf4j-api-1.7.5.jar $(CLASS_DIR)/slf4j-nop-1.7.5.jar

TOPDIST=./VERSION ./COPYING ./Makefile.in ./CMakeLists.txt ./CTestConfig.cmake \
	./Readme.txt \
	./runconfig-example.sh \
	./configure.in ./config/config* ./config/install-sh ./config/Rules.mk \
	./config/config/cmake/* \
	./configure ./native/Makefile.in ./native/CMakeLists.txt \
	./Makefile.in ./CMakeLists.txt ./hdf/Makefile.in ./hdf/CMakeLists.txt

JHIDISTFILES=./native/hdflib/Makefile.in \
	./native/hdflib/nt_makefile \
	./native/hdflib/*.c \
	./native/hdflib/Makefile.in ./native/hdflib/CMakeLists.txt \
	./hdf/hdflib/*.java \
	./hdf/hdflib/Makefile.in ./hdf/hdflib/CMakeLists.txt

JHI5DISTFILES= ./native/hdf5lib/Makefile.in \
	./native/hdf5lib/nt_makefile \
	./native/hdf5lib/*.c ./native/hdf5lib/*.h \
	./native/hdf5lib/Makefile.in ./native/hdf5lib/CMakeLists.txt \
	./hdf/hdf5lib/*.java  \
	./hdf/hdf5lib/callbacks/*.java \
	./hdf/hdf5lib/exceptions/*.java \
	./hdf/hdf5lib/structs/*.java \
	./hdf/hdf5lib/Makefile.in ./hdf/hdf5lib/CMakeLists.txt \
	./hdf/hdf5lib/callbacks/Makefile.in \
	./hdf/hdf5lib/exceptions/Makefile.in \
	./hdf/hdf5lib/structs/Makefile.in 

EXAMPLESFILES=./examples/*.in ./examples/CMakeLists.txt \
	./examples/intro/*.java ./examples/intro/*.in ./examples/intro/CMakeLists.txt \
	./examples/groups/*.java ./examples/groups/*.in ./examples/groups/CMakeLists.txt ./examples/groups/*.h5 \
	./examples/datasets/*.java ./examples/datasets/*.in ./examples/datsets/CMakeLists.txt \
	./examples/datatypes/*.java ./examples/datatypes/*.in ./examples/datatypes/CMakeLists.txt \
	./examples/testfiles/*.txt

TESTFILES=./test/Makefile.in ./test/Makefile.in ./test/CMakeLists.txt \
	./test/hdf5lib/*.in ./test/hdf5lib/CMakeLists.txt ./test/hdf5lib/*.java \
	./test/hdf5lib/h5ex_g_iterate.hdf

DOCFILES=

DISTFILES= $(TOPDIST) $(JHI5DISTFILES) $(JHIDISTFILES) $(TESTFILES) $(DOCFILES) $(JUNITSDISTJARFILE) $(EXAMPLESFILES)


JHIPACKAGES = \
	hdf.hdflib

JHI5PACKAGES = \
	hdf.hdf5lib.callbacks \
	hdf.hdf5lib.exceptions \
	hdf.hdf5lib.structs \
	hdf.hdf5lib 

all: natives hdfs do-examples

just-hdf4: hdflib jhdf-packages

just-hdf5: hdf5lib jhdf5-packages

install-just-hdf4: install-hdflib install-jhdf

install-just-hdf5: install-hdf5lib install-jhdf5

packages: jhdf-packages jhdf5-packages

jhdf-packages: 
	@if test x'$(H4INC)' != x'' ; then $(MAKE) do-jhdf-packages; fi

do-jhdf-packages: $(JHIPACKAGES)  
	$(JAR) cf $(CLASS_DIR)/jhdf.jar -C $(CLASS_DIR) $(JHICLASSES)

jhdf5-packages: $(JHI5PACKAGES)  
	$(JAR) cf $(CLASS_DIR)/jhdf5.jar -C $(CLASS_DIR) $(JHI5CLASSES)

classes: packages

hdfs: FORCE
	cd hdf; \
	$(MAKE) 

natives: FORCE
	cd native; \
	$(MAKE) 

hdflib: FORCE
	cd native; \
	$(MAKE) hdflib

hdf5lib: FORCE
	cd native; \
	$(MAKE) hdf5lib

FORCE:

## revise arrangement of docs, java docs.

docs: javadocs

javadocs:
	-mkdir -p docs/javadocs;
	@if test x'$(H45INC)' != x'' ; then \
	$(JAVADOC) -sourcepath $(CLASSPATH) -d ./docs/javadocs $(JAVADOC_FLAGS) $(JH45PACKAGES) hdf.hdflib $(JHI5PACKAGES) $(HDFOBJPACKAGES) $(H4OBJPACKAGES) $(H5OBJPACKAGES); \
	else \
	$(JAVADOC) -sourcepath $(CLASSPATH) -d ./docs/javadocs $(JAVADOC_FLAGS) hdf.hdflib $(JHI5PACKAGES) $(HDFOBJPACKAGES) $(H4OBJPACKAGES) $(H5OBJPACKAGES) ; \
	fi

tests:
	@if test -d "test"; then cd test; $(MAKE); fi

do-examples:
	@if test -d "examples"; then cd examples; $(MAKE); fi

clean-examples:
	@if test -d "examples"; then cd examples; $(MAKE) clean; fi

clean-test:
	@if test -d "test"; then  cd test; $(MAKE) clean; fi

clean: clean-natives clean-classes clean-test clean-examples

clean-classes:
	$(FIND) ./ \( -name '#*' -o -name '*~' -o -name '*.class' \) -exec $(RM) -f {} \; ;\
	$(RM) -f $(CLASS_DIR)/jhdf.jar
	$(RM) -f $(CLASS_DIR)/jhdf5.jar

clean-packages: clean-classes

clean-natives:
	cd native; \
	$(MAKE) clean;

clean-hdflib:
	cd native; \
	$(MAKE) clean-hdflib;

clean-hdf5lib:
	cd native; \
	$(MAKE) clean-hdf5lib;

clean-docs:
	cd docs; \
	$(RM) *.html
	cd docs/javadocs; \
	$(RM) -r *.html

check-all: check

check: packages
	cd test; \
	$(MAKE) check;
	cd examples; \
	$(MAKE) check;

install: install-lib install-jhdf install-jhdf5
	@echo "Install complete"

uninstall: uninstall-lib uninstall-jhi uninstall-jhi5 

install-lib: natives
	-mkdir -p $(LIBDIR);
	-mkdir -p $(LIBDIR)/@JAVATARG@
	@if test x'$(H5INC)' != x'' ; then \
	cp $(CLASS_DIR)/@JAVATARG@/libjhdf5.$(JSLEXT) $(LIBDIR)/@JAVATARG@ ;  \
	cp $(H5INC)/../lib/*.settings $(LIBDIR)/@JAVATARG@ ; fi
	@if test x'$(H4INC)' != x'' ; then \
	cp $(CLASS_DIR)/@JAVATARG@/libjhdf.$(JSLEXT) $(LIBDIR)/@JAVATARG@ ;  \
	cp $(H4INC)/../lib/*.settings $(LIBDIR)/@JAVATARG@ ; fi
	@if test x'$(H45INC)' != x'' ; then \
	cp $(CLASS_DIR)/@JAVATARG@/libjh4toh5.$(JSLEXT) $(LIBDIR)/@JAVATARG@ ; fi
	@echo "Install Natives complete"

install-hdflib: 
	@if test x'$(H4INC)' != x'' ; then $(MAKE) do-install-hdflib ; fi

do-install-hdflib: hdflib
	-mkdir -p $(LIBDIR);
	-mkdir -p $(LIBDIR)/@JAVATARG@
	cp $(CLASS_DIR)/@JAVATARG@/libjhdf.$(JSLEXT) $(LIBDIR)/@JAVATARG@
	@echo "Install Native HDF complete"

install-hdf5lib: hdf5lib
	@if test x'$(H5INC)' != x'' ; then $(MAKE) do-install-hdf5lib ; fi

do-install-hdf5lib: hdf5lib
	-mkdir -p $(LIBDIR);
	-mkdir -p $(LIBDIR)/@JAVATARG@
	cp $(CLASS_DIR)/@JAVATARG@/libjhdf5.$(JSLEXT) $(LIBDIR)/@JAVATARG@
	echo "Install Native HDF5 complete"

uninstall-lib:
	$(RM) -f $(LIBDIR)/@JAVATARG@/libjhdf.$(JSLEXT)
	$(RM) -f $(LIBDIR)/@JAVATARG@/libjhdf5.$(JSLEXT)

install-jars: install-jhdf install-jhdf5

install-jhdf: 
	@if test x'$(H4INC)' != x'' ; then $(MAKE) do-install-jhdf ; fi

do-install-jhdf: jhdf-packages
	-mkdir -p $(LIBDIR);
	$(JAR) cf $(JH45INSTALLDIR)/lib/jhdf.jar -C $(CLASS_DIR) $(JHICLASSES)
	@echo "Install JHI complete"

install-jhdf5: 
	@if test x'$(H5INC)' != x'' ; then $(MAKE) do-install-jhdf5 ; fi

do-install-jhdf5: jhdf5-packages
	-mkdir -p $(LIBDIR);
	$(JAR) cf $(JH45INSTALLDIR)/lib/jhdf5.jar -C $(CLASS_DIR) $(JHI5CLASSES)
	@echo "Install JHI5 complete"

uninstall-jhi5: 
	$(RM) -f $(JH45INSTALLDIR)/lib/jhdf5.jar

uninstall-jhi: 
	$(RM) -f $(JH45INSTALLDIR)/lib/jhdf.jar

install-docs: install-javadocs

install-javadocs:
	-mkdir -p $(DOCDIR)/javadocs;
	@if test x'$(H45INC)' != x'' ; then \
	$(JAVADOC) -sourcepath $(CLASSPATH) -d $(DOCDIR)/javadocs $(JAVADOC_FLAGS) $(JH45PACKAGES) hdf.hdflib $(JHI5PACKAGES); \
	else \
	$(JAVADOC) -sourcepath $(CLASSPATH) -d $(DOCDIR)/javadocs $(JAVADOC_FLAGS) hdf.hdflib $(JHI5PACKAGES); \
	fi
	-mkdir -p $(DOCDIR)/javadocs/images;
	cp docs/javadocs/images/*.gif $(DOCDIR)/javadocs/images;

uninstall-javadocs:
	$(RM) -rf $(DOCDIR)/javadocs/*.html $(DOCDIR)/images

distclean: clean-natives clean-classes clean-test clean-examples
	$(RM) -f config.cache config.status config.log 
	$(RM) -rf $(CLASS_DIR)/@JAVATARG@
	$(RM) -rf $(CLASS_DIR)/jhdf.jar
	$(RM) -rf $(CLASS_DIR)/jhdf5.jar
	$(RM) -f ./native/Makefile
	$(RM) -rf ./native/hdflib/Makefile
	$(RM) -rf ./native/hdf5lib/Makefile
	$(RM) -f ./Makefile
	$(RM) -rf ./hdf/Makefile
	$(RM) -rf ./hdf/hdflib/Makefile
	$(RM) -rf ./hdf/hdf5lib/Makefile
	$(RM) -rf ./hdf/hdf5lib/callbacks/Makefile
	$(RM) -rf ./hdf/hdf5lib/exceptions/Makefile
	$(RM) -rf ./hdf/hdf5lib/structs/Makefile
	$(RM) -rf ./test/Makefile
	$(RM) -rf ./test/hdf5lib/Makefile
	$(RM) -rf ./test/hdf5lib/*.sh
	$(RM) -rf ./examples/Makefile
	$(RM) -rf ./examples/runExample.sh
	$(RM) -rf ./examples/intro/Makefile
	$(RM) -rf ./examples/groups/Makefile
	$(RM) -rf ./examples/datasets/Makefile
	$(RM) -rf ./examples/datatypes/Makefile
	$(RM) -rf ./Makefile

src-dist: docs
	-mkdir -p hdf-java
	tar cvf $(VERSION)-x.tar $(DISTFILES) ; mv $(VERSION)-x.tar hdf-java/
	cd hdf-java ; tar xf $(VERSION)-x.tar ; $(RM) -f $(VERSION)-x.tar ; find . -name .svn -exec rm -rf {} \;
	cd ..
	tar cvf $(VERSION)-src.tar hdf-java/*
	$(RM) -rf hdf-java


# --------
# Packages
# --------

hdf.hdf5lib: \
	$(CLASS_DIR)/hdf/hdf5lib/H5.class \
	$(CLASS_DIR)/hdf/hdf5lib/HDF5Constants.class \
	$(CLASS_DIR)/hdf/hdf5lib/HDF5GroupInfo.class \
	$(CLASS_DIR)/hdf/hdf5lib/HDFArray.class \
	$(CLASS_DIR)/hdf/hdf5lib/HDFNativeData.class 

hdf.hdf5lib.exceptions: \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5AtomException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5AttributeException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5BtreeException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5DataFiltersException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5DataStorageException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5DatasetInterfaceException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5DataspaceInterfaceException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5DatatypeInterfaceException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5Exception.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5ExternalFileListException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5FileInterfaceException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5FunctionArgumentException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5FunctionEntryExitException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5HeapException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5InternalErrorException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5JavaException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5LibraryException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5LowLevelIOException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5MetaDataCacheException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5ObjectHeaderException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5PropertyListInterfaceException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5ReferenceException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5ResourceUnavailableException.class \
	$(CLASS_DIR)/hdf/hdf5lib/exceptions/HDF5SymbolTableException.class 

hdf.hdf5lib.callbacks: \
	$(CLASS_DIR)/hdf/hdf5lib/callbacks/Callbacks.class \
	$(CLASS_DIR)/hdf/hdf5lib/callbacks/H5L_iterate_cb.class \
	$(CLASS_DIR)/hdf/hdf5lib/callbacks/H5L_iterate_t.class \
	$(CLASS_DIR)/hdf/hdf5lib/callbacks/H5O_iterate_cb.class \
	$(CLASS_DIR)/hdf/hdf5lib/callbacks/H5O_iterate_t.class

hdf.hdf5lib.structs: \
	$(CLASS_DIR)/hdf/hdf5lib/structs/H5_ih_info_t.class \
	$(CLASS_DIR)/hdf/hdf5lib/structs/H5A_info_t.class \
	$(CLASS_DIR)/hdf/hdf5lib/structs/H5G_info_t.class \
	$(CLASS_DIR)/hdf/hdf5lib/structs/H5L_info_t.class \
	$(CLASS_DIR)/hdf/hdf5lib/structs/H5O_info_t.class \
	$(CLASS_DIR)/hdf/hdf5lib/structs/H5O_hdr_info_t.class

hdf.hdflib: \
	$(CLASS_DIR)/hdf/hdflib/HDFArray.class \
	$(CLASS_DIR)/hdf/hdflib/HDFChunkInfo.class \
	$(CLASS_DIR)/hdf/hdflib/HDFCompInfo.class \
	$(CLASS_DIR)/hdf/hdflib/HDFConstants.class \
	$(CLASS_DIR)/hdf/hdflib/HDFDeflateCompInfo.class \
	$(CLASS_DIR)/hdf/hdflib/HDFDeprecated.class \
	$(CLASS_DIR)/hdf/hdflib/HDFException.class \
	$(CLASS_DIR)/hdf/hdflib/HDFIMCOMPCompInfo.class \
	$(CLASS_DIR)/hdf/hdflib/HDFJPEGCompInfo.class \
	$(CLASS_DIR)/hdf/hdflib/HDFJavaException.class \
	$(CLASS_DIR)/hdf/hdflib/HDFLibrary.class \
	$(CLASS_DIR)/hdf/hdflib/HDFLibraryException.class \
	$(CLASS_DIR)/hdf/hdflib/HDFNBITChunkInfo.class \
	$(CLASS_DIR)/hdf/hdflib/HDFNBITCompInfo.class \
	$(CLASS_DIR)/hdf/hdflib/HDFNativeData.class \
	$(CLASS_DIR)/hdf/hdflib/HDFNewCompInfo.class \
	$(CLASS_DIR)/hdf/hdflib/HDFNotImplementedException.class \
	$(CLASS_DIR)/hdf/hdflib/HDFOldCompInfo.class \
	$(CLASS_DIR)/hdf/hdflib/HDFOldRLECompInfo.class \
	$(CLASS_DIR)/hdf/hdflib/HDFRLECompInfo.class \
	$(CLASS_DIR)/hdf/hdflib/HDFSKPHUFFCompInfo.class \
	$(CLASS_DIR)/hdf/hdflib/HDFSZIPCompInfo.class \
	$(CLASS_DIR)/hdf/hdflib/HDFTable.class 

#  All classes that are built, including private classes:
#     This is what is loaded into the 'jar' file.
#


JHI5CLASSES= hdf/hdf5lib

JHICLASSES= hdf/hdflib

##
#  Source to pack for distribution
##
JAVASRCS= \
./hdf/hdf5lib/H5.java  \
./hdf/hdf5lib/HDF5Constants.java  \
./hdf/hdf5lib/HDF5GroupInfo.java  \
./hdf/hdf5lib/HDFArray.java  \
./hdf/hdf5lib/HDFNativeData.java  \
./hdf/hdf5lib/exceptions/HDF5AtomException.java  \
./hdf/hdf5lib/exceptions/HDF5AttributeException.java  \
./hdf/hdf5lib/exceptions/HDF5BtreeException.java  \
./hdf/hdf5lib/exceptions/HDF5DataFiltersException.java  \
./hdf/hdf5lib/exceptions/HDF5DataStorageException.java  \
./hdf/hdf5lib/exceptions/HDF5DatasetInterfaceException.java  \
./hdf/hdf5lib/exceptions/HDF5DataspaceInterfaceException.java  \
./hdf/hdf5lib/exceptions/HDF5DatatypeInterfaceException.java  \
./hdf/hdf5lib/exceptions/HDF5Exception.java  \
./hdf/hdf5lib/exceptions/HDF5ExternalFileListException.java  \
./hdf/hdf5lib/exceptions/HDF5FileInterfaceException.java  \
./hdf/hdf5lib/exceptions/HDF5FunctionArgumentException.java  \
./hdf/hdf5lib/exceptions/HDF5FunctionEntryExitException.java  \
./hdf/hdf5lib/exceptions/HDF5HeapException.java  \
./hdf/hdf5lib/exceptions/HDF5InternalErrorException.java  \
./hdf/hdf5lib/exceptions/HDF5JavaException.java  \
./hdf/hdf5lib/exceptions/HDF5LibraryException.java  \
./hdf/hdf5lib/exceptions/HDF5LowLevelIOException.java  \
./hdf/hdf5lib/exceptions/HDF5MetaDataCacheException.java  \
./hdf/hdf5lib/exceptions/HDF5ObjectHeaderException.java  \
./hdf/hdf5lib/exceptions/HDF5PropertyListInterfaceException.java  \
./hdf/hdf5lib/exceptions/HDF5ReferenceException.java  \
./hdf/hdf5lib/exceptions/HDF5ResourceUnavailableException.java  \
./hdf/hdf5lib/exceptions/HDF5SymbolTableException.java  \
./hdf/hdf5lib/callbacks/Callbacks.java \
./hdf/hdf5lib/callbacks/H5L_iterate_cb.java \
./hdf/hdf5lib/callbacks/H5L_iterate_t.java \
./hdf/hdf5lib/callbacks/H5O_iterate_cb.java \
./hdf/hdf5lib/callbacks/H5O_iterate_t.java \
./hdf/hdf5lib/structs/H5_ih_info_t.java \
./hdf/hdf5lib/structs/H5A_info_t.java \
./hdf/hdf5lib/structs/H5G_info_t.java \
./hdf/hdf5lib/structs/H5L_info_t.java \
./hdf/hdf5lib/structs/H5O_info_t.java \
./hdf/hdf5lib/structs/H5O_hdr_info_t.java \
./hdf/hdflib/HDFArray.java  \
./hdf/hdflib/HDFChunkInfo.java  \
./hdf/hdflib/HDFCompInfo.java  \
./hdf/hdflib/HDFConstants.java  \
./hdf/hdflib/HDFDeflateCompInfo.java  \
./hdf/hdflib/HDFDeprecated.java  \
./hdf/hdflib/HDFException.java  \
./hdf/hdflib/HDFIMCOMPCompInfo.java  \
./hdf/hdflib/HDFJPEGCompInfo.java  \
./hdf/hdflib/HDFSZIPCompInfo.java  \
./hdf/hdflib/HDFJavaException.java  \
./hdf/hdflib/HDFLibrary.java  \
./hdf/hdflib/HDFLibraryException.java  \
./hdf/hdflib/HDFNBITChunkInfo.java  \
./hdf/hdflib/HDFNBITCompInfo.java  \
./hdf/hdflib/HDFNativeData.java  \
./hdf/hdflib/HDFNewCompInfo.java  \
./hdf/hdflib/HDFNotImplementedException.java  \
./hdf/hdflib/HDFOldCompInfo.java  \
./hdf/hdflib/HDFOldRLECompInfo.java  \
./hdf/hdflib/HDFRLECompInfo.java  \
./hdf/hdflib/HDFSKPHUFFCompInfo.java  \
./hdf/hdflib/HDFTable.java  \
