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