98 lines
2.8 KiB
Makefile
98 lines
2.8 KiB
Makefile
|
FC = gfortran
|
||
|
F2PY = f2py3
|
||
|
|
||
|
DEBUG = 0
|
||
|
VERBOSE = 0
|
||
|
BUILDDIR = ./build
|
||
|
|
||
|
|
||
|
################################################################################
|
||
|
# GFORTRAN CONFIGURATION #
|
||
|
################################################################################
|
||
|
GFORTRAN_FFLAGS = -O2 -ffast-math
|
||
|
GFORTRAN_FFLAGS_DBG = -g -Wall -Wextra -Warray-temporaries -Wconversion
|
||
|
GFORTRAN_FFLAGS_DBG += -fbacktrace -ffree-line-length-0 -fcheck=all
|
||
|
GFORTRAN_FFLAGS_DBG += -ffpe-trap=zero,overflow,underflow -finit-real=nan
|
||
|
################################################################################
|
||
|
|
||
|
################################################################################
|
||
|
# IFORT CONFIGURATION #
|
||
|
################################################################################
|
||
|
IFORT_FFLAGS =
|
||
|
IFORT_FFLAGS_DBG =
|
||
|
################################################################################
|
||
|
|
||
|
################################################################################
|
||
|
# F2PY CONFIGURATION #
|
||
|
################################################################################
|
||
|
F2PYFLAGS = --opt=-O2
|
||
|
F2PYFLAGS_DBG = --debug-capi --debug
|
||
|
################################################################################
|
||
|
|
||
|
|
||
|
|
||
|
################################################################################
|
||
|
# /!\ DO NOT EDIT BELOW THAT LINE (unlesss you know what you're doing...) #
|
||
|
# CORE CONFIGURATION #
|
||
|
################################################################################
|
||
|
VERSION:=$(shell python -c "import msspec; print(msspec.__version__)")
|
||
|
|
||
|
ifeq ($(VERBOSE),0)
|
||
|
OUPUT_REDIRECTION := 1>/dev/null 2>/dev/null
|
||
|
MAKEFLAGS = -s --no-print-directory
|
||
|
else
|
||
|
OUPUT_REDIRECTION:=
|
||
|
MAKEFLAGS += --debug=b
|
||
|
endif
|
||
|
|
||
|
PREFIX=
|
||
|
SUFFIX=
|
||
|
|
||
|
ifeq ($(FC),gfortran)
|
||
|
PREFIX = GFORTRAN
|
||
|
endif
|
||
|
|
||
|
ifeq ($(FC),IFORT)
|
||
|
PREFIX = IFORT
|
||
|
endif
|
||
|
|
||
|
ifeq ($(DEBUG),1)
|
||
|
SUFFIX = _DBG
|
||
|
endif
|
||
|
|
||
|
FFLAGS = $($(PREFIX)_FFLAGS$(SUFFIX))
|
||
|
|
||
|
OBJS = $(addprefix $(BUILDDIR)/, $(patsubst %.f,%.o, $(filter-out $(MAIN_F), $(SRCS))))
|
||
|
|
||
|
.PHONY: clean obj all compilation_info
|
||
|
|
||
|
compilation_info:
|
||
|
@echo "Compiler used: $(FC)"
|
||
|
@echo "fortran flags: $(FFLAGS)"
|
||
|
@echo "f2py flags: $(FFLAGS)"
|
||
|
|
||
|
|
||
|
all: $(SO)
|
||
|
|
||
|
|
||
|
obj: $(OBJS)
|
||
|
|
||
|
|
||
|
clean:
|
||
|
@echo "Cleaning..."
|
||
|
rm -rf $(BUILDDIR)
|
||
|
rm -rf $(SO)
|
||
|
|
||
|
|
||
|
$(BUILDDIR)/%.o: %.f
|
||
|
@echo "Compiling $@..."
|
||
|
mkdir -p $(basename $@)
|
||
|
$(FC) $(FFLAGS) -J $(BUILDDIR) -I $(BUILDDIR) -fPIC -o $@ -c $^ $(OUPUT_REDIRECTION)
|
||
|
|
||
|
|
||
|
$(SO): $(OBJS) $(MAIN_F)
|
||
|
@echo "building Python binding $@..."
|
||
|
mkdir -p $(BUILDDIR)
|
||
|
$(F2PY) $(F2PYFLAGS) -I$(BUILDDIR) -m $(basename $@) -c $(OBJS) $(MAIN_F) $(OUPUT_REDIRECTION)
|
||
|
mv $(basename $@).*.so $@
|