1PETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc 2CEED_DIR ?= ../.. 3ceed.pc := $(CEED_DIR)/lib/pkgconfig/ceed.pc 4 5CC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc)) 6CFLAGS = -std=c99 $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) $(call pkgconf, --cflags-only-other $(PETSc.pc)) $(OPT) 7CPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc)) 8LDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc)) 9LDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc))) 10LDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm 11 12bp.c := $(sort $(wildcard bp*.c)) 13bp := $(bp.c:%.c=%) 14 15all: $(bp) 16$(bp): | $(PETSc.pc) $(ceed.pc) 17 18# Rules for building the examples 19%: %.c 20 $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(abspath $<) -o $@ \ 21 $(LDLIBS) 22 23print: $(PETSc.pc) $(ceed.pc) 24 $(info CC : $(CC)) 25 $(info CFLAGS : $(CFLAGS)) 26 $(info CPPFLAGS: $(CPPFLAGS)) 27 $(info LDFLAGS : $(LDFLAGS)) 28 $(info LDLIBS : $(LDLIBS)) 29 @true 30 31clean: 32 $(RM) $(bp) 33 34$(PETSc.pc): 35 $(if $(wildcard $@),,$(error \ 36 PETSc config not found. Please set PETSC_DIR and PETSC_ARCH)) 37 38.PHONY: all print clean 39 40pkgconf = $(shell pkg-config $1 | sed -e 's/^"//g' -e 's/"$$//g') 41