xref: /libCEED/examples/mfem/Makefile (revision 3d8e882215d238700cdceb37404f76ca7fa24eaa)
1# Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors
2# All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3#
4# SPDX-License-Identifier: BSD-2-Clause
5#
6# This file is part of CEED:  http://github.com/ceed
7
8COMMON ?= ../../common.mk
9-include $(COMMON)
10
11OPT ?= -O -g
12
13# Ceed directory
14CEED_DIR ?= ../..
15CEED_FLAGS ?= -I$(CEED_DIR)/include $(OPT)
16CEED_LIBS ?= -Wl,-rpath,$(abspath $(CEED_DIR)/lib) -L$(CEED_DIR)/lib -lceed
17
18# Use an MFEM build directory or an MFEM install directory
19MFEM_DIR ?= ../../../mfem
20CONFIG_MK ?= $(or $(wildcard $(MFEM_DIR)/config/config.mk),$(wildcard\
21  $(MFEM_DIR)/share/mfem/config.mk),invalid_mfem_dir)
22MFEM_DEF = -DMFEM_DIR="\"$(abspath $(MFEM_DIR))\""
23
24MFEM_LIB_FILE = mfem_is_not_built
25-include $(wildcard $(CONFIG_MK))
26
27MFEM_EXAMPLES =  bp1 bp3
28
29.SUFFIXES:
30.SUFFIXES: .cpp
31.PHONY: all clean
32
33all: $(MFEM_EXAMPLES)
34
35# Quiet, color output
36quiet ?= $($(1))
37
38# Rules for building the examples
39%: %.cpp $(CONFIG_MK) $(MFEM_LIB_FILE)
40	$(call quiet,MFEM_CXX) $(CEED_FLAGS) $(MFEM_FLAGS) $(MFEM_DEF) $(abspath $<) -o $@ \
41	  $(CEED_LIBS) $(MFEM_LIBS)
42
43# Generate an error message if the MFEM library is not built and exit
44$(MFEM_LIB_FILE):
45	$(if $(wildcard $@),,$(error The MFEM library is not built))
46
47$(CONFIG_MK):
48	$(if $(wildcard $@),,$(error \
49	  MFEM config file not found. Please set MFEM_DIR))
50
51test : $(MFEM_EXAMPLES)
52	@./tap.sh bp1
53	@./tap.sh bp3
54
55clean:
56	rm -f *~ $(MFEM_EXAMPLES)
57	rm -rf *.dSYM *.TVD.*breakpoints
58