xref: /libCEED/examples/fluids/Makefile (revision ed9ed3dea34fef5853dd3f23fdf30a7807a29b2c)
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
83d8e8822SJeremy 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
17e51ac267SJames WrightCONFIG ?= ../../config.mk
18e51ac267SJames Wright-include $(CONFIG)
19777ff853SJeremy L ThompsonCOMMON ?= ../../common.mk
20777ff853SJeremy L Thompson-include $(COMMON)
21777ff853SJeremy L Thompson
22ccaff030SJeremy L ThompsonPETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc
23ccaff030SJeremy L ThompsonCEED_DIR ?= ../..
24ccaff030SJeremy L Thompsonceed.pc := $(CEED_DIR)/lib/pkgconfig/ceed.pc
25ccaff030SJeremy L Thompson
261b561cd6SJames Wright# ASAN must be left empty if you don't want to use it
271b561cd6SJames WrightASAN ?=
281b561cd6SJames Wright
29ccaff030SJeremy L ThompsonCC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc))
3077841947SLeila GhaffariCFLAGS = -std=c99 \
3177841947SLeila Ghaffari  $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) \
3277841947SLeila Ghaffari  $(call pkgconf, --cflags-only-other $(PETSc.pc)) \
33e334ad8fSJed Brown  $(OPT) $(OPT_EXAMPLES)
3477841947SLeila GhaffariCPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc)) \
3577841947SLeila Ghaffari  $(call pkgconf, --variable=cflags_dep $(PETSc.pc))
36ccaff030SJeremy L ThompsonLDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc))
37ccaff030SJeremy L ThompsonLDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc)))
38ccaff030SJeremy L ThompsonLDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm
39ccaff030SJeremy L Thompson
401b561cd6SJames WrightAFLAGS ?= -fsanitize=address #-fsanitize=undefined -fno-omit-frame-pointer
411b561cd6SJames WrightCFLAGS += $(if $(ASAN),$(AFLAGS))
421b561cd6SJames WrightFFLAGS += $(if $(ASAN),$(AFLAGS))
431b561cd6SJames WrightLDFLAGS += $(if $(ASAN),$(AFLAGS))
44*ed9ed3deSJames WrightCPPFLAGS += -I./include
451b561cd6SJames Wright
4677841947SLeila GhaffariOBJDIR := build
4777841947SLeila GhaffariSRCDIR := src
4877841947SLeila GhaffariPROBLEMDIR := problems
49ccaff030SJeremy L Thompson
5077841947SLeila Ghaffarisrc.c := navierstokes.c $(sort $(wildcard $(PROBLEMDIR)/*.c)) $(sort $(wildcard $(SRCDIR)/*.c))
5177841947SLeila Ghaffarisrc.o = $(src.c:%.c=$(OBJDIR)/%.o)
5277841947SLeila Ghaffari
53fc818f1bSJames Wright# Path to install directory for SmartRedis. Example: /software/smartredis/install
54fc818f1bSJames WrightSMARTREDIS_DIR ?=
55fc818f1bSJames Wrightifdef SMARTREDIS_DIR
56fc818f1bSJames Wright	hiredis.pc := $(SMARTREDIS_DIR)/lib/pkgconfig/hiredis.pc
57fc818f1bSJames Wright	lsmartredis:= -lsmartredis
58fc818f1bSJames Wright	redis++.pc = $(wildcard $(SMARTREDIS_DIR)/lib/pkgconfig/redis++.pc $(SMARTREDIS_DIR)/lib64/pkgconfig/redis++.pc)
59fc818f1bSJames Wright
60fc818f1bSJames Wright	CPPFLAGS += $(call pkgconf, --cflags-only-I $(hiredis.pc) $(redis++.pc))
61fc818f1bSJames Wright	LDFLAGS += $(call pkgconf, --libs-only-L --libs-only-other $(hiredis.pc) $(redis++.pc))
62fc818f1bSJames Wright	LDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(hiredis.pc) $(redis++.pc)))
63fc818f1bSJames Wright	LDLIBS += $(call pkgconf, --libs-only-l $(hiredis.pc) $(redis++.pc)) $(lsmartredis)
64fc818f1bSJames Wright	src.c += $(sort $(wildcard $(SRCDIR)/smartsim/*.c))
65fc818f1bSJames Wrightendif
66fc818f1bSJames Wright
6777841947SLeila Ghaffariall: navierstokes
6877841947SLeila Ghaffari
6977841947SLeila Ghaffarinavierstokes: $(src.o) | $(PETSc.pc) $(ceed.pc)
7077841947SLeila Ghaffari	$(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
7177841947SLeila Ghaffari
7277841947SLeila Ghaffari.SECONDEXPANSION: # to expand $$(@D)/.DIR
7377841947SLeila Ghaffari%/.DIR :
7477841947SLeila Ghaffari	@mkdir -p $(@D)
7577841947SLeila Ghaffari	@touch $@
76ccaff030SJeremy L Thompson
77777ff853SJeremy L Thompson# Quiet, color output
78777ff853SJeremy L Thompsonquiet ?= $($(1))
79777ff853SJeremy L Thompson
8077841947SLeila Ghaffari$(OBJDIR)/%.o : %.c | $$(@D)/.DIR
8177841947SLeila Ghaffari	$(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<)
8277841947SLeila Ghaffari
83ccaff030SJeremy L Thompsonprint: $(PETSc.pc) $(ceed.pc)
84ccaff030SJeremy L Thompson	$(info CC      : $(CC))
85ccaff030SJeremy L Thompson	$(info CFLAGS  : $(CFLAGS))
86ccaff030SJeremy L Thompson	$(info CPPFLAGS: $(CPPFLAGS))
87ccaff030SJeremy L Thompson	$(info LDFLAGS : $(LDFLAGS))
88ccaff030SJeremy L Thompson	$(info LDLIBS  : $(LDLIBS))
89ccaff030SJeremy L Thompson	$(info OPT     : $(OPT))
90ccaff030SJeremy L Thompson	@true
91ccaff030SJeremy L Thompson
92a25bd800SJames Wrightprint-% :
93a25bd800SJames Wright	$(info [ variable name]: $*)
94a25bd800SJames Wright	$(info [        origin]: $(origin $*))
95a25bd800SJames Wright	$(info [        flavor]: $(flavor $*))
96a25bd800SJames Wright	$(info [         value]: $(value $*))
97a25bd800SJames Wright	$(info [expanded value]: $($*))
98a25bd800SJames Wright	$(info )
99a25bd800SJames Wright	@true
100a25bd800SJames Wright
101ccaff030SJeremy L Thompsonclean:
10277841947SLeila Ghaffari	$(RM) -r $(OBJDIR) navierstokes *.vtu *.bin* *.csv *.png
103ccaff030SJeremy L Thompson
104ccaff030SJeremy L Thompson$(PETSc.pc):
105ccaff030SJeremy L Thompson	$(if $(wildcard $@),,$(error \
106ccaff030SJeremy L Thompson	  PETSc config not found. Please set PETSC_DIR and PETSC_ARCH))
107ccaff030SJeremy L Thompson
108ccaff030SJeremy L Thompson.PHONY: all print clean
109ccaff030SJeremy L Thompson
110a25bd800SJames Wrightpkgconf = $(shell pkg-config $(if $(STATIC),--static) $1 | sed -e 's/^"//g' -e 's/"$$//g')
11177841947SLeila Ghaffari
11277841947SLeila Ghaffari-include $(src.o:%.o=%.d)
113