2014-10-23 21:39:15 +00:00
|
|
|
PLATFORM := $(shell uname -s)
|
2016-01-12 03:32:33 +00:00
|
|
|
BASH_EXISTS := $(shell which bash)
|
2015-05-05 20:55:49 +00:00
|
|
|
SHELL := $(shell which bash)
|
2016-10-24 09:31:22 +00:00
|
|
|
SOURCE_DIR := $(shell pwd)
|
2015-04-01 04:18:56 +00:00
|
|
|
|
2016-01-30 02:31:51 +00:00
|
|
|
ifneq ($(MAKECMDGOALS),deps)
|
|
|
|
GIT_EXISTS := $(shell which git)
|
|
|
|
endif
|
|
|
|
|
2015-05-05 20:55:49 +00:00
|
|
|
MAKE = make
|
|
|
|
ifeq ($(PLATFORM),FreeBSD)
|
|
|
|
MAKE = gmake
|
|
|
|
endif
|
2015-04-03 07:44:27 +00:00
|
|
|
|
|
|
|
DISTRO := $(shell . ./tools/lib.sh; _platform)
|
|
|
|
DISTRO_VERSION := $(shell . ./tools/lib.sh; _distro $(DISTRO))
|
2016-11-16 03:41:53 +00:00
|
|
|
DARWIN_BUILD := 10.12
|
2015-04-03 07:44:27 +00:00
|
|
|
ifeq ($(DISTRO),darwin)
|
2016-11-03 03:31:16 +00:00
|
|
|
BUILD_DIR = darwin$(DISTRO_VERSION)
|
2015-09-24 23:12:26 +00:00
|
|
|
else ifeq ($(DISTRO),freebsd)
|
|
|
|
BUILD_DIR = freebsd$(DISTRO_VERSION)
|
2014-10-23 21:39:15 +00:00
|
|
|
else
|
2015-04-03 07:44:27 +00:00
|
|
|
BUILD_DIR = $(DISTRO_VERSION)
|
2014-10-23 21:39:15 +00:00
|
|
|
endif
|
|
|
|
|
2016-07-31 18:32:31 +00:00
|
|
|
ifneq ($(OSQUERY_DEPS),)
|
|
|
|
DEPS_DIR = $(OSQUERY_DEPS)
|
|
|
|
else
|
|
|
|
DEPS_DIR = /usr/local/osquery
|
|
|
|
endif
|
2016-11-10 16:14:26 +00:00
|
|
|
|
2016-08-15 08:33:17 +00:00
|
|
|
PATH_SET := PATH="$(DEPS_DIR)/bin:/usr/local/bin:$(PATH)"
|
|
|
|
CMAKE := $(PATH_SET) CXXFLAGS="-L$(DEPS_DIR)/lib" cmake ../../
|
2016-10-24 09:31:22 +00:00
|
|
|
CTEST := $(PATH_SET) ctest ../../
|
2016-08-29 19:37:04 +00:00
|
|
|
FORMAT_COMMAND := python tools/formatting/git-clang-format.py \
|
|
|
|
"--commit" "master" "-f" "--style=file"
|
2016-07-31 18:32:31 +00:00
|
|
|
|
2016-10-24 09:31:22 +00:00
|
|
|
ANALYSIS := ${SOURCE_DIR}/tools/analysis
|
2016-10-25 00:12:37 +00:00
|
|
|
DEFINES := CTEST_OUTPUT_ON_FAILURE=1 \
|
2016-10-24 09:31:22 +00:00
|
|
|
LSAN_OPTIONS="detect_container_overflow=0 \
|
|
|
|
suppressions=${ANALYSIS}/lsan.supp" \
|
|
|
|
ASAN_OPTIONS="suppressions=${ANALYSIS}/asan.supp" \
|
2017-02-04 06:58:09 +00:00
|
|
|
TSAN_OPTIONS="suppressions=${ANALYSIS}/tsan.supp,second_deadlock_stack=1"
|
2016-10-24 09:31:22 +00:00
|
|
|
|
2015-04-21 22:40:02 +00:00
|
|
|
.PHONY: docs build
|
2015-03-02 04:08:05 +00:00
|
|
|
|
2014-11-09 00:55:19 +00:00
|
|
|
all: .setup
|
2016-11-10 16:14:26 +00:00
|
|
|
ifeq ($(wildcard $(DEPS_DIR)/.*),)
|
|
|
|
@echo "-- Warning! Cannot find dependencies install directory: $(DEPS_DIR)"
|
|
|
|
@echo "-- Have you run: make deps?"
|
|
|
|
@false
|
|
|
|
endif
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/$(BUILD_DIR) && $(CMAKE) && \
|
2015-03-02 04:08:05 +00:00
|
|
|
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
|
2014-09-24 03:23:03 +00:00
|
|
|
|
2015-03-09 00:00:14 +00:00
|
|
|
docs: .setup
|
2017-01-07 21:31:12 +00:00
|
|
|
@mkdir -p docs
|
|
|
|
@cd build/docs && DOCS=True $(CMAKE) && \
|
2015-03-09 00:00:14 +00:00
|
|
|
$(DEFINES) $(MAKE) docs --no-print-directory $(MAKEFLAGS)
|
|
|
|
|
2016-08-15 08:33:17 +00:00
|
|
|
format_master:
|
2016-08-29 19:37:04 +00:00
|
|
|
@echo "[+] clang-format (`$(PATH_SET) which clang-format`) version: `$(PATH_SET) clang-format --version`"
|
2016-08-15 08:33:17 +00:00
|
|
|
@$(PATH_SET) $(FORMAT_COMMAND)
|
|
|
|
|
2014-11-09 00:55:19 +00:00
|
|
|
debug: .setup
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/debug_$(BUILD_DIR) && DEBUG=True $(CMAKE) && \
|
2016-01-12 03:32:33 +00:00
|
|
|
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
|
2014-10-27 16:34:13 +00:00
|
|
|
|
2015-02-11 03:18:56 +00:00
|
|
|
test_debug: .setup
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/debug_$(BUILD_DIR) && DEBUG=True $(CMAKE) && \
|
2015-04-01 04:18:56 +00:00
|
|
|
$(DEFINES) $(MAKE) test --no-print-directory $(MAKEFLAGS)
|
2015-02-11 03:18:56 +00:00
|
|
|
|
2015-01-31 11:09:30 +00:00
|
|
|
analyze: .setup
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/$(BUILD_DIR) && ANALYZE=True $(CMAKE) && \
|
2015-04-01 04:18:56 +00:00
|
|
|
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
|
2015-01-31 11:09:30 +00:00
|
|
|
|
2015-01-31 11:26:28 +00:00
|
|
|
sanitize: .setup
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/$(BUILD_DIR) && SANITIZE=True $(CMAKE) && \
|
2015-04-01 04:18:56 +00:00
|
|
|
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
|
2015-01-31 11:26:28 +00:00
|
|
|
|
2016-09-14 03:37:31 +00:00
|
|
|
fuzz: .setup
|
|
|
|
@echo "[+] zzuf (`$(PATH_SET) which zzuf`) version: `$(PATH_SET) zzuf -V | head -n 1`"
|
|
|
|
@$(PATH_SET) python tools/analysis/fuzz.py
|
|
|
|
|
2015-02-03 05:21:36 +00:00
|
|
|
sdk: .setup
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/$(BUILD_DIR) && SDK=True $(CMAKE) && \
|
2015-04-01 04:18:56 +00:00
|
|
|
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
|
2015-02-03 05:21:36 +00:00
|
|
|
|
|
|
|
test_sdk: .setup
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/$(BUILD_DIR) && SDK=True $(CMAKE) && \
|
2015-04-01 04:18:56 +00:00
|
|
|
$(DEFINES) $(MAKE) test --no-print-directory $(MAKEFLAGS)
|
2015-02-03 05:21:36 +00:00
|
|
|
|
2015-02-19 01:19:45 +00:00
|
|
|
debug_sdk: .setup
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/debug_$(BUILD_DIR) && SDK=True DEBUG=True $(CMAKE) && \
|
2015-04-01 04:18:56 +00:00
|
|
|
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
|
2015-02-19 01:19:45 +00:00
|
|
|
|
|
|
|
test_debug_sdk: .setup
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/debug_$(BUILD_DIR) && SDK=True DEBUG=True $(CMAKE) && \
|
2015-04-01 04:18:56 +00:00
|
|
|
$(DEFINES) $(MAKE) test --no-print-directory $(MAKEFLAGS)
|
2015-02-19 01:19:45 +00:00
|
|
|
|
2016-08-15 08:33:17 +00:00
|
|
|
check:
|
2016-08-29 19:37:04 +00:00
|
|
|
@echo "[+] cppcheck (`$(PATH_SET) which cppcheck`) version: `$(PATH_SET) cppcheck --version`"
|
2016-08-15 08:33:17 +00:00
|
|
|
@$(PATH_SET) cppcheck --quiet --enable=all --error-exitcode=0 \
|
|
|
|
-I ./include ./osquery
|
2016-08-17 23:00:30 +00:00
|
|
|
@# We want check to produce an error if there are critical issues.
|
2016-08-15 08:33:17 +00:00
|
|
|
@echo ""
|
|
|
|
@$(PATH_SET) cppcheck --quiet --enable=warning --error-exitcode=1 \
|
|
|
|
-I ./include ./osquery
|
2015-04-21 22:40:02 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2014-11-09 00:55:19 +00:00
|
|
|
deps: .setup
|
2016-07-31 18:32:31 +00:00
|
|
|
./tools/provision.sh build $(BUILD_DIR)
|
2014-09-24 03:23:03 +00:00
|
|
|
|
2016-12-01 18:20:30 +00:00
|
|
|
sysprep: .setup
|
|
|
|
@SKIP_DISTRO_MAIN=0 ./tools/provision.sh build $(BUILD_DIR)
|
|
|
|
|
|
|
|
build_deps: .setup
|
|
|
|
@OSQUERY_BUILD_DEPS=1 SKIP_DISTRO_MAIN=0 make deps
|
|
|
|
|
2015-05-05 20:55:49 +00:00
|
|
|
clean: .setup
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/$(BUILD_DIR) && $(CMAKE) && \
|
2015-05-05 20:55:49 +00:00
|
|
|
$(DEFINES) $(MAKE) clean --no-print-directory $(MAKEFLAGS)
|
|
|
|
|
2016-03-05 04:41:06 +00:00
|
|
|
strip: .setup
|
|
|
|
cd build/$(BUILD_DIR) && find ./osquery -executable -type f | xargs strip
|
|
|
|
|
2014-09-24 03:23:03 +00:00
|
|
|
distclean:
|
2016-11-07 05:56:54 +00:00
|
|
|
rm -rf .sources build/$(BUILD_DIR) build/debug_$(BUILD_DIR) build/docs build/wiki
|
2014-11-09 00:55:19 +00:00
|
|
|
ifeq ($(PLATFORM),Linux)
|
2016-11-03 03:31:16 +00:00
|
|
|
rm -rf build/linux build/debug_linux
|
|
|
|
endif
|
|
|
|
ifeq ($(PLATFORM),Darwin)
|
|
|
|
rm -rf build/darwin build/debug_darwin
|
2014-11-09 00:55:19 +00:00
|
|
|
endif
|
2014-09-24 03:23:03 +00:00
|
|
|
|
2016-07-31 18:32:31 +00:00
|
|
|
depsclean:
|
|
|
|
./tools/provision.sh clean $(BUILD_DIR)
|
|
|
|
|
2014-11-09 00:55:19 +00:00
|
|
|
.setup:
|
2016-01-30 02:31:51 +00:00
|
|
|
ifneq ($(MAKECMDGOALS),deps)
|
2016-01-12 03:32:33 +00:00
|
|
|
ifeq ($(GIT_EXISTS),)
|
|
|
|
@echo "Problem: cannot find 'git'"
|
2016-01-30 02:31:51 +00:00
|
|
|
@false
|
|
|
|
endif
|
2016-01-12 03:32:33 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(BASH_EXISTS),)
|
|
|
|
@echo "Problem: cannot find 'bash'"
|
2016-01-30 02:31:51 +00:00
|
|
|
@false
|
2016-01-12 03:32:33 +00:00
|
|
|
endif
|
|
|
|
|
2015-04-03 07:44:27 +00:00
|
|
|
ifeq ($(DISTRO),unknown_version)
|
2015-04-01 04:18:56 +00:00
|
|
|
@echo Unknown, non-Redhat, non-Ubuntu based Linux distro
|
2016-01-30 02:31:51 +00:00
|
|
|
@false
|
2016-11-16 03:41:53 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(DISTRO),darwin)
|
|
|
|
ifneq ($(DISTRO_VERSION),$(DARWIN_BUILD))
|
|
|
|
@echo "-- Warning! The only Apple OS supported for building is $(DARWIN_BUILD)"
|
|
|
|
@echo "-- Note: Installing and running osquery is supported on versions 10.9+"
|
|
|
|
endif
|
2015-04-01 04:18:56 +00:00
|
|
|
endif
|
2015-08-27 19:55:43 +00:00
|
|
|
@mkdir -p build/docs
|
2015-04-15 03:58:25 +00:00
|
|
|
@mkdir -p build/$(BUILD_DIR)
|
|
|
|
@mkdir -p build/debug_$(BUILD_DIR)
|
2014-11-09 00:55:19 +00:00
|
|
|
ifeq ($(PLATFORM),Linux)
|
2016-01-12 03:32:33 +00:00
|
|
|
@ln -snf $(BUILD_DIR) build/linux
|
|
|
|
@ln -snf debug_$(BUILD_DIR) build/debug_linux
|
2016-11-03 03:31:16 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(PLATFORM),Darwin)
|
|
|
|
@ln -sfn $(BUILD_DIR) build/darwin
|
|
|
|
@ln -sfn debug_$(BUILD_DIR) build/debug_darwin
|
2014-11-09 00:55:19 +00:00
|
|
|
endif
|
2016-09-21 17:37:07 +00:00
|
|
|
@export PYTHONPATH="$DEPS_DIR/lib/python2.7/site-packages"
|
2016-07-31 18:32:31 +00:00
|
|
|
|
2015-05-04 21:15:19 +00:00
|
|
|
package: .setup
|
2015-01-11 07:02:32 +00:00
|
|
|
# Alias for packages (do not use CPack)
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/$(BUILD_DIR) && PACKAGE=True $(CMAKE) && \
|
2016-08-15 08:33:17 +00:00
|
|
|
$(DEFINES) $(MAKE) packages/fast --no-print-directory $(MAKEFLAGS)
|
2015-05-04 21:15:19 +00:00
|
|
|
|
2016-02-02 00:42:37 +00:00
|
|
|
debug_package: .setup
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/debug_$(BUILD_DIR) && DEBUG=True PACKAGE=True $(CMAKE) && \
|
2016-02-02 00:42:37 +00:00
|
|
|
$(DEFINES) $(MAKE) packages --no-print-directory $(MAKEFLAGS)
|
|
|
|
|
2015-05-04 21:15:19 +00:00
|
|
|
packages: .setup
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/$(BUILD_DIR) && PACKAGE=True $(CMAKE) && \
|
2016-08-15 08:33:17 +00:00
|
|
|
$(DEFINES) $(MAKE) packages/fast --no-print-directory $(MAKEFLAGS)
|
2015-01-11 07:02:32 +00:00
|
|
|
|
2016-10-24 09:31:22 +00:00
|
|
|
debug_packages: .setup
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/debug_$(BUILD_DIR) && DEBUG=True PACKAGE=True $(CMAKE) && \
|
2016-02-02 00:42:37 +00:00
|
|
|
$(DEFINES) $(MAKE) packages --no-print-directory $(MAKEFLAGS)
|
|
|
|
|
2015-05-05 20:55:49 +00:00
|
|
|
sync: .setup
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/$(BUILD_DIR) && PACKAGE=True $(CMAKE) && \
|
2015-05-05 20:55:49 +00:00
|
|
|
$(DEFINES) $(MAKE) sync --no-print-directory $(MAKEFLAGS)
|
|
|
|
|
2016-10-24 09:31:22 +00:00
|
|
|
test:
|
|
|
|
@cd build/$(BUILD_DIR) && $(DEFINES) $(CTEST)
|
2016-10-25 00:12:37 +00:00
|
|
|
|
2014-11-09 00:55:19 +00:00
|
|
|
%::
|
2016-07-31 18:32:31 +00:00
|
|
|
@cd build/$(BUILD_DIR) && $(CMAKE) && \
|
2015-04-01 04:18:56 +00:00
|
|
|
$(DEFINES) $(MAKE) --no-print-directory $@
|