xref: /honee/Makefile (revision 066464ba6f584ea5159308b4d335b53ca8193d83)
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
17*066464baSJames WrightCONFIG ?= ../../config.mk
18*066464baSJames 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))
447df379d9SJames Wright
45a515125bSLeila GhaffariOBJDIR := build
46a515125bSLeila GhaffariSRCDIR := src
47a515125bSLeila GhaffariPROBLEMDIR := problems
48ea10196cSJeremy L Thompson
49a515125bSLeila Ghaffarisrc.c := navierstokes.c $(sort $(wildcard $(PROBLEMDIR)/*.c)) $(sort $(wildcard $(SRCDIR)/*.c))
50a515125bSLeila Ghaffarisrc.o = $(src.c:%.c=$(OBJDIR)/%.o)
51a515125bSLeila Ghaffari
529e6f9b5eSJames Wright# Path to install directory for SmartRedis. Example: /software/smartredis/install
539e6f9b5eSJames WrightSMARTREDIS_DIR ?=
549e6f9b5eSJames Wrightifdef SMARTREDIS_DIR
559e6f9b5eSJames Wright	hiredis.pc := $(SMARTREDIS_DIR)/lib/pkgconfig/hiredis.pc
569e6f9b5eSJames Wright	lsmartredis:= -lsmartredis
579e6f9b5eSJames Wright	redis++.pc = $(wildcard $(SMARTREDIS_DIR)/lib/pkgconfig/redis++.pc $(SMARTREDIS_DIR)/lib64/pkgconfig/redis++.pc)
589e6f9b5eSJames Wright
599e6f9b5eSJames Wright	CPPFLAGS += $(call pkgconf, --cflags-only-I $(hiredis.pc) $(redis++.pc))
609e6f9b5eSJames Wright	LDFLAGS += $(call pkgconf, --libs-only-L --libs-only-other $(hiredis.pc) $(redis++.pc))
619e6f9b5eSJames Wright	LDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(hiredis.pc) $(redis++.pc)))
629e6f9b5eSJames Wright	LDLIBS += $(call pkgconf, --libs-only-l $(hiredis.pc) $(redis++.pc)) $(lsmartredis)
639e6f9b5eSJames Wright	src.c += $(sort $(wildcard $(SRCDIR)/smartsim/*.c))
649e6f9b5eSJames Wrightendif
659e6f9b5eSJames Wright
66a515125bSLeila Ghaffariall: navierstokes
67a515125bSLeila Ghaffari
68a515125bSLeila Ghaffarinavierstokes: $(src.o) | $(PETSc.pc) $(ceed.pc)
69a515125bSLeila Ghaffari	$(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
70a515125bSLeila Ghaffari
71a515125bSLeila Ghaffari.SECONDEXPANSION: # to expand $$(@D)/.DIR
72a515125bSLeila Ghaffari%/.DIR :
73a515125bSLeila Ghaffari	@mkdir -p $(@D)
74a515125bSLeila Ghaffari	@touch $@
75ea10196cSJeremy L Thompson
764f863122SJeremy L Thompson# Quiet, color output
774f863122SJeremy L Thompsonquiet ?= $($(1))
784f863122SJeremy L Thompson
79a515125bSLeila Ghaffari$(OBJDIR)/%.o : %.c | $$(@D)/.DIR
80a515125bSLeila Ghaffari	$(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<)
81a515125bSLeila Ghaffari
82ea10196cSJeremy L Thompsonprint: $(PETSc.pc) $(ceed.pc)
83ea10196cSJeremy L Thompson	$(info CC      : $(CC))
84ea10196cSJeremy L Thompson	$(info CFLAGS  : $(CFLAGS))
85ea10196cSJeremy L Thompson	$(info CPPFLAGS: $(CPPFLAGS))
86ea10196cSJeremy L Thompson	$(info LDFLAGS : $(LDFLAGS))
87ea10196cSJeremy L Thompson	$(info LDLIBS  : $(LDLIBS))
88ea10196cSJeremy L Thompson	$(info OPT     : $(OPT))
89ea10196cSJeremy L Thompson	@true
90ea10196cSJeremy L Thompson
910e8fe9d5SJames Wrightprint-% :
920e8fe9d5SJames Wright	$(info [ variable name]: $*)
930e8fe9d5SJames Wright	$(info [        origin]: $(origin $*))
940e8fe9d5SJames Wright	$(info [        flavor]: $(flavor $*))
950e8fe9d5SJames Wright	$(info [         value]: $(value $*))
960e8fe9d5SJames Wright	$(info [expanded value]: $($*))
970e8fe9d5SJames Wright	$(info )
980e8fe9d5SJames Wright	@true
990e8fe9d5SJames Wright
100ea10196cSJeremy L Thompsonclean:
101a515125bSLeila Ghaffari	$(RM) -r $(OBJDIR) navierstokes *.vtu *.bin* *.csv *.png
102ea10196cSJeremy L Thompson
103ea10196cSJeremy L Thompson$(PETSc.pc):
104ea10196cSJeremy L Thompson	$(if $(wildcard $@),,$(error \
105ea10196cSJeremy L Thompson	  PETSc config not found. Please set PETSC_DIR and PETSC_ARCH))
106ea10196cSJeremy L Thompson
107ea10196cSJeremy L Thompson.PHONY: all print clean
108ea10196cSJeremy L Thompson
1090e8fe9d5SJames Wrightpkgconf = $(shell pkg-config $(if $(STATIC),--static) $1 | sed -e 's/^"//g' -e 's/"$$//g')
110a515125bSLeila Ghaffari
111a515125bSLeila Ghaffari-include $(src.o:%.o=%.d)
112