-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathMakefile
More file actions
165 lines (139 loc) · 4.98 KB
/
Makefile
File metadata and controls
165 lines (139 loc) · 4.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#
# CoDiPack, a Code Differentiation Package
#
# Copyright (C) 2015-2026 Chair for Scientific Computing (SciComp), RPTU University Kaiserslautern-Landau
# Homepage: http://scicomp.rptu.de
# Contact: Prof. Nicolas R. Gauger (codi@scicomp.uni-kl.de)
#
# Lead developers: Max Sagebaum, Johannes Blühdorn (SciComp, RPTU University Kaiserslautern-Landau)
#
# This file is part of CoDiPack (http://scicomp.rptu.de/software/codi).
#
# CoDiPack is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# CoDiPack is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU General Public License for more details.
# You should have received a copy of the GNU
# General Public License along with CoDiPack.
# If not, see <http://www.gnu.org/licenses/>.
#
# For other licensing options please contact us.
#
# Authors:
# - SciComp, RPTU University Kaiserslautern-Landau:
# - Max Sagebaum
# - Johannes Blühdorn
# - Former members:
# - Tim Albring
#
# names of the basic directories
BUILD_DIR = build
DEFINITION_DIR = definitions
DOC_DIR = documentation
EXAMPLE_DIR = $(DOC_DIR)/examples
TUTORIAL_DIR = $(DOC_DIR)/tutorials
DEVELOPER_DIR = $(DOC_DIR)/developer
EIGEN_DEFINE=
ifdef EIGEN_DIR
EIGEN_DEFINE=-I$(EIGEN_DIR) -DCODI_EnableEigen=true
endif
ENZYME_DEFINE=
ifdef ENZYME_DIR
CLANG_VERSION := 14
ENZYME_DEFINE = -DCODI_EnableEnzyme=true -flegacy-pass-manager -Xclang -load -Xclang $(ENZYME_DIR)/lib/ClangEnzyme-$(CLANG_VERSION).so -Xclang -plugin-arg-enzyme -Xclang -enzyme-globals-default-inactive=1
endif
#list all source files in DOC_DIR
TUTORIAL_FILES = $(wildcard $(TUTORIAL_DIR)/*.cpp)
EXAMPLE_FILES = $(wildcard $(EXAMPLE_DIR)/*.cpp) $(wildcard $(DEVELOPER_DIR)/*.cpp)
DEFINITION_FILES = $(wildcard $(DEFINITION_DIR)/*/*/*.hpp)
#list all dependency files in BUILD_DIR
DEP_FILES = $(wildcard $(BUILD_DIR)/*.d)
DEP_FILES += $(wildcard $(BUILD_DIR)/**/*.d)
DEP_FILES += $(wildcard $(BUILD_DIR)/**/**/*.d)
MAJOR_VERSION = $(shell grep -oP 'define CODI_MAJOR_VERSION \K\d+' include/codi.hpp)
MINOR_VERSION = $(shell grep -oP 'define CODI_MINOR_VERSION \K\d+' include/codi.hpp)
BUILD_VERSION = $(shell grep -oP 'define CODI_BUILD_VERSION \K\d+' include/codi.hpp)
CODI_VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(BUILD_VERSION)
CODI_DIR := .
FLAGS = -std=c++17 -Wall -Werror=return-type -pedantic -DCODI_OptIgnoreInvalidJacobians=true -DCODI_EnableAssert=true -I$(CODI_DIR)/include -fopenmp $(EIGEN_DEFINE) $(ENZYME_DEFINE) -DCODI_StatementEvents
ifndef CLANG_FORMAT
CLANG_FORMAT := clang-format
else
CLANG_FORMAT := $(CLANG_FORMAT)
endif
ifeq ($(OPT), yes)
FLAGS += -O3
else
FLAGS += -O0 -g
endif
ifeq ($(MPI), yes)
FLAGS += -DCODI_EnableMPI
ifdef MEDI_DIR
FLAGS += -I$(MEDI_DIR)/include -I$(MEDI_DIR)/src
else
$(error Error: 'MEDI_DIR' is not defined for the MPI build. You can get it at 'https://scicomp.rptu.de/software/medi/' or with 'git clone https://github.com/SciCompKL/MeDiPack.git')
endif
endif
ifeq ($(OPENMP), yes)
FLAGS += -DCODI_EnableOpenMP -fopenmp
ifeq ($(OPDILIB), yes)
FLAGS += -DCODI_EnableOpDiLib
ifdef OPDI_DIR
FLAGS += -I$(OPDI_DIR)/include
else
$(error Error: 'OPDI_DIR' is not defined for the OpDiLib build. You can get it at 'https://scicomp.rptu.de/software/opdi/' or with 'git clone https://github.com/SciCompKL/OpDiLib.git')
endif
endif
else
ifeq ($(OPDILIB), yes)
$(error Error: OPDILIB=yes requires OPENMP=yes)
endif
endif
ifndef CXX
ifeq ($(MPI), yes)
CXX := mpic++
else
CXX := g++
endif
else
CXX := $(CXX)
endif
TUTORIALS = $(patsubst %.cpp,$(BUILD_DIR)/%.exe,$(TUTORIAL_FILES))
EXAMPLES = $(patsubst %.cpp,$(BUILD_DIR)/%.exe,$(EXAMPLE_FILES))
GENERATED = $(patsubst $(DEFINITION_DIR)/%.hpp,include/codi/tools/%.hpp,$(DEFINITION_FILES))
# set default rule
all: tutorials examples
$(BUILD_DIR)/%.exe : %.cpp $(BUILD_DIR)/compiler_flags
@mkdir -p $(@D)
$(CXX) $(FLAGS) $< -o $@
@$(CXX) $(FLAGS) $< -MM -MP -MT $@ -MF $@.d
tutorials: $(TUTORIALS)
examples: $(EXAMPLES)
include/codi/tools/%.hpp: $(DEFINITION_DIR)/%.hpp
@mkdir -p $(@D)
python $(EXT_FUNC_GENERATOR_DIR)/externalfunctionparser/externalfunctionparser.py $< -o $@
$(CLANG_FORMAT) -i $@
generate: $(GENERATED)
doc:
@mkdir -p $(BUILD_DIR)
@mkdir -p $(BUILD_DIR)/documentation
CODI_VERSION=$(CODI_VERSION) doxygen
single_header:
quom --include_directory include include/codi.hpp $(BUILD_DIR)/codi_single.hpp
.PHONY: format
format:
find include tests/general/include tests/general/src tests/events/include tests/events/src -type f -exec $(CLANG_FORMAT) -i {} \;
.PHONY: clean
clean:
rm -fr $(BUILD_DIR)
.PHONY: force
$(BUILD_DIR)/compiler_flags: force
@mkdir -p $(@D)
@echo '$(FLAGS)' | cmp -s - $@ || echo '$(FLAGS)' > $@
-include $(DEP_FILES)