#############################################################################
# 
# 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.
# 
#############################################################################

# source files.
SRC_C   = hl_region_H5LTf.c hl_region_H5LRf.c
SRC_F90 = hl_region_H5LTff.f90 hl_region_H5LRff.f90 h5hl_region.f90

OBJ_C   = $(SRC_C:.c=.o)
OBJ_F90 = $(SRC_F90:.f90=.o)

OUT = ./libhdf5_hl_region_fortran.a

# include directories
INCLUDES = -I$(HDF5_INSTALL_DIR)/include

# compiler
CC = $(HDF5_INSTALL_DIR)/bin/h5cc
FC = $(HDF5_INSTALL_DIR)/bin/h5fc

.SUFFIXES: .c .f90

default: $(OUT)

.c.o:
	$(CC) $(INCLUDES) $(CCFLAGS) -c $< -o $@

.f90.o:
	$(FC) $(INCLUDES) $(FCFLAGS) -c $< -o $@

$(OUT): $(OBJ_C) $(OBJ_F90)
	ar rcs $(OUT) $(OBJ_C) $(OBJ_F90)
# link the module files so the compiler can find them
# to avoid setting the module path explicitly
	ln -sf ../src/hl_region_h5lr.mod ../examples/hl_region_h5lr.mod
	ln -sf ../src/hl_region_h5lt.mod ../examples/hl_region_h5lt.mod
	ln -sf ../src/h5hl_region.mod ../examples/h5hl_region.mod
	ln -sf ../src/hl_region_h5lr.mod ../test/hl_region_h5lr.mod
	ln -sf ../src/hl_region_h5lt.mod ../test/hl_region_h5lt.mod
	ln -sf ../src/h5hl_region.mod ../test/h5hl_region.mod

clean:
	\rm -f $(OBJ_C) $(OBJ_F90) $(OUT) *.mod 
