12f4d9adbSJeremy L Thompson# Note: PETSC_ARCH can be undefined or empty for installations which do not use 22f4d9adbSJeremy L Thompson# PETSC_ARCH - for example when using PETSc installed through Spack. 39f8a8fa0SJed BrownPETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc 46ea7c6c1SJed BrownCEED_DIR ?= ../.. 56ea7c6c1SJed Brownceed.pc := $(CEED_DIR)/lib/pkgconfig/ceed.pc 69f8a8fa0SJed Brown 7c0c38e35SVeselin DobrevCC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc)) 80c59ef15SJeremy L ThompsonCFLAGS = -std=c99 $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) $(call pkgconf, --cflags-only-other $(PETSc.pc)) $(OPT) -D__DIR__=\"$(dir $(abspath $(lastword $<)))\" 9c0c38e35SVeselin DobrevCPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc)) 10c0c38e35SVeselin DobrevLDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc)) 11c0c38e35SVeselin DobrevLDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc))) 12c0c38e35SVeselin DobrevLDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm 139f8a8fa0SJed Brown 14*dc7d240cSValeria Barraarea.c := area.c 15*dc7d240cSValeria Barraarea := $(area.c:%.c=%) 16cb32e2e7SValeria Barra 170c59ef15SJeremy L Thompsonbps.c := bps.c 180c59ef15SJeremy L Thompsonbps := $(bps.c:%.c=%) 199f8a8fa0SJed Brown 20*dc7d240cSValeria Barrabpsraw.c := bpsraw.c 21*dc7d240cSValeria Barrabpsraw := $(bpsraw.c:%.c=%) 22*dc7d240cSValeria Barra 236c5df90dSjeremyltmultigrid.c := multigrid.c 246c5df90dSjeremyltmultigrid := $(multigrid.c:%.c=%) 256c5df90dSjeremylt 26*dc7d240cSValeria Barraall: $(area) $(bps) $(bpsraw) $(multigrid) 27*dc7d240cSValeria Barra$(area): | $(PETSc.pc) $(ceed.pc) 280c59ef15SJeremy L Thompson$(bps): | $(PETSc.pc) $(ceed.pc) 29*dc7d240cSValeria Barra$(bpsraw): | $(PETSc.pc) $(ceed.pc) 306c5df90dSjeremylt$(multigrid): | $(PETSc.pc) $(ceed.pc) 319f8a8fa0SJed Brown 3233795f53Sjeremylt# Rules for building the examples 3333795f53Sjeremylt%: %.c 3433795f53Sjeremylt $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(abspath $<) -o $@ \ 3533795f53Sjeremylt $(LDLIBS) 3633795f53Sjeremylt 37c0c38e35SVeselin Dobrevprint: $(PETSc.pc) $(ceed.pc) 389f8a8fa0SJed Brown $(info CC : $(CC)) 399f8a8fa0SJed Brown $(info CFLAGS : $(CFLAGS)) 409f8a8fa0SJed Brown $(info CPPFLAGS: $(CPPFLAGS)) 419f8a8fa0SJed Brown $(info LDFLAGS : $(LDFLAGS)) 429f8a8fa0SJed Brown $(info LDLIBS : $(LDLIBS)) 43c0c38e35SVeselin Dobrev @true 449f8a8fa0SJed Brown 459f8a8fa0SJed Brownclean: 46*dc7d240cSValeria Barra $(RM) $(area) $(bps) $(bpsraw) $(multigrid) 479f8a8fa0SJed Brown 48c0c38e35SVeselin Dobrev$(PETSc.pc): 4908779805SVeselin Dobrev $(if $(wildcard $@),,$(error \ 506f87d196Sjeremylt PETSc config not found at $@. Please set PETSC_DIR and PETSC_ARCH)) 51c0c38e35SVeselin Dobrev 529f8a8fa0SJed Brown.PHONY: all print clean 53c0c38e35SVeselin Dobrev 54c0c38e35SVeselin Dobrevpkgconf = $(shell pkg-config $1 | sed -e 's/^"//g' -e 's/"$$//g') 55