1# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3# 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 17COMMON ?= ../../common.mk 18-include $(COMMON) 19 20# Note: PETSC_ARCH can be undefined or empty for installations which do not use 21# PETSC_ARCH - for example when using PETSc installed through Spack. 22PETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc 23CEED_DIR ?= ../.. 24ceed.pc := $(CEED_DIR)/lib/pkgconfig/ceed.pc 25 26CC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc)) 27CFLAGS = -std=c99 $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) $(call pkgconf, --cflags-only-other $(PETSc.pc)) $(OPT) 28CPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc)) 29LDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc)) 30LDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc))) 31LDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm 32 33area.c := area.c 34area := $(area.c:%.c=%) 35 36bps.c := bps.c 37bps := $(bps.c:%.c=%) 38 39bpsraw.c := bpsraw.c 40bpsraw := $(bpsraw.c:%.c=%) 41 42bpssphere.c := bpssphere.c 43bpssphere := $(bpssphere.c:%.c=%) 44 45multigrid.c := multigrid.c 46multigrid := $(multigrid.c:%.c=%) 47 48all: $(area) $(bps) $(bpsraw) $(bpssphere) $(multigrid) 49$(area): | $(PETSc.pc) $(ceed.pc) 50$(bps): | $(PETSc.pc) $(ceed.pc) 51$(bpsraw): | $(PETSc.pc) $(ceed.pc) 52$(bpssphere): | $(PETSc.pc) $(ceed.pc) 53$(multigrid): | $(PETSc.pc) $(ceed.pc) 54 55# Quiet, color output 56quiet ?= $($(1)) 57 58# Rules for building the examples 59%: %.c 60 $(call quiet,CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(CEED_LDFLAGS) $(abspath $<) -o $@ \ 61 $(LDLIBS) 62 63print: $(PETSc.pc) $(ceed.pc) 64 $(info CC : $(CC)) 65 $(info CFLAGS : $(CFLAGS)) 66 $(info CPPFLAGS: $(CPPFLAGS)) 67 $(info LDFLAGS : $(LDFLAGS)) 68 $(info LDLIBS : $(LDLIBS)) 69 @true 70 71clean: 72 $(RM) $(area) $(bps) $(bpsraw) $(bpssphere) $(multigrid) 73 74$(PETSc.pc): 75 $(if $(wildcard $@),,$(error \ 76 PETSc config not found at $@. Please set PETSC_DIR and PETSC_ARCH)) 77 78.PHONY: all print clean 79 80pkgconf = $(shell pkg-config $1 | sed -e 's/^"//g' -e 's/"$$//g') 81