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 17CONFIG ?= ../../config.mk 18-include $(CONFIG) 19COMMON ?= ../../common.mk 20-include $(COMMON) 21 22PETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc 23CEED_DIR ?= ../.. 24ceed.pc := $(CEED_DIR)/lib/pkgconfig/ceed.pc 25 26# ASAN must be left empty if you don't want to use it 27ASAN ?= 28 29CC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc)) 30CFLAGS = -std=c99 \ 31 $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) \ 32 $(call pkgconf, --cflags-only-other $(PETSc.pc)) \ 33 $(OPT) $(OPT_EXAMPLES) 34CPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc)) \ 35 $(call pkgconf, --variable=cflags_dep $(PETSc.pc)) 36LDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc)) 37LDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc))) 38LDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm 39 40AFLAGS ?= -fsanitize=address #-fsanitize=undefined -fno-omit-frame-pointer 41CFLAGS += $(if $(ASAN),$(AFLAGS)) 42FFLAGS += $(if $(ASAN),$(AFLAGS)) 43LDFLAGS += $(if $(ASAN),$(AFLAGS)) 44CPPFLAGS += -I./include 45 46OBJDIR := build 47SRCDIR := src 48PROBLEMDIR := problems 49 50src.c := navierstokes.c $(sort $(wildcard $(PROBLEMDIR)/*.c)) $(sort $(wildcard $(SRCDIR)/*.c)) 51src.o = $(src.c:%.c=$(OBJDIR)/%.o) 52 53# Path to install directory for SmartRedis. Example: /software/smartredis/install 54SMARTREDIS_DIR ?= 55ifdef SMARTREDIS_DIR 56 hiredis.pc := $(SMARTREDIS_DIR)/lib/pkgconfig/hiredis.pc 57 lsmartredis:= -lsmartredis 58 redis++.pc = $(wildcard $(SMARTREDIS_DIR)/lib/pkgconfig/redis++.pc $(SMARTREDIS_DIR)/lib64/pkgconfig/redis++.pc) 59 60 CPPFLAGS += $(call pkgconf, --cflags-only-I $(hiredis.pc) $(redis++.pc)) 61 LDFLAGS += $(call pkgconf, --libs-only-L --libs-only-other $(hiredis.pc) $(redis++.pc)) 62 LDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(hiredis.pc) $(redis++.pc))) 63 LDLIBS += $(call pkgconf, --libs-only-l $(hiredis.pc) $(redis++.pc)) $(lsmartredis) 64 src.c += $(sort $(wildcard $(SRCDIR)/smartsim/*.c)) 65endif 66 67all: navierstokes 68 69navierstokes: $(src.o) | $(PETSc.pc) $(ceed.pc) 70 $(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ 71 72.SECONDEXPANSION: # to expand $$(@D)/.DIR 73%/.DIR : 74 @mkdir -p $(@D) 75 @touch $@ 76 77# Quiet, color output 78quiet ?= $($(1)) 79 80$(OBJDIR)/%.o : %.c | $$(@D)/.DIR 81 $(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<) 82 83print: $(PETSc.pc) $(ceed.pc) 84 $(info CC : $(CC)) 85 $(info CFLAGS : $(CFLAGS)) 86 $(info CPPFLAGS: $(CPPFLAGS)) 87 $(info LDFLAGS : $(LDFLAGS)) 88 $(info LDLIBS : $(LDLIBS)) 89 $(info OPT : $(OPT)) 90 @true 91 92print-% : 93 $(info [ variable name]: $*) 94 $(info [ origin]: $(origin $*)) 95 $(info [ flavor]: $(flavor $*)) 96 $(info [ value]: $(value $*)) 97 $(info [expanded value]: $($*)) 98 $(info ) 99 @true 100 101clean: 102 $(RM) -r $(OBJDIR) navierstokes *.vtu *.bin* *.csv *.png 103 104$(PETSc.pc): 105 $(if $(wildcard $@),,$(error \ 106 PETSc config not found. Please set PETSC_DIR and PETSC_ARCH)) 107 108.PHONY: all print clean 109 110pkgconf = $(shell pkg-config $(if $(STATIC),--static) $1 | sed -e 's/^"//g' -e 's/"$$//g') 111 112-include $(src.o:%.o=%.d) 113