xref: /libCEED/examples/fluids/Makefile (revision 777ff853944a0dbc06f7f09486fdf4674828e728)
1ccaff030SJeremy L Thompson# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2ccaff030SJeremy L Thompson# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3ccaff030SJeremy L Thompson# reserved. See files LICENSE and NOTICE for details.
4ccaff030SJeremy L Thompson#
5ccaff030SJeremy L Thompson# This file is part of CEED, a collection of benchmarks, miniapps, software
6ccaff030SJeremy L Thompson# libraries and APIs for efficient high-order finite element and spectral
7ccaff030SJeremy L Thompson# element discretizations for exascale applications. For more information and
8ccaff030SJeremy L Thompson# source code availability see http://github.com/ceed.
9ccaff030SJeremy L Thompson#
10ccaff030SJeremy L Thompson# The CEED research is supported by the Exascale Computing Project (17-SC-20-SC)
11ccaff030SJeremy L Thompson# a collaborative effort of two U.S. Department of Energy organizations (Office
12ccaff030SJeremy L Thompson# of Science and the National Nuclear Security Administration) responsible for
13ccaff030SJeremy L Thompson# the planning and preparation of a capable exascale ecosystem, including
14ccaff030SJeremy L Thompson# software, applications, hardware, advanced system engineering and early
15ccaff030SJeremy L Thompson# testbed platforms, in support of the nation's exascale computing imperative.
16ccaff030SJeremy L Thompson
17*777ff853SJeremy L ThompsonCOMMON ?= ../../common.mk
18*777ff853SJeremy L Thompson-include $(COMMON)
19*777ff853SJeremy L Thompson
20ccaff030SJeremy L ThompsonPETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc
21ccaff030SJeremy L ThompsonCEED_DIR ?= ../..
22ccaff030SJeremy L Thompsonceed.pc := $(CEED_DIR)/lib/pkgconfig/ceed.pc
23ccaff030SJeremy L Thompson
24ccaff030SJeremy L ThompsonCC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc))
25ccaff030SJeremy L ThompsonCFLAGS = -std=c99 $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) $(call pkgconf, --cflags-only-other $(PETSc.pc)) $(OPT) -Wno-unused-variable
26ccaff030SJeremy L ThompsonCPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc))
27ccaff030SJeremy L ThompsonLDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc))
28ccaff030SJeremy L ThompsonLDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc)))
29ccaff030SJeremy L ThompsonLDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm
30ccaff030SJeremy L Thompson
31ccaff030SJeremy L Thompsonnavierstokes.c := $(wildcard navierstokes*.c)
32ccaff030SJeremy L Thompsonnavierstokes := $(navierstokes.c:%.c=%)
33ccaff030SJeremy L Thompson
34ccaff030SJeremy L Thompsonall: $(navierstokes)
35ccaff030SJeremy L Thompson$(navierstokes): | $(PETSc.pc) $(ceed.pc)
36ccaff030SJeremy L Thompson
37*777ff853SJeremy L Thompson# Quiet, color output
38*777ff853SJeremy L Thompsonquiet ?= $($(1))
39*777ff853SJeremy L Thompson
40ccaff030SJeremy L Thompson# Rules for building the example
41ccaff030SJeremy L Thompson%: %.c
42*777ff853SJeremy L Thompson	$(call quiet,CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(CEED_LDFLAGS) $(abspath $<) -o $@ $(LDLIBS)
43ccaff030SJeremy L Thompson
44ccaff030SJeremy L Thompsonprint: $(PETSc.pc) $(ceed.pc)
45ccaff030SJeremy L Thompson	$(info CC      : $(CC))
46ccaff030SJeremy L Thompson	$(info CFLAGS  : $(CFLAGS))
47ccaff030SJeremy L Thompson	$(info CPPFLAGS: $(CPPFLAGS))
48ccaff030SJeremy L Thompson	$(info LDFLAGS : $(LDFLAGS))
49ccaff030SJeremy L Thompson	$(info LDLIBS  : $(LDLIBS))
50ccaff030SJeremy L Thompson	$(info OPT     : $(OPT))
51ccaff030SJeremy L Thompson	@true
52ccaff030SJeremy L Thompson
53ccaff030SJeremy L Thompsonclean:
54ccaff030SJeremy L Thompson	$(RM) $(navierstokes) *.vtr *.vts *.vtu *.bin*
55ccaff030SJeremy L Thompson
56ccaff030SJeremy L Thompson$(PETSc.pc):
57ccaff030SJeremy L Thompson	$(if $(wildcard $@),,$(error \
58ccaff030SJeremy L Thompson	  PETSc config not found. Please set PETSC_DIR and PETSC_ARCH))
59ccaff030SJeremy L Thompson
60ccaff030SJeremy L Thompson.PHONY: all print clean
61ccaff030SJeremy L Thompson
62ccaff030SJeremy L Thompsonpkgconf = $(shell pkg-config $1 | sed -e 's/^"//g' -e 's/"$$//g')
63