diff --git a/makefile b/makefile index 8db73a45e..d6d6fdf62 100644 --- a/makefile +++ b/makefile @@ -49,6 +49,15 @@ MKOCTFILE = mkoctfile OFLAGS = # For experts only, location of MWrap executable (see docs/install.rst): MWRAP = mwrap + +# depenency root +DEPS_ROOT := deps + +# xsimd repo url +XSIMD_URL := https://github.com/xtensor-stack/xsimd.git +XSIMD_VERSION := 13.0.0 +XSIMD_DIR := $(DEPS_ROOT)/xsimd + # absolute path of this makefile, ie FINUFFT's top-level directory... FINUFFT = $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) @@ -60,7 +69,7 @@ FINUFFT = $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) # -fPIC (position-indep code) needed to build dyn lib (.so) # Also, we force return (via :=) to the land of simply-expanded variables... INCL = -Iinclude -CXXFLAGS := $(CXXFLAGS) $(INCL) -fPIC -std=c++14 +CXXFLAGS := $(CXXFLAGS) $(INCL) -fPIC -std=c++17 CFLAGS := $(CFLAGS) $(INCL) -fPIC # here /usr/include needed for fftw3.f "fortran header"... (JiriK: no longer) FFLAGS := $(FFLAGS) $(INCL) -I/usr/include -fPIC @@ -116,7 +125,7 @@ OBJSD = $(OBJS) $(OBJSF) $(OBJS_PI) default: usage -all: test perftest lib examples fortran matlab octave python +all: test perftest lib examples fortran matlab octave python setup usage: @echo "Makefile for FINUFFT library. Please specify your task:" @@ -165,14 +174,14 @@ src/spreadinterp.o: src/ker_horner_allw_loop.c src/ker_lowupsampfac_horner_allw_ # lib ----------------------------------------------------------------------- # build library with double/single prec both bundled in... lib: $(STATICLIB) $(DYNLIB) -$(STATICLIB): $(OBJSD) +$(STATICLIB): setup $(OBJSD) ar rcs $(STATICLIB) $(OBJSD) ifeq ($(OMP),OFF) @echo "$(STATICLIB) built, single-thread version" else @echo "$(STATICLIB) built, multithreaded version" endif -$(DYNLIB): $(OBJSD) +$(DYNLIB): setup $(OBJSD) # using *absolute* path in the -o here is needed to make portable executables # when compiled against it, in mac OSX, strangely... $(CXX) -shared ${LDFLAGS} $(OMPFLAGS) $(OBJSD) -o $(ABSDYNLIB) $(LIBSFFT) @@ -190,7 +199,7 @@ endif # examples (C++/C) ----------------------------------------------------------- # build all examples (single-prec codes separate, and not all have one)... EXAMPLES = $(basename $(wildcard examples/*.c examples/*.cpp)) -examples: $(EXAMPLES) +examples: setup $(EXAMPLES) ifneq ($(MINGW),ON) # Windows-MSYS does not find the dynamic libraries, so we make a temporary copy # Windows-MSYS has same commands as Linux/OSX @@ -406,7 +415,35 @@ wheel: $(STATICLIB) $(DYNLIB) docker-wheel: docker run --rm -e package_name=finufft -v `pwd`:/io libinlu/manylinux2010_x86_64_fftw /io/python/ci/build-wheels.sh - +# =============================== SETUP ==================================== + +define clone_repo + @echo "Cloning repository $(1) at tag $(2) into directory $(3)" + @if [ ! -d "$(3)" ]; then \ + git clone --branch $(2) $(1) $(3); \ + else \ + cd $(3) && \ + CURRENT_VERSION=$$(git describe --tags --abbrev=0) && \ + if [ "$$CURRENT_VERSION" = "$(2)" ]; then \ + echo "Directory $(3) already exists and is at the correct version $(2)."; \ + else \ + echo "Directory $(3) exists but is at version $$CURRENT_VERSION. Checking out the correct version $(2)."; \ + git fetch --tags && \ + git checkout $(2) || { echo "Error: Failed to checkout version $(2) in $(3)."; exit 1; }; \ + fi; \ + fi +endef + +setup: + @echo "Downloading dependencies..." + @echo "Downloading xsimd..." + mkdir -p $(DEPS_ROOT) + $(call clone_repo,$(XSIMD_URL),$(XSIMD_VERSION),$(XSIMD_DIR)) + @echo "xsimd downloaded in deps/xsimd" + CXXFLAGS += -I$(XSIMD_DIR)/include + +setupclean: + rm -rf $(DEPS_ROOT) # =============================== DOCUMENTATION ============================= @@ -420,7 +457,7 @@ docs/matlabhelp.doc: docs/genmatlabhelp.sh matlab/*.sh matlab/*.docsrc matlab/*. # =============================== CLEAN UP ================================== -clean: objclean pyclean +clean: objclean pyclean setupclean ifneq ($(MINGW),ON) # non-Windows-WSL clean up... rm -f $(STATICLIB) $(DYNLIB) @@ -440,6 +477,7 @@ else del examples\core, test\core, perftest\core, $(subst /,\, $(FE_DIR))\core endif + # indiscriminate .o killer; needed before changing threading... objclean: ifneq ($(MINGW),ON) @@ -473,3 +511,4 @@ else # Windows-WSL... del matlab\finufft_plan.m matlab\finufft.cpp matlab\finufft.mex* endif +