xref: /libCEED/examples/mfem/Makefile (revision 9df49d7ef0a77c7a3baec2427d8a7274681409b6)
1# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3# reserved. See files LICENSE and NOTICE for details.
4#
5# This file is part of CEED, a collection of benchmarks, miniapps, software
6# libraries and APIs for efficient high-order finite element and spectral
7# element discretizations for exascale applications. For more information and
8# source code availability see http://github.com/ceed.
9#
10# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11# a collaborative effort of two U.S. Department of Energy organizations (Office
12# of Science and the National Nuclear Security Administration) responsible for
13# the planning and preparation of a capable exascale ecosystem, including
14# software, applications, hardware, advanced system engineering and early
15# testbed platforms, in support of the nation's exascale computing imperative.
16
17COMMON ?= ../../common.mk
18-include $(COMMON)
19
20OPT ?= -O -g
21
22# Ceed directory
23CEED_DIR ?= ../..
24CEED_FLAGS ?= -I$(CEED_DIR)/include $(OPT)
25CEED_LIBS ?= -Wl,-rpath,$(abspath $(CEED_DIR)/lib) -L$(CEED_DIR)/lib -lceed
26
27# Use an MFEM build directory or an MFEM install directory
28MFEM_DIR ?= ../../../mfem
29CONFIG_MK ?= $(or $(wildcard $(MFEM_DIR)/config/config.mk),$(wildcard\
30  $(MFEM_DIR)/share/mfem/config.mk),invalid_mfem_dir)
31MFEM_DEF = -DMFEM_DIR="\"$(abspath $(MFEM_DIR))\""
32
33MFEM_LIB_FILE = mfem_is_not_built
34-include $(wildcard $(CONFIG_MK))
35
36MFEM_EXAMPLES =  bp1 bp3
37
38.SUFFIXES:
39.SUFFIXES: .cpp
40.PHONY: all clean
41
42all: $(MFEM_EXAMPLES)
43
44# Quiet, color output
45quiet ?= $($(1))
46
47# Rules for building the examples
48%: %.cpp $(CONFIG_MK) $(MFEM_LIB_FILE)
49	$(call quiet,MFEM_CXX) $(CEED_FLAGS) $(MFEM_FLAGS) $(MFEM_DEF) $(abspath $<) -o $@ \
50	  $(CEED_LIBS) $(MFEM_LIBS)
51
52# Generate an error message if the MFEM library is not built and exit
53$(MFEM_LIB_FILE):
54	$(if $(wildcard $@),,$(error The MFEM library is not built))
55
56$(CONFIG_MK):
57	$(if $(wildcard $@),,$(error \
58	  MFEM config file not found. Please set MFEM_DIR))
59
60test : $(MFEM_EXAMPLES)
61	@./tap.sh bp1
62	@./tap.sh bp3
63
64clean:
65	rm -f *~ $(MFEM_EXAMPLES)
66	rm -rf *.dSYM *.TVD.*breakpoints
67