xref: /honee/Makefile (revision 9e6f9b5e7852e489d3084055b7a37406a2a744fa)
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
247df379d9SJames Wright# ASAN must be left empty if you don't want to use it
257df379d9SJames WrightASAN ?=
267df379d9SJames 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
387df379d9SJames WrightAFLAGS ?= -fsanitize=address #-fsanitize=undefined -fno-omit-frame-pointer
397df379d9SJames WrightCFLAGS += $(if $(ASAN),$(AFLAGS))
407df379d9SJames WrightFFLAGS += $(if $(ASAN),$(AFLAGS))
417df379d9SJames WrightLDFLAGS += $(if $(ASAN),$(AFLAGS))
427df379d9SJames 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
50*9e6f9b5eSJames Wright# Path to install directory for SmartRedis. Example: /software/smartredis/install
51*9e6f9b5eSJames WrightSMARTREDIS_DIR ?=
52*9e6f9b5eSJames Wrightifdef SMARTREDIS_DIR
53*9e6f9b5eSJames Wright	hiredis.pc := $(SMARTREDIS_DIR)/lib/pkgconfig/hiredis.pc
54*9e6f9b5eSJames Wright	lsmartredis:= -lsmartredis
55*9e6f9b5eSJames Wright	redis++.pc = $(wildcard $(SMARTREDIS_DIR)/lib/pkgconfig/redis++.pc $(SMARTREDIS_DIR)/lib64/pkgconfig/redis++.pc)
56*9e6f9b5eSJames Wright
57*9e6f9b5eSJames Wright	CPPFLAGS += $(call pkgconf, --cflags-only-I $(hiredis.pc) $(redis++.pc))
58*9e6f9b5eSJames Wright	LDFLAGS += $(call pkgconf, --libs-only-L --libs-only-other $(hiredis.pc) $(redis++.pc))
59*9e6f9b5eSJames Wright	LDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(hiredis.pc) $(redis++.pc)))
60*9e6f9b5eSJames Wright	LDLIBS += $(call pkgconf, --libs-only-l $(hiredis.pc) $(redis++.pc)) $(lsmartredis)
61*9e6f9b5eSJames Wright	src.c += $(sort $(wildcard $(SRCDIR)/smartsim/*.c))
62*9e6f9b5eSJames Wrightendif
63*9e6f9b5eSJames Wright
64a515125bSLeila Ghaffariall: navierstokes
65a515125bSLeila Ghaffari
66a515125bSLeila Ghaffarinavierstokes: $(src.o) | $(PETSc.pc) $(ceed.pc)
67a515125bSLeila Ghaffari	$(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
68a515125bSLeila Ghaffari
69a515125bSLeila Ghaffari.SECONDEXPANSION: # to expand $$(@D)/.DIR
70a515125bSLeila Ghaffari%/.DIR :
71a515125bSLeila Ghaffari	@mkdir -p $(@D)
72a515125bSLeila Ghaffari	@touch $@
73ea10196cSJeremy L Thompson
744f863122SJeremy L Thompson# Quiet, color output
754f863122SJeremy L Thompsonquiet ?= $($(1))
764f863122SJeremy L Thompson
77a515125bSLeila Ghaffari$(OBJDIR)/%.o : %.c | $$(@D)/.DIR
78a515125bSLeila Ghaffari	$(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<)
79a515125bSLeila Ghaffari
80ea10196cSJeremy L Thompsonprint: $(PETSc.pc) $(ceed.pc)
81ea10196cSJeremy L Thompson	$(info CC      : $(CC))
82ea10196cSJeremy L Thompson	$(info CFLAGS  : $(CFLAGS))
83ea10196cSJeremy L Thompson	$(info CPPFLAGS: $(CPPFLAGS))
84ea10196cSJeremy L Thompson	$(info LDFLAGS : $(LDFLAGS))
85ea10196cSJeremy L Thompson	$(info LDLIBS  : $(LDLIBS))
86ea10196cSJeremy L Thompson	$(info OPT     : $(OPT))
87ea10196cSJeremy L Thompson	@true
88ea10196cSJeremy L Thompson
890e8fe9d5SJames Wrightprint-% :
900e8fe9d5SJames Wright	$(info [ variable name]: $*)
910e8fe9d5SJames Wright	$(info [        origin]: $(origin $*))
920e8fe9d5SJames Wright	$(info [        flavor]: $(flavor $*))
930e8fe9d5SJames Wright	$(info [         value]: $(value $*))
940e8fe9d5SJames Wright	$(info [expanded value]: $($*))
950e8fe9d5SJames Wright	$(info )
960e8fe9d5SJames Wright	@true
970e8fe9d5SJames Wright
98ea10196cSJeremy L Thompsonclean:
99a515125bSLeila Ghaffari	$(RM) -r $(OBJDIR) navierstokes *.vtu *.bin* *.csv *.png
100ea10196cSJeremy L Thompson
101ea10196cSJeremy L Thompson$(PETSc.pc):
102ea10196cSJeremy L Thompson	$(if $(wildcard $@),,$(error \
103ea10196cSJeremy L Thompson	  PETSc config not found. Please set PETSC_DIR and PETSC_ARCH))
104ea10196cSJeremy L Thompson
105ea10196cSJeremy L Thompson.PHONY: all print clean
106ea10196cSJeremy L Thompson
1070e8fe9d5SJames Wrightpkgconf = $(shell pkg-config $(if $(STATIC),--static) $1 | sed -e 's/^"//g' -e 's/"$$//g')
108a515125bSLeila Ghaffari
109a515125bSLeila Ghaffari-include $(src.o:%.o=%.d)
110