xref: /libCEED/examples/fluids/Makefile (revision 506c99b823b792d61b71c4ce79f89b431690045e) !
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
26ccaff030SJeremy L ThompsonCC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc))
27*d4f9124cSJed BrownCFLAGS = -std=c11 \
2877841947SLeila Ghaffari  $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) \
2977841947SLeila Ghaffari  $(call pkgconf, --cflags-only-other $(PETSc.pc)) \
30e334ad8fSJed Brown  $(OPT) $(OPT_EXAMPLES)
3177841947SLeila GhaffariCPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc)) \
3277841947SLeila Ghaffari  $(call pkgconf, --variable=cflags_dep $(PETSc.pc))
33ccaff030SJeremy L ThompsonLDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc))
34ccaff030SJeremy L ThompsonLDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc)))
353e0c2f3fSJeremy L ThompsonLDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm
36ccaff030SJeremy L Thompson
37013a5551SJames Wright# Address Sanitizer Setup
38013a5551SJames Wright# ASAN must be left empty if you don't want to use it
39013a5551SJames WrightASAN ?=
40013a5551SJames WrightAFLAGS ?= -fsanitize=address
41013a5551SJames Wright# Also: -fsanitize=undefined -fno-omit-frame-pointer
421b561cd6SJames WrightCFLAGS += $(if $(ASAN),$(AFLAGS))
431b561cd6SJames WrightFFLAGS += $(if $(ASAN),$(AFLAGS))
441b561cd6SJames WrightLDFLAGS += $(if $(ASAN),$(AFLAGS))
45ed9ed3deSJames WrightCPPFLAGS += -I./include
461b561cd6SJames Wright
47013a5551SJames Wright# Source Files
4877841947SLeila GhaffariOBJDIR := build
4977841947SLeila GhaffariSRCDIR := src
5077841947SLeila GhaffariPROBLEMDIR := problems
51ccaff030SJeremy L Thompson
5277841947SLeila Ghaffarisrc.c := navierstokes.c $(sort $(wildcard $(PROBLEMDIR)/*.c)) $(sort $(wildcard $(SRCDIR)/*.c))
533e0c2f3fSJeremy L Thompsonsrc.o = $(src.c:%.c=$(OBJDIR)/%.o)
54fc818f1bSJames Wright
5577841947SLeila Ghaffariall: navierstokes
5677841947SLeila Ghaffari
5777841947SLeila Ghaffarinavierstokes: $(src.o) | $(PETSc.pc) $(ceed.pc)
58013a5551SJames Wright	$(call quiet,LINK.o) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
5977841947SLeila Ghaffari
6077841947SLeila Ghaffari.SECONDEXPANSION: # to expand $$(@D)/.DIR
6177841947SLeila Ghaffari%/.DIR :
6277841947SLeila Ghaffari	@mkdir -p $(@D)
6377841947SLeila Ghaffari	@touch $@
64ccaff030SJeremy L Thompson
65777ff853SJeremy L Thompson# Quiet, color output
66777ff853SJeremy L Thompsonquiet ?= $($(1))
67777ff853SJeremy L Thompson
68c0bf4d34SJames Wright$(OBJDIR)/%.o : %.c  Makefile | $$(@D)/.DIR
6977841947SLeila Ghaffari	$(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<)
7077841947SLeila Ghaffari
71ccaff030SJeremy L Thompsonprint: $(PETSc.pc) $(ceed.pc)
72ccaff030SJeremy L Thompson	$(info CC      : $(CC))
73ccaff030SJeremy L Thompson	$(info CFLAGS  : $(CFLAGS))
74ccaff030SJeremy L Thompson	$(info CPPFLAGS: $(CPPFLAGS))
75ccaff030SJeremy L Thompson	$(info LDFLAGS : $(LDFLAGS))
76ccaff030SJeremy L Thompson	$(info LDLIBS  : $(LDLIBS))
77ccaff030SJeremy L Thompson	$(info OPT     : $(OPT))
78ccaff030SJeremy L Thompson	@true
79ccaff030SJeremy L Thompson
80a25bd800SJames Wrightprint-% :
81a25bd800SJames Wright	$(info [ variable name]: $*)
82a25bd800SJames Wright	$(info [        origin]: $(origin $*))
83a25bd800SJames Wright	$(info [        flavor]: $(flavor $*))
84a25bd800SJames Wright	$(info [         value]: $(value $*))
85a25bd800SJames Wright	$(info [expanded value]: $($*))
86a25bd800SJames Wright	$(info )
87a25bd800SJames Wright	@true
88a25bd800SJames Wright
89ccaff030SJeremy L Thompsonclean:
9077841947SLeila Ghaffari	$(RM) -r $(OBJDIR) navierstokes *.vtu *.bin* *.csv *.png
91ccaff030SJeremy L Thompson
92ccaff030SJeremy L Thompson$(PETSc.pc):
93ccaff030SJeremy L Thompson	$(if $(wildcard $@),,$(error \
94ccaff030SJeremy L Thompson	  PETSc config not found. Please set PETSC_DIR and PETSC_ARCH))
95ccaff030SJeremy L Thompson
96ccaff030SJeremy L Thompson.PHONY: all print clean
97ccaff030SJeremy L Thompson
98a25bd800SJames Wrightpkgconf = $(shell pkg-config $(if $(STATIC),--static) $1 | sed -e 's/^"//g' -e 's/"$$//g')
9977841947SLeila Ghaffari
10077841947SLeila Ghaffari-include $(src.o:%.o=%.d)
101