xref: /libCEED/Makefile (revision 1571c99d1f6878671bebdd65f042c55ec98b920f)
1# Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
2# Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
3# All Rights reserved. See files LICENSE and NOTICE for details.
4#
5# This file is part of CEED, a collection of benchmarks, miniapps, software
6# libraries and APIs for efficient high-order finite element and spectral
7# element discretizations for exascale applications. For more information and
8# source code availability see http://github.com/ceed.
9#
10# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11# a collaborative effort of two U.S. Department of Energy organizations (Office
12# of Science and the National Nuclear Security Administration) responsible for
13# the planning and preparation of a capable exascale ecosystem, including
14# software, applications, hardware, advanced system engineering and early
15# testbed platforms, in support of the nation's exascale computing imperative.
16
17-include config.mk
18
19ifeq (,$(filter-out undefined default,$(origin CC)))
20  CC = gcc
21endif
22ifeq (,$(filter-out undefined default,$(origin FC)))
23  FC = gfortran
24endif
25NVCC = $(CUDA_DIR)/bin/nvcc
26
27# ASAN must be left empty if you don't want to use it
28ASAN ?=
29
30LDFLAGS ?=
31UNDERSCORE ?= 1
32
33# MFEM_DIR env variable should point to sibling directory
34ifneq ($(wildcard ../mfem/libmfem.*),)
35  MFEM_DIR ?= ../mfem
36endif
37
38# NEK5K_DIR env variable should point to sibling directory
39ifneq ($(wildcard ../Nek5000/*),)
40  NEK5K_DIR ?= ../Nek5000
41endif
42
43# XSMM_DIR env variable should point to XSMM master (github.com/hfp/libxsmm)
44XSMM_DIR ?= ../libxsmm
45
46# OCCA_DIR env variable should point to OCCA master (github.com/libocca/occa)
47OCCA_DIR ?= ../occa
48
49# env variable MAGMA_DIR can be used too
50MAGMA_DIR ?= ../magma
51# If CUDA_DIR is not set, check for nvcc, or resort to /usr/local/cuda
52CUDA_DIR  ?= $(or $(patsubst %/,%,$(dir $(patsubst %/,%,$(dir \
53               $(shell which nvcc 2> /dev/null))))),/usr/local/cuda)
54
55# Check for PETSc in ../petsc
56ifneq ($(wildcard ../petsc/lib/libpetsc.*),)
57  PETSC_DIR ?= ../petsc
58endif
59
60# Warning: SANTIZ options still don't run with /gpu/occa
61# export LSAN_OPTIONS=suppressions=.asanignore
62AFLAGS = -fsanitize=address #-fsanitize=undefined -fno-omit-frame-pointer
63
64OPT    = -O -g -march=native -ffp-contract=fast -fopenmp-simd
65CFLAGS = -std=c99 $(OPT) -Wall -Wextra -Wno-unused-parameter -fPIC -MMD -MP
66NVCCFLAGS = -Xcompiler "$(OPT)" -Xcompiler -fPIC
67# If using the IBM XL Fortran (xlf) replace FFLAGS appropriately:
68ifneq ($(filter %xlf %xlf_r,$(FC)),)
69  FFLAGS = $(OPT) -ffree-form -qpreprocess -qextname -qpic -MMD
70else # gfortran/Intel-style options
71  FFLAGS = -cpp     $(OPT) -Wall -Wextra -Wno-unused-parameter -Wno-unused-dummy-argument -fPIC -MMD -MP
72endif
73
74ifeq ($(UNDERSCORE), 1)
75  CFLAGS += -DUNDERSCORE
76endif
77
78ifeq ($(COVERAGE), 1)
79  CFLAGS += --coverage
80  LDFLAGS += --coverage
81endif
82
83CFLAGS += $(if $(ASAN),$(AFLAGS))
84FFLAGS += $(if $(ASAN),$(AFLAGS))
85LDFLAGS += $(if $(ASAN),$(AFLAGS))
86CPPFLAGS = -I./include
87LDLIBS = -lm
88OBJDIR := build
89LIBDIR := lib
90
91# Installation variables
92prefix ?= /usr/local
93bindir = $(prefix)/bin
94libdir = $(prefix)/lib
95okldir = $(libdir)/okl
96includedir = $(prefix)/include
97pkgconfigdir = $(libdir)/pkgconfig
98INSTALL = install
99INSTALL_PROGRAM = $(INSTALL)
100INSTALL_DATA = $(INSTALL) -m644
101
102# Get number of processors of the machine
103NPROCS := $(shell getconf _NPROCESSORS_ONLN)
104# prepare make options to run in parallel
105MFLAGS := -j $(NPROCS) --warn-undefined-variables \
106                       --no-print-directory --no-keep-going
107
108PYTHON ?= python3
109PROVE ?= prove
110PROVE_OPTS ?= -j $(NPROCS)
111DARWIN := $(filter Darwin,$(shell uname -s))
112SO_EXT := $(if $(DARWIN),dylib,so)
113
114ceed.pc := $(LIBDIR)/pkgconfig/ceed.pc
115libceed := $(LIBDIR)/libceed.$(SO_EXT)
116CEED_LIBS = -lceed
117libceed.c := $(wildcard interface/ceed*.c)
118libceed_test := $(LIBDIR)/libceed_test.$(SO_EXT)
119libceeds = $(libceed) $(libceed_test)
120BACKENDS_BUILTIN := /cpu/self/ref/serial /cpu/self/ref/blocked /cpu/self/opt/serial /cpu/self/opt/blocked
121BACKENDS := $(BACKENDS_BUILTIN)
122
123# Tests
124tests.c   := $(sort $(wildcard tests/t[0-9][0-9][0-9]-*.c))
125tests.f   := $(sort $(wildcard tests/t[0-9][0-9][0-9]-*.f90))
126tests     := $(tests.c:tests/%.c=$(OBJDIR)/%)
127ctests    := $(tests)
128tests     += $(tests.f:tests/%.f90=$(OBJDIR)/%)
129#examples
130examples.c := $(sort $(wildcard examples/ceed/*.c))
131examples.f := $(sort $(wildcard examples/ceed/*.f))
132examples  := $(examples.c:examples/ceed/%.c=$(OBJDIR)/%)
133examples  += $(examples.f:examples/ceed/%.f=$(OBJDIR)/%)
134#mfemexamples
135mfemexamples.cpp := $(sort $(wildcard examples/mfem/*.cpp))
136mfemexamples  := $(mfemexamples.cpp:examples/mfem/%.cpp=$(OBJDIR)/mfem-%)
137#nekexamples
138nekexamples.usr := $(sort $(wildcard examples/nek5000/*.usr))
139nekexamples  := $(nekexamples.usr:examples/nek5000/%.usr=$(OBJDIR)/nek-%)
140#petscexamples
141petscexamples.c := $(sort $(wildcard examples/petsc/*.c))
142petscexamples  := $(petscexamples.c:examples/petsc/%.c=$(OBJDIR)/petsc-%)
143#navierstokesexample
144navierstokesexample.c := $(sort $(wildcard examples/navier-stokes/*.c))
145navierstokesexample  := $(navierstokesexample.c:examples/navier-stokes/%.c=$(OBJDIR)/navier-stokes-%)
146
147# backends/[ref, blocked, template, memcheck, opt, avx, occa, magma]
148ref.c          := $(sort $(wildcard backends/ref/*.c))
149blocked.c      := $(sort $(wildcard backends/blocked/*.c))
150template.c     := $(sort $(wildcard backends/template/*.c))
151ceedmemcheck.c := $(sort $(wildcard backends/memcheck/*.c))
152opt.c          := $(sort $(wildcard backends/opt/*.c))
153avx.c          := $(sort $(wildcard backends/avx/*.c))
154xsmm.c         := $(sort $(wildcard backends/xsmm/*.c))
155cuda.c         := $(sort $(wildcard backends/cuda/*.c))
156cuda.cu        := $(sort $(wildcard backends/cuda/*.cu))
157cuda-reg.c     := $(sort $(wildcard backends/cuda-reg/*.c))
158cuda-reg.cu    := $(sort $(wildcard backends/cuda-reg/*.cu))
159cuda-shared.c  := $(sort $(wildcard backends/cuda-shared/*.c))
160cuda-shared.cu := $(sort $(wildcard backends/cuda-shared/*.cu))
161occa.c         := $(sort $(wildcard backends/occa/*.c))
162magma_preprocessor := python backends/magma/gccm.py
163magma_pre_src  := $(filter-out %_tmp.c, $(wildcard backends/magma/ceed-*.c))
164magma_dsrc     := $(wildcard backends/magma/magma_d*.c)
165magma_tmp.c    := $(magma_pre_src:%.c=%_tmp.c)
166magma_tmp.cu   := $(magma_pre_src:%.c=%_cuda.cu)
167magma_allsrc.c := $(magma_dsrc) $(magma_tmp.c)
168magma_allsrc.cu:= $(magma_tmp.cu)
169
170# Output using the 216-color rules mode
171rule_file = $(notdir $(1))
172rule_path = $(patsubst %/,%,$(dir $(1)))
173last_path = $(notdir $(patsubst %/,%,$(dir $(1))))
174ansicolor = $(shell echo $(call last_path,$(1)) | cksum | cut -b1-2 | xargs -IS expr 2 \* S + 17)
175emacs_out = @printf "  %10s %s/%s\n" $(1) $(call rule_path,$(2)) $(call rule_file,$(2))
176color_out = @if [ -t 1 ]; then \
177				printf "  %10s \033[38;5;%d;1m%s\033[m/%s\n" \
178					$(1) $(call ansicolor,$(2)) \
179					$(call rule_path,$(2)) $(call rule_file,$(2)); else \
180				printf "  %10s %s\n" $(1) $(2); fi
181# if TERM=dumb, use it, otherwise switch to the term one
182output = $(if $(TERM:dumb=),$(call color_out,$1,$2),$(call emacs_out,$1,$2))
183
184# if V is set to non-nil, turn the verbose mode
185quiet = $(if $(V),$($(1)),$(call output,$1,$@);$($(1)))
186
187# Cancel built-in and old-fashioned implicit rules which we don't use
188.SUFFIXES:
189
190.SECONDEXPANSION: # to expand $$(@D)/.DIR
191
192.SECONDARY: $(magma_tmp.c) $(magma_tmp.cu)
193
194%/.DIR :
195	@mkdir -p $(@D)
196	@touch $@
197
198.PRECIOUS: %/.DIR
199
200lib: $(libceed) $(ceed.pc)
201# run 'lib' target in parallel
202par:;@$(MAKE) $(MFLAGS) V=$(V) lib
203backend_status = $(if $(filter $1,$(BACKENDS)), [backends: $1], [not found])
204info:
205	$(info ------------------------------------)
206	$(info CC            = $(CC))
207	$(info FC            = $(FC))
208	$(info CPPFLAGS      = $(CPPFLAGS))
209	$(info CFLAGS        = $(value CFLAGS))
210	$(info FFLAGS        = $(value FFLAGS))
211	$(info NVCCFLAGS     = $(value NVCCFLAGS))
212	$(info LDFLAGS       = $(value LDFLAGS))
213	$(info LDLIBS        = $(LDLIBS))
214	$(info OPT           = $(OPT))
215	$(info AFLAGS        = $(AFLAGS))
216	$(info ASAN          = $(or $(ASAN),(empty)))
217	$(info V             = $(or $(V),(empty)) [verbose=$(if $(V),on,off)])
218	$(info ------------------------------------)
219	$(info MEMCHK_STATUS = $(MEMCHK_STATUS)$(call backend_status,/cpu/self/ref/memcheck))
220	$(info AVX_STATUS    = $(AVX_STATUS)$(call backend_status,/cpu/self/avx/serial /cpu/self/avx/blocked))
221	$(info XSMM_DIR      = $(XSMM_DIR)$(call backend_status,/cpu/self/xsmm/serial /cpu/self/xsmm/blocked))
222	$(info OCCA_DIR      = $(OCCA_DIR)$(call backend_status,/cpu/occa /gpu/occa /omp/occa))
223	$(info MAGMA_DIR     = $(MAGMA_DIR)$(call backend_status,/gpu/magma))
224	$(info CUDA_DIR      = $(CUDA_DIR)$(call backend_status,$(CUDA_BACKENDS)))
225	$(info ------------------------------------)
226	$(info MFEM_DIR      = $(MFEM_DIR))
227	$(info NEK5K_DIR     = $(NEK5K_DIR))
228	$(info PETSC_DIR     = $(PETSC_DIR))
229	$(info ------------------------------------)
230	$(info prefix        = $(prefix))
231	$(info includedir    = $(value includedir))
232	$(info libdir        = $(value libdir))
233	$(info okldir        = $(value okldir))
234	$(info pkgconfigdir  = $(value pkgconfigdir))
235	$(info ------------------------------------)
236	@true
237info-backends:
238	$(info make: 'lib' with optional backends: $(filter-out $(BACKENDS_BUILTIN),$(BACKENDS)))
239.PHONY: lib all par info info-backends
240
241$(libceed) : LDFLAGS += $(if $(DARWIN), -install_name @rpath/$(notdir $(libceed)))
242$(libceed_test) : LDFLAGS += $(if $(DARWIN), -install_name @rpath/$(notdir $(libceed_test)))
243
244# Standard Backends
245libceed.c += $(ref.c)
246libceed.c += $(blocked.c)
247libceed.c += $(opt.c)
248
249# Testing Backends
250test_backends.c := $(template.c)
251TEST_BACKENDS := /cpu/self/tmpl /cpu/self/tmpl/sub
252
253# Memcheck Backend
254MEMCHK_STATUS = Disabled
255MEMCHK := $(shell echo "\#include <valgrind/memcheck.h>" | $(CC) $(CPPFLAGS) -E - >/dev/null 2>&1 && echo 1)
256ifeq ($(MEMCHK),1)
257  MEMCHK_STATUS = Enabled
258  libceed.c += $(ceedmemcheck.c)
259  BACKENDS += /cpu/self/ref/memcheck
260endif
261
262# AVX Backed
263AVX_STATUS = Disabled
264AVX := $(shell $(CC) $(OPT) -v -E - < /dev/null 2>&1 | grep -c avx)
265ifeq ($(AVX),1)
266  AVX_STATUS = Enabled
267  libceed.c += $(avx.c)
268  BACKENDS += /cpu/self/avx/serial /cpu/self/avx/blocked
269endif
270
271# libXSMM Backends
272ifneq ($(wildcard $(XSMM_DIR)/lib/libxsmm.*),)
273  $(libceeds) : LDFLAGS += -L$(XSMM_DIR)/lib -Wl,-rpath,$(abspath $(XSMM_DIR)/lib)
274  $(libceeds) : LDLIBS += -lxsmm -ldl
275  MKL ?= 0
276  ifneq (0,$(MKL))
277    $(libceeds) : LDLIBS += -mkl
278  else
279    $(libceeds) : LDLIBS += -lblas
280  endif
281  libceed.c += $(xsmm.c)
282  $(xsmm.c:%.c=$(OBJDIR)/%.o) $(xsmm.c:%=%.tidy) : CPPFLAGS += -I$(XSMM_DIR)/include
283  BACKENDS += /cpu/self/xsmm/serial /cpu/self/xsmm/blocked
284endif
285
286# OCCA Backends
287ifneq ($(wildcard $(OCCA_DIR)/lib/libocca.*),)
288  $(libceeds) : LDFLAGS += -L$(OCCA_DIR)/lib -Wl,-rpath,$(abspath $(OCCA_DIR)/lib)
289  $(libceeds) : LDLIBS += -locca
290  libceed.c += $(occa.c)
291  $(occa.c:%.c=$(OBJDIR)/%.o) $(occa.c:%=%.tidy) : CPPFLAGS += -I$(OCCA_DIR)/include
292  BACKENDS += /cpu/occa /gpu/occa /omp/occa
293endif
294
295# Cuda Backend
296CUDA_LIB_DIR := $(wildcard $(foreach d,lib lib64,$(CUDA_DIR)/$d/libcudart.${SO_EXT}))
297CUDA_LIB_DIR := $(patsubst %/,%,$(dir $(firstword $(CUDA_LIB_DIR))))
298CUDA_BACKENDS = /gpu/cuda/ref /gpu/cuda/reg /gpu/cuda/shared
299ifneq ($(CUDA_LIB_DIR),)
300  $(libceeds) : CFLAGS += -I$(CUDA_DIR)/include
301  $(libceeds) : LDFLAGS += -L$(CUDA_LIB_DIR) -Wl,-rpath,$(abspath $(CUDA_LIB_DIR))
302  $(libceeds) : LDLIBS += -lcudart -lnvrtc -lcuda
303  libceed.c  += $(cuda.c) $(cuda-reg.c) $(cuda-shared.c)
304  libceed.cu += $(cuda.cu) $(cuda-reg.cu) $(cuda-shared.cu)
305  BACKENDS += $(CUDA_BACKENDS)
306endif
307
308# MAGMA Backend
309ifneq ($(wildcard $(MAGMA_DIR)/lib/libmagma.*),)
310  ifneq ($(CUDA_LIB_DIR),)
311  cuda_link = -Wl,-rpath,$(CUDA_LIB_DIR) -L$(CUDA_LIB_DIR) -lcublas -lcusparse -lcudart
312  omp_link = -fopenmp
313  magma_link_static = -L$(MAGMA_DIR)/lib -lmagma $(cuda_link) $(omp_link)
314  magma_link_shared = -L$(MAGMA_DIR)/lib -Wl,-rpath,$(abspath $(MAGMA_DIR)/lib) -lmagma
315  magma_link := $(if $(wildcard $(MAGMA_DIR)/lib/libmagma.${SO_EXT}),$(magma_link_shared),$(magma_link_static))
316  $(libceeds)           : LDLIBS += $(magma_link)
317  $(tests) $(examples) : LDLIBS += $(magma_link)
318  libceed.c  += $(magma_allsrc.c)
319  libceed.cu += $(magma_allsrc.cu)
320  $(magma_allsrc.c:%.c=$(OBJDIR)/%.o) $(magma_allsrc.c:%=%.tidy) : CPPFLAGS += -DADD_ -I$(MAGMA_DIR)/include -I$(CUDA_DIR)/include
321  $(magma_allsrc.cu:%.cu=$(OBJDIR)/%.o) : NVCCFLAGS += --compiler-options=-fPIC -DADD_ -I$(MAGMA_DIR)/include -I$(MAGMA_DIR)/magmablas -I$(MAGMA_DIR)/control -I$(CUDA_DIR)/include
322  BACKENDS += /gpu/magma
323  endif
324endif
325
326export BACKENDS
327
328# generate magma_tmp.c and magma_cuda.cu from magma.c
329%_tmp.c %_cuda.cu : %.c
330	$(magma_preprocessor) $<
331
332libceed.o = $(libceed.c:%.c=$(OBJDIR)/%.o) $(libceed.cu:%.cu=$(OBJDIR)/%.o)
333$(libceed.o): | info-backends
334$(libceed) : $(libceed.o) | $$(@D)/.DIR
335	$(call quiet,CC) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS)
336
337$(OBJDIR)/%.o : $(CURDIR)/%.c | $$(@D)/.DIR
338	$(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<)
339
340$(OBJDIR)/%.o : $(CURDIR)/%.cu | $$(@D)/.DIR
341	$(call quiet,NVCC) $(CPPFLAGS) $(NVCCFLAGS) -c -o $@ $(abspath $<)
342
343$(OBJDIR)/% : tests/%.c | $$(@D)/.DIR
344	$(call quiet,LINK.c) -o $@ $(abspath $<) $(CEED_LIBS) $(LDLIBS)
345
346$(OBJDIR)/% : tests/%.f90 | $$(@D)/.DIR
347	$(call quiet,LINK.F) -o $@ $(abspath $<) $(CEED_LIBS) $(LDLIBS)
348
349$(OBJDIR)/% : examples/ceed/%.c | $$(@D)/.DIR
350	$(call quiet,LINK.c) -o $@ $(abspath $<) $(CEED_LIBS) $(LDLIBS)
351
352$(OBJDIR)/% : examples/ceed/%.f | $$(@D)/.DIR
353	$(call quiet,LINK.F) -o $@ $(abspath $<) $(CEED_LIBS) $(LDLIBS)
354
355$(OBJDIR)/mfem-% : examples/mfem/%.cpp $(libceed) | $$(@D)/.DIR
356	+$(MAKE) -C examples/mfem CEED_DIR=`pwd` \
357	  MFEM_DIR="$(abspath $(MFEM_DIR))" $*
358	mv examples/mfem/$* $@
359
360$(OBJDIR)/petsc-% : examples/petsc/%.c $(libceed) $(ceed.pc) | $$(@D)/.DIR
361	+$(MAKE) -C examples/petsc CEED_DIR=`pwd` \
362	  PETSC_DIR="$(abspath $(PETSC_DIR))" $*
363	mv examples/petsc/$* $@
364
365$(OBJDIR)/navier-stokes-% : examples/navier-stokes/%.c $(libceed) $(ceed.pc) | $$(@D)/.DIR
366	+$(MAKE) -C examples/navier-stokes CEED_DIR=`pwd` \
367	  PETSC_DIR="$(abspath $(PETSC_DIR))" $*
368	mv examples/navier-stokes/$* $@
369
370libceed_test.o = $(test_backends.c:%.c=$(OBJDIR)/%.o)
371$(libceed_test) : $(libceed.o) $(libceed_test.o) | $$(@D)/.DIR
372	$(call quiet,CC) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS)
373
374$(examples) : $(libceed)
375$(tests) : $(libceed_test)
376$(tests) : CEED_LIBS = -lceed_test
377$(tests) $(examples) : LDFLAGS += -Wl,-rpath,$(abspath $(LIBDIR)) -L$(LIBDIR)
378
379run-t% : BACKENDS += $(TEST_BACKENDS)
380run-% : $(OBJDIR)/%
381	@tests/tap.sh $(<:$(OBJDIR)/%=%)
382
383external_examples := \
384	$(if $(MFEM_DIR),$(mfemexamples)) \
385	$(if $(PETSC_DIR),$(petscexamples)) \
386	$(if $(NEK5K_DIR),$(nekexamples))
387
388allexamples = $(examples) $(external_examples)
389
390# The test and prove targets can be controlled via pattern searches.  The
391# default is to run tests and those examples that have no external dependencies.
392# Examples of finer grained control:
393#
394#   make test search='petsc mfem'      # PETSc and MFEM examples
395#   make prove search='t3'             # t3xx series tests
396#   make junit search='ex petsc'       # core ex* and PETSc tests
397search ?= t ex
398realsearch = $(search:%=%%)
399matched = $(foreach pattern,$(realsearch),$(filter $(OBJDIR)/$(pattern),$(tests) $(allexamples)))
400# Work around Nek examples not having normal targets
401matched_prereq = $(filter-out $(OBJDIR)/nek%,$(matched)) $(if $(findstring nek,$(matched)),prepnektests)
402
403# Test core libCEED
404test : $(matched:$(OBJDIR)/%=run-%)
405
406# run test target in parallel
407tst : ;@$(MAKE) $(MFLAGS) V=$(V) test
408# CPU C tests only for backend %
409ctc-% : $(ctests);@$(foreach tst,$(ctests),$(tst) /cpu/$*;)
410
411prove : BACKENDS += $(TEST_BACKENDS)
412prove : $(matched_prereq)
413	$(info Testing backends: $(BACKENDS))
414	$(PROVE) $(PROVE_OPTS) --exec 'tests/tap.sh' $(matched:$(OBJDIR)/%=%)
415# run prove target in parallel
416prv : ;@$(MAKE) $(MFLAGS) V=$(V) prove
417
418prepnektests:
419	(export CC FC && cd examples && make prepnektests)
420
421prove-all :
422	+$(MAKE) prove realsearch=%
423
424junit-t% : BACKENDS += $(TEST_BACKENDS)
425junit-% : $(OBJDIR)/%
426	@printf "  %10s %s\n" TEST $(<:$(OBJDIR)/%=%); $(PYTHON) tests/junit.py $(<:$(OBJDIR)/%=%)
427
428junit : $(alltests:$(OBJDIR)/%=junit-%)
429
430all: $(alltests)
431
432examples : $(allexamples)
433
434# Benchmarks
435allbenchmarks = petsc-bps
436bench_targets = $(addprefix bench-,$(allbenchmarks))
437.PHONY: $(bench_targets) benchmarks
438$(bench_targets): bench-%: $(OBJDIR)/%
439	cd benchmarks && ./benchmark.sh --ceed "$(BACKENDS)" -r $(*).sh
440benchmarks: $(bench_targets)
441
442$(ceed.pc) : pkgconfig-prefix = $(abspath .)
443$(OBJDIR)/ceed.pc : pkgconfig-prefix = $(prefix)
444.INTERMEDIATE : $(OBJDIR)/ceed.pc
445%/ceed.pc : ceed.pc.template | $$(@D)/.DIR
446	@sed "s:%prefix%:$(pkgconfig-prefix):" $< > $@
447
448OCCA        := $(OCCA_DIR)/bin/occa
449OKL_KERNELS := $(wildcard backends/occa/*.okl)
450
451okl-cache :
452	$(OCCA) cache ceed $(OKL_KERNELS)
453
454okl-clear:
455	$(OCCA) clear -y -l ceed
456
457install : $(libceed) $(OBJDIR)/ceed.pc
458	$(INSTALL) -d $(addprefix $(if $(DESTDIR),"$(DESTDIR)"),"$(includedir)"\
459	  "$(libdir)" "$(pkgconfigdir)" $(if $(OCCA_ON),"$(okldir)"))
460	$(INSTALL_DATA) include/ceed.h "$(DESTDIR)$(includedir)/"
461	$(INSTALL_DATA) include/ceedf.h "$(DESTDIR)$(includedir)/"
462	$(INSTALL_DATA) $(libceed) "$(DESTDIR)$(libdir)/"
463	$(INSTALL_DATA) $(OBJDIR)/ceed.pc "$(DESTDIR)$(pkgconfigdir)/"
464	$(if $(OCCA_ON),$(INSTALL_DATA) $(OKL_KERNELS) "$(DESTDIR)$(okldir)/")
465
466.PHONY : cln clean doc lib install all print test tst prove prv prove-all junit examples style tidy okl-cache okl-clear info info-backends
467
468cln clean :
469	$(RM) -r $(OBJDIR) $(LIBDIR)
470	$(MAKE) -C examples clean
471	$(RM) $(magma_tmp.c) $(magma_tmp.cu) backends/magma/*~ backends/magma/*.o
472	$(RM) -rf benchmarks/*output.txt
473
474distclean : clean
475	$(RM) -r doc/html
476
477doc :
478	doxygen Doxyfile
479
480style :
481	@astyle --options=.astylerc \
482          $(filter-out include/ceedf.h tests/t310-basis-f.h, \
483            $(wildcard include/*.h interface/*.[ch] tests/*.[ch] backends/*/*.[ch] \
484              examples/*/*.[ch] examples/*/*.[ch]pp))
485
486CLANG_TIDY ?= clang-tidy
487%.c.tidy : %.c
488	$(CLANG_TIDY) $^ -- $(CPPFLAGS)
489
490tidy : $(libceed.c:%=%.tidy)
491
492print :
493	@echo $(VAR)=$($(VAR))
494
495print-% :
496	$(info [ variable name]: $*)
497	$(info [        origin]: $(origin $*))
498	$(info [         value]: $(value $*))
499	$(info [expanded value]: $($*))
500	$(info )
501	@true
502
503-include $(libceed.c:%.c=$(OBJDIR)/%.d) $(tests.c:tests/%.c=$(OBJDIR)/%.d)
504