summaryrefslogtreecommitdiff
path: root/Makefile
blob: 686ae96c088736297711b918ef7cb26c29cca73c (plain)
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
#  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.

###########################################################################

## installing the configuration makefile

ROOT := .

include global.mk

CLEANTARGETS :=

SAMPLESCLEAN :=

LIB_OBJECTS := 

SAMPLES :=

TESTS :=

BENCHMARKS :=

EXTRA_IDIR :=

DEPS := $(shell find $(DEPENDDIR)/*/ -name *.d)

INCLUDEDIR := $(foreach d,$(INCLUDEDIRS),-I./$(d))

###########################################################################
## Building libolb.a and the  

all: compile

include $(addsuffix /module.mk, $(SUBDIRS))

include $(addsuffix /module.mk, $(EXAMPLEDIRS))

include $(addsuffix /module.mk, $(TESTDIRS))

include $(foreach dependency_file,$(LIB_OBJECTS:.o=.d), $(wildcard $(subst $(OBJDIR)/,$(DEPENDDIR)/,$(dependency_file))))

compile: lib

$(OBJDIR)/%.o: %.cpp | $(DEPENDDIR)/%.d
	@mkdir -p $(dir $@)
	$(CXX) $(CXXFLAGS) -DTIXML_USE_STL $(INCLUDEDIR) -c $< -o $@

lib: $(LIBDIR)/lib$(LIB).a $(LIBDIR)/libz.a

$(LIBDIR)/lib$(LIB).a: $(LIB_OBJECTS)
	@mkdir -p $(LIBDIR)
	@$(ARPRG) -rusv $(LIBDIR)/lib$(LIB).a $(LIB_OBJECTS) > /dev/null

.PRECIOUS: $(DEPENDDIR)/%.d

$(DEPENDDIR)/%.d : %.cpp
	@mkdir -p $(dir $@)
	@$(SHELL) -ec '$(CXX) -M $(CXXFLAGS) $(INCLUDEDIR) $(EXTRA_IDIR) $< \
	    | sed -e "s!$(basename $(notdir $@))\.o!$(OBJDIR)/$*.o!1" > $@;'

###########################################################################
## removing generated files

cleansamples: $(SAMPLESCLEAN)

cleanbuild cleanlib:
	@rm -f $(LIB_OBJECTS) &> /dev/null || true
	@rm -f $(LIBDIR)/lib$(LIB).a &> /dev/null || true

clean: $(CLEANTARGETS) cleanlib
	@rm -r -f $(shell find $(DEPENDDIR) -name *.d) &> /dev/null || true


## handling of the examples

samples: lib $(SAMPLES)

############################yy###############################################
## user guide documentation

userguide:
	@cd doc/userGuide/; \
	latexmk -pdf -silent -f olb-ug.tex

###########################################################################
## doxygen documentation

doxygen:
	doxygen doc/DoxygenConfig

###########################################################################
## checking whether to automatically install the git hook
GITDEPEND := $(shell test -d ".git" && echo .git/hooks/pre-commit)

ifneq ($(strip $(GITDEPEND)),)
.git/hooks/pre-commit: hooks/pre-commit
	@echo Installing git hook
	cp hooks/pre-commit .git/hooks/pre-commit
	chmod +x .git/hooks/pre-commit
endif