##########################################################################################################################################################
#
#
#
#  Makefile for compiling the TinyXCLASS package for python
#  Copyright (C) 2012 - 2024  Thomas Moeller
#
#  I. Physikalisches Institut, University of Cologne
#
#
#
#  Versions of the program:
#
#  Who           When        What
#
#  T. Moeller    2016-04-19  Initial version
#
#
#
#
#  Makefile options:    - "all":    builds the TinyXCLASS package
#
#                                   Used files:     src/CalculateXCLASS.f90
#
#                       - "sig":    creates signature file
#
#
##########################################################################################################################################################


#---------------------------------------------------------------------------------------------------------------------------------------------------------
# FORTRAN compiler

# intel fortran compiler
# FC = ifort
# FFLAGS = -O3 -openmp -fp-model strict -check all -fstack-security-check -W1


# gfortran compiler
FC = python3 -m numpy.f2py
FFLAGS = --fcompiler=gnu95 --f90flags="-O5 -ffree-form -ffree-line-length-none -fbounds-check -frange-check -Wall"


##--------------------------------------------------------------------------------------------------------------------------------------------------------
## define name of the executable file
EXEC = xclasslite


##--------------------------------------------------------------------------------------------------------------------------------------------------------
## define names of fortran source files
FSRC = src/XCLASS-lite.f90

.SUFFIXES: $(SUFFIXES) .f90


#=========================================================================================================================================================
#=========================================================================================================================================================
# define rules
#=========================================================================================================================================================
#=========================================================================================================================================================


#---------------------------------------------------------------------------------------------------------------------------------------------------------
# define compilation rules


## define order of commands
all: f2py clean move


#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# compile f2py


## compilation commands
f2py:
	$(FC) -c $(FFLAGS) -m $(EXEC) $(FSRC)

sig:
	$(FC) -h CalculateXCLASS.pyf -m $(EXEC) $(FSRC)


#---------------------------------------------------------------------------------------------------------------------------------------------------------
# clean directories and previous compilations
clean:
	rm -f $(OBJS) *.mod *.o *.pyf bin/*


#---------------------------------------------------------------------------------------------------------------------------------------------------------
# move module file to bin directory
move:
	mv *.so bin/$(EXEC).so


#---------------------------------------------------------------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------------------------------------------------------
# done
#---------------------------------------------------------------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------------------------------------------------------

