1777ff853SJeremy L Thompson# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2777ff853SJeremy L Thompson# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3777ff853SJeremy L Thompson# reserved. See files LICENSE and NOTICE for details. 4777ff853SJeremy L Thompson# 5777ff853SJeremy L Thompson# This file is part of CEED, a collection of benchmarks, miniapps, software 6777ff853SJeremy L Thompson# libraries and APIs for efficient high-order finite element and spectral 7777ff853SJeremy L Thompson# element discretizations for exascale applications. For more information and 8777ff853SJeremy L Thompson# source code availability see http://github.com/ceed. 9777ff853SJeremy L Thompson# 10777ff853SJeremy L Thompson# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11777ff853SJeremy L Thompson# a collaborative effort of two U.S. Department of Energy organizations (Office 12777ff853SJeremy L Thompson# of Science and the National Nuclear Security Administration) responsible for 13777ff853SJeremy L Thompson# the planning and preparation of a capable exascale ecosystem, including 14777ff853SJeremy L Thompson# software, applications, hardware, advanced system engineering and early 15777ff853SJeremy L Thompson# testbed platforms, in support of the nation's exascale computing imperative. 16777ff853SJeremy L Thompson 17777ff853SJeremy L ThompsonCOMMON ?= ../../common.mk 18777ff853SJeremy L Thompson-include $(COMMON) 19777ff853SJeremy L Thompson 202f4d9adbSJeremy L Thompson# Note: PETSC_ARCH can be undefined or empty for installations which do not use 212f4d9adbSJeremy L Thompson# PETSC_ARCH - for example when using PETSc installed through Spack. 229f8a8fa0SJed BrownPETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc 236ea7c6c1SJed BrownCEED_DIR ?= ../.. 246ea7c6c1SJed Brownceed.pc := $(CEED_DIR)/lib/pkgconfig/ceed.pc 259f8a8fa0SJed Brown 26c0c38e35SVeselin DobrevCC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc)) 27e83e87a5SjeremyltCFLAGS = -std=c99 \ 28e83e87a5Sjeremylt $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) \ 29e83e87a5Sjeremylt $(call pkgconf, --cflags-only-other $(PETSc.pc)) \ 30e83e87a5Sjeremylt $(OPT) 31e83e87a5SjeremyltCPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc)) \ 32e83e87a5Sjeremylt $(call pkgconf, --variable=cflags_dep $(PETSc.pc)) 33c0c38e35SVeselin DobrevLDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc)) 34c0c38e35SVeselin DobrevLDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc))) 35c0c38e35SVeselin DobrevLDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm 369f8a8fa0SJed Brown 37e83e87a5SjeremyltOBJDIR := build 38e83e87a5SjeremyltSRCDIR := src 39cb32e2e7SValeria Barra 40e83e87a5Sjeremyltutils.c := $(sort $(wildcard $(SRCDIR)/*.c)) 41*636cccdbSjeremyltutils.o = $(utils.c:%.c=$(OBJDIR)/%.o) 429f8a8fa0SJed Brown 43e83e87a5Sjeremyltall: area bps bpsraw bpssphere multigrid 44dc7d240cSValeria Barra 45*636cccdbSjeremyltarea.c := area.c 46e83e87a5Sjeremyltarea.o = $(area.c:%.c=$(OBJDIR)/%.o) 47*636cccdbSjeremyltarea: $(area.o) $(utils.o) | $(PETSc.pc) $(ceed.pc) 48e83e87a5Sjeremylt $(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ 49ed264d09SValeria Barra 50*636cccdbSjeremyltbps.c := bps.c 51e83e87a5Sjeremyltbps.o = $(bps.c:%.c=$(OBJDIR)/%.o) 52*636cccdbSjeremyltbps: $(bps.o) $(utils.o) | $(PETSc.pc) $(ceed.pc) 53e83e87a5Sjeremylt $(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ 546c5df90dSjeremylt 55*636cccdbSjeremyltbpsraw.c := bpsraw.c 56e83e87a5Sjeremyltbpsraw.o = $(bpsraw.c:%.c=$(OBJDIR)/%.o) 57*636cccdbSjeremyltbpsraw: $(bpsraw.o) $(utils.o) | $(PETSc.pc) $(ceed.pc) 58e83e87a5Sjeremylt $(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ 59e83e87a5Sjeremylt 60*636cccdbSjeremyltbpssphere.c := bpssphere.c 61e83e87a5Sjeremyltbpssphere.o = $(bpssphere.c:%.c=$(OBJDIR)/%.o) 62*636cccdbSjeremyltbpssphere: $(bpssphere.o) $(utils.o) | $(PETSc.pc) $(ceed.pc) 63e83e87a5Sjeremylt $(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ 64e83e87a5Sjeremylt 65*636cccdbSjeremyltmultigrid.c := multigrid.c 66e83e87a5Sjeremyltmultigrid.o = $(multigrid.c:%.c=$(OBJDIR)/%.o) 67*636cccdbSjeremyltmultigrid: $(multigrid.o) $(utils.o) | $(PETSc.pc) $(ceed.pc) 68e83e87a5Sjeremylt $(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ 69e83e87a5Sjeremylt 70e83e87a5Sjeremylt.SECONDEXPANSION: # to expand $$(@D)/.DIR 71e83e87a5Sjeremylt%/.DIR : 72e83e87a5Sjeremylt @mkdir -p $(@D) 73e83e87a5Sjeremylt @touch $@ 749f8a8fa0SJed Brown 75777ff853SJeremy L Thompson# Quiet, color output 76777ff853SJeremy L Thompsonquiet ?= $($(1)) 77777ff853SJeremy L Thompson 78e83e87a5Sjeremylt$(OBJDIR)/%.o : %.c | $$(@D)/.DIR 79e83e87a5Sjeremylt $(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<) 80e83e87a5Sjeremylt 8133795f53Sjeremylt# Rules for building the examples 82e83e87a5Sjeremylt#%: %.c 8333795f53Sjeremylt 84c0c38e35SVeselin Dobrevprint: $(PETSc.pc) $(ceed.pc) 859f8a8fa0SJed Brown $(info CC : $(CC)) 869f8a8fa0SJed Brown $(info CFLAGS : $(CFLAGS)) 879f8a8fa0SJed Brown $(info CPPFLAGS: $(CPPFLAGS)) 889f8a8fa0SJed Brown $(info LDFLAGS : $(LDFLAGS)) 899f8a8fa0SJed Brown $(info LDLIBS : $(LDLIBS)) 90c0c38e35SVeselin Dobrev @true 919f8a8fa0SJed Brown 929f8a8fa0SJed Brownclean: 93e83e87a5Sjeremylt $(RM) -r $(OBJDIR) *.vtu area bps bpsraw bpssphere multigrid 949f8a8fa0SJed Brown 95c0c38e35SVeselin Dobrev$(PETSc.pc): 9608779805SVeselin Dobrev $(if $(wildcard $@),,$(error \ 976f87d196Sjeremylt PETSc config not found at $@. Please set PETSC_DIR and PETSC_ARCH)) 98c0c38e35SVeselin Dobrev 999f8a8fa0SJed Brown.PHONY: all print clean 100c0c38e35SVeselin Dobrev 101c0c38e35SVeselin Dobrevpkgconf = $(shell pkg-config $1 | sed -e 's/^"//g' -e 's/"$$//g') 102e83e87a5Sjeremylt 103e83e87a5Sjeremylt-include $(src.o:%.o=%.d) 104