2014-10-23 21:39:15 +00:00
|
|
|
PLATFORM := $(shell uname -s)
|
2014-11-06 11:15:26 +00:00
|
|
|
MAKE = make
|
2014-10-23 21:39:15 +00:00
|
|
|
ifeq ($(PLATFORM),Darwin)
|
2014-10-29 10:38:21 +00:00
|
|
|
BUILD_DIR=darwin
|
2014-11-06 08:16:28 +00:00
|
|
|
else ifeq ($(PLATFORM),FreeBSD)
|
|
|
|
BUILD_DIR=freebsd
|
2014-11-16 20:29:50 +00:00
|
|
|
MAKE=gmake
|
2014-10-23 21:39:15 +00:00
|
|
|
else
|
2014-10-29 10:38:21 +00:00
|
|
|
DISTRO := $(shell if [ -f "/etc/redhat-release" ]; then echo "Centos"; fi)
|
|
|
|
ifeq ($(DISTRO),Centos)
|
2015-02-12 01:19:45 +00:00
|
|
|
BUILD_DIR := $(shell cat /etc/redhat-release | grep -o "release [6-7]" | sed 's/release /centos/g')
|
2014-10-29 10:38:21 +00:00
|
|
|
else
|
2015-01-30 22:55:28 +00:00
|
|
|
DISTRO := $(shell if [ -f "/etc/lsb-release" ]; then echo "Ubuntu"; fi)
|
|
|
|
BUILD_DIR := $(shell lsb_release -sc)
|
2014-10-29 10:38:21 +00:00
|
|
|
endif
|
2014-10-23 21:39:15 +00:00
|
|
|
endif
|
|
|
|
|
2015-02-10 05:57:45 +00:00
|
|
|
SYNC_DIR=build/sync
|
|
|
|
|
2014-11-09 00:55:19 +00:00
|
|
|
all: .setup
|
2015-01-31 11:09:30 +00:00
|
|
|
cd build/$(BUILD_DIR) && cmake ../.. && \
|
2014-11-12 20:52:04 +00:00
|
|
|
$(MAKE) --no-print-directory $(MAKEFLAGS)
|
2014-09-24 03:23:03 +00:00
|
|
|
|
2014-11-09 00:55:19 +00:00
|
|
|
debug: .setup
|
2015-01-31 11:09:30 +00:00
|
|
|
cd build/$(BUILD_DIR) && DEBUG=True cmake ../../ && \
|
2014-11-12 20:52:04 +00:00
|
|
|
$(MAKE) --no-print-directory $(MAKEFLAGS)
|
2014-10-27 16:34:13 +00:00
|
|
|
|
2015-02-11 03:18:56 +00:00
|
|
|
test_debug: .setup
|
|
|
|
cd build/$(BUILD_DIR)/sdk && DEBUG=True cmake ../../../ && \
|
2015-02-12 01:19:45 +00:00
|
|
|
$(MAKE) test --no-print-directory $(MAKEFLAGS)
|
2015-02-11 03:18:56 +00:00
|
|
|
|
2015-01-31 11:09:30 +00:00
|
|
|
analyze: .setup
|
|
|
|
cd build/$(BUILD_DIR) && ANALYZE=True cmake ../../ && \
|
|
|
|
$(MAKE) --no-print-directory $(MAKEFLAGS)
|
|
|
|
|
2015-01-31 11:26:28 +00:00
|
|
|
sanitize: .setup
|
|
|
|
cd build/$(BUILD_DIR) && SANITIZE=True cmake ../../ && \
|
|
|
|
$(MAKE) --no-print-directory $(MAKEFLAGS)
|
|
|
|
|
2015-02-03 05:21:36 +00:00
|
|
|
sdk: .setup
|
2015-02-10 01:31:54 +00:00
|
|
|
cd build/$(BUILD_DIR)/sdk && SDK=True cmake ../../../ && \
|
2015-02-03 05:21:36 +00:00
|
|
|
$(MAKE) --no-print-directory $(MAKEFLAGS)
|
|
|
|
|
|
|
|
test_sdk: .setup
|
2015-02-10 01:31:54 +00:00
|
|
|
cd build/$(BUILD_DIR)/sdk && SDK=True cmake ../../../ && \
|
2015-02-12 01:19:45 +00:00
|
|
|
$(MAKE) test --no-print-directory $(MAKEFLAGS)
|
2015-02-03 05:21:36 +00:00
|
|
|
|
2014-11-09 00:55:19 +00:00
|
|
|
deps: .setup
|
|
|
|
./tools/provision.sh build build/$(BUILD_DIR)
|
2014-09-24 03:23:03 +00:00
|
|
|
|
|
|
|
distclean:
|
2015-02-10 05:57:45 +00:00
|
|
|
rm -rf .sources build/$(BUILD_DIR) doxygen/html doxygen/latex $(SYNC_DIR)
|
2014-11-09 00:55:19 +00:00
|
|
|
ifeq ($(PLATFORM),Linux)
|
|
|
|
rm -rf build/linux
|
|
|
|
endif
|
2014-09-24 03:23:03 +00:00
|
|
|
|
2014-11-09 00:55:19 +00:00
|
|
|
.setup:
|
2015-02-05 01:31:06 +00:00
|
|
|
mkdir -p build/$(BUILD_DIR)/generated
|
|
|
|
mkdir -p build/$(BUILD_DIR)/sdk/generated
|
2014-11-09 00:55:19 +00:00
|
|
|
ifeq ($(PLATFORM),Linux)
|
|
|
|
ln -snf $(BUILD_DIR) build/linux
|
|
|
|
endif
|
|
|
|
|
2015-01-11 07:02:32 +00:00
|
|
|
package:
|
|
|
|
# Alias for packages (do not use CPack)
|
2015-01-31 11:09:30 +00:00
|
|
|
cd build/$(BUILD_DIR) && cmake ../../ && \
|
2015-01-11 07:02:32 +00:00
|
|
|
$(MAKE) packages --no-print-directory $(MAKEFLAGS)
|
|
|
|
|
2015-02-10 05:57:45 +00:00
|
|
|
sync:
|
|
|
|
mkdir -p $(SYNC_DIR)
|
|
|
|
rm -rf $(SYNC_DIR)/osquery*
|
|
|
|
@
|
|
|
|
@# merge the headers with the implementation files
|
|
|
|
cp -R osquery $(SYNC_DIR)
|
|
|
|
cp -R include/osquery $(SYNC_DIR)
|
|
|
|
cp -R build/$(BUILD_DIR)/sdk/generated/ $(SYNC_DIR)/osquery
|
|
|
|
cp osquery.thrift $(SYNC_DIR)/osquery/extensions
|
|
|
|
@
|
|
|
|
@# delete all of the old CMake files
|
|
|
|
find $(SYNC_DIR) -type f -name "CMakeLists.txt" -exec rm -f {} \;
|
|
|
|
@
|
|
|
|
@# make the targets file
|
|
|
|
mkdir -p $(SYNC_DIR)/code-analysis
|
|
|
|
cd $(SYNC_DIR)/code-analysis && SDK=True cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../../../
|
|
|
|
SDK=True
|
|
|
|
python tools/codegen/gentargets.py -i $(SYNC_DIR)/code-analysis/compile_commands.json > $(SYNC_DIR)/osquery/TARGETS
|
|
|
|
@
|
|
|
|
@# wrap it up in a tarball
|
|
|
|
cd $(SYNC_DIR) && tar -zcf osquery-sync.tar.gz osquery
|
|
|
|
@echo "The output file is located at $(SYNC_DIR)/osquery-sync.tar.gz"
|
|
|
|
|
2014-11-09 00:55:19 +00:00
|
|
|
%::
|
2014-11-12 20:52:04 +00:00
|
|
|
cd build/$(BUILD_DIR) && cmake ../.. && $(MAKE) --no-print-directory $@
|