#!/bin/sh

############################################################################
#
#  Makefile to compile and link a Fortran 90 application to 
#  Cantera.
#
#############################################################################

# the name of the executable program to be created
PROG_NAME = __PROGRAM__

# the object files to be linked together. List those generated from Fortran
# and from C/C++ separately
OBJS = __OBJS__

# additional flags to be passed to the linker. If your program
# requires other external libraries, put them here
LINK_OPTIONS = 


#############################################################################

# the Fortran compiler
FORT = @F90@

# Fortran compile flags  
FORT_FLAGS = @FFLAGS@ 

# Fortran libraries 
FORT_LIBS = @FLIBS@

# the C++ compiler
CXX = @CXX@

# C++ compile flags
CXX_FLAGS = @CXXFLAGS@

# external libraries
EXT_LIBS = -lcvode -lrecipes @LAPACK_LIBRARY@ @BLAS_LIBRARY@ 

#------  you probably don't have to change anything below this line -----

# Fortran module directory
FTN_MODULE_DIR = @CANTERA_ROOT@/Cantera/fortran

# Cantera modules
CT_MODULES = $(FTN_MODULE_DIR)/ctmixturemod.f \
             $(FTN_MODULE_DIR)/ctreactormod.f \
             $(FTN_MODULE_DIR)/ctfdevmod.f \
             $(FTN_MODULE_DIR)/ctmod.f 

# the directory where the Cantera libraries are located
CANTERA_LIBDIR=@CANTERA_LIBDIR@

# required Cantera libraries
CANTERA_LIBS =  -lctf -lcantera -lckreader

# the directory where Cantera include files may be found.
CANTERA_INCDIR=@CANTERA_INCDIR@

# flags passed to the C++ compiler/linker for the linking step
LCXX_FLAGS = -L$(CANTERA_LIBDIR) @LOCAL_LIB_DIRS@ @CXXFLAGS@

# how to compile C++ source files to object files
.@CXX_EXT@.@OBJ_EXT@:
	$(CXX) -c $< -I$(CANTERA_INCDIR) $(CXX_FLAGS)

# how to compile Fortran source files to object files
.@F77_EXT@.@OBJ_EXT@: 
	$(FORT) -c $< $(FORT_FLAGS)

.@F90_EXT@.@OBJ_EXT@: 
	$(FORT) -c $< $(FORT_FLAGS)

PROGRAM = $(PROG_NAME)$(EXE_EXT)

all: $(PROGRAM)

$(PROGRAM): $(OBJS)
	$(FORT) -o $(PROGRAM) $(CT_MODULES) $(OBJS) $(LF90_FLAGS) $(CANTERA_LIBS) $(LINK_OPTIONS) $(EXT_LIBS) @LIBS@ 

clean:
	$(RM) $(OBJS) $(PROGRAM)






