# HDF5 HL_REGION version 1.1.0 currently under development
# 
# Copyright by The HDF Group.
# All rights reserved.
#
# This file is part of the hl_region High-Level HDF5 APIs.  The full copyright 
# notice, including terms governing use, modification, and redistribution, 
# is contained in the file COPYING, which can be found at the root of the
# source code distribution tree and in the documentation directory (doc/html/).  
# If you do not have access to this file, you may request a copy of 
# "the hl_region High-Level HDF5 APIs copyright and license statement" from 
# help@hdfgroup.org.
# 
############################################################################
#
#  Program:         HL REGION
#
#  Module:          Makefile
#
#  Purpose:         Top-level Makefile to build both C and Fortran interfaces.
#
#  Creation date:   July 24, 2009
#  Modification date:  December 20, 2011 
#
#  Notes: User must set the enviroment variable HDF5_INSTALL_DIR to 
#         the location hdf5 is installed. If --enable-fortran option
#         was used in compiling hdf5 then fortran routines will be 
#         compiled. Fortran compiler should support ISO_C_BINDINGS module.
#
############################################################################

PREFIX = $(HDF5_INSTALL_DIR)

all: compile

compile:
	(cd src; $(MAKE))
	(cd examples; $(MAKE))
	(cd test; $(MAKE))
# if h5fc is available then compile FORTRAN source
	if test -e $(HDF5_INSTALL_DIR)/bin/h5fc; then \
	(cd fortran/src; $(MAKE); \
	 cd ../examples; $(MAKE); \
	 cd ../test; $(MAKE));fi

install:
	(mkdir -p $(PREFIX)/lib)
	(mkdir -p $(PREFIX)/include)
	(cp src/libhdf5_hl_region.a $(PREFIX)/lib )
	(cp src/hl_region_H5LRpublic.h $(PREFIX)/include )
	(cp src/hl_region_H5LTpublic.h $(PREFIX)/include )
	(cp src/h5hl_region.h $(PREFIX)/include )
# if h5fc is available then install FORTRAN source
	if test -e $(HDF5_INSTALL_DIR)/bin/h5fc; then \
	(cp fortran/src/libhdf5_hl_region_fortran.a $(PREFIX)/lib; \
	 cp fortran/src/*.mod $(PREFIX)/include );fi


tests:
	(cd test; $(MAKE) tests )
	(cd examples; $(MAKE) tests )
# if h5fc is available then test FORTRAN source
	if test -e $(HDF5_INSTALL_DIR)/bin/h5fc; then \
	(cd fortran/test; $(MAKE) tests; \
	 cd ../examples; $(MAKE) tests );fi

clean:
	(cd src; $(MAKE) clean )
	(cd examples; $(MAKE)  clean )
	(cd test; $(MAKE) clean )
	(cd fortran/src; $(MAKE) clean )
	(cd fortran/examples; $(MAKE)  clean )
	(cd fortran/test; $(MAKE) clean )

uninstall:
	(\rm -f $(PREFIX)/lib/libhdf5_hl_region.a)
	(\rm -f $(PREFIX)/include/hl_region_H5LRpublic.h)
	(\rm -f $(PREFIX)/include/hl_region_H5LTpublic.h)
	(\rm -f $(PREFIX)/include/h5hl_region.h)
	(\rm -f $(PREFIX)/lib/libhdf5_hl_region_fortran.a)
	(\rm -f $(PREFIX)/include/hl_region_*.mod)
