| 1 |
# Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced |
| 2 |
# at the Lawrence Livermore National Laboratory. All Rights reserved. See files |
| 3 |
# LICENSE and NOTICE for details. LLNL-CODE-806117. |
| 4 |
# |
| 5 |
# This file is part of the MFEM library. For more information and source code |
| 6 |
# availability visit https://mfem.org. |
| 7 |
# |
| 8 |
# MFEM is free software; you can redistribute it and/or modify it under the |
| 9 |
# terms of the BSD-3 license. We welcome feedback and contributions, see file |
| 10 |
# CONTRIBUTING.md for details. |
| 11 |
|
| 12 |
# Use the MFEM build directory |
| 13 |
MFEM_DIR ?= ../.. |
| 14 |
MFEM_BUILD_DIR ?= ../.. |
| 15 |
MFEM_INSTALL_DIR ?= ../../mfem |
| 16 |
SRC = $(if $(MFEM_DIR:../..=),$(MFEM_DIR)/miniapps/tools/,) |
| 17 |
CONFIG_MK = $(or $(wildcard $(MFEM_BUILD_DIR)/config/config.mk),\ |
| 18 |
$(wildcard $(MFEM_INSTALL_DIR)/share/mfem/config.mk)) |
| 19 |
|
| 20 |
MFEM_LIB_FILE = mfem_is_not_built |
| 21 |
-include $(CONFIG_MK) |
| 22 |
|
| 23 |
SEQ_MINIAPPS = display-basis load-dc convert-dc get-values lor-transfer \ |
| 24 |
tmop-check-metric tmop-metric-magnitude |
| 25 |
|
| 26 |
PAR_MINIAPPS = nodal-transfer plor-transfer gridfunction-bounds |
| 27 |
|
| 28 |
ifeq ($(MFEM_USE_MPI),NO) |
| 29 |
MINIAPPS = $(SEQ_MINIAPPS) |
| 30 |
else |
| 31 |
MINIAPPS = $(PAR_MINIAPPS) $(SEQ_MINIAPPS) |
| 32 |
endif |
| 33 |
|
| 34 |
.SUFFIXES: |
| 35 |
.SUFFIXES: .o .cpp .mk |
| 36 |
.PHONY: all lib-common clean clean-build clean-exec |
| 37 |
.PRECIOUS: %.o |
| 38 |
|
| 39 |
COMMON_LIB = -L$(MFEM_BUILD_DIR)/miniapps/common -lmfem-common |
| 40 |
|
| 41 |
# If MFEM_SHARED is set, add the ../common rpath |
| 42 |
COMMON_LIB += $(if $(MFEM_SHARED:YES=),,\ |
| 43 |
$(MFEM_XLINKER)-rpath,$(abspath $(MFEM_BUILD_DIR)/miniapps/common)) |
| 44 |
|
| 45 |
all: $(MINIAPPS) |
| 46 |
|
| 47 |
# Remove built-in rules |
| 48 |
%: %.cpp |
| 49 |
%.o: %.cpp |
| 50 |
|
| 51 |
# Replace the default implicit rule for *.cpp files |
| 52 |
%: $(SRC)%.cpp $(MFEM_LIB_FILE) $(CONFIG_MK) |
| 53 |
$(MFEM_CXX) $(MFEM_FLAGS) $< -o $@ $(MFEM_LIBS) |
| 54 |
|
| 55 |
# Tools that depend on lib-common |
| 56 |
display-basis: %: $(SRC)%.cpp $(MFEM_LIB_FILE) $(CONFIG_MK) | lib-common |
| 57 |
$(MFEM_CXX) $(MFEM_FLAGS) -c $(<) |
| 58 |
$(MFEM_CXX) $(MFEM_LINK_FLAGS) -o $@ [email protected] $(COMMON_LIB) $(MFEM_LIBS) |
| 59 |
|
| 60 |
tmop-metric-magnitude: %: $(SRC)%.cpp $(MFEM_LIB_FILE) $(CONFIG_MK) | lib-common |
| 61 |
$(MFEM_CXX) $(MFEM_FLAGS) -c $(<) |
| 62 |
$(MFEM_CXX) $(MFEM_LINK_FLAGS) -o $@ [email protected] $(COMMON_LIB) $(MFEM_LIBS) |
| 63 |
|
| 64 |
# Rule for building lib-common |
| 65 |
lib-common: |
| 66 |
$(MAKE) -C $(MFEM_BUILD_DIR)/miniapps/common |
| 67 |
|
| 68 |
MFEM_TESTS = MINIAPPS |
| 69 |
include $(MFEM_TEST_MK) |
| 70 |
|
| 71 |
# Testing: Parallel vs. serial runs |
| 72 |
RUN_MPI = $(MFEM_MPIEXEC) $(MFEM_MPIEXEC_NP) $(MFEM_MPI_NP) |
| 73 |
%-test-par: % |
| 74 |
@$(call mfem-test,$<, $(RUN_MPI), Tools miniapp) |
| 75 |
%-test-seq: % |
| 76 |
@$(call mfem-test,$<,, Tools miniapp) |
| 77 |
|
| 78 |
# Testing: Specific execution options |
| 79 |
# Do not test: display-basis, load-dc, convert-dc, get-values, lor-transfer, plor-transfer |
| 80 |
NO_TEST_APPS = display-basis load-dc convert-dc get-values lor-transfer \ |
| 81 |
plor-transfer tmop-check-metric tmop-metric-magnitude gridfunction-bounds |
| 82 |
$(foreach app,$(NO_TEST_APPS),$(app)-test-seq $(app)-test-par): |
| 83 |
@true |
| 84 |
|
| 85 |
# Testing: "test" target and mfem-test* variables are defined in config/test.mk |
| 86 |
|
| 87 |
# Generate an error message if the MFEM library is not built and exit |
| 88 |
$(MFEM_LIB_FILE): |
| 89 |
$(error The MFEM library is not built) |
| 90 |
|
| 91 |
clean: clean-build clean-exec |
| 92 |
|
| 93 |
clean-build: |
| 94 |
rm -f *.o *~ $(SEQ_MINIAPPS) $(PAR_MINIAPPS) |
| 95 |
rm -rf *.dSYM *.TVD.*breakpoints |
| 96 |
|
| 97 |
clean-exec: |
| 98 |
@rm -rf mesh_* gridfunc_* jacobian-determinant-bounds* |
| 99 |
@true |