xref: /honee/Makefile (revision 7df379d9580a71200853c69fc7006b92a8fe7ca8)
1ea10196cSJeremy L Thompson# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2ea10196cSJeremy L Thompson# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3ea10196cSJeremy L Thompson# reserved. See files LICENSE and NOTICE for details.
4ea10196cSJeremy L Thompson#
5ea10196cSJeremy L Thompson# This file is part of CEED, a collection of benchmarks, miniapps, software
6ea10196cSJeremy L Thompson# libraries and APIs for efficient high-order finite element and spectral
7ea10196cSJeremy L Thompson# element discretizations for exascale applications. For more information and
8727da7e7SJeremy L Thompson# source code availability see http://github.com/ceed
9ea10196cSJeremy L Thompson#
10ea10196cSJeremy L Thompson# The CEED research is supported by the Exascale Computing Project (17-SC-20-SC)
11ea10196cSJeremy L Thompson# a collaborative effort of two U.S. Department of Energy organizations (Office
12ea10196cSJeremy L Thompson# of Science and the National Nuclear Security Administration) responsible for
13ea10196cSJeremy L Thompson# the planning and preparation of a capable exascale ecosystem, including
14ea10196cSJeremy L Thompson# software, applications, hardware, advanced system engineering and early
15ea10196cSJeremy L Thompson# testbed platforms, in support of the nation's exascale computing imperative.
16ea10196cSJeremy L Thompson
174f863122SJeremy L ThompsonCOMMON ?= ../../common.mk
184f863122SJeremy L Thompson-include $(COMMON)
194f863122SJeremy L Thompson
20ea10196cSJeremy L ThompsonPETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc
21ea10196cSJeremy L ThompsonCEED_DIR ?= ../..
22ea10196cSJeremy L Thompsonceed.pc := $(CEED_DIR)/lib/pkgconfig/ceed.pc
23ea10196cSJeremy L Thompson
24*7df379d9SJames Wright# ASAN must be left empty if you don't want to use it
25*7df379d9SJames WrightASAN ?=
26*7df379d9SJames Wright
27ea10196cSJeremy L ThompsonCC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc))
28a515125bSLeila GhaffariCFLAGS = -std=c99 \
29a515125bSLeila Ghaffari  $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) \
30a515125bSLeila Ghaffari  $(call pkgconf, --cflags-only-other $(PETSc.pc)) \
31f0b65372SJed Brown  $(OPT) $(OPT_EXAMPLES)
32a515125bSLeila GhaffariCPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc)) \
33a515125bSLeila Ghaffari  $(call pkgconf, --variable=cflags_dep $(PETSc.pc))
34ea10196cSJeremy L ThompsonLDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc))
35ea10196cSJeremy L ThompsonLDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc)))
36ea10196cSJeremy L ThompsonLDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm
37ea10196cSJeremy L Thompson
38*7df379d9SJames WrightAFLAGS ?= -fsanitize=address #-fsanitize=undefined -fno-omit-frame-pointer
39*7df379d9SJames WrightCFLAGS += $(if $(ASAN),$(AFLAGS))
40*7df379d9SJames WrightFFLAGS += $(if $(ASAN),$(AFLAGS))
41*7df379d9SJames WrightLDFLAGS += $(if $(ASAN),$(AFLAGS))
42*7df379d9SJames Wright
43a515125bSLeila GhaffariOBJDIR := build
44a515125bSLeila GhaffariSRCDIR := src
45a515125bSLeila GhaffariPROBLEMDIR := problems
46ea10196cSJeremy L Thompson
47a515125bSLeila Ghaffarisrc.c := navierstokes.c $(sort $(wildcard $(PROBLEMDIR)/*.c)) $(sort $(wildcard $(SRCDIR)/*.c))
48a515125bSLeila Ghaffarisrc.o = $(src.c:%.c=$(OBJDIR)/%.o)
49a515125bSLeila Ghaffari
50a515125bSLeila Ghaffariall: navierstokes
51a515125bSLeila Ghaffari
52a515125bSLeila Ghaffarinavierstokes: $(src.o) | $(PETSc.pc) $(ceed.pc)
53a515125bSLeila Ghaffari	$(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
54a515125bSLeila Ghaffari
55a515125bSLeila Ghaffari.SECONDEXPANSION: # to expand $$(@D)/.DIR
56a515125bSLeila Ghaffari%/.DIR :
57a515125bSLeila Ghaffari	@mkdir -p $(@D)
58a515125bSLeila Ghaffari	@touch $@
59ea10196cSJeremy L Thompson
604f863122SJeremy L Thompson# Quiet, color output
614f863122SJeremy L Thompsonquiet ?= $($(1))
624f863122SJeremy L Thompson
63a515125bSLeila Ghaffari$(OBJDIR)/%.o : %.c | $$(@D)/.DIR
64a515125bSLeila Ghaffari	$(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<)
65a515125bSLeila Ghaffari
66a515125bSLeila Ghaffari# Rules for building the examples
67a515125bSLeila Ghaffari#%: %.c
68ea10196cSJeremy L Thompson
69ea10196cSJeremy L Thompsonprint: $(PETSc.pc) $(ceed.pc)
70ea10196cSJeremy L Thompson	$(info CC      : $(CC))
71ea10196cSJeremy L Thompson	$(info CFLAGS  : $(CFLAGS))
72ea10196cSJeremy L Thompson	$(info CPPFLAGS: $(CPPFLAGS))
73ea10196cSJeremy L Thompson	$(info LDFLAGS : $(LDFLAGS))
74ea10196cSJeremy L Thompson	$(info LDLIBS  : $(LDLIBS))
75ea10196cSJeremy L Thompson	$(info OPT     : $(OPT))
76ea10196cSJeremy L Thompson	@true
77ea10196cSJeremy L Thompson
780e8fe9d5SJames Wrightprint-% :
790e8fe9d5SJames Wright	$(info [ variable name]: $*)
800e8fe9d5SJames Wright	$(info [        origin]: $(origin $*))
810e8fe9d5SJames Wright	$(info [        flavor]: $(flavor $*))
820e8fe9d5SJames Wright	$(info [         value]: $(value $*))
830e8fe9d5SJames Wright	$(info [expanded value]: $($*))
840e8fe9d5SJames Wright	$(info )
850e8fe9d5SJames Wright	@true
860e8fe9d5SJames Wright
87ea10196cSJeremy L Thompsonclean:
88a515125bSLeila Ghaffari	$(RM) -r $(OBJDIR) navierstokes *.vtu *.bin* *.csv *.png
89ea10196cSJeremy L Thompson
90ea10196cSJeremy L Thompson$(PETSc.pc):
91ea10196cSJeremy L Thompson	$(if $(wildcard $@),,$(error \
92ea10196cSJeremy L Thompson	  PETSc config not found. Please set PETSC_DIR and PETSC_ARCH))
93ea10196cSJeremy L Thompson
94ea10196cSJeremy L Thompson.PHONY: all print clean
95ea10196cSJeremy L Thompson
960e8fe9d5SJames Wrightpkgconf = $(shell pkg-config $(if $(STATIC),--static) $1 | sed -e 's/^"//g' -e 's/"$$//g')
97a515125bSLeila Ghaffari
98a515125bSLeila Ghaffari-include $(src.o:%.o=%.d)
99