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 140c59ef15SJeremy L Thompsonbps.c := bps.c 150c59ef15SJeremy L Thompsonbps := $(bps.c:%.c=%) 169f8a8fa0SJed Brown 17819eb1b3Sjeremyltbpsdmplex.c := bpsdmplex.c 18819eb1b3Sjeremyltbpsdmplex := $(bpsdmplex.c:%.c=%) 19819eb1b3Sjeremylt 20*6c5df90dSjeremyltmultigrid.c := multigrid.c 21*6c5df90dSjeremyltmultigrid := $(multigrid.c:%.c=%) 22*6c5df90dSjeremylt 23*6c5df90dSjeremyltall: $(bps) $(bpsdmplex) $(multigrid) 240c59ef15SJeremy L Thompson$(bps): | $(PETSc.pc) $(ceed.pc) 25819eb1b3Sjeremylt$(bpsdmplex): | $(PETSc.pc) $(ceed.pc) 26*6c5df90dSjeremylt$(multigrid): | $(PETSc.pc) $(ceed.pc) 279f8a8fa0SJed Brown 2833795f53Sjeremylt# Rules for building the examples 2933795f53Sjeremylt%: %.c 3033795f53Sjeremylt $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(abspath $<) -o $@ \ 3133795f53Sjeremylt $(LDLIBS) 3233795f53Sjeremylt 33c0c38e35SVeselin Dobrevprint: $(PETSc.pc) $(ceed.pc) 349f8a8fa0SJed Brown $(info CC : $(CC)) 359f8a8fa0SJed Brown $(info CFLAGS : $(CFLAGS)) 369f8a8fa0SJed Brown $(info CPPFLAGS: $(CPPFLAGS)) 379f8a8fa0SJed Brown $(info LDFLAGS : $(LDFLAGS)) 389f8a8fa0SJed Brown $(info LDLIBS : $(LDLIBS)) 39c0c38e35SVeselin Dobrev @true 409f8a8fa0SJed Brown 419f8a8fa0SJed Brownclean: 42*6c5df90dSjeremylt $(RM) $(bps) $(bpsdmplex) $(multigrid) 439f8a8fa0SJed Brown 44c0c38e35SVeselin Dobrev$(PETSc.pc): 4508779805SVeselin Dobrev $(if $(wildcard $@),,$(error \ 466f87d196Sjeremylt PETSc config not found at $@. Please set PETSC_DIR and PETSC_ARCH)) 47c0c38e35SVeselin Dobrev 489f8a8fa0SJed Brown.PHONY: all print clean 49c0c38e35SVeselin Dobrev 50c0c38e35SVeselin Dobrevpkgconf = $(shell pkg-config $1 | sed -e 's/^"//g' -e 's/"$$//g') 51