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
|
# This file is part of the OpenLB library
#
# Copyright (C) 2017 Markus Mohrhard
# E-mail contact: info@openlb.net
# The most recent release of OpenLB can be downloaded at
# <http://www.openlb.net/>
#
# This program 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 2
# of the License, or (at your option) any later version.
#
# This program 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 this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
###########################################################################
include global.mk
###############################################################
## Handling of our samples
# documentation of the arguments:
# $(1) the source file name
# $(2) the object file name
define sample_object
$(2) : $(1)
$(CXX) $(CXXFLAGS) $(INCLUDEDIR) -c $$< -o $$@
$(DEPENDDIR)/$(2:.o=.d) : $(1)
@mkdir -p $$(dir $$@)
@$(SHELL) -ec '$(CXX) -M $(CXXFLAGS) $(INCLUDEDIR) $(EXTRA_IDIR) $$< \
| sed -e "s!$(notdir $(2))!$(2)!1" > $$@;'
include $(wildcard $(DEPENDDIR)/$(2:.o=.d))
endef
# documentation of the arguments:
# $(1) the sample name
# $(2) the list of source files
# $(3) the directory name
define sample
$(foreach source,$(2),$(eval $(call sample_object,$(source),$(source:.cpp=.o))))
$(1) : $(2:.cpp=.o) $(LIBDIR)/lib$(LIB).a $(LIBDIR)/libz.a | $(DEPENDDIR)/$(2:.cpp=.d)
$(CXX) $(LDFLAGS) $(2:.cpp=.o) -L./$(LIBDIR) $(LIBS) -o $$@
$(1)_clean :
@rm -f $(2:.cpp=.o) &> /dev/null || true
@rm -f $(1) &> /dev/null || true
@rm -f $(DIR)*.d
$(1)_samples_clean :
$(eval DIR=$(dir $(2)))
@rm -f $(DIR)core $(DIR).tmpfile $(DIR)tmp/*.*
@rm -f $(DIR)tmp/vtkData/*.* $(DIR)tmp/vtkData/data/*.* $(DIR)tmp/imageData/*.* $(DIR)tmp/gnuplotData/*.*
@rm -f $(DIR)*.d
CLEANTARGETS += $(1)_clean
SAMPLESCLEAN += $(1)_clean \
$(1)_samples_clean
SAMPLES += $(1)
endef
# define the target patterns necessary for the tests
# These are:
# * runTest -> executing a test binary
# * compileTest -> generate the object file for a test file
# * linkTest -> link the test object file with the test framework and libolb.a
define runTest
$(1) : $(2)
$(2)
.PHONY: $(1)
endef
define compileTest
$(OBJDIR)/$(1).o : $(1).cpp $(SHARED_TEST_HEADER)
@echo $$@
mkdir -p $$(dir $$@)
$(CXX) $(CXXFLAGS) $(INCLUDEDIR) -DPATH='"$$(realpath $$(dir $$<))/"' -DGTEST_HAS_PTHREAD=0 -I./$(UNIT_TEST_DIR) -I./tests/external/gtest/include -c $$< -o $$@
$(DEPENDDIR)/$(1).d : $(1).cpp
@mkdir -p $$(dir $$@)
@$(SHELL) -ec '$(CXX) -M $(CXXFLAGS) $(INCLUDEDIR) -I./$(UNIT_TEST_DIR) -I./tests/external/gtest/include $(EXTRA_IDIR) $$< \
| sed -e "s!$(notdir $(1)).o!$(OBJDIR)/$(1).o!1" > $$@;'
include $(wildcard $(DEPENDDIR)/$(1).d)
endef
define linkTest
$(1) : $(OBJDIR)/$(1).o $(DEPENDDIR)/$(1).d $(LIBDIR)/gtest_main.a $(LIBDIR)/lib$(LIB).a $(LIBDIR)/libz.a
$(CXX) $(LDFLAGS) $$< -L./$(LIBDIR) $(LIBS) -l:gtest_main.a -o $$@
$(1)_clean :
@rm -f $(1) &> /dev/null || true
@rm -f $(OBJDIR)/$(1).o &> /dev/null || true
@rm -f $(DEPENDDIR)/$(1).d &> /dev/null || true
CLEANTARGETS += $(1)_clean
endef
|