forked from SciCompKL/CoDiPack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
129 lines (110 loc) · 3.57 KB
/
Makefile
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
#
# CoDiPack, a Code Differentiation Package
#
# Copyright (C) 2015-2021 Chair for Scientific Computing (SciComp), TU Kaiserslautern
# Homepage: http://www.scicomp.uni-kl.de
# Contact: Prof. Nicolas R. Gauger ([email protected])
#
# Lead developers: Max Sagebaum, Johannes Blühdorn (SciComp, TU Kaiserslautern)
#
# This file is part of CoDiPack (http://www.scicomp.uni-kl.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, TU Kaiserslautern:
# - Max Sagebaum
# - Johannes Blühdorn
# - Former members:
# - Tim Albring
#
# names of the basic directories
BUILD_DIR = build
DOC_DIR = documentation
EXAMPLE_DIR = $(DOC_DIR)/examples
TUTORIAL_DIR = $(DOC_DIR)/tutorials
DEVELOPER_DIR = $(DOC_DIR)/developer
#list all source files in DOC_DIR
TUTORIAL_FILES = $(wildcard $(TUTORIAL_DIR)/*.cpp)
EXAMPLE_FILES = $(wildcard $(EXAMPLE_DIR)/*.cpp) $(wildcard $(DEVELOPER_DIR)/*.cpp)
#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 = -Wall -pedantic -DCODI_OptIgnoreInvalidJacobians=true -DCODI_EnableAssert=true -I$(CODI_DIR)/include -fopenmp
ifndef CLANG_FORMAT
CLANG_FORMAT := clang-format
else
CLANG_FORMAT := $(CLANG_FORMAT)
endif
ifeq ($(CPP14), yes)
FLAGS += -std=c++14
else
FLAGS += -std=c++11
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://www.scicomp.uni-kl.de/software/medi/' or with 'git clone https://github.com/SciCompKL/MeDiPack.git'.)
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))
# 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 [email protected]
tutorials: $(TUTORIALS)
examples: $(EXAMPLES)
doc:
@mkdir -p $(BUILD_DIR)
@mkdir -p $(BUILD_DIR)/documentation
CODI_VERSION=$(CODI_VERSION) doxygen
.PHONY: format
format:
find include tests/include tests/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)