xref: /honee/Makefile (revision 0e8fe9d5f66cc9ffe66aed8cb73758a98e90ab24)
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
24ea10196cSJeremy L ThompsonCC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc))
25a515125bSLeila GhaffariCFLAGS = -std=c99 \
26a515125bSLeila Ghaffari  $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) \
27a515125bSLeila Ghaffari  $(call pkgconf, --cflags-only-other $(PETSc.pc)) \
28f0b65372SJed Brown  $(OPT) $(OPT_EXAMPLES)
29a515125bSLeila GhaffariCPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc)) \
30a515125bSLeila Ghaffari  $(call pkgconf, --variable=cflags_dep $(PETSc.pc))
31ea10196cSJeremy L ThompsonLDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc))
32ea10196cSJeremy L ThompsonLDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc)))
33ea10196cSJeremy L ThompsonLDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm
34ea10196cSJeremy L Thompson
35a515125bSLeila GhaffariOBJDIR := build
36a515125bSLeila GhaffariSRCDIR := src
37a515125bSLeila GhaffariPROBLEMDIR := problems
38ea10196cSJeremy L Thompson
39a515125bSLeila Ghaffarisrc.c := navierstokes.c $(sort $(wildcard $(PROBLEMDIR)/*.c)) $(sort $(wildcard $(SRCDIR)/*.c))
40a515125bSLeila Ghaffarisrc.o = $(src.c:%.c=$(OBJDIR)/%.o)
41a515125bSLeila Ghaffari
42a515125bSLeila Ghaffariall: navierstokes
43a515125bSLeila Ghaffari
44a515125bSLeila Ghaffarinavierstokes: $(src.o) | $(PETSc.pc) $(ceed.pc)
45a515125bSLeila Ghaffari	$(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
46a515125bSLeila Ghaffari
47a515125bSLeila Ghaffari.SECONDEXPANSION: # to expand $$(@D)/.DIR
48a515125bSLeila Ghaffari%/.DIR :
49a515125bSLeila Ghaffari	@mkdir -p $(@D)
50a515125bSLeila Ghaffari	@touch $@
51ea10196cSJeremy L Thompson
524f863122SJeremy L Thompson# Quiet, color output
534f863122SJeremy L Thompsonquiet ?= $($(1))
544f863122SJeremy L Thompson
55a515125bSLeila Ghaffari$(OBJDIR)/%.o : %.c | $$(@D)/.DIR
56a515125bSLeila Ghaffari	$(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<)
57a515125bSLeila Ghaffari
58a515125bSLeila Ghaffari# Rules for building the examples
59a515125bSLeila Ghaffari#%: %.c
60ea10196cSJeremy L Thompson
61ea10196cSJeremy L Thompsonprint: $(PETSc.pc) $(ceed.pc)
62ea10196cSJeremy L Thompson	$(info CC      : $(CC))
63ea10196cSJeremy L Thompson	$(info CFLAGS  : $(CFLAGS))
64ea10196cSJeremy L Thompson	$(info CPPFLAGS: $(CPPFLAGS))
65ea10196cSJeremy L Thompson	$(info LDFLAGS : $(LDFLAGS))
66ea10196cSJeremy L Thompson	$(info LDLIBS  : $(LDLIBS))
67ea10196cSJeremy L Thompson	$(info OPT     : $(OPT))
68ea10196cSJeremy L Thompson	@true
69ea10196cSJeremy L Thompson
70*0e8fe9d5SJames Wrightprint-% :
71*0e8fe9d5SJames Wright	$(info [ variable name]: $*)
72*0e8fe9d5SJames Wright	$(info [        origin]: $(origin $*))
73*0e8fe9d5SJames Wright	$(info [        flavor]: $(flavor $*))
74*0e8fe9d5SJames Wright	$(info [         value]: $(value $*))
75*0e8fe9d5SJames Wright	$(info [expanded value]: $($*))
76*0e8fe9d5SJames Wright	$(info )
77*0e8fe9d5SJames Wright	@true
78*0e8fe9d5SJames Wright
79ea10196cSJeremy L Thompsonclean:
80a515125bSLeila Ghaffari	$(RM) -r $(OBJDIR) navierstokes *.vtu *.bin* *.csv *.png
81ea10196cSJeremy L Thompson
82ea10196cSJeremy L Thompson$(PETSc.pc):
83ea10196cSJeremy L Thompson	$(if $(wildcard $@),,$(error \
84ea10196cSJeremy L Thompson	  PETSc config not found. Please set PETSC_DIR and PETSC_ARCH))
85ea10196cSJeremy L Thompson
86ea10196cSJeremy L Thompson.PHONY: all print clean
87ea10196cSJeremy L Thompson
88*0e8fe9d5SJames Wrightpkgconf = $(shell pkg-config $(if $(STATIC),--static) $1 | sed -e 's/^"//g' -e 's/"$$//g')
89a515125bSLeila Ghaffari
90a515125bSLeila Ghaffari-include $(src.o:%.o=%.d)
91