-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
71 lines (54 loc) · 1.79 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
# Copyright (C) 2014 - 2022 Red Hat, Inc.
#
# This file is part of cswrap.
#
# cswrap 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
# any later version.
#
# cswrap 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 cswrap. If not, see <http://www.gnu.org/licenses/>.
NUM_CPU ?= $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
CMAKE ?= cmake
CTEST ?= ctest -j$(NUM_CPU)
STATIC ?= OFF
SANITIZERS ?= OFF
CMAKE_BUILD_TYPE ?= RelWithDebInfo
.PHONY: all check clean static sanitizers distclean \
distcheck distcheck-static distcheck-sanitizers install
# define $(space) as " " to be used in $(subst ...)
space := $(subst ,, )
# generate ;-sepearated $(CTEST_CMD)
CTEST_CMD = $(subst $(space),;,$(CTEST) --output-on-failure)
all:
mkdir -p cswrap_build
cd cswrap_build && $(CMAKE) \
-DCMAKE_BUILD_TYPE="$(CMAKE_BUILD_TYPE)" \
-DCMAKE_CTEST_COMMAND="$(CTEST_CMD)" \
-DSTATIC_LINKING="$(STATIC)" \
-DSANITIZERS="$(SANITIZERS)" ..
$(MAKE) -sC cswrap_build -j$(NUM_CPU)
static:
$(MAKE) -s all STATIC=ON
sanitizers:
$(MAKE) -s all SANITIZERS=ON
check: all
cd cswrap_build && $(MAKE) check
clean:
if test -e cswrap_build/Makefile; then $(MAKE) clean -C cswrap_build; fi
distclean:
rm -rf cswrap_build
distcheck-static:
$(MAKE) -s distcheck STATIC=ON
distcheck-sanitizers:
$(MAKE) -s distcheck SANITIZERS=ON
distcheck: distclean
$(MAKE) -s check
install: all
$(MAKE) -C cswrap_build install