xref: /libCEED/examples/mfem/Makefile (revision e0f331b732c79a3c523e8063f829e2266ccf82dd)
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
17# Ceed directory
18CEED_DIR ?= ../..
19CEED_FLAGS ?= -I$(CEED_DIR)/include
20CEED_LIBS ?= -Wl,-rpath,$(abspath $(CEED_DIR)/lib) -L$(CEED_DIR)/lib -lceed
21
22OCCA_DIR ?= ../../../occa
23
24# Use an MFEM build directory or an MFEM install directory
25MFEM_DIR ?= ../../../mfem
26CONFIG_MK ?= $(or $(wildcard $(MFEM_DIR)/config/config.mk),$(wildcard\
27  $(MFEM_DIR)/share/mfem/config.mk),invalid_mfem_dir)
28MFEM_DEF = -DMFEM_DIR="\"$(abspath $(MFEM_DIR))\""
29
30MFEM_LIB_FILE = mfem_is_not_built
31-include $(CONFIG_MK)
32
33MFEM_EXAMPLES = bp1 bp3
34
35.SUFFIXES:
36.SUFFIXES: .cpp
37.PHONY: all clean
38
39all: $(MFEM_EXAMPLES)
40
41# Remove built-in rules
42%: %.cpp
43
44# Rules for building the examples
45%: %.cpp $(CONFIG_MK) $(MFEM_LIB_FILE) okl-lib-cache
46	$(MFEM_CXX) $(CEED_FLAGS) $(MFEM_FLAGS) $(MFEM_DEF) $< -o $@ \
47	  $(CEED_LIBS) $(MFEM_LIBS)
48
49# Generate an error message if the MFEM library is not built and exit
50$(MFEM_LIB_FILE):
51	$(error The MFEM library is not built)
52
53$(CONFIG_MK):
54	$(error MFEM config file not found. Please set MFEM_DIR)
55
56# okl-lib-cache depending on OCCA and INSTALL
57okl-lib-cache:
58# First test to see if libceed was compiled with OCCA
59ifneq ($(wildcard $(OCCA_DIR)/lib/libocca.*),)
60# Second test to see if '../..' is CEED_DIR
61ifneq ($(CEED_DIR),../..)
62okl-lib-cache:
63	$(OCCA_DIR)/bin/occa cache ceed $(abspath $(CEED_DIR)/lib/okl/*.okl)
64endif
65endif
66
67clean:
68	rm -f *~ $(MFEM_EXAMPLES)
69	rm -rf *.dSYM *.TVD.*breakpoints
70