xref: /honee/Makefile (revision 45101827a72e1dfba25c19c9e7c2f41a3f45f828)
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
17066464baSJames WrightCONFIG ?= ../../config.mk
18066464baSJames Wright-include $(CONFIG)
194f863122SJeremy L ThompsonCOMMON ?= ../../common.mk
204f863122SJeremy L Thompson-include $(COMMON)
214f863122SJeremy L Thompson
22ea10196cSJeremy L ThompsonPETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc
23ea10196cSJeremy L ThompsonCEED_DIR ?= ../..
24ea10196cSJeremy L Thompsonceed.pc := $(CEED_DIR)/lib/pkgconfig/ceed.pc
25ea10196cSJeremy L Thompson
267df379d9SJames Wright# ASAN must be left empty if you don't want to use it
277df379d9SJames WrightASAN ?=
287df379d9SJames Wright
29ea10196cSJeremy L ThompsonCC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc))
30a515125bSLeila GhaffariCFLAGS = -std=c99 \
31a515125bSLeila Ghaffari  $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) \
32a515125bSLeila Ghaffari  $(call pkgconf, --cflags-only-other $(PETSc.pc)) \
33f0b65372SJed Brown  $(OPT) $(OPT_EXAMPLES)
34a515125bSLeila GhaffariCPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc)) \
35a515125bSLeila Ghaffari  $(call pkgconf, --variable=cflags_dep $(PETSc.pc))
36ea10196cSJeremy L ThompsonLDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc))
37ea10196cSJeremy L ThompsonLDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc)))
38ea10196cSJeremy L ThompsonLDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm
39ea10196cSJeremy L Thompson
407df379d9SJames WrightAFLAGS ?= -fsanitize=address #-fsanitize=undefined -fno-omit-frame-pointer
417df379d9SJames WrightCFLAGS += $(if $(ASAN),$(AFLAGS))
427df379d9SJames WrightFFLAGS += $(if $(ASAN),$(AFLAGS))
437df379d9SJames WrightLDFLAGS += $(if $(ASAN),$(AFLAGS))
44*45101827SJames WrightCPPFLAGS += -I./include
457df379d9SJames Wright
46a515125bSLeila GhaffariOBJDIR := build
47a515125bSLeila GhaffariSRCDIR := src
48a515125bSLeila GhaffariPROBLEMDIR := problems
49ea10196cSJeremy L Thompson
50a515125bSLeila Ghaffarisrc.c := navierstokes.c $(sort $(wildcard $(PROBLEMDIR)/*.c)) $(sort $(wildcard $(SRCDIR)/*.c))
51a515125bSLeila Ghaffarisrc.o = $(src.c:%.c=$(OBJDIR)/%.o)
52a515125bSLeila Ghaffari
539e6f9b5eSJames Wright# Path to install directory for SmartRedis. Example: /software/smartredis/install
549e6f9b5eSJames WrightSMARTREDIS_DIR ?=
559e6f9b5eSJames Wrightifdef SMARTREDIS_DIR
569e6f9b5eSJames Wright	hiredis.pc := $(SMARTREDIS_DIR)/lib/pkgconfig/hiredis.pc
579e6f9b5eSJames Wright	lsmartredis:= -lsmartredis
589e6f9b5eSJames Wright	redis++.pc = $(wildcard $(SMARTREDIS_DIR)/lib/pkgconfig/redis++.pc $(SMARTREDIS_DIR)/lib64/pkgconfig/redis++.pc)
599e6f9b5eSJames Wright
609e6f9b5eSJames Wright	CPPFLAGS += $(call pkgconf, --cflags-only-I $(hiredis.pc) $(redis++.pc))
619e6f9b5eSJames Wright	LDFLAGS += $(call pkgconf, --libs-only-L --libs-only-other $(hiredis.pc) $(redis++.pc))
629e6f9b5eSJames Wright	LDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(hiredis.pc) $(redis++.pc)))
639e6f9b5eSJames Wright	LDLIBS += $(call pkgconf, --libs-only-l $(hiredis.pc) $(redis++.pc)) $(lsmartredis)
649e6f9b5eSJames Wright	src.c += $(sort $(wildcard $(SRCDIR)/smartsim/*.c))
659e6f9b5eSJames Wrightendif
669e6f9b5eSJames Wright
67a515125bSLeila Ghaffariall: navierstokes
68a515125bSLeila Ghaffari
69a515125bSLeila Ghaffarinavierstokes: $(src.o) | $(PETSc.pc) $(ceed.pc)
70a515125bSLeila Ghaffari	$(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
71a515125bSLeila Ghaffari
72a515125bSLeila Ghaffari.SECONDEXPANSION: # to expand $$(@D)/.DIR
73a515125bSLeila Ghaffari%/.DIR :
74a515125bSLeila Ghaffari	@mkdir -p $(@D)
75a515125bSLeila Ghaffari	@touch $@
76ea10196cSJeremy L Thompson
774f863122SJeremy L Thompson# Quiet, color output
784f863122SJeremy L Thompsonquiet ?= $($(1))
794f863122SJeremy L Thompson
80a515125bSLeila Ghaffari$(OBJDIR)/%.o : %.c | $$(@D)/.DIR
81a515125bSLeila Ghaffari	$(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<)
82a515125bSLeila Ghaffari
83ea10196cSJeremy L Thompsonprint: $(PETSc.pc) $(ceed.pc)
84ea10196cSJeremy L Thompson	$(info CC      : $(CC))
85ea10196cSJeremy L Thompson	$(info CFLAGS  : $(CFLAGS))
86ea10196cSJeremy L Thompson	$(info CPPFLAGS: $(CPPFLAGS))
87ea10196cSJeremy L Thompson	$(info LDFLAGS : $(LDFLAGS))
88ea10196cSJeremy L Thompson	$(info LDLIBS  : $(LDLIBS))
89ea10196cSJeremy L Thompson	$(info OPT     : $(OPT))
90ea10196cSJeremy L Thompson	@true
91ea10196cSJeremy L Thompson
920e8fe9d5SJames Wrightprint-% :
930e8fe9d5SJames Wright	$(info [ variable name]: $*)
940e8fe9d5SJames Wright	$(info [        origin]: $(origin $*))
950e8fe9d5SJames Wright	$(info [        flavor]: $(flavor $*))
960e8fe9d5SJames Wright	$(info [         value]: $(value $*))
970e8fe9d5SJames Wright	$(info [expanded value]: $($*))
980e8fe9d5SJames Wright	$(info )
990e8fe9d5SJames Wright	@true
1000e8fe9d5SJames Wright
101ea10196cSJeremy L Thompsonclean:
102a515125bSLeila Ghaffari	$(RM) -r $(OBJDIR) navierstokes *.vtu *.bin* *.csv *.png
103ea10196cSJeremy L Thompson
104ea10196cSJeremy L Thompson$(PETSc.pc):
105ea10196cSJeremy L Thompson	$(if $(wildcard $@),,$(error \
106ea10196cSJeremy L Thompson	  PETSc config not found. Please set PETSC_DIR and PETSC_ARCH))
107ea10196cSJeremy L Thompson
108ea10196cSJeremy L Thompson.PHONY: all print clean
109ea10196cSJeremy L Thompson
1100e8fe9d5SJames Wrightpkgconf = $(shell pkg-config $(if $(STATIC),--static) $1 | sed -e 's/^"//g' -e 's/"$$//g')
111a515125bSLeila Ghaffari
112a515125bSLeila Ghaffari-include $(src.o:%.o=%.d)
113