osquery-1/Makefile

190 lines
5.4 KiB
Makefile
Raw Normal View History

PLATFORM := $(shell uname -s)
BASH_EXISTS := $(shell which bash)
2015-05-05 20:55:49 +00:00
SHELL := $(shell which bash)
SOURCE_DIR := $(shell pwd)
2015-04-01 04:18:56 +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
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
2016-07-31 18:32:31 +00:00
ifneq ($(OSQUERY_DEPS),)
DEPS_DIR = $(OSQUERY_DEPS)
else
DEPS_DIR = /usr/local/osquery
endif
PATH_SET := PATH="$(DEPS_DIR)/bin:/usr/local/bin:$(PATH)"
CMAKE := $(PATH_SET) CXXFLAGS="-L$(DEPS_DIR)/lib" cmake ../../
CTEST := $(PATH_SET) ctest ../../
DOCS_CMAKE := $(PATH_SET) CXXFLAGS="-L$(DEPS_DIR)/lib" cmake ../
FORMAT_COMMAND := python tools/formatting/git-clang-format.py \
"--commit" "master" "-f" "--style=file"
2016-07-31 18:32:31 +00:00
ANALYSIS := ${SOURCE_DIR}/tools/analysis
DEFINES := CTEST_OUTPUT_ON_FAILURE=1 \
LSAN_OPTIONS="detect_container_overflow=0 \
suppressions=${ANALYSIS}/lsan.supp" \
ASAN_OPTIONS="suppressions=${ANALYSIS}/asan.supp" \
TSAN_OPTIONS="suppressions=${ANALYSIS}/tsan.supp"
2015-04-21 22:40:02 +00:00
.PHONY: docs build
2014-11-09 00:55:19 +00:00
all: .setup
2016-07-31 18:32:31 +00:00
@cd build/$(BUILD_DIR) && $(CMAKE) && \
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
2015-03-09 00:00:14 +00:00
docs: .setup
@cd build && DOCS=True $(DOCS_CMAKE) && \
2015-03-09 00:00:14 +00:00
$(DEFINES) $(MAKE) docs --no-print-directory $(MAKEFLAGS)
format_master:
@echo "[+] clang-format (`$(PATH_SET) which clang-format`) version: `$(PATH_SET) clang-format --version`"
@$(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) && \
$(DEFINES) $(MAKE) --no-print-directory $(MAKEFLAGS)
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
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: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
check:
@echo "[+] cppcheck (`$(PATH_SET) which cppcheck`) version: `$(PATH_SET) cppcheck --version`"
@$(PATH_SET) cppcheck --quiet --enable=all --error-exitcode=0 \
-I ./include ./osquery
@# We want check to produce an error if there are critical issues.
@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)
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
distclean:
2015-04-24 20:52:17 +00:00
rm -rf .sources build/$(BUILD_DIR) build/debug_$(BUILD_DIR) build/docs
2014-11-09 00:55:19 +00:00
ifeq ($(PLATFORM),Linux)
rm -rf build/linux
endif
2016-07-31 18:32:31 +00:00
depsclean:
./tools/provision.sh clean $(BUILD_DIR)
2014-11-09 00:55:19 +00:00
.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)
2015-04-01 04:18:56 +00:00
@echo Unknown, non-Redhat, non-Ubuntu based Linux distro
@false
2015-04-01 04:18:56 +00:00
endif
@mkdir -p build/docs
@mkdir -p build/$(BUILD_DIR)
@mkdir -p build/debug_$(BUILD_DIR)
2014-11-09 00:55:19 +00:00
ifeq ($(PLATFORM),Linux)
@ln -snf $(BUILD_DIR) build/linux
@ln -snf debug_$(BUILD_DIR) build/debug_linux
2014-11-09 00:55:19 +00:00
endif
@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) && \
$(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) && \
$(DEFINES) $(MAKE) packages/fast --no-print-directory $(MAKEFLAGS)
2015-01-11 07:02:32 +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)
test:
@cd build/$(BUILD_DIR) && $(DEFINES) $(CTEST)
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 $@