forked from osquery/osquery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
150 lines (120 loc) · 4 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
PLATFORM := $(shell uname -s)
BASH_EXISTS := $(shell which bash)
SHELL := $(shell which bash)
ifneq ($(MAKECMDGOALS),deps)
GIT_EXISTS := $(shell which git)
endif
MAKE = make
ifeq ($(PLATFORM),FreeBSD)
MAKE = gmake
endif
DISTRO := $(shell . ./tools/lib.sh; _platform)
DISTRO_VERSION := $(shell . ./tools/lib.sh; _distro $(DISTRO))
ifeq ($(DISTRO),darwin)
ifeq ($(DISTRO_VERSION), 10.11)
BUILD_DIR = darwin
else
BUILD_DIR = darwin$(DISTRO_VERSION)
endif
else ifeq ($(DISTRO),freebsd)
BUILD_DIR = freebsd$(DISTRO_VERSION)
else
BUILD_DIR = $(DISTRO_VERSION)
endif
DEFINES := CTEST_OUTPUT_ON_FAILURE=1
.PHONY: docs build
all: .setup
cd build/$(BUILD_DIR) && cmake ../../ && \
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
docs: .setup
cd build && cmake ../ && \
$(DEFINES) $(MAKE) docs --no-print-directory $(MAKEFLAGS)
debug: .setup
cd build/debug_$(BUILD_DIR) && DEBUG=True cmake ../../ && \
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
test_debug: .setup
cd build/debug_$(BUILD_DIR) && DEBUG=True cmake ../../ && \
$(DEFINES) $(MAKE) test --no-print-directory $(MAKEFLAGS)
analyze: .setup
cd build/$(BUILD_DIR) && ANALYZE=True cmake ../../ && \
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
sanitize: .setup
cd build/$(BUILD_DIR) && SANITIZE=True cmake ../../ && \
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
sdk: .setup
cd build/$(BUILD_DIR) && SDK=True cmake ../../ && \
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
test_sdk: .setup
cd build/$(BUILD_DIR) && SDK=True cmake ../../ && \
$(DEFINES) $(MAKE) test --no-print-directory $(MAKEFLAGS)
debug_sdk: .setup
cd build/debug_$(BUILD_DIR) && SDK=True DEBUG=True cmake ../../ && \
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
test_debug_sdk: .setup
cd build/debug_$(BUILD_DIR) && SDK=True DEBUG=True cmake ../../ && \
$(DEFINES) $(MAKE) test --no-print-directory $(MAKEFLAGS)
build:
cd build/$(BUILD_DIR) && \
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
debug_build:
cd build/debug_$(BUILD_DIR) && \
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
test_build:
cd build/$(BUILD_DIR) && \
$(DEFINES) $(MAKE) test --no-print-directory $(MAKEFLAGS)
test_debug_build:
cd build/debug_$(BUILD_DIR) && \
$(DEFINES) $(MAKE) test --no-print-directory $(MAKEFLAGS)
deps: .setup
./tools/provision.sh build build/$(BUILD_DIR)
clean: .setup
cd build/$(BUILD_DIR) && cmake ../../ && \
$(DEFINES) $(MAKE) clean --no-print-directory $(MAKEFLAGS)
strip: .setup
cd build/$(BUILD_DIR) && find ./osquery -executable -type f | xargs strip
distclean:
rm -rf .sources build/$(BUILD_DIR) build/debug_$(BUILD_DIR) build/docs
ifeq ($(PLATFORM),Linux)
rm -rf build/linux
endif
.setup:
ifneq ($(MAKECMDGOALS),deps)
ifeq ($(GIT_EXISTS),)
@echo "Problem: cannot find 'git'"
@false
endif
endif
ifeq ($(BASH_EXISTS),)
@echo "Problem: cannot find 'bash'"
@false
endif
ifeq ($(DISTRO),unknown_version)
@echo Unknown, non-Redhat, non-Ubuntu based Linux distro
@false
endif
@mkdir -p build/docs
@mkdir -p build/$(BUILD_DIR)
@mkdir -p build/debug_$(BUILD_DIR)
ifeq ($(PLATFORM),Linux)
@ln -snf $(BUILD_DIR) build/linux
@ln -snf debug_$(BUILD_DIR) build/debug_linux
endif
package: .setup
# Alias for packages (do not use CPack)
cd build/$(BUILD_DIR) && PACKAGE=True cmake ../../ && \
$(DEFINES) $(MAKE) packages --no-print-directory $(MAKEFLAGS)
debug_package: .setup
cd build/debug_$(BUILD_DIR) && DEBUG=True PACKAGE=True cmake ../../ && \
$(DEFINES) $(MAKE) packages --no-print-directory $(MAKEFLAGS)
packages: .setup
cd build/$(BUILD_DIR) && PACKAGE=True cmake ../../ && \
$(DEFINES) $(MAKE) packages --no-print-directory $(MAKEFLAGS)
debug_packages:
cd build/debug_$(BUILD_DIR) && DEBUG=True PACKAGE=True cmake ../../ && \
$(DEFINES) $(MAKE) packages --no-print-directory $(MAKEFLAGS)
sync: .setup
cd build/$(BUILD_DIR) && PACKAGE=True cmake ../../ && \
$(DEFINES) $(MAKE) sync --no-print-directory $(MAKEFLAGS)
%::
cd build/$(BUILD_DIR) && cmake ../../ && \
$(DEFINES) $(MAKE) --no-print-directory $@