xref: /libCEED/examples/petsc/Makefile (revision cb32e2e7f026784d97a57f1901677e9727def907)
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*cb32e2e7SValeria Barrabpsraw.c := bpsraw.c
15*cb32e2e7SValeria Barrabpsraw := $(bpsraw.c:%.c=%)
16*cb32e2e7SValeria Barra
170c59ef15SJeremy L Thompsonbps.c := bps.c
180c59ef15SJeremy L Thompsonbps := $(bps.c:%.c=%)
199f8a8fa0SJed Brown
206c5df90dSjeremyltmultigrid.c := multigrid.c
216c5df90dSjeremyltmultigrid := $(multigrid.c:%.c=%)
226c5df90dSjeremylt
23*cb32e2e7SValeria Barraarea.c := area.c
24*cb32e2e7SValeria Barraarea := $(area.c:%.c=%)
25*cb32e2e7SValeria Barra
26*cb32e2e7SValeria Barraall: $(bpsraw) $(bps) $(multigrid) $(area)
270c59ef15SJeremy L Thompson$(bps): | $(PETSc.pc) $(ceed.pc)
28819eb1b3Sjeremylt$(bpsdmplex): | $(PETSc.pc) $(ceed.pc)
296c5df90dSjeremylt$(multigrid): | $(PETSc.pc) $(ceed.pc)
30*cb32e2e7SValeria Barra$(areadmplex): | $(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*cb32e2e7SValeria Barra	$(RM) $(bpsraw) $(bps) $(multigrid) $(area)
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