xref: /libCEED/Makefile (revision 832499a0bd4c636edb3246364925e3d43eb7abda)
1# Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2# All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3#
4# SPDX-License-Identifier: BSD-2-Clause
5#
6# This file is part of CEED:  http://github.com/ceed
7
8CONFIG ?= config.mk
9-include $(CONFIG)
10COMMON ?= common.mk
11-include $(COMMON)
12
13ifeq (,$(filter-out undefined default,$(origin CC)))
14  CC = gcc
15endif
16ifeq (,$(filter-out undefined default,$(origin CXX)))
17  CXX = g++
18endif
19ifeq (,$(filter-out undefined default,$(origin FC)))
20  FC = gfortran
21endif
22ifeq (,$(filter-out undefined default,$(origin LINK)))
23  LINK = $(CC)
24endif
25ifeq (,$(filter-out undefined default,$(origin AR)))
26  AR = ar
27endif
28ifeq (,$(filter-out undefined default,$(origin ARFLAGS)))
29  ARFLAGS = crD
30endif
31NVCC ?= $(CUDA_DIR)/bin/nvcc
32NVCC_CXX ?= $(CXX)
33HIPCC ?= $(HIP_DIR)/bin/hipcc
34SED ?= sed
35ifneq ($(EMSCRIPTEN),)
36  STATIC = 1
37  EXE_SUFFIX = .wasm
38  EM_LDFLAGS = -s TOTAL_MEMORY=256MB
39endif
40
41# ASAN must be left empty if you don't want to use it
42ASAN ?=
43
44# These are the values automatically detected here in the makefile. They are
45# augmented with LDFLAGS and LDLIBS from the environment/passed by command line,
46# if any. If the user sets CEED_LDFLAGS or CEED_LDLIBS, they are used *instead
47# of* what we populate here (thus that's advanced usage and not recommended).
48CEED_LDFLAGS ?=
49CEED_LDLIBS ?=
50
51UNDERSCORE ?= 1
52
53# Verbose mode, V or VERBOSE
54V ?= $(VERBOSE)
55
56# MFEM_DIR env variable should point to sibling directory
57ifneq ($(wildcard ../mfem/libmfem.*),)
58  MFEM_DIR ?= ../mfem
59endif
60
61# NEK5K_DIR env variable should point to sibling directory
62ifneq ($(wildcard ../Nek5000/*),)
63  NEK5K_DIR ?= $(abspath ../Nek5000)
64endif
65export NEK5K_DIR
66MPI ?= 1
67
68# CEED_DIR env for NEK5K testing
69export CEED_DIR = $(abspath .)
70
71# XSMM_DIR env variable should point to XSMM main (github.com/hfp/libxsmm)
72XSMM_DIR ?= ../libxsmm
73
74# OCCA_DIR env variable should point to OCCA main (github.com/libocca/occa)
75OCCA_DIR ?= ../occa/install
76
77# env variable MAGMA_DIR can be used too
78MAGMA_DIR ?= ../magma
79
80# Often /opt/cuda or /usr/local/cuda, but sometimes present on machines that don't support CUDA
81CUDA_DIR  ?=
82CUDA_ARCH ?=
83
84# Often /opt/rocm, but sometimes present on machines that don't support HIP
85HIP_DIR ?=
86HIP_ARCH ?=
87
88# Check for PETSc in ../petsc
89ifneq ($(wildcard ../petsc/lib/libpetsc.*),)
90  PETSC_DIR ?= ../petsc
91endif
92
93# Warning: SANTIZ options still don't run with /gpu/occa
94# export LSAN_OPTIONS=suppressions=.asanignore
95AFLAGS = -fsanitize=address #-fsanitize=undefined -fno-omit-frame-pointer
96
97# Note: Intel oneAPI C/C++ compiler is now icx/icpx
98CC_VENDOR := $(subst icc_orig,icc,$(subst oneAPI,icc,$(firstword $(filter gcc clang icc icc_orig oneAPI XL emcc,$(subst -, ,$(shell $(CC) --version))))))
99FC_VENDOR := $(if $(FC),$(firstword $(filter GNU ifort ifx XL,$(shell $(FC) --version 2>&1 || $(FC) -qversion))))
100
101# Default extra flags by vendor
102MARCHFLAG.gcc           := -march=native
103MARCHFLAG.clang         := $(MARCHFLAG.gcc)
104MARCHFLAG.icc           :=
105MARCHFLAG.oneAPI        := $(MARCHFLAG.clang)
106OMP_SIMD_FLAG.gcc       := -fopenmp-simd
107OMP_SIMD_FLAG.clang     := $(OMP_SIMD_FLAG.gcc)
108OMP_SIMD_FLAG.icc       := -qopenmp-simd
109OMP_SIMD_FLAG.oneAPI    := $(OMP_SIMD_FLAG.clang)
110OPT.gcc                 := -g -ffp-contract=fast
111OPT.clang               := $(OPT.gcc)
112OPT.oneAPI              := $(OPT.clang)
113OPT.emcc                :=
114CFLAGS.gcc              := $(if $(STATIC),,-fPIC) -std=c99 -Wall -Wextra -Wno-unused-parameter -MMD -MP
115CFLAGS.clang            := $(CFLAGS.gcc)
116CFLAGS.icc              := $(CFLAGS.gcc)
117CFLAGS.oneAPI           := $(CFLAGS.clang)
118CFLAGS.XL               := $(if $(STATIC),,-qpic) -MMD
119CFLAGS.emcc             := $(CFLAGS.clang)
120CXXFLAGS.gcc            := $(if $(STATIC),,-fPIC) -std=c++11 -Wall -Wextra -Wno-unused-parameter -MMD -MP
121CXXFLAGS.clang          := $(CXXFLAGS.gcc)
122CXXFLAGS.icc            := $(CXXFLAGS.gcc)
123CXXFLAGS.oneAPI         := $(CXXFLAGS.clang)
124CXXFLAGS.XL             := $(if $(STATIC),,-qpic) -std=c++11 -MMD
125CXXFLAGS.emcc           := $(CXXFLAGS.clang)
126FFLAGS.GNU              := $(if $(STATIC),,-fPIC) -cpp -Wall -Wextra -Wno-unused-parameter -Wno-unused-dummy-argument -MMD -MP
127FFLAGS.ifort            := $(if $(STATIC),,-fPIC) -cpp
128FFLAGS.ifx              := $(FFLAGS.ifort)
129FFLAGS.XL               := $(if $(STATIC),,-qpic) -ffree-form -qpreprocess -qextname -MMD
130
131# This check works with compilers that use gcc and clang.  It fails with some
132# compilers; e.g., xlc apparently ignores all options when -E is passed, thus
133# succeeds with any flags.  Users can pass MARCHFLAG=... if desired.
134cc_check_flag = $(shell $(CC) -E -Werror $(1) -x c /dev/null > /dev/null 2>&1 && echo 1)
135MARCHFLAG := $(MARCHFLAG.$(CC_VENDOR))
136MARCHFLAG := $(if $(call cc_check_flag,$(MARCHFLAG)),$(MARCHFLAG),-mcpu=native)
137MARCHFLAG := $(if $(call cc_check_flag,$(MARCHFLAG)),$(MARCHFLAG))
138
139OMP_SIMD_FLAG := $(OMP_SIMD_FLAG.$(CC_VENDOR))
140OMP_SIMD_FLAG := $(if $(call cc_check_flag,$(OMP_SIMD_FLAG)),$(OMP_SIMD_FLAG))
141
142OPT    ?= -O $(MARCHFLAG) $(OPT.$(CC_VENDOR)) $(OMP_SIMD_FLAG)
143CFLAGS ?= $(OPT) $(CFLAGS.$(CC_VENDOR))
144CXXFLAGS ?= $(OPT) $(CXXFLAGS.$(CC_VENDOR))
145LIBCXX ?= -lstdc++
146NVCCFLAGS ?= -ccbin $(CXX) -Xcompiler "$(OPT)" -Xcompiler -fPIC
147ifneq ($(CUDA_ARCH),)
148  NVCCFLAGS += -arch=$(CUDA_ARCH)
149endif
150HIPCCFLAGS ?= $(filter-out $(OMP_SIMD_FLAG),$(OPT)) -fPIC -munsafe-fp-atomics
151ifneq ($(HIP_ARCH),)
152  HIPCCFLAGS += --amdgpu-target=$(HIP_ARCH)
153endif
154FFLAGS ?= $(OPT) $(FFLAGS.$(FC_VENDOR))
155
156ifeq ($(COVERAGE), 1)
157  CFLAGS += --coverage
158  CXXFLAGS += --coverage
159  CEED_LDFLAGS += --coverage
160endif
161
162CFLAGS += $(if $(ASAN),$(AFLAGS))
163FFLAGS += $(if $(ASAN),$(AFLAGS))
164CEED_LDFLAGS += $(if $(ASAN),$(AFLAGS))
165CPPFLAGS += -I./include
166CEED_LDLIBS = -lm
167OBJDIR := build
168for_install := $(filter install,$(MAKECMDGOALS))
169LIBDIR := $(if $(for_install),$(OBJDIR),lib)
170
171
172# Installation variables
173prefix ?= /usr/local
174bindir = $(prefix)/bin
175libdir = $(prefix)/lib
176includedir = $(prefix)/include
177pkgconfigdir = $(libdir)/pkgconfig
178INSTALL = install
179INSTALL_PROGRAM = $(INSTALL)
180INSTALL_DATA = $(INSTALL) -m644
181
182# Get number of processors of the machine
183NPROCS := $(shell getconf _NPROCESSORS_ONLN)
184# prepare make options to run in parallel
185MFLAGS := -j $(NPROCS) --warn-undefined-variables \
186                       --no-print-directory --no-keep-going
187
188PYTHON ?= python3
189PROVE ?= prove
190PROVE_OPTS ?= -j $(NPROCS)
191DARWIN := $(filter Darwin,$(shell uname -s))
192SO_EXT := $(if $(DARWIN),dylib,so)
193
194ceed.pc := $(LIBDIR)/pkgconfig/ceed.pc
195libceed.so := $(LIBDIR)/libceed.$(SO_EXT)
196libceed.a := $(LIBDIR)/libceed.a
197libceed := $(if $(STATIC),$(libceed.a),$(libceed.so))
198CEED_LIBS = -lceed
199libceed.c := $(filter-out interface/ceed-cuda.c interface/ceed-hip.c interface/ceed-jit-source-root-$(if $(for_install),default,install).c, $(wildcard interface/ceed*.c backends/*.c gallery/*.c))
200gallery.c := $(wildcard gallery/*/ceed*.c)
201libceed.c += $(gallery.c)
202libceeds = $(libceed)
203BACKENDS_BUILTIN := /cpu/self/ref/serial /cpu/self/ref/blocked /cpu/self/opt/serial /cpu/self/opt/blocked
204BACKENDS_MAKE := $(BACKENDS_BUILTIN)
205TEST_BACKENDS := /cpu/self/tmpl /cpu/self/tmpl/sub
206
207# Tests
208tests.c   := $(sort $(wildcard tests/t[0-9][0-9][0-9]-*.c))
209tests.f   := $(if $(FC),$(sort $(wildcard tests/t[0-9][0-9][0-9]-*.f90)))
210tests     := $(tests.c:tests/%.c=$(OBJDIR)/%$(EXE_SUFFIX))
211ctests    := $(tests)
212tests     += $(tests.f:tests/%.f90=$(OBJDIR)/%$(EXE_SUFFIX))
213# Examples
214examples.c := $(sort $(wildcard examples/ceed/*.c))
215examples.f := $(if $(FC),$(sort $(wildcard examples/ceed/*.f)))
216examples  := $(examples.c:examples/ceed/%.c=$(OBJDIR)/%$(EXE_SUFFIX))
217examples  += $(examples.f:examples/ceed/%.f=$(OBJDIR)/%$(EXE_SUFFIX))
218# MFEM Examples
219mfemexamples.cpp := $(sort $(wildcard examples/mfem/*.cpp))
220mfemexamples  := $(mfemexamples.cpp:examples/mfem/%.cpp=$(OBJDIR)/mfem-%)
221# Nek5K Examples
222nekexamples  := $(OBJDIR)/nek-bps
223# PETSc Examples
224petscexamples.c := $(wildcard examples/petsc/*.c)
225petscexamples   := $(petscexamples.c:examples/petsc/%.c=$(OBJDIR)/petsc-%)
226# Fluid Dynamics Examples
227fluidsexamples.c := $(sort $(wildcard examples/fluids/*.c))
228fluidsexamples  := $(fluidsexamples.c:examples/fluids/%.c=$(OBJDIR)/fluids-%)
229# Solid Mechanics Examples
230solidsexamples.c := $(sort $(wildcard examples/solids/*.c))
231solidsexamples   := $(solidsexamples.c:examples/solids/%.c=$(OBJDIR)/solids-%)
232
233# Backends/[ref, blocked, memcheck, opt, avx, occa, magma]
234ref.c          := $(sort $(wildcard backends/ref/*.c))
235blocked.c      := $(sort $(wildcard backends/blocked/*.c))
236ceedmemcheck.c := $(sort $(wildcard backends/memcheck/*.c))
237opt.c          := $(sort $(wildcard backends/opt/*.c))
238avx.c          := $(sort $(wildcard backends/avx/*.c))
239xsmm.c         := $(sort $(wildcard backends/xsmm/*.c))
240cuda.c         := $(sort $(wildcard backends/cuda/*.c))
241cuda.cpp       := $(sort $(wildcard backends/cuda/*.cpp))
242cuda-ref.c     := $(sort $(wildcard backends/cuda-ref/*.c))
243cuda-ref.cpp   := $(sort $(wildcard backends/cuda-ref/*.cpp))
244cuda-ref.cu    := $(sort $(wildcard backends/cuda-ref/kernels/*.cu))
245cuda-shared.c  := $(sort $(wildcard backends/cuda-shared/*.c))
246cuda-shared.cu := $(sort $(wildcard backends/cuda-shared/kernels/*.cu))
247cuda-gen.c     := $(sort $(wildcard backends/cuda-gen/*.c))
248cuda-gen.cpp   := $(sort $(wildcard backends/cuda-gen/*.cpp))
249cuda-gen.cu    := $(sort $(wildcard backends/cuda-gen/kernels/*.cu))
250occa.cpp       := $(sort $(shell find backends/occa -type f -name *.cpp))
251magma.c        := $(sort $(wildcard backends/magma/*.c))
252magma.cpp      := $(sort $(wildcard backends/magma/*.cpp))
253magma.cu       := $(sort $(wildcard backends/magma/kernels/cuda/*.cu))
254magma.hip      := $(sort $(wildcard backends/magma/kernels/hip/*.hip.cpp))
255hip.c          := $(sort $(wildcard backends/hip/*.c))
256hip.cpp        := $(sort $(wildcard backends/hip/*.cpp))
257hip-ref.c      := $(sort $(wildcard backends/hip-ref/*.c))
258hip-ref.cpp    := $(sort $(wildcard backends/hip-ref/*.cpp))
259hip-ref.hip    := $(sort $(wildcard backends/hip-ref/kernels/*.hip.cpp))
260hip-shared.c   := $(sort $(wildcard backends/hip-shared/*.c))
261hip-gen.c      := $(sort $(wildcard backends/hip-gen/*.c))
262hip-gen.cpp    := $(sort $(wildcard backends/hip-gen/*.cpp))
263
264# Quiet, color output
265quiet ?= $($(1))
266
267# Cancel built-in and old-fashioned implicit rules which we don't use
268.SUFFIXES:
269
270.SECONDEXPANSION: # to expand $$(@D)/.DIR
271
272%/.DIR :
273	@mkdir -p $(@D)
274	@touch $@
275
276.PRECIOUS: %/.DIR
277
278lib: $(libceed) $(ceed.pc)
279# run 'lib' target in parallel
280par:;@$(MAKE) $(MFLAGS) V=$(V) lib
281backend_status = $(if $(filter $1,$(BACKENDS_MAKE)), [backends: $1], [not found])
282info:
283	$(info ------------------------------------)
284	$(info CC            = $(CC))
285	$(info CXX           = $(CXX))
286	$(info FC            = $(FC))
287	$(info CPPFLAGS      = $(CPPFLAGS))
288	$(info CFLAGS        = $(value CFLAGS))
289	$(info CXXFLAGS      = $(value CXXFLAGS))
290	$(info FFLAGS        = $(value FFLAGS))
291	$(info NVCCFLAGS     = $(value NVCCFLAGS))
292	$(info HIPCCFLAGS    = $(value HIPCCFLAGS))
293	$(info CEED_LDFLAGS  = $(value CEED_LDFLAGS))
294	$(info CEED_LDLIBS   = $(value CEED_LDLIBS))
295	$(info AR            = $(AR))
296	$(info ARFLAGS       = $(ARFLAGS))
297	$(info OPT           = $(OPT))
298	$(info AFLAGS        = $(AFLAGS))
299	$(info ASAN          = $(or $(ASAN),(empty)))
300	$(info VERBOSE       = $(or $(V),(empty)) [verbose=$(if $(V),on,off)])
301	$(info ------------------------------------)
302	$(info MEMCHK_STATUS = $(MEMCHK_STATUS)$(call backend_status,$(MEMCHK_BACKENDS)))
303	$(info AVX_STATUS    = $(AVX_STATUS)$(call backend_status,$(AVX_BACKENDS)))
304	$(info XSMM_DIR      = $(XSMM_DIR)$(call backend_status,$(XSMM_BACKENDS)))
305	$(info OCCA_DIR      = $(OCCA_DIR)$(call backend_status,$(OCCA_BACKENDS)))
306	$(info MAGMA_DIR     = $(MAGMA_DIR)$(call backend_status,$(MAGMA_BACKENDS)))
307	$(info CUDA_DIR      = $(CUDA_DIR)$(call backend_status,$(CUDA_BACKENDS)))
308	$(info HIP_DIR       = $(HIP_DIR)$(call backend_status,$(HIP_BACKENDS)))
309	$(info ------------------------------------)
310	$(info MFEM_DIR      = $(MFEM_DIR))
311	$(info NEK5K_DIR     = $(NEK5K_DIR))
312	$(info PETSC_DIR     = $(PETSC_DIR))
313	$(info ------------------------------------)
314	$(info prefix        = $(prefix))
315	$(info includedir    = $(value includedir))
316	$(info libdir        = $(value libdir))
317	$(info pkgconfigdir  = $(value pkgconfigdir))
318	$(info ------------------------------------)
319	@true
320info-backends:
321	$(info make: 'lib' with optional backends: $(filter-out $(BACKENDS_BUILTIN),$(BACKENDS)))
322	@true
323info-backends-all:
324	$(info make: 'lib' with backends: $(filter-out $(TEST_BACKENDS),$(BACKENDS)))
325	@true
326
327$(libceed.so) : CEED_LDFLAGS += $(if $(DARWIN), -install_name @rpath/$(notdir $(libceed.so)))
328
329# Standard Backends
330libceed.c += $(ref.c)
331libceed.c += $(blocked.c)
332libceed.c += $(opt.c)
333
334# Memcheck Backend
335MEMCHK_STATUS = Disabled
336MEMCHK := $(shell echo "$(HASH)include <valgrind/memcheck.h>" | $(CC) $(CPPFLAGS) -E - >/dev/null 2>&1 && echo 1)
337MEMCHK_BACKENDS = /cpu/self/memcheck/serial /cpu/self/memcheck/blocked
338ifeq ($(MEMCHK),1)
339  MEMCHK_STATUS = Enabled
340  libceed.c += $(ceedmemcheck.c)
341  BACKENDS_MAKE += $(MEMCHK_BACKENDS)
342endif
343
344# AVX Backed
345AVX_STATUS = Disabled
346AVX_FLAG := $(if $(filter clang,$(CC_VENDOR)),+avx,-mavx)
347AVX := $(filter $(AVX_FLAG),$(shell $(CC) $(CFLAGS) -v -E -x c /dev/null 2>&1))
348AVX_BACKENDS = /cpu/self/avx/serial /cpu/self/avx/blocked
349ifneq ($(AVX),)
350  AVX_STATUS = Enabled
351  libceed.c += $(avx.c)
352  BACKENDS_MAKE += $(AVX_BACKENDS)
353endif
354
355# Collect list of libraries and paths for use in linking and pkg-config
356PKG_LIBS =
357# Stubs that will not be RPATH'd
358PKG_STUBS_LIBS =
359
360# libXSMM Backends
361XSMM_BACKENDS = /cpu/self/xsmm/serial /cpu/self/xsmm/blocked
362ifneq ($(wildcard $(XSMM_DIR)/lib/libxsmm.*),)
363  PKG_LIBS += -L$(abspath $(XSMM_DIR))/lib -lxsmm -ldl
364  MKL ?=
365  ifeq (,$(MKL)$(MKLROOT))
366    BLAS_LIB = -lblas
367  else
368    ifneq ($(MKLROOT),)
369      # Some installs put everything inside an intel64 subdirectory, others not
370      MKL_LIBDIR = $(dir $(firstword $(wildcard $(MKLROOT)/lib/intel64/libmkl_sequential.* $(MKLROOT)/lib/libmkl_sequential.*)))
371      MKL_LINK = -L$(MKL_LIBDIR)
372      PKG_LIB_DIRS += $(MKL_LIBDIR)
373    endif
374    BLAS_LIB = $(MKL_LINK) -Wl,--push-state,--no-as-needed -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl -Wl,--pop-state
375  endif
376  PKG_LIBS += $(BLAS_LIB)
377  libceed.c += $(xsmm.c)
378  $(xsmm.c:%.c=$(OBJDIR)/%.o) $(xsmm.c:%=%.tidy) : CPPFLAGS += -I$(XSMM_DIR)/include
379  BACKENDS_MAKE += $(XSMM_BACKENDS)
380endif
381
382# OCCA Backends
383OCCA_BACKENDS = /cpu/self/occa
384ifneq ($(wildcard $(OCCA_DIR)/lib/libocca.*),)
385  OCCA_MODES := $(shell LD_LIBRARY_PATH=$(OCCA_DIR)/lib $(OCCA_DIR)/bin/occa modes)
386  OCCA_BACKENDS += $(if $(filter OpenMP,$(OCCA_MODES)),/cpu/openmp/occa)
387  OCCA_BACKENDS += $(if $(filter dpcpp,$(OCCA_MODES)),/gpu/dpcpp/occa)
388  OCCA_BACKENDS += $(if $(filter OpenCL,$(OCCA_MODES)),/gpu/opencl/occa)
389  OCCA_BACKENDS += $(if $(filter HIP,$(OCCA_MODES)),/gpu/hip/occa)
390  OCCA_BACKENDS += $(if $(filter CUDA,$(OCCA_MODES)),/gpu/cuda/occa)
391
392  $(libceeds) : CPPFLAGS += -I$(OCCA_DIR)/include
393  PKG_LIBS += -L$(abspath $(OCCA_DIR))/lib -locca
394  LIBCEED_CONTAINS_CXX = 1
395  libceed.cpp += $(occa.cpp)
396  BACKENDS_MAKE += $(OCCA_BACKENDS)
397endif
398
399# CUDA Backends
400ifneq ($(CUDA_DIR),)
401	CUDA_LIB_DIR := $(wildcard $(foreach d,lib lib64 lib/x86_64-linux-gnu,$(CUDA_DIR)/$d/libcudart.${SO_EXT}))
402	CUDA_LIB_DIR := $(patsubst %/,%,$(dir $(firstword $(CUDA_LIB_DIR))))
403endif
404CUDA_LIB_DIR_STUBS := $(CUDA_LIB_DIR)/stubs
405CUDA_BACKENDS = /gpu/cuda/ref /gpu/cuda/shared /gpu/cuda/gen
406ifneq ($(CUDA_LIB_DIR),)
407  $(libceeds) : CPPFLAGS += -I$(CUDA_DIR)/include
408  PKG_LIBS += -L$(abspath $(CUDA_LIB_DIR)) -lcudart -lnvrtc -lcuda -lcublas
409  PKG_STUBS_LIBS += -L$(CUDA_LIB_DIR_STUBS)
410  LIBCEED_CONTAINS_CXX = 1
411  libceed.c     += interface/ceed-cuda.c
412  libceed.c     += $(cuda.c) $(cuda-ref.c) $(cuda-shared.c) $(cuda-gen.c)
413  libceed.cpp   += $(cuda.cpp) $(cuda-ref.cpp) $(cuda-gen.cpp)
414  libceed.cu    += $(cuda-ref.cu) $(cuda-shared.cu) $(cuda-gen.cu)
415  BACKENDS_MAKE += $(CUDA_BACKENDS)
416endif
417
418# HIP Backends
419HIP_LIB_DIR := $(wildcard $(foreach d,lib lib64,$(HIP_DIR)/$d/libamdhip64.${SO_EXT}))
420HIP_LIB_DIR := $(patsubst %/,%,$(dir $(firstword $(HIP_LIB_DIR))))
421HIP_BACKENDS = /gpu/hip/ref /gpu/hip/shared /gpu/hip/gen
422ifneq ($(HIP_LIB_DIR),)
423  $(libceeds) : HIPCCFLAGS += -I./include
424  ifneq ($(CXX), $(HIPCC))
425    CPPFLAGS += $(subst =,,$(shell $(HIP_DIR)/bin/hipconfig -C))
426  endif
427  $(libceeds) : CPPFLAGS += -I$(HIP_DIR)/include
428  PKG_LIBS += -L$(abspath $(HIP_LIB_DIR)) -lamdhip64 -lhipblas
429  LIBCEED_CONTAINS_CXX = 1
430  libceed.c     += interface/ceed-hip.c
431  libceed.c     += $(hip.c) $(hip-ref.c) $(hip-shared.c) $(hip-gen.c)
432  libceed.cpp   += $(hip.cpp) $(hip-ref.cpp) $(hip-gen.cpp)
433  libceed.hip   += $(hip-ref.hip)
434  BACKENDS_MAKE += $(HIP_BACKENDS)
435endif
436
437# MAGMA Backend
438ifneq ($(wildcard $(MAGMA_DIR)/lib/libmagma.*),)
439  MAGMA_ARCH=$(shell nm -g $(MAGMA_DIR)/lib/libmagma.* | grep -c "hipblas")
440  ifeq ($(MAGMA_ARCH), 0) #CUDA MAGMA
441    ifneq ($(CUDA_LIB_DIR),)
442      cuda_link = $(if $(STATIC),,-Wl,-rpath,$(CUDA_LIB_DIR)) -L$(CUDA_LIB_DIR) -lcublas -lcusparse -lcudart
443      omp_link = -fopenmp
444      magma_link_static = -L$(MAGMA_DIR)/lib -lmagma $(cuda_link) $(omp_link)
445      magma_link_shared = -L$(MAGMA_DIR)/lib $(if $(STATIC),,-Wl,-rpath,$(abspath $(MAGMA_DIR)/lib)) -lmagma
446      magma_link := $(if $(wildcard $(MAGMA_DIR)/lib/libmagma.${SO_EXT}),$(magma_link_shared),$(magma_link_static))
447      PKG_LIBS += $(magma_link)
448      libceed.c   += $(magma.c)
449      libceed.cpp += $(magma.cpp)
450      libceed.cu  += $(magma.cu)
451      $(magma.c:%.c=$(OBJDIR)/%.o) $(magma.c:%=%.tidy) : CPPFLAGS += -DADD_ -I$(MAGMA_DIR)/include -I$(CUDA_DIR)/include
452      $(magma.cpp:%.cpp=$(OBJDIR)/%.o) $(magma.cpp:%=%.tidy) : CPPFLAGS += -DADD_ -I$(MAGMA_DIR)/include -I$(CUDA_DIR)/include
453      $(magma.cu:%.cu=$(OBJDIR)/%.o) : CPPFLAGS += --compiler-options=-fPIC -DADD_ -I$(MAGMA_DIR)/include -I$(MAGMA_DIR)/magmablas -I$(CUDA_DIR)/include
454      MAGMA_BACKENDS = /gpu/cuda/magma /gpu/cuda/magma/det
455    endif
456  else  # HIP MAGMA
457    ifneq ($(HIP_LIB_DIR),)
458      hip_link = $(if $(STATIC),,-Wl,-rpath,$(HIP_LIB_DIR)) -L$(HIP_LIB_DIR) -lhipblas -lhipsparse -lamdhip64
459      omp_link = -fopenmp
460      magma_link_static = -L$(MAGMA_DIR)/lib -lmagma $(hip_link) $(omp_link)
461      magma_link_shared = -L$(MAGMA_DIR)/lib $(if $(STATIC),,-Wl,-rpath,$(abspath $(MAGMA_DIR)/lib)) -lmagma
462      magma_link := $(if $(wildcard $(MAGMA_DIR)/lib/libmagma.${SO_EXT}),$(magma_link_shared),$(magma_link_static))
463      PKG_LIBS += $(magma_link)
464      libceed.c   += $(magma.c)
465      libceed.cpp += $(magma.cpp)
466      libceed.hip += $(magma.hip)
467      ifneq ($(CXX), $(HIPCC))
468        $(magma.c:%.c=$(OBJDIR)/%.o) $(magma.c:%=%.tidy) : CPPFLAGS += -I$(MAGMA_DIR)/include -I$(HIP_DIR)/include -DCEED_MAGMA_USE_HIP -DADD_
469        $(magma.cpp:%.cpp=$(OBJDIR)/%.o) $(magma.cpp:%=%.tidy) : CPPFLAGS += -I$(MAGMA_DIR)/include -I$(HIP_DIR)/include -DCEED_MAGMA_USE_HIP -DADD_
470      else
471        $(magma.c:%.c=$(OBJDIR)/%.o) $(magma.c:%=%.tidy) : HIPCCFLAGS += -I$(MAGMA_DIR)/include -I$(HIP_DIR)/include -DCEED_MAGMA_USE_HIP -DADD_
472        $(magma.cpp:%.cpp=$(OBJDIR)/%.o) $(magma.cpp:%=%.tidy) : HIPCCFLAGS += -I$(MAGMA_DIR)/include -I$(HIP_DIR)/include -DCEED_MAGMA_USE_HIP -DADD_
473      endif
474      $(magma.hip:%.hip.cpp=$(OBJDIR)/%.o) : HIPCCFLAGS += -I$(MAGMA_DIR)/include -I$(MAGMA_DIR)/magmablas -I$(HIP_DIR)/include -DCEED_MAGMA_USE_HIP -DADD_
475      MAGMA_BACKENDS = /gpu/hip/magma /gpu/hip/magma/det
476    endif
477  endif
478  LIBCEED_CONTAINS_CXX = 1
479  BACKENDS_MAKE += $(MAGMA_BACKENDS)
480endif
481
482BACKENDS ?= $(BACKENDS_MAKE)
483export BACKENDS
484
485_pkg_ldflags = $(filter -L%,$(PKG_LIBS))
486_pkg_ldlibs = $(filter-out -L%,$(PKG_LIBS))
487$(libceeds) : CEED_LDFLAGS += $(_pkg_ldflags) $(if $(STATIC),,$(_pkg_ldflags:-L%=-Wl,-rpath,%)) $(PKG_STUBS_LIBS)
488$(libceeds) : CEED_LDLIBS += $(_pkg_ldlibs)
489ifeq ($(STATIC),1)
490$(examples) $(tests) : CEED_LDFLAGS += $(EM_LDFLAGS) $(_pkg_ldflags) $(if $(STATIC),,$(_pkg_ldflags:-L%=-Wl,-rpath,%)) $(PKG_STUBS_LIBS)
491$(examples) $(tests) : CEED_LDLIBS += $(_pkg_ldlibs)
492endif
493
494pkgconfig-libs-private = $(PKG_LIBS)
495ifeq ($(LIBCEED_CONTAINS_CXX),1)
496  $(libceeds) : LINK = $(CXX)
497  ifeq ($(STATIC),1)
498    $(examples) $(tests) : CEED_LDLIBS += $(LIBCXX)
499	  pkgconfig-libs-private += $(LIBCXX)
500  endif
501endif
502
503# File names *-weak.c contain weak symbol definitions, which must be listed last
504# when creating shared or static libraries.
505weak_last = $(filter-out %-weak.o,$(1)) $(filter %-weak.o,$(1))
506
507libceed.o = $(libceed.c:%.c=$(OBJDIR)/%.o) $(libceed.cpp:%.cpp=$(OBJDIR)/%.o) $(libceed.cu:%.cu=$(OBJDIR)/%.o) $(libceed.hip:%.hip.cpp=$(OBJDIR)/%.o)
508$(filter %fortran.o,$(libceed.o)) : CPPFLAGS += $(if $(filter 1,$(UNDERSCORE)),-DUNDERSCORE)
509$(libceed.o): | info-backends
510$(libceed.so) : $(call weak_last,$(libceed.o)) | $$(@D)/.DIR
511	$(call quiet,LINK) $(LDFLAGS) $(CEED_LDFLAGS) -shared -o $@ $^ $(CEED_LDLIBS) $(LDLIBS)
512
513$(libceed.a) : $(call weak_last,$(libceed.o)) | $$(@D)/.DIR
514	$(call quiet,AR) $(ARFLAGS) $@ $^
515
516$(OBJDIR)/%.o : $(CURDIR)/%.c | $$(@D)/.DIR
517	$(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<)
518
519$(OBJDIR)/%.o : $(CURDIR)/%.cpp | $$(@D)/.DIR
520	$(call quiet,CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(abspath $<)
521
522$(OBJDIR)/%.o : $(CURDIR)/%.cu | $$(@D)/.DIR
523	$(call quiet,NVCC) $(filter-out -Wno-unused-function, $(CPPFLAGS)) $(NVCCFLAGS) -c -o $@ $(abspath $<)
524
525$(OBJDIR)/%.o : $(CURDIR)/%.hip.cpp | $$(@D)/.DIR
526	$(call quiet,HIPCC) $(HIPCCFLAGS) -c -o $@ $(abspath $<)
527
528$(OBJDIR)/%$(EXE_SUFFIX) : tests/%.c | $$(@D)/.DIR
529	$(call quiet,LINK.c) $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS)
530
531$(OBJDIR)/%$(EXE_SUFFIX) : tests/%.f90 | $$(@D)/.DIR
532	$(call quiet,LINK.F) -DSOURCE_DIR='"$(abspath $(<D))/"' $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS)
533
534$(OBJDIR)/%$(EXE_SUFFIX) : examples/ceed/%.c | $$(@D)/.DIR
535	$(call quiet,LINK.c) $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS)
536
537$(OBJDIR)/%$(EXE_SUFFIX) : examples/ceed/%.f | $$(@D)/.DIR
538	$(call quiet,LINK.F) -DSOURCE_DIR='"$(abspath $(<D))/"' $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS)
539
540$(OBJDIR)/mfem-% : examples/mfem/%.cpp $(libceed) | $$(@D)/.DIR
541	+$(MAKE) -C examples/mfem CEED_DIR=`pwd` \
542	  MFEM_DIR="$(abspath $(MFEM_DIR))" CXX=$(CXX) $*
543	cp examples/mfem/$* $@
544
545# Note: Multiple Nek files cannot be built in parallel. The '+' here enables
546#       this single Nek bps file to be built in parallel with other examples,
547#       such as when calling `make prove-all -j2`.
548$(OBJDIR)/nek-bps : examples/nek/bps/bps.usr examples/nek/nek-examples.sh $(libceed) | $$(@D)/.DIR
549	+$(MAKE) -C examples MPI=$(MPI) CEED_DIR=`pwd` NEK5K_DIR="$(abspath $(NEK5K_DIR))" nek
550	mv examples/nek/build/bps $(OBJDIR)/bps
551	cp examples/nek/nek-examples.sh $(OBJDIR)/nek-bps
552
553# Several executables have common utilities, but we can't build the utilities
554# from separate submake invocations because they'll compete with each
555# other/corrupt output. So we put it in this utility library, but we don't want
556# to manually list source dependencies up at this level, so we'll just always
557# call recursive make to check that this utility is up to date.
558examples/petsc/libutils.a.PHONY: $(libceed) $(ceed.pc)
559	+$(call quiet,MAKE) -C examples/petsc CEED_DIR=`pwd` AR=$(AR) ARFLAGS=$(ARFLAGS) \
560	  PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $(basename $(@F))
561
562$(OBJDIR)/petsc-% : examples/petsc/%.c examples/petsc/libutils.a.PHONY $(libceed) $(ceed.pc) | $$(@D)/.DIR
563	+$(call quiet,MAKE) -C examples/petsc CEED_DIR=`pwd` \
564	  PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $*
565	cp examples/petsc/$* $@
566
567$(OBJDIR)/fluids-% : examples/fluids/%.c examples/fluids/src/*.c examples/fluids/*.h examples/fluids/problems/*.c examples/fluids/qfunctions/*.h $(libceed) $(ceed.pc) | $$(@D)/.DIR
568	+$(call quiet,MAKE) -C examples/fluids CEED_DIR=`pwd` \
569	  PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $*
570	cp examples/fluids/$* $@
571
572$(OBJDIR)/solids-% : examples/solids/%.c examples/solids/%.h \
573    examples/solids/problems/*.c examples/solids/src/*.c \
574    examples/solids/include/*.h examples/solids/problems/*.h examples/solids/qfunctions/*.h \
575    $(libceed) $(ceed.pc) | $$(@D)/.DIR
576	+$(call quiet,MAKE) -C examples/solids CEED_DIR=`pwd` \
577	  PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $*
578	cp examples/solids/$* $@
579
580$(examples) : $(libceed)
581$(tests) : $(libceed)
582$(tests) $(examples) : override LDFLAGS += $(if $(STATIC),,-Wl,-rpath,$(abspath $(LIBDIR))) -L$(LIBDIR)
583
584run-% : $(OBJDIR)/%
585	@$(PYTHON) tests/junit.py --mode tap $(<:$(OBJDIR)/%=%)
586
587external_examples := \
588	$(if $(MFEM_DIR),$(mfemexamples)) \
589	$(if $(PETSC_DIR),$(petscexamples)) \
590	$(if $(NEK5K_DIR),$(nekexamples)) \
591	$(if $(PETSC_DIR),$(fluidsexamples)) \
592	$(if $(PETSC_DIR),$(solidsexamples))
593
594allexamples = $(examples) $(external_examples)
595
596# The test and prove targets can be controlled via pattern searches.  The
597# default is to run tests and those examples that have no external dependencies.
598# Examples of finer grained control:
599#
600#   make test search='petsc mfem'      # PETSc and MFEM examples
601#   make prove search='t3'             # t3xx series tests
602#   make junit search='ex petsc'       # core ex* and PETSc tests
603search ?= t ex
604realsearch = $(search:%=%%)
605matched = $(foreach pattern,$(realsearch),$(filter $(OBJDIR)/$(pattern),$(tests) $(allexamples)))
606
607# Test core libCEED
608test : $(matched:$(OBJDIR)/%=run-%)
609
610# Run test target in parallel
611tst : ;@$(MAKE) $(MFLAGS) V=$(V) test
612# CPU C tests only for backend %
613ctc-% : $(ctests);@$(foreach tst,$(ctests),$(tst) /cpu/$*;)
614
615prove : $(matched)
616	$(info Testing backends: $(BACKENDS))
617	$(PROVE) $(PROVE_OPTS) --exec 'tests/junit.py --mode tap' $(matched:$(OBJDIR)/%=%)
618# Run prove target in parallel
619prv : ;@$(MAKE) $(MFLAGS) V=$(V) prove
620
621prove-all :
622	+$(MAKE) prove realsearch=%
623
624junit-% : $(OBJDIR)/%
625	@printf "  %10s %s\n" TEST $(<:$(OBJDIR)/%=%); $(PYTHON) tests/junit.py $(<:$(OBJDIR)/%=%)
626
627junit : $(matched:$(OBJDIR)/%=junit-%)
628
629all: $(alltests)
630
631examples : $(allexamples)
632ceedexamples : $(examples)
633nekexamples : $(nekexamples)
634mfemexamples : $(mfemexamples)
635petscexamples : $(petscexamples)
636
637# Benchmarks
638allbenchmarks = petsc-bps
639bench_targets = $(addprefix bench-,$(allbenchmarks))
640.PHONY: $(bench_targets) benchmarks
641$(bench_targets): bench-%: $(OBJDIR)/%
642	cd benchmarks && ./benchmark.sh --ceed "$(BACKENDS_MAKE)" -r $(*).sh
643benchmarks: $(bench_targets)
644
645$(ceed.pc) : pkgconfig-prefix = $(abspath .)
646$(OBJDIR)/ceed.pc : pkgconfig-prefix = $(prefix)
647.INTERMEDIATE : $(OBJDIR)/ceed.pc
648%/ceed.pc : ceed.pc.template | $$(@D)/.DIR
649	@$(SED) \
650	    -e "s:%prefix%:$(pkgconfig-prefix):" \
651	    -e "s:%libs_private%:$(pkgconfig-libs-private):" $< > $@
652
653$(OBJDIR)/interface/ceed-jit-source-root-default.o : CPPFLAGS += -DCEED_JIT_SOUCE_ROOT_DEFAULT="\"$(abspath ./include)/\""
654$(OBJDIR)/interface/ceed-jit-source-root-install.o : CPPFLAGS += -DCEED_JIT_SOUCE_ROOT_DEFAULT="\"$(abspath $(includedir))/\""
655
656install : $(libceed) $(OBJDIR)/ceed.pc
657	$(INSTALL) -d $(addprefix $(if $(DESTDIR),"$(DESTDIR)"),"$(includedir)"\
658	  "$(includedir)/ceed/" "$(includedir)/ceed/jit-source/"\
659	  "$(includedir)/ceed/jit-source/cuda/" "$(includedir)/ceed/jit-source/hip/"\
660	  "$(includedir)/ceed/jit-source/gallery/" "$(libdir)" "$(pkgconfigdir)")
661	$(INSTALL_DATA) include/ceed/ceed.h "$(DESTDIR)$(includedir)/ceed/"
662	$(INSTALL_DATA) include/ceed/types.h "$(DESTDIR)$(includedir)/ceed/"
663	$(INSTALL_DATA) include/ceed/ceed-f32.h "$(DESTDIR)$(includedir)/ceed/"
664	$(INSTALL_DATA) include/ceed/ceed-f64.h "$(DESTDIR)$(includedir)/ceed/"
665	$(INSTALL_DATA) include/ceed/fortran.h "$(DESTDIR)$(includedir)/ceed/"
666	$(INSTALL_DATA) include/ceed/backend.h "$(DESTDIR)$(includedir)/ceed/"
667	$(INSTALL_DATA) include/ceed/cuda.h "$(DESTDIR)$(includedir)/ceed/"
668	$(INSTALL_DATA) include/ceed/hip.h "$(DESTDIR)$(includedir)/ceed/"
669	$(INSTALL_DATA) include/ceed/hash.h "$(DESTDIR)$(includedir)/ceed/"
670	$(INSTALL_DATA) include/ceed/khash.h "$(DESTDIR)$(includedir)/ceed/"
671	$(INSTALL_DATA) $(libceed) "$(DESTDIR)$(libdir)/"
672	$(INSTALL_DATA) $(OBJDIR)/ceed.pc "$(DESTDIR)$(pkgconfigdir)/"
673	$(INSTALL_DATA) include/ceed.h "$(DESTDIR)$(includedir)/"
674	$(INSTALL_DATA) include/ceedf.h "$(DESTDIR)$(includedir)/"
675	$(INSTALL_DATA) $(wildcard include/ceed/jit-source/cuda/*.h) "$(DESTDIR)$(includedir)/ceed/jit-source/cuda/"
676	$(INSTALL_DATA) $(wildcard include/ceed/jit-source/hip/*.h) "$(DESTDIR)$(includedir)/ceed/jit-source/hip/"
677	$(INSTALL_DATA) $(wildcard include/ceed/jit-source/gallery/*.h) "$(DESTDIR)$(includedir)/ceed/jit-source/gallery/"
678
679.PHONY : all cln clean doxygen doc lib install par print test tst prove prv prove-all junit examples style style-c style-py tidy iwyu info info-backends info-backends-all
680
681cln clean :
682	$(RM) -r $(OBJDIR) $(LIBDIR) dist *egg* .pytest_cache *cffi*
683	$(call quiet,MAKE) -C examples clean NEK5K_DIR="$(abspath $(NEK5K_DIR))"
684	$(call quiet,MAKE) -C python/tests clean
685	$(RM) benchmarks/*output.txt
686
687distclean : clean
688	$(RM) -r doc/html doc/sphinx/build $(CONFIG)
689
690DOXYGEN ?= doxygen
691doxygen :
692	$(DOXYGEN) -q Doxyfile
693
694doc-html doc-latexpdf doc-epub doc-livehtml : doc-% : doxygen
695	make -C doc/sphinx $*
696
697doc : doc-html
698
699style-c :
700	@astyle --options=.astylerc \
701          $(filter-out include/ceedf.h $(wildcard tests/t*-f.h), \
702            $(wildcard include/*.h interface/*.[ch] tests/*.[ch] backends/*/*.[ch] \
703              examples/*/*/*.[ch] examples/*/*.[ch] examples/*/*.[ch]pp gallery/*/*.[ch]))
704
705AUTOPEP8 = autopep8
706style-py : AUTOPEP8_ARGS = --in-place --aggressive
707style-py :
708	@$(AUTOPEP8) $(AUTOPEP8_ARGS) $(wildcard *.py python**/*.py python/tests/*.py examples**/*.py doc/sphinx/source**/*.py benchmarks/*.py)
709
710style : style-c style-py
711
712CLANG_TIDY ?= clang-tidy
713
714%.c.tidy : %.c
715	$(CLANG_TIDY) $(TIDY_OPTS) $^ -- $(CPPFLAGS) --std=c99 -I$(CUDA_DIR)/include -I$(HIP_DIR)/include -DCEED_JIT_SOUCE_ROOT_DEFAULT="\"$(abspath ./include)/\""
716
717%.cpp.tidy : %.cpp
718	$(CLANG_TIDY) $(TIDY_OPTS) $^ -- $(CPPFLAGS) --std=c++11 -I$(CUDA_DIR)/include -I$(OCCA_DIR)/include -I$(HIP_DIR)/include
719
720tidy_c   : $(libceed.c:%=%.tidy)
721tidy_cpp : $(libceed.cpp:%=%.tidy)
722
723tidy : tidy_c tidy_cpp
724
725ifneq ($(wildcard ../iwyu/*),)
726  IWYU_DIR ?= ../iwyu
727  IWYU_CC  ?= $(IWYU_DIR)/build/bin/include-what-you-use
728endif
729
730iwyu : CC=$(IWYU_CC)
731iwyu : lib
732
733print :
734	@echo $(VAR)=$($(VAR))
735
736print-% :
737	$(info [ variable name]: $*)
738	$(info [        origin]: $(origin $*))
739	$(info [        flavor]: $(flavor $*))
740	$(info [         value]: $(value $*))
741	$(info [expanded value]: $($*))
742	$(info )
743	@true
744
745# "make configure" detects any variables passed on the command line or
746# previously set in config.mk, caching them in config.mk as simple
747# (:=) variables.  Variables set in config.mk or on the command line
748# take precedence over the defaults provided in the file.  Typical
749# usage:
750#
751#   make configure CC=/path/to/my/cc CUDA_DIR=/opt/cuda
752#   make
753#   make prove
754#
755# The values in the file can be updated by passing them on the command
756# line, e.g.,
757#
758#   make configure CC=/path/to/other/clang
759
760# All variables to consider for caching
761CONFIG_VARS = CC CXX FC NVCC NVCC_CXX HIPCC \
762	OPT CFLAGS CPPFLAGS CXXFLAGS FFLAGS NVCCFLAGS HIPCCFLAGS \
763	AR ARFLAGS LDFLAGS LDLIBS LIBCXX SED \
764	MAGMA_DIR OCCA_DIR XSMM_DIR CUDA_DIR CUDA_ARCH MFEM_DIR PETSC_DIR NEK5K_DIR HIP_DIR HIP_ARCH
765
766# $(call needs_save,CFLAGS) returns true (a nonempty string) if CFLAGS
767# was set on the command line or in config.mk (where it will appear as
768# a simple variable).
769needs_save = $(or $(filter command line,$(origin $(1))),$(filter simple,$(flavor $(1))))
770
771configure :
772	$(file > $(CONFIG))
773	$(foreach v,$(CONFIG_VARS),$(if $(call needs_save,$(v)),$(file >> $(CONFIG),$(v) := $($(v)))))
774	@echo "Configuration cached in $(CONFIG):"
775	@cat $(CONFIG)
776
777wheel : export MARCHFLAG = -march=generic
778wheel : export WHEEL_PLAT = manylinux2010_x86_64
779wheel :
780	docker run -it --user $(shell id -u):$(shell id -g) --rm -v $(PWD):/io -w /io \
781		-e MARCHFLAG -e WHEEL_PLAT \
782		quay.io/pypa/$(WHEEL_PLAT) python/make-wheels.sh
783
784.PHONY : configure wheel
785
786# Include *.d deps when not -B = --always-make: useful if the paths are wonky in a container
787-include $(if $(filter B,$(MAKEFLAGS)),,$(libceed.c:%.c=$(OBJDIR)/%.d) $(tests.c:tests/%.c=$(OBJDIR)/%.d))
788