2021-02-22 20:28:13 +01:00
|
|
|
PYTHON = python
|
|
|
|
PYMAJ = 3
|
|
|
|
PYMIN = 6
|
|
|
|
|
2020-11-24 09:57:35 +01:00
|
|
|
FC = gfortran
|
2021-07-21 23:06:41 +02:00
|
|
|
F2PY = f2py3 --f77exec=$(FC) --f90exec=$(FC)
|
2020-11-24 09:57:35 +01:00
|
|
|
|
2021-02-22 20:28:13 +01:00
|
|
|
NO_VENV = 0
|
2020-11-24 09:57:35 +01:00
|
|
|
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
|
|
|
|
2021-02-22 20:28:13 +01:00
|
|
|
|
|
|
|
# Checking Python path and version
|
|
|
|
PYTHON_EXE := $(shell command -v $(PYTHON) 2> /dev/null)
|
|
|
|
|
|
|
|
ifndef PYTHON_EXE
|
|
|
|
$(error Unable to find the $(PYTHON) executable!)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(shell $(PYTHON_EXE) -c "import sys; exit(sys.version_info >= ($(PYMAJ),$(PYMIN)))"; echo $$?),0)
|
|
|
|
$(error Python version >= $(PYMAJ).$(PYMIN) is needed!)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Checking your distribution type and release
|
|
|
|
LSB_RELEASE := $(shell command -v lsb_release 2> /dev/null)
|
|
|
|
DISTRO_RELEASE =
|
|
|
|
|
|
|
|
ifdef LSB_RELEASE
|
|
|
|
DISTRO_RELEASE = $(shell echo $(shell $(LSB_RELEASE) -s -i)-$(shell $(LSB_RELEASE) -s -r) | tr [:upper:] [:lower:] )
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef DISTRO_RELEASE
|
|
|
|
$(warning Unable to guess your OS name and version)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Define the INSIDE_VENV variable
|
|
|
|
ifeq ($(NO_VENV), 1)
|
|
|
|
INSIDE_VENV =
|
|
|
|
else
|
|
|
|
INSIDE_VENV = . $(VENV_PATH)/bin/activate &&
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-24 09:57:35 +01:00
|
|
|
ifeq ($(VERBOSE),0)
|
2021-02-22 20:28:13 +01:00
|
|
|
OUPUT_REDIRECTION := 1>/dev/null 2>/dev/null
|
|
|
|
MAKEFLAGS = -s --no-print-directory
|
2020-11-24 09:57:35 +01:00
|
|
|
else
|
2021-02-22 20:28:13 +01:00
|
|
|
OUPUT_REDIRECTION:=
|
|
|
|
MAKEFLAGS += --debug=b
|
2020-11-24 09:57:35 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
PREFIX=
|
|
|
|
SUFFIX=
|
|
|
|
|
|
|
|
ifeq ($(FC),gfortran)
|
2021-02-22 20:28:13 +01:00
|
|
|
PREFIX = GFORTRAN
|
2020-11-24 09:57:35 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(FC),IFORT)
|
2021-02-22 20:28:13 +01:00
|
|
|
PREFIX = IFORT
|
2020-11-24 09:57:35 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(DEBUG),1)
|
2021-02-22 20:28:13 +01:00
|
|
|
SUFFIX = _DBG
|
2020-11-24 09:57:35 +01:00
|
|
|
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 $@
|