Debian Codegraph @

miniapps/common/makefile

raw
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/common/,)
17 CONFIG_MK = $(or $(wildcard $(MFEM_BUILD_DIR)/config/config.mk),\
18 $(wildcard $(MFEM_INSTALL_DIR)/share/mfem/config.mk))
19
20 # Default target
21 all: lib-common
22
23 # Include defaults.mk to get the definition of BUILD_SOFLAGS
24 DEFAULTS_MK = $(MFEM_DIR)/config/defaults.mk
25 include $(DEFAULTS_MK)
26
27 USER_CONFIG = $(MFEM_BUILD_DIR)/config/user.mk
28 -include $(USER_CONFIG)
29
30 MFEM_LIB_FILE = mfem_is_not_built
31 ifneq (clean,$(MAKECMDGOALS))
32 -include $(CONFIG_MK)
33
34 XLINKER = $(MFEM_XLINKER)
35
36 BUILD_REAL_DIR = $(realpath .)
37 BUILD_SOFLAGS := $(subst libmfem.,libmfem-common.,$(BUILD_SOFLAGS))
38
39 # Internal shortcuts
40 override static = $(if $(MFEM_STATIC:YES=),,YES)
41 override shared = $(if $(MFEM_SHARED:YES=),,YES)
42 endif
43
44 SEQ_MINIOBJS = mesh_extras.o fem_extras.o particles_extras.o
45 ifeq ($(MFEM_USE_MPI),NO)
46 MINIOBJS = $(SEQ_MINIOBJS)
47 else
48 MINIOBJS = $(SEQ_MINIOBJS) pfem_extras.o dist_solver.o
49 endif
50
51 .SUFFIXES:
52 .SUFFIXES: .o .cpp .mk
53 .PHONY: all lib-common clean
54
55 # Remove built-in rule
56 %.o: %.cpp
57
58 # Replace the default implicit rule for *.cpp files
59 %.o: $(SRC)%.cpp $(CONFIG_MK)
60 $(MFEM_CXX) $(MFEM_PICFLAG) $(MFEM_FLAGS) -c $(<) -o $(@)
61
62 lib-common: $(if $(static),libmfem-common.a)\
63 $(if $(shared),libmfem-common.$(SO_EXT))
64
65 libmfem-common.a: $(MINIOBJS)
66 $(AR) $(ARFLAGS) $(@) $(MINIOBJS)
67 $(RANLIB) $(@)
68
69 libmfem-common.$(SO_VER): $(MINIOBJS)
70 $(MFEM_CXX) $(MFEM_LINK_FLAGS) $(BUILD_SOFLAGS) $(MINIOBJS) \
71 $(EXT_LIBS) -o $(@)
72
73 libmfem-common.$(SO_EXT): libmfem-common.$(SO_VER)
74 ln -sf $(<) $(@)
75
76 # Generate an error message if the MFEM library is not configured and exit
77 $(CONFIG_MK):
78 $(error The MFEM library is not configured)
79
80 # Generate an error message if the MFEM library is not built and exit
81 $(MFEM_LIB_FILE):
82 $(error The MFEM library is not built)
83 clean:
84 rm -rf *.o *~ libmfem-common.*
85 rm -rf *.dSYM *.TVD.*breakpoints