-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
157 lines (131 loc) · 3.26 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
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
# Makefile -- Use this to build on *NIX systems.
# Options set on command line.
debug = not-set
mpi = not-set
shared = not-set
precision = not-set
verbose = not-set
prefix = not-set
sanitize = not-set
CC = not-set
CXX = not-set
FC = not-set
travis = not-set
# This proxies everything to the builddir cmake.
cputype = $(shell uname -m | sed "s/\\ /_/g")
systype = $(shell uname -s)
BUILDDIR := build/$(systype)-$(cputype)
CONFIG_FLAGS = -DUNIX=1 -Wno-dev
# Process configuration options.
# Should we skip PETSc tests (generally because we are running on a compile node at a supercomputing center, on which cannot run tests)?
# Note that we check for both SKIP_PETSC_TESTS or PETSC_SKIP_TESTS,
# since it is easy for users to confuse the order if only one is considered "correct".
ifdef SKIP_PETSC_TESTS
CONFIG_FLAGS += -DPETSC_SKIP_TESTS:BOOL=ON
endif
ifdef PETSC_SKIP_TESTS
CONFIG_FLAGS += -DPETSC_SKIP_TESTS:BOOL=ON
endif
# Travis-CI build
ifeq ($(travis), not-set)
CONFIG_FLAGS += -DTRAVIS_CI=0
else
CONFIG_FLAGS += -DTRAVIS_CI=1
endif
# Verbose builds?
ifeq ($(verbose), 1)
CONFIG_FLAGS += -DCMAKE_VERBOSE_MAKEFILE=1
endif
# MPI
ifeq ($(mpi), 1)
BUILDDIR := ${BUILDDIR}-mpi
CC = mpicc
CXX = mpicxx
FC = mpif90
CONFIG_FLAGS += -DHAVE_MPI=1
else
ifeq ($(CC), not-set)
CC = cc
endif
ifeq ($(CXX), not-set)
CXX = c++
endif
ifeq ($(FC), not-set)
FC = gfortran
endif
CONFIG_FLAGS += -DHAVE_MPI=0
endif
# Shared libs?
ifeq ($(shared), 1)
BUILDDIR := ${BUILDDIR}-shared
CONFIG_FLAGS += -DBUILD_SHARED_LIBS=ON
else
BUILDDIR := ${BUILDDIR}-static
CONFIG_FLAGS += -DBUILD_SHARED_LIBS=OFF
endif
# Precision.
ifneq ($(precision), not-set)
BUILDDIR := ${BUILDDIR}-$(precision)
else
BUILDDIR := ${BUILDDIR}-double
endif
BUILDDIR := ${BUILDDIR}-`basename ${CC}`
CONFIG_FLAGS += -DCC=${CC} -DCXX=${CXX}
ifneq ($(FC), )
CONFIG_FLAGS += -DFC=${FC}
endif
# Debugging symbols
ifeq ($(debug), not-set)
BUILDDIR := ${BUILDDIR}-Debug
CONFIG_FLAGS += -DCMAKE_BUILD_TYPE=Debug
else
ifeq ($(debug), 0)
BUILDDIR := ${BUILDDIR}-Release
CONFIG_FLAGS += -DCMAKE_BUILD_TYPE=Release
else
BUILDDIR := ${BUILDDIR}-Debug
CONFIG_FLAGS += -DCMAKE_BUILD_TYPE=Debug
endif
endif
# Installation prefix.
ifeq ($(prefix), not-set)
prefix = $(CURDIR)/local
endif
CONFIG_FLAGS += -DCMAKE_INSTALL_PREFIX:PATH=$(prefix)
# Special considerations for specific systems.
ifeq ($(systype), Darwin)
CONFIG_FLAGS += -DAPPLE=1
else
ifeq ($(systype), Linux)
CONFIG_FLAGS += -DLINUX=1
endif
endif
# Address sanitizer.
ifeq ($(sanitize), 1)
BUILDDIR := ${BUILDDIR}-AddressSanitizer
CONFIG_FLAGS += -DADDRESS_SANITIZER=1
endif
define run-config
@mkdir -p $(BUILDDIR)
@cd $(BUILDDIR) && cmake $(CURDIR) $(CONFIG_FLAGS)
endef
all test clean install:
@if [ ! -f $(BUILDDIR)/Makefile ]; then \
more INSTALL; \
else \
$(MAKE) -C $(BUILDDIR) $@ --no-print-directory $(MAKEFLAGS); \
fi
config: distclean
$(run-config)
distclean:
@rm -rf $(BUILDDIR)
@rm -rf ./local
stats:
@python tools/gather_stats.py
prepend-license:
@python tools/prepend_license.py
ctags-emacs :
@ctags -e -f ETAGS -R --exclude=.git --exclude=build
#dist:
# utils/mkdist.sh $(PKGNAME)
.PHONY: config distclean all clean install uninstall