xref: /libCEED/examples/mfem/Makefile (revision c0c38e35a0c9ca20859bbaac6eea4bddeab4b4f6)
1cbc56ef6SVeselin Dobrev# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2cbc56ef6SVeselin Dobrev# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3cbc56ef6SVeselin Dobrev# reserved. See files LICENSE and NOTICE for details.
4cbc56ef6SVeselin Dobrev#
5cbc56ef6SVeselin Dobrev# This file is part of CEED, a collection of benchmarks, miniapps, software
6cbc56ef6SVeselin Dobrev# libraries and APIs for efficient high-order finite element and spectral
7cbc56ef6SVeselin Dobrev# element discretizations for exascale applications. For more information and
8cbc56ef6SVeselin Dobrev# source code availability see http://github.com/ceed.
9cbc56ef6SVeselin Dobrev#
10cbc56ef6SVeselin Dobrev# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11cbc56ef6SVeselin Dobrev# a collaborative effort of two U.S. Department of Energy organizations (Office
12cbc56ef6SVeselin Dobrev# of Science and the National Nuclear Security Administration) responsible for
13cbc56ef6SVeselin Dobrev# the planning and preparation of a capable exascale ecosystem, including
14cbc56ef6SVeselin Dobrev# software, applications, hardware, advanced system engineering and early
15cbc56ef6SVeselin Dobrev# testbed platforms, in support of the nation's exascale computing imperative.
16cbc56ef6SVeselin Dobrev
17cbc56ef6SVeselin Dobrev# Ceed directory
18cbc56ef6SVeselin DobrevCEED_DIR ?= ../..
19*c0c38e35SVeselin DobrevCEED_FLAGS ?= -I$(CEED_DIR)/include
206ea7c6c1SJed BrownCEED_LIBS ?= -Wl,-rpath,$(abspath $(CEED_DIR)/lib) -L$(CEED_DIR)/lib -lceed
21cbc56ef6SVeselin Dobrev
22dd9a71b6SVeselin DobrevOCCA_DIR ?= ../../../occa
23dd9a71b6SVeselin Dobrev
24cbc56ef6SVeselin Dobrev# Use an MFEM build directory or an MFEM install directory
25cbc56ef6SVeselin DobrevMFEM_DIR ?= ../../../mfem
26cbc56ef6SVeselin DobrevCONFIG_MK ?= $(or $(wildcard $(MFEM_DIR)/config/config.mk),$(wildcard\
27*c0c38e35SVeselin Dobrev  $(MFEM_DIR)/share/mfem/config.mk),invalid_mfem_dir)
28*c0c38e35SVeselin DobrevMFEM_DEF = -DMFEM_DIR="\"$(abspath $(MFEM_DIR))\""
29cbc56ef6SVeselin Dobrev
30cbc56ef6SVeselin DobrevMFEM_LIB_FILE = mfem_is_not_built
31cbc56ef6SVeselin Dobrev-include $(CONFIG_MK)
32cbc56ef6SVeselin Dobrev
33182fbe45STzanioMFEM_EXAMPLES = bp1 bp3
34cbc56ef6SVeselin Dobrev
35cbc56ef6SVeselin Dobrev.SUFFIXES:
36cbc56ef6SVeselin Dobrev.SUFFIXES: .cpp
37cbc56ef6SVeselin Dobrev.PHONY: all clean
38cbc56ef6SVeselin Dobrev
39cbc56ef6SVeselin Dobrevall: $(MFEM_EXAMPLES)
40cbc56ef6SVeselin Dobrev
41cbc56ef6SVeselin Dobrev# Remove built-in rules
42cbc56ef6SVeselin Dobrev%: %.cpp
43cbc56ef6SVeselin Dobrev
44cbc56ef6SVeselin Dobrev# Rules for building the examples
45*c0c38e35SVeselin Dobrev%: %.cpp $(CONFIG_MK) $(MFEM_LIB_FILE) okl-lib-cache
46*c0c38e35SVeselin Dobrev	$(MFEM_CXX) $(CEED_FLAGS) $(MFEM_FLAGS) $(MFEM_DEF) $< -o $@ \
47*c0c38e35SVeselin Dobrev	  $(CEED_LIBS) $(MFEM_LIBS) $(OCCA_LIBS)
48cbc56ef6SVeselin Dobrev
49cbc56ef6SVeselin Dobrev# Generate an error message if the MFEM library is not built and exit
50cbc56ef6SVeselin Dobrev$(MFEM_LIB_FILE):
51cbc56ef6SVeselin Dobrev	$(error The MFEM library is not built)
52cbc56ef6SVeselin Dobrev
53*c0c38e35SVeselin Dobrev$(CONFIG_MK):
54*c0c38e35SVeselin Dobrev	$(error MFEM config file not found. Please set MFEM_DIR)
55*c0c38e35SVeselin Dobrev
56edbbdbadScamierjs# okl-lib-cache depending on OCCA and INSTALL
57edbbdbadScamierjsokl-lib-cache:
58edbbdbadScamierjs# First test to see if libceed was compiled with OCCA
59edbbdbadScamierjsifneq ($(wildcard $(OCCA_DIR)/lib/libocca.*),)
6024ed8b5fSTzanio# Second test to see if '../..' is CEED_DIR
610b8e4d72STzanioifneq ($(CEED_DIR),../..)
62edbbdbadScamierjsokl-lib-cache:
630b8e4d72STzanio	$(OCCA_DIR)/bin/occa cache ceed $(abspath $(CEED_DIR)/lib/okl/*.okl)
64edbbdbadScamierjsendif
65edbbdbadScamierjsendif
66edbbdbadScamierjs
67cbc56ef6SVeselin Dobrevclean:
68cbc56ef6SVeselin Dobrev	rm -f *~ $(MFEM_EXAMPLES)
69cbc56ef6SVeselin Dobrev	rm -rf *.dSYM *.TVD.*breakpoints
70