1ccaff030SJeremy L Thompson# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2ccaff030SJeremy L Thompson# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3ccaff030SJeremy L Thompson# reserved. See files LICENSE and NOTICE for details. 4ccaff030SJeremy L Thompson# 5ccaff030SJeremy L Thompson# This file is part of CEED, a collection of benchmarks, miniapps, software 6ccaff030SJeremy L Thompson# libraries and APIs for efficient high-order finite element and spectral 7ccaff030SJeremy L Thompson# element discretizations for exascale applications. For more information and 8*3d8e8822SJeremy L Thompson# source code availability see http://github.com/ceed 9ccaff030SJeremy L Thompson# 10ccaff030SJeremy L Thompson# The CEED research is supported by the Exascale Computing Project (17-SC-20-SC) 11ccaff030SJeremy L Thompson# a collaborative effort of two U.S. Department of Energy organizations (Office 12ccaff030SJeremy L Thompson# of Science and the National Nuclear Security Administration) responsible for 13ccaff030SJeremy L Thompson# the planning and preparation of a capable exascale ecosystem, including 14ccaff030SJeremy L Thompson# software, applications, hardware, advanced system engineering and early 15ccaff030SJeremy L Thompson# testbed platforms, in support of the nation's exascale computing imperative. 16ccaff030SJeremy L Thompson 17777ff853SJeremy L ThompsonCOMMON ?= ../../common.mk 18777ff853SJeremy L Thompson-include $(COMMON) 19777ff853SJeremy L Thompson 20ccaff030SJeremy L ThompsonPETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc 21ccaff030SJeremy L ThompsonCEED_DIR ?= ../.. 22ccaff030SJeremy L Thompsonceed.pc := $(CEED_DIR)/lib/pkgconfig/ceed.pc 23ccaff030SJeremy L Thompson 24ccaff030SJeremy L ThompsonCC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc)) 2577841947SLeila GhaffariCFLAGS = -std=c99 \ 2677841947SLeila Ghaffari $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) \ 2777841947SLeila Ghaffari $(call pkgconf, --cflags-only-other $(PETSc.pc)) \ 2877841947SLeila Ghaffari $(OPT) 2977841947SLeila GhaffariCPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc)) \ 3077841947SLeila Ghaffari $(call pkgconf, --variable=cflags_dep $(PETSc.pc)) 31ccaff030SJeremy L ThompsonLDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc)) 32ccaff030SJeremy L ThompsonLDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc))) 33ccaff030SJeremy L ThompsonLDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm 34ccaff030SJeremy L Thompson 3577841947SLeila GhaffariOBJDIR := build 3677841947SLeila GhaffariSRCDIR := src 3777841947SLeila GhaffariPROBLEMDIR := problems 38ccaff030SJeremy L Thompson 3977841947SLeila Ghaffarisrc.c := navierstokes.c $(sort $(wildcard $(PROBLEMDIR)/*.c)) $(sort $(wildcard $(SRCDIR)/*.c)) 4077841947SLeila Ghaffarisrc.o = $(src.c:%.c=$(OBJDIR)/%.o) 4177841947SLeila Ghaffari 4277841947SLeila Ghaffariall: navierstokes 4377841947SLeila Ghaffari 4477841947SLeila Ghaffarinavierstokes: $(src.o) | $(PETSc.pc) $(ceed.pc) 4577841947SLeila Ghaffari $(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ 4677841947SLeila Ghaffari 4777841947SLeila Ghaffari.SECONDEXPANSION: # to expand $$(@D)/.DIR 4877841947SLeila Ghaffari%/.DIR : 4977841947SLeila Ghaffari @mkdir -p $(@D) 5077841947SLeila Ghaffari @touch $@ 51ccaff030SJeremy L Thompson 52777ff853SJeremy L Thompson# Quiet, color output 53777ff853SJeremy L Thompsonquiet ?= $($(1)) 54777ff853SJeremy L Thompson 5577841947SLeila Ghaffari$(OBJDIR)/%.o : %.c | $$(@D)/.DIR 5677841947SLeila Ghaffari $(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<) 5777841947SLeila Ghaffari 5877841947SLeila Ghaffari# Rules for building the examples 5977841947SLeila Ghaffari#%: %.c 60ccaff030SJeremy L Thompson 61ccaff030SJeremy L Thompsonprint: $(PETSc.pc) $(ceed.pc) 62ccaff030SJeremy L Thompson $(info CC : $(CC)) 63ccaff030SJeremy L Thompson $(info CFLAGS : $(CFLAGS)) 64ccaff030SJeremy L Thompson $(info CPPFLAGS: $(CPPFLAGS)) 65ccaff030SJeremy L Thompson $(info LDFLAGS : $(LDFLAGS)) 66ccaff030SJeremy L Thompson $(info LDLIBS : $(LDLIBS)) 67ccaff030SJeremy L Thompson $(info OPT : $(OPT)) 68ccaff030SJeremy L Thompson @true 69ccaff030SJeremy L Thompson 70ccaff030SJeremy L Thompsonclean: 7177841947SLeila Ghaffari $(RM) -r $(OBJDIR) navierstokes *.vtu *.bin* *.csv *.png 72ccaff030SJeremy L Thompson 73ccaff030SJeremy L Thompson$(PETSc.pc): 74ccaff030SJeremy L Thompson $(if $(wildcard $@),,$(error \ 75ccaff030SJeremy L Thompson PETSc config not found. Please set PETSC_DIR and PETSC_ARCH)) 76ccaff030SJeremy L Thompson 77ccaff030SJeremy L Thompson.PHONY: all print clean 78ccaff030SJeremy L Thompson 79ccaff030SJeremy L Thompsonpkgconf = $(shell pkg-config $1 | sed -e 's/^"//g' -e 's/"$$//g') 8077841947SLeila Ghaffari 8177841947SLeila Ghaffari-include $(src.o:%.o=%.d) 82