msspec_python3/src/msspec/spec/fortran/Makefile

99 lines
3.8 KiB
Makefile

COMP:=gfortran
F2PY:=f2py3
COMP_OPTS:= -O2 -ffast-math -fno-automatic
LINKER_FLAGS:=
F2PY_OPTS:=
DEBUG:=0
USE_MKL:=0
includes := -I./memalloc/ -I./cluster_gen/ -I./common_sub -I./renormalization
includes += -I./phd_se_noso_nosp_nosym
includes += -I./eig/common -I./eig/mi -I./eig/pw
memalloc_src:=memalloc/dim_mod.f memalloc/modules.f memalloc/allocation.f
cluster_gen_src:=$(wildcard cluster_gen/*.f)
common_sub_src:=$(wildcard common_sub/*.f)
renormalization_src:=$(wildcard renormalization/*.f)
phd_se_noso_nosp_nosym_src:=$(filter-out phd_se_noso_nosp_nosym/main.f, $(wildcard phd_se_noso_nosp_nosym/*.f))
phd_mi_noso_nosp_nosym_src:=$(filter-out phd_mi_noso_nosp_nosym/main.f, $(wildcard phd_mi_noso_nosp_nosym/*.f))
eig_common_src:=$(wildcard eig/common/*.f)
eig_mi_src:=$(filter-out eig/mi/main.f, $(wildcard eig/mi/*.f))
eig_pw_src:=$(filter-out eig/pw/main.f, $(wildcard eig/pw/*.f))
ifeq ($(USE_MKL), 1)
eig_common_src:=$(filter-out $(wildcard eig/common/lapack*.f), $(eig_common_src))
phd_mi_noso_nosp_nosym_src:=$(filter-out $(wildcard phd_mi_noso_nosp_nosym/lapack*.f), $(phd_mi_noso_nosp_nosym_src))
LINKER_FLAGS:=$(shell pkg-config --libs lapack)
# MKL:=-L$(MKLROOT) -lmkl_core -lmkl_intel_lp64 -lmkl_sequential
endif
objects_src := $(memalloc_src) $(cluster_gen_src) $(common_sub_src)
objects_src += $(renormalization_src) $(phd_se_noso_nosp_nosym_src)
objects_src += $(eig_common_src) $(eig_mi_src) $(eig_pw_src)
objects_src += $(phd_mi_noso_nosp_nosym_src)
memalloc_obj:=$(patsubst %.f,%.o, $(memalloc_src))
cluster_gen_obj:=$(patsubst %.f,%.o, $(cluster_gen_src))
common_sub_obj:=$(patsubst %.f,%.o, $(common_sub_src))
renormalization_obj:=$(patsubst %.f,%.o, $(renormalization_src))
phd_se_noso_nosp_nosym_obj:=$(patsubst %.f,%.o, $(phd_se_noso_nosp_nosym_src))
phd_mi_noso_nosp_nosym_obj:=$(patsubst %.f,%.o, $(phd_mi_noso_nosp_nosym_src))
eig_common_obj:=$(patsubst %.f,%.o, $(eig_common_src))
eig_mi_obj:=$(patsubst %.f,%.o, $(eig_mi_src))
eig_pw_obj:=$(patsubst %.f,%.o, $(eig_pw_src))
objects:=$(patsubst %.f,%.o, $(objects_src))
libs_targets := phd_se_noso_nosp_nosym.target phd_mi_noso_nosp_nosym.target eig_mi.target eig_pw.target
EXE=prog
ifeq ($(DEBUG),1)
COMP_OPTS:=$(COMP_OPTS) -g -Wall -Wextra -Warray-temporaries -Wconversion -fbacktrace -ffree-line-length-0 -fcheck=all -ffpe-trap=zero,overflow,underflow -finit-real=nan
F2PY_OPTS:=$(F2PY_OPTS) --debug-capi --debug
endif
export COMP
export COMP_OPTS
.PHONY: clean
pybinding: $(libs_targets)
phd_se_noso_nosp_nosym.target: $(memalloc_obj) $(cluster_gen_obj) $(common_sub_obj) $(renormalization_obj) $(phd_se_noso_nosp_nosym_obj)
@echo "building Python binding..."
@$(F2PY) $(includes) $^ $(F2PY_OPTS) -c -m $(patsubst %.target, %, $@) phd_se_noso_nosp_nosym/main.f
@touch $@
phd_mi_noso_nosp_nosym.target: $(memalloc_obj) $(cluster_gen_obj) $(common_sub_obj) $(renormalization_obj) $(phd_mi_noso_nosp_nosym_obj)
@echo "building Python binding..."
@$(F2PY) $(includes) $^ $(F2PY_OPTS) -c -m $(patsubst %.target, %, $@) phd_mi_noso_nosp_nosym/main.f $(LINKER_FLAGS)
@touch $@
eig_mi.target: $(memalloc_obj) $(cluster_gen_obj) $(common_sub_obj) $(renormalization_obj) $(eig_common_obj) $(eig_mi_obj)
@echo "building Python binding..."
@$(F2PY) $(includes) $^ $(F2PY_OPTS) -c -m $(patsubst %.target, %, $@) eig/mi/main.f $(LINKER_FLAGS)
@touch $@
eig_pw.target: $(memalloc_obj) $(cluster_gen_obj) $(common_sub_obj) $(renormalization_obj) $(eig_common_obj) $(eig_pw_obj)
@echo "building Python binding..."
@$(F2PY) $(includes) $^ $(F2PY_OPTS) -c -m $(patsubst %.target, %, $@) eig/pw/main.f $(LINKER_FLAGS)
@touch $@
%.o: %.f
@echo "compiling $@..."
@$(COMP) $(COMP_OPTS) -I./memalloc/ -fPIC -o $@ -c $^
clean:
@echo "cleaning..."
@rm -rf *.o *.mod
@rm -rf $(objects)
@rm -rf $(libs_targets)