2020-11-24 09:57:35 +01:00
|
|
|
FC = gfortran
|
|
|
|
F2PY = f2py3
|
|
|
|
|
|
|
|
DEBUG = 0
|
|
|
|
VERBOSE = 0
|
|
|
|
BUILDDIR = ./build
|
2020-12-02 18:18:47 +01:00
|
|
|
INSTALL_PREFIX = $(HOME)/.local
|
2020-11-24 09:57:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# 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 #
|
|
|
|
################################################################################
|
2020-11-30 16:39:29 +01:00
|
|
|
#VERSION:=$(shell python -c "import msspec; print(msspec.__version__)")
|
|
|
|
VERSION:=$(shell git describe|sed 's/-\([[:digit:]]\+\)-.*/\.post\1/')
|
2020-12-02 18:18:47 +01:00
|
|
|
VENV_PATH := $(INSTALL_PREFIX)/src/msspec_venv_$(VERSION)
|
2020-11-24 09:57:35 +01:00
|
|
|
|
|
|
|
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))))
|
|
|
|
|
2020-11-30 16:39:29 +01:00
|
|
|
.PHONY: clean obj all info
|
2020-11-24 09:57:35 +01:00
|
|
|
|
2021-01-13 18:26:08 +01:00
|
|
|
help:
|
|
|
|
|
|
|
|
|
2020-11-30 16:39:29 +01:00
|
|
|
info:
|
|
|
|
@echo "Compilation information for msspec $(VERSION)"
|
|
|
|
@echo "FC : $(FC)"
|
|
|
|
@echo "FFLAGS:"
|
|
|
|
@for flag in $(FFLAGS); do echo "\t$$flag"; done
|
2020-11-24 09:57:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
all: $(SO)
|
|
|
|
|
|
|
|
|
|
|
|
obj: $(OBJS)
|
|
|
|
|
|
|
|
|
2020-11-30 16:39:29 +01:00
|
|
|
clean::
|
|
|
|
@if test -d $(abspath $(BUILDDIR)); then \
|
2020-12-02 18:18:47 +01:00
|
|
|
echo "Removing $(abspath $(BUILDDIR))..."; \
|
|
|
|
rm -r $(abspath $(BUILDDIR)); \
|
|
|
|
fi
|
2020-11-30 16:39:29 +01:00
|
|
|
@if test x$(SO) != x; then \
|
|
|
|
if test -f $(SO); then \
|
|
|
|
echo "Removing $(SO)..."; rm $(SO); \
|
|
|
|
fi; \
|
|
|
|
fi
|
2020-11-24 09:57:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
$(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 $@
|