Commit 46188a56 authored by Michael Ott's avatar Michael Ott
Browse files

Move everything related to 3rd party dependencies to dependencies.mk

parent d1da8c12
include config.mk
MAKEFILENAME := $(lastword $(MAKEFILE_LIST))
SUB_DIRS = lib collectagent dcdbpusher analytics tools scripts
SOURCEFORGE_MROR = vorboss
CASSANDRA_VERSION = 3.0.18
MOSQUITTO_VERSION = 1.5.5
BOOST_VERSION = 1.70.0
OPENSSL_VERSION = 1.1.1c
CPPDRV_VERSION = 2.10.0
LIBUV_VERSION = 1.24.0
BACNET-STACK_VERSION = 0.8.6
FREEIPMI_VERSION = 1.6.3
GCRYPT_VERSION = 1.8.4
GPG-ERROR_VERSION = 1.36
NET-SNMP_VERSION = 5.8
OPENCV_VERSION = 4.1.0
BOOST_VERSION_U = $(subst .,_,$(BOOST_VERSION))
DISTFILES = apache-cassandra-$(CASSANDRA_VERSION).tar.gz;http://archive.apache.org/dist/cassandra/$(CASSANDRA_VERSION)/apache-cassandra-$(CASSANDRA_VERSION)-bin.tar.gz \
mosquitto-$(MOSQUITTO_VERSION).tar.gz;http://mosquitto.org/files/source/mosquitto-$(MOSQUITTO_VERSION).tar.gz \
boost_$(BOOST_VERSION_U).tar.gz;http://$(SOURCEFORGE_MROR).dl.sourceforge.net/project/boost/boost/$(BOOST_VERSION)/boost_$(BOOST_VERSION_U).tar.gz \
openssl-$(OPENSSL_VERSION).tar.gz;https://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz \
libuv-v$(LIBUV_VERSION).tar.gz;https://dist.libuv.org/dist/v$(LIBUV_VERSION)/libuv-v$(LIBUV_VERSION).tar.gz \
cpp-driver-$(CPPDRV_VERSION).tar.gz;https://github.com/datastax/cpp-driver/archive/$(CPPDRV_VERSION).tar.gz \
bacnet-stack-$(BACNET-STACK_VERSION).tgz;https://downloads.sourceforge.net/project/bacnet/bacnet-stack/bacnet-stack-$(BACNET-STACK_VERSION)/bacnet-stack-$(BACNET-STACK_VERSION).tgz \
libgpg-error-$(GPG-ERROR_VERSION).tar.gz;https://gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-$(GPG-ERROR_VERSION).tar.gz \
libgcrypt-$(GCRYPT_VERSION).tar.gz;https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-$(GCRYPT_VERSION).tar.gz \
freeipmi-$(FREEIPMI_VERSION).tar.gz;http://ftp.gnu.org/gnu/freeipmi/freeipmi-$(FREEIPMI_VERSION).tar.gz \
net-snmp-$(NET-SNMP_VERSION).tar.gz;https://sourceforge.net/projects/net-snmp/files/net-snmp/$(NET-SNMP_VERSION)/net-snmp-$(NET-SNMP_VERSION).tar.gz/download \
opencv-$(OPENCV_VERSION).tar.gz;https://github.com/opencv/opencv/archive/$(OPENCV_VERSION).tar.gz
DISTFILES_HASHES = apache-cassandra-3.0.18.tar.gz|94dbdaa58b366166c53f881b8e266bc8;\
mosquitto-1.5.5.tar.gz|a17dffc6f63b2a4ab2eb5c51139e60e9;\
boost_1_70_0.tar.gz|fea771fe8176828fabf9c09242ee8c26;\
openssl-1.1.1c.tar.gz|15e21da6efe8aa0e0768ffd8cd37a5f6;\
cpp-driver-2.10.0.tar.gz|6d15dd2cccd2efd1fdc86089d26971d0;\
libuv-v1.24.0.tar.gz|90320330757253b07404d2a97f59c66b;\
bacnet-stack-0.8.6.tgz|544ebd42ed959deb2213209b66bbc460;\
libgcrypt-1.8.4.tar.gz|433ab0a47b25994fa92b165db185f174;\
libgpg-error-1.36.tar.gz|f2283e22959ef71f44d8be3d0987a96b;\
freeipmi-1.6.3.tar.gz|b2d97e20db9b81b460ce1b9dad5bf54e;\
net-snmp-5.8.tar.gz|63bfc65fbb86cdb616598df1aff6458a; \
opencv-4.1.0.tar.gz|b80c59c7e4feee6a00608315e02b0b73;
include common.mk
CASSANDRA_CLUSTER_NAME = Datacenter Monitor Database
CASSANDRA_FLUSH_LARGEST_MEMTABLES_AT = 0.5
CASSANDRA_REDUCE_CACHE_SIZES_AT = 0.6
CASSANDRA_REDUCE_CACHE_CAPACITY_TO = 0.4
CASSANDRA_PARTITIONER = org.apache.cassandra.dht.ByteOrderedPartitioner
CASSANDRA_COMMITLOG_TOTAL_SPACE_IN_MB = 256
CASSANDRA_COMMITLOG_SEGMENT_SIZE_IN_MB = 16
CASSANDRA_TOMBSTONE_WARN_THRESHOLD = 100000
CASSANDRA_TOMBSTONE_FAILURE_THRESHOLD = 10000000
# If cross-compiling for ARM, adjust the build settings
ifeq ("$(ARCH)", "arm")
OPENSSL_TARGET = "linux-generic32"
else
OPENSSL_TARGET = $(if $(findstring $(shell uname),Darwin),"darwin64-x86_64-cc","linux-x86_64")
endif
PUBHEADERS = dcdbdaemon.h
.PHONY : info all clean cleanall cleandoc distclean deps depsinstall $(SUB_DIRS) doc
FULL_CC = $(shell which $(CC))
FULL_CXX = $(shell which $(CXX))
.PHONY : info all clean cleanall cleandoc distclean check-cross-compile deps depsinstall $(SUB_DIRS) doc
all: deps $(foreach s,$(SUB_DIRS),$(s)-build)
include dependencies.mk
info:
@echo ""
......@@ -99,14 +34,12 @@ info:
@echo "For ARM cross compilation, please type:"
@echo " make ARCH=arm CROSS_COMPILE=<X> all"
@echo "where <X> is your cross copmlier prefix ( e.g. arm-linux-gnueabihf- )"
@$(foreach f,$(DISTFILES), echo "$(f)";)
clean:
@$(foreach s,$(SUB_DIRS),echo "Cleaning $(s)..." && make -C $(s) clean && echo;)
cleandeps:
@$(foreach f,$(DISTFILESPATHS),echo "Cleaning $(f)..." && rm -rf $(DCDBDEPSPATH)/$(f) && echo;)
@$(foreach f,cpp-netlib,echo "Cleaning $(f)..." && rm -rf $(DCDBDEPSPATH)/$(f)_build && echo;)
@$(foreach f,$(DISTFILESPATHS_FULL),echo "Cleaning $(f)..." && rm -rf $(DCDBDEPSPATH)/$(f) && echo;)
cleandoc:
@echo "Cleaning doc/html..."
......@@ -130,8 +63,6 @@ doc:
@cd doc/ && doxygen Doxyfile && ln -sf ./html/index.html ./dcdb_documentation.html
@echo "Generated docs into doc/html"
all: check-cross-compile deps $(foreach s,$(SUB_DIRS),$(s)-build)
install: depsinstall $(SUB_DIRS)
@cd common/include && install $(PUBHEADERS) $(DCDBDEPLOYPATH)/include/dcdb && cd ..
@echo DONE
......@@ -140,163 +71,6 @@ deps: $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.built)
depsinstall: $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.installed)
$(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.built: $(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.patched
@echo "Building OpenSSL library..."
cd $(@D) && ./Configure shared --prefix=$(DCDBDEPLOYPATH) $(OPENSSL_TARGET)
cd $(@D) && make && touch $(@)
$(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.installed: $(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.built | $(DCDBDEPLOYPATH)
@echo "Installing OpenSSL library..."
cd $(@D) && make install_sw && touch $(@)
$(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.built: $(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.patched
@echo "Building Mosquitto library...";
mkdir -p $(@D)/build;
cd $(@D)/build && \
CC=$(FULL_CC) CXX=$(FULL_CXX) cmake $(CMAKE_CROSS_FLAGS) \
-DWITH_SRV=no \
-DWITH_TLS=yes \
-DWITH_TLS_PSK=yes \
-DDOCUMENTATION=no \
-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
$(@D) && \
make -j $(MAKETHREADS) && \
touch $(@)
$(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.installed: $(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.built | $(DCDBDEPLOYPATH)
@echo "Installing Mosquitto library..."
cd $(@D)/build && make install && touch $(@)
$(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.built: $(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.patched
@echo "Building Boost..."
@ if [ "$(ARCH)" = "arm" ]; then \
echo " using gcc : arm : $(CROSS_COMPILE)g++ ; " > $(@D)/tools/build/src/user-config.jam; \
fi
cd $(@D) && ./bootstrap.sh --prefix=$(DCDBDEPLOYPATH) --with-libraries=atomic,chrono,date_time,exception,filesystem,log,program_options,random,regex,system,thread,timer && \
./b2 stage && touch $(@)
$(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.installed: $(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.built
cd $(@D) && ./b2 -j $(MAKETHREADS) --no-cmake-config install && touch $(@)
$(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.built: $(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.patched
@echo "Building libuv..."
mkdir -p $(@D)/build
cd $(@D)/build && \
CC=$(FULL_CC) CXX=$(FULL_CXX) cmake $(CMAKE_CROSS_FLAGS) \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
.. && \
make -j $(MAKETHREADS) && touch $(@)
$(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.installed: $(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.built | $(DCDBDEPLOYPATH)
@echo "Installing libuv..."
cd $(@D)/build && make install && touch $(@)
$(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.built: $(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.patched $(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.built $(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.built
@echo "Building cpp-driver..."
mkdir -p $(@D)/build
cd $(@D)/build && \
CC=$(FULL_CC) CXX=$(FULL_CXX) cmake $(CMAKE_CROSS_FLAGS) \
-DOPENSSL_ROOT_DIR=$(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION) \
-DLIBUV_ROOT_DIR=$(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION) \
-DCASS_BUILD_EXAMPLES=NO \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
-DCMAKE_EXE_LINKER_FLAGS="-L$(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/stage/lib -lboost_random" \
-DCMAKE_SHARED_LINKER_FLAGS="-L$(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/stage/lib -lboost_random" \
.. && \
make -j $(MAKETHREADS) && touch $(@)
$(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.installed: $(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.built | $(DCDBDEPLOYPATH)
@echo "Installing cpp-driver..."
cd $(@D)/build && make install && touch $(@)
$(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.built: $(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.patched
@touch $(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.built
$(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.installed: $(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.built | $(DCDBDEPLOYPATH)
@echo ""
@echo "Staging and configuring Cassandra..."
@rsync -rlptD $(@D)/ $(DCDBDEPLOYPATH)/cassandra
@$(eval P := $(shell echo "$(DCDBDEPLOYPATH)" | sed 's/\//\\\//g'))
@sed -i.original -e 's/\/var\/lib\/cassandra/$(P)\/var\/lib\/cassandra/g' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*cluster_name:.*/cluster_name:\ '\''$(CASSANDRA_CLUSTER_NAME)'\''/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*flush_largest_memtables_at:.*/flush_largest_memtables_at:\ $(CASSANDRA_FLUSH_LARGEST_MEMTABLES_AT)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*reduce_cache_sizes_at:.*/reduce_cache_sizes_at:\ $(CASSANDRA_REDUCE_CACHE_SIZES_AT)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*reduce_cache_capacity_to:.*/reduce_cache_capacity_to:\ $(CASSANDRA_REDUCE_CACHE_CAPACITY_TO)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*partitioner:.*/partitioner:\ $(CASSANDRA_PARTITIONER)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*commitlog_total_space_in_mb:.*/commitlog_total_space_in_mb: $(CASSANDRA_COMMITLOG_TOTAL_SPACE_IN_MB)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*commitlog_segment_size_in_mb:.*/commitlog_segment_size_in_mb: $(CASSANDRA_COMMITLOG_SEGMENT_SIZE_IN_MB)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*tombstone_warn_threshold:.*/tombstone_warn_threshold: $(CASSANDRA_TOMBSTONE_WARN_THRESHOLD)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*tombstone_failure_threshold:.*/tombstone_failure_threshold: $(CASSANDRA_TOMBSTONE_FAILURE_THRESHOLD)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@touch $@
$(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/.built: $(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/.patched
@echo ""
@echo "Building BACNet-Stack..."
$(eval BACNET_PORT:= $(if $(filter $(OS),Darwin),bsd,linux))
cd $(@D) && BACNET_PORT=$(BACNET_PORT) MAKE_DEFINE=-fpic make -j $(MAKETHREADS) library
touch $(@)
$(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/.installed: $(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/.built | $(DCDBDEPLOYPATH)
@echo "Installing BACNet-Stack..."
mkdir $(DCDBDEPLOYPATH)/include/bacnet && \
install $(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/include/* /$(DCDBDEPLOYPATH)/include/bacnet && \
install $(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/lib/libbacnet.a /$(DCDBDEPLOYPATH)/lib/ && touch $(@)
$(DCDBDEPSPATH)/libgpg-error-$(GPG-ERROR_VERSION)/.built: $(DCDBDEPSPATH)/libgpg-error-$(GPG-ERROR_VERSION)/.patched
@echo ""
@echo "Building gpg-error library..."
cd $(@D) && ./configure --prefix=$(DCDBDEPLOYPATH)
cd $(@D) && make -j $(MAKETHREADS) && touch $(@)
$(DCDBDEPSPATH)/libgpg-error-$(GPG-ERROR_VERSION)/.installed: $(DCDBDEPSPATH)/libgpg-error-$(GPG-ERROR_VERSION)/.built
@echo "Installing gpg-error library..."
cd $(@D) && make install && touch $(@)
$(DCDBDEPSPATH)/libgcrypt-$(GCRYPT_VERSION)/.built: $(DCDBDEPSPATH)/libgcrypt-$(GCRYPT_VERSION)/.patched
@echo ""
@echo "Building gcrypt library..."
cd $(@D) && ./configure --prefix=$(DCDBDEPLOYPATH) --with-libgpg-error-prefix=$(DCDBDEPLOYPATH)
cd $(@D) && make -j $(MAKETHREADS) && touch $(@)
$(DCDBDEPSPATH)/libgcrypt-$(GCRYPT_VERSION)/.installed: $(DCDBDEPSPATH)/libgcrypt-$(GCRYPT_VERSION)/.built
@echo "Installing gcrypt library..."
cd $(@D) && make install && touch $(@)
$(DCDBDEPSPATH)/freeipmi-$(FREEIPMI_VERSION)/.built: $(DCDBDEPSPATH)/freeipmi-$(FREEIPMI_VERSION)/.patched
@echo ""
@echo "Building FreeIPMI library..."
cd $(@D) && ./configure --prefix=$(DCDBDEPLOYPATH) --without-argp
cd $(@D) && make -j $(MAKETHREADS) && touch $(@)
$(DCDBDEPSPATH)/freeipmi-$(FREEIPMI_VERSION)/.installed: $(DCDBDEPSPATH)/freeipmi-$(FREEIPMI_VERSION)/.built | $(DCDBDEPLOYPATH)
@echo "Installing FreeIPMI library..."
cd $(@D) && make install && touch $(@)
$(DCDBDEPSPATH)/net-snmp-$(NET-SNMP_VERSION)/.built: $(DCDBDEPSPATH)/net-snmp-$(NET-SNMP_VERSION)/.patched
@echo ""
@echo "Building net-SNMP library..."
cd $(@D) && ./configure --prefix=$(DCDBDEPLOYPATH) --with-default-snmp-version=3 --with-defaults --with-logfile=none --with-persistent-directory=$(DCDBDEPLOYPATH)/var/net-snmp --disable-embedded-perl --disable-perl-cc-checks --without-perl-modules --disable-agent --disable-applications --disable-manuals --disable-scripts --disable-mibs
cd $(@D) && make -j $(MAKETHREADS) && touch $(@)
$(DCDBDEPSPATH)/net-snmp-$(NET-SNMP_VERSION)/.installed: $(DCDBDEPSPATH)/net-snmp-$(NET-SNMP_VERSION)/.built | $(DCDBDEPLOYPATH)
@echo ""
@echo "Installing net-SNMP library..."
cd $(@D) && make install && touch $(@)
$(DCDBDEPSPATH)/opencv-$(OPENCV_VERSION)/.built: $(DCDBDEPSPATH)/opencv-$(OPENCV_VERSION)/.patched
@echo ""
@echo "Building OpenCV library..."
cd $(@D) && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH) -DCMAKE_INSTALL_LIBDIR=lib -DINSTALL_C_EXAMPLES=OFF -DBUILD_EXAMPLES=OFF -DBUILD_LIST=core,dnn,features2d,flann,gapi,ml ..
cd $(@D) && cd build && make -j $(MAKETHREADS) && touch $(@)
$(DCDBDEPSPATH)/opencv-$(OPENCV_VERSION)/.installed: $(DCDBDEPSPATH)/opencv-$(OPENCV_VERSION)/.built | $(DCDBDEPLOYPATH)
@echo ""
@echo "Installing OpenCV library..."
cd $(@D) && cd build && make install && touch $(@)
%-build: deps
@echo "Building $*"
@$(MAKE) -j $(MAKETHREADS) CC=$(CC) CXX=$(CXX) -C $*
......
FETCH = wget -c --no-check-certificate -O
MD5 = $(if $(shell which md5 2>/dev/null),md5,$(if $(shell md5sum --tag Makefile 2&> /dev/null || true),md5sum --tag,openssl md5))
OS = $(shell uname -s)
MAKETHREADS ?= $(if $(findstring $(shell uname),Darwin),$(shell sysctl machdep.cpu.thread_count | cut -b 27-),\
$(if $(findstring $(shell uname),Linux),$(shell cat /proc/cpuinfo | grep processor | wc -l),4))
DISTFILESNAMES = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/;.*//'))
DISTFILESPATHS = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/.tar.gz;.*//; s/.tgz;.*//; s/.zip;.*//' ))
CFLAGS += -I$(DCDBDEPLOYPATH)/include -O2 -g -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
LDFLAGS += -L$(DCDBDEPLOYPATH)/lib -O2 -g
.PHONY: all info
.PRECIOUS: $(DCDBDEPSPATH)/distfiles/% $(DCDBDEPSPATH)/%/.extracted $(DCDBDEPSPATH)/%/.patched
.SECONDEXPANSION:
getarchive = $(filter $1%,$(DISTFILESNAMES))
gethash = $(subst $(1)|,,$(filter $(1)%,$(subst ;, ,$(DISTFILES_HASHES))))
all: $(TARGET)
$(DCDBDEPSPATH):
@mkdir -p $(DCDBDEPSPATH)
$(DCDBDEPSPATH)/distfiles: | $(DCDBDEPSPATH)
@mkdir -p $(DCDBDEPSPATH)/distfiles
$(DCDBDEPLOYPATH):
@mkdir -p $(DCDBDEPLOYPATH)/bin
@mkdir -p $(DCDBDEPLOYPATH)/include
@mkdir -p $(DCDBDEPLOYPATH)/lib
$(DCDBDEPSPATH)/distfiles/%: | $(DCDBDEPSPATH)/distfiles
@echo "Check for $(*)"
$(eval U := $(shell echo "$(DISTFILES)" | sed 's/.*$(*);//' | sed 's/ .*//'))
@if [ -e $(@) ]; then \
if [ `$(MD5) $(@)|sed -e 's/.*\ //'` != $(call gethash,$(*)) ]; then \
rm $(@); \
fi; \
fi
@if [ ! -e $(@) ]; then \
$(FETCH) $(@) $(U); \
fi
$(DCDBDEPSPATH)/%/.extracted: | $(DCDBDEPSPATH)/distfiles/$$(call getarchive,%)
$(eval F := $(notdir $(|)))
@if [ ! -e $(@) ]; then \
printf "Verifying checksum: $(F) "; \
if [ `$(MD5) $(|)|sed -e 's/.*\ //'` = $(call gethash,$(F)) ]; then \
echo " => OK!"; \
else \
echo " => FAIL!"; \
exit 2; \
fi; \
echo Extracting: $(F); \
if [ "$(suffix $(F))" = "zip" ]; then \
cd $(DCDBDEPSPATH) && unzip distfiles/$(F); \
else \
cd $(DCDBDEPSPATH) && tar xf distfiles/$(F) > /dev/null; \
fi; \
fi
@touch $@
$(DCDBDEPSPATH)/%/.patched: $(DCDBDEPSPATH)/%/.extracted
$(eval P := $(realpath patches))
if [ ! -e $(@) ] && [ -e $(P)/$(*).patch ]; then \
echo Patching: $(*); \
cd $(@D) && (patch -N -p1 < $(P)/$(*).patch); \
fi
@touch $@
......@@ -2,6 +2,9 @@ DCDBBASEPATH ?= $(realpath $(dir $(lastword $(MAKEFILE_LIST)))/..)
DCDBDEPSPATH ?= $(DCDBBASEPATH)/deps
DCDBDEPLOYPATH ?= $(DCDBBASEPATH)/install
# dcdbpusher plugins to be built
PLUGINS = procfs pdu sysfs ipmi bacnet snmp gpfsmon msr tester
DEFAULT_VERSION = 0.3
GIT_VERSION = $(shell git describe --tags 2>/dev/null|sed 's/-\([0-9]*\)/.\1/')
VERSION := $(if $(GIT_VERSION),$(GIT_VERSION),$(DEFAULT_VERSION))
......@@ -11,5 +14,10 @@ CXXFLAGS = -std=c++11 -O2 -g -Wall -fmessage-length=0 \
-DBOOST_LOG_DYN_LINK -DVERSION=\"$(VERSION)\" \
-Wno-unused-function \
-Wno-unused-variable
FULL_CC = $(shell which $(CC))
FULL_CXX = $(shell which $(CXX))
OS = $(shell uname -s)
MAKETHREADS ?= $(if $(findstring $(shell uname),Darwin),$(shell sysctl machdep.cpu.thread_count | cut -b 27-),\
$(if $(findstring $(shell uname),Linux),$(shell cat /proc/cpuinfo | grep processor | wc -l),4))
include ../config.mk
include ../common.mk
CXXFLAGS += -DBOOST_NETWORK_ENABLE_HTTPS \
-I../common/include \
......@@ -32,7 +31,6 @@ OBJS = dcdbpusher.o \
../common/src/RESTHttpsServer.o
TARGET = dcdbpusher
PLUGINS = procfs pdu sysfs ipmi bacnet snmp gpfsmon msr tester
ifeq ($(OS),Darwin)
BACNET_PORT = bsd
......@@ -43,18 +41,21 @@ else
BACNET_PORT = linux
LIBEXT = so
LIBFLAGS = -shared -Wl,-soname,
PLUGINS+= perfevent caliper
PLUGINFLAGS = -fPIC
endif
PLUGIN_LIBS = $(foreach p,$(PLUGINS),libdcdbplugin_$(p).$(LIBEXT))
all: $(TARGET) $(PLUGIN_LIBS)
$(TARGET): $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.installed) $(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
all: $(TARGET) $(PLUGIN_LIBS)
debug: CXXFLAGS += -DDEBUG
debug: all
info:
@echo $(PLUGINS) $(PLUGIN_LIBS)
clean:
rm -f $(PLUGIN_LIBS) $(TARGET) $(OBJS) $(shell find ./sensors -name "*.o")
......
SOURCEFORGE_MROR = vorboss
CASSANDRA_VERSION = 3.0.18
MOSQUITTO_VERSION = 1.5.5
BOOST_VERSION = 1.70.0
OPENSSL_VERSION = 1.1.1c
CPPDRV_VERSION = 2.10.0
LIBUV_VERSION = 1.24.0
BACNET-STACK_VERSION = 0.8.6
FREEIPMI_VERSION = 1.6.3
GCRYPT_VERSION = 1.8.4
GPG-ERROR_VERSION = 1.36
NET-SNMP_VERSION = 5.8
OPENCV_VERSION = 4.1.0
BOOST_VERSION_U = $(subst .,_,$(BOOST_VERSION))
DISTFILES = apache-cassandra-$(CASSANDRA_VERSION).tar.gz;http://archive.apache.org/dist/cassandra/$(CASSANDRA_VERSION)/apache-cassandra-$(CASSANDRA_VERSION)-bin.tar.gz \
mosquitto-$(MOSQUITTO_VERSION).tar.gz;http://mosquitto.org/files/source/mosquitto-$(MOSQUITTO_VERSION).tar.gz \
boost_$(BOOST_VERSION_U).tar.gz;http://$(SOURCEFORGE_MROR).dl.sourceforge.net/project/boost/boost/$(BOOST_VERSION)/boost_$(BOOST_VERSION_U).tar.gz \
openssl-$(OPENSSL_VERSION).tar.gz;https://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz \
libuv-v$(LIBUV_VERSION).tar.gz;https://dist.libuv.org/dist/v$(LIBUV_VERSION)/libuv-v$(LIBUV_VERSION).tar.gz \
cpp-driver-$(CPPDRV_VERSION).tar.gz;https://github.com/datastax/cpp-driver/archive/$(CPPDRV_VERSION).tar.gz \
bacnet-stack-$(BACNET-STACK_VERSION).tgz;https://downloads.sourceforge.net/project/bacnet/bacnet-stack/bacnet-stack-$(BACNET-STACK_VERSION)/bacnet-stack-$(BACNET-STACK_VERSION).tgz \
libgpg-error-$(GPG-ERROR_VERSION).tar.gz;https://gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-$(GPG-ERROR_VERSION).tar.gz \
libgcrypt-$(GCRYPT_VERSION).tar.gz;https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-$(GCRYPT_VERSION).tar.gz \
freeipmi-$(FREEIPMI_VERSION).tar.gz;http://ftp.gnu.org/gnu/freeipmi/freeipmi-$(FREEIPMI_VERSION).tar.gz \
net-snmp-$(NET-SNMP_VERSION).tar.gz;https://sourceforge.net/projects/net-snmp/files/net-snmp/$(NET-SNMP_VERSION)/net-snmp-$(NET-SNMP_VERSION).tar.gz/download \
opencv-$(OPENCV_VERSION).tar.gz;https://github.com/opencv/opencv/archive/$(OPENCV_VERSION).tar.gz
DISTFILES_HASHES = apache-cassandra-3.0.18.tar.gz|94dbdaa58b366166c53f881b8e266bc8;\
mosquitto-1.5.5.tar.gz|a17dffc6f63b2a4ab2eb5c51139e60e9;\
boost_1_70_0.tar.gz|fea771fe8176828fabf9c09242ee8c26;\
openssl-1.1.1c.tar.gz|15e21da6efe8aa0e0768ffd8cd37a5f6;\
cpp-driver-2.10.0.tar.gz|6d15dd2cccd2efd1fdc86089d26971d0;\
libuv-v1.24.0.tar.gz|90320330757253b07404d2a97f59c66b;\
bacnet-stack-0.8.6.tgz|544ebd42ed959deb2213209b66bbc460;\
libgcrypt-1.8.4.tar.gz|433ab0a47b25994fa92b165db185f174;\
libgpg-error-1.36.tar.gz|f2283e22959ef71f44d8be3d0987a96b;\
freeipmi-1.6.3.tar.gz|b2d97e20db9b81b460ce1b9dad5bf54e;\
net-snmp-5.8.tar.gz|63bfc65fbb86cdb616598df1aff6458a; \
opencv-4.1.0.tar.gz|b80c59c7e4feee6a00608315e02b0b73;
CASSANDRA_CLUSTER_NAME = Datacenter Monitor Database
CASSANDRA_FLUSH_LARGEST_MEMTABLES_AT = 0.5
CASSANDRA_REDUCE_CACHE_SIZES_AT = 0.6
CASSANDRA_REDUCE_CACHE_CAPACITY_TO = 0.4
CASSANDRA_PARTITIONER = org.apache.cassandra.dht.ByteOrderedPartitioner
CASSANDRA_COMMITLOG_TOTAL_SPACE_IN_MB = 256
CASSANDRA_COMMITLOG_SEGMENT_SIZE_IN_MB = 16
CASSANDRA_TOMBSTONE_WARN_THRESHOLD = 100000
CASSANDRA_TOMBSTONE_FAILURE_THRESHOLD = 10000000
FETCH = wget -c --no-check-certificate -O
MD5 = $(if $(shell which md5 2>/dev/null),md5,$(if $(shell md5sum --tag Makefile 2&> /dev/null || true),md5sum --tag,openssl md5))
DISTFILESNAMES = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/;.*//'))
DISTFILESPATHS_FULL = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/.tar.gz;.*//; s/.tgz;.*//; s/.zip;.*//' ))
DISTFILESPATHS = apache-cassandra-$(CASSANDRA_VERSION) mosquitto-$(MOSQUITTO_VERSION) boost_$(BOOST_VERSION_U) openssl-$(OPENSSL_VERSION) libuv-v$(LIBUV_VERSION) cpp-driver-$(CPPDRV_VERSION) opencv-$(OPENCV_VERSION)
ifneq (,$(findstring bacnet,$(PLUGINS)))
DISTFILESPATHS += bacnet-stack-$(BACNET-STACK_VERSION)
endif
ifneq (,$(findstring ipmi,$(PLUGINS)))
DISTFILESPATHS += libgpg-error-$(GPG-ERROR_VERSION) libgcrypt-$(GCRYPT_VERSION) freeipmi-$(FREEIPMI_VERSION)
endif
ifneq (,$(findstring snmp,$(PLUGINS)))
DISTFILESPATHS += net-snmp-$(NET-SNMP_VERSION)
endif
# If cross-compiling for ARM, adjust the build settings
ifeq ("$(ARCH)", "arm")
OPENSSL_TARGET = "linux-generic32"
else
OPENSSL_TARGET = $(if $(findstring $(shell uname),Darwin),"darwin64-x86_64-cc","linux-x86_64")
endif
.PRECIOUS: $(DCDBDEPSPATH)/distfiles/% $(DCDBDEPSPATH)/%/.extracted $(DCDBDEPSPATH)/%/.patched
.SECONDEXPANSION:
getarchive = $(filter $1%,$(DISTFILESNAMES))
gethash = $(subst $(1)|,,$(filter $(1)%,$(subst ;, ,$(DISTFILES_HASHES))))
$(DCDBDEPSPATH):
@mkdir -p $(DCDBDEPSPATH)
$(DCDBDEPSPATH)/distfiles: | $(DCDBDEPSPATH)
@mkdir -p $(DCDBDEPSPATH)/distfiles
$(DCDBDEPLOYPATH):
@mkdir -p $(DCDBDEPLOYPATH)/bin
@mkdir -p $(DCDBDEPLOYPATH)/include
@mkdir -p $(DCDBDEPLOYPATH)/lib
$(DCDBDEPSPATH)/distfiles/%: | $(DCDBDEPSPATH)/distfiles
@echo "Check for $(*)"
$(eval U := $(shell echo "$(DISTFILES)" | sed 's/.*$(*);//' | sed 's/ .*//'))
@if [ -e $(@) ]; then \
if [ `$(MD5) $(@)|sed -e 's/.*\ //'` != $(call gethash,$(*)) ]; then \
rm $(@); \
fi; \
fi
@if [ ! -e $(@) ]; then \
$(FETCH) $(@) $(U); \
fi
$(DCDBDEPSPATH)/%/.extracted: | $(DCDBDEPSPATH)/distfiles/$$(call getarchive,%)
$(eval F := $(notdir $(|)))
@if [ ! -e $(@) ]; then \
printf "Verifying checksum: $(F) "; \
if [ `$(MD5) $(|)|sed -e 's/.*\ //'` = $(call gethash,$(F)) ]; then \
echo " => OK!"; \
else \
echo " => FAIL!"; \
exit 2; \
fi; \
echo Extracting: $(F); \
if [ "$(suffix $(F))" = "zip" ]; then \
cd $(DCDBDEPSPATH) && unzip distfiles/$(F); \
else \
cd $(DCDBDEPSPATH) && tar xf distfiles/$(F) > /dev/null; \
fi; \
fi
@touch $@
$(DCDBDEPSPATH)/%/.patched: $(DCDBDEPSPATH)/%/.extracted
$(eval P := $(realpath patches))
if [ ! -e $(@) ] && [ -e $(P)/$(*).patch ]; then \
echo Patching: $(*); \
cd $(@D) && (patch -N -p1 < $(P)/$(*).patch); \
fi
@touch $@
$(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.built: $(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.patched
@echo "Building OpenSSL library..."
cd $(@D) && ./Configure shared --prefix=$(DCDBDEPLOYPATH) $(OPENSSL_TARGET)
cd $(@D) && make && touch $(@)
$(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.installed: $(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.built | $(DCDBDEPLOYPATH)
@echo "Installing OpenSSL library..."
cd $(@D) && make install_sw && touch $(@)
$(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.built: $(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.patched
@echo "Building Mosquitto library...";
mkdir -p $(@D)/build;
cd $(@D)/build && \
CC=$(FULL_CC) CXX=$(FULL_CXX) cmake $(CMAKE_CROSS_FLAGS) \
-DWITH_SRV=no \
-DWITH_TLS=yes \
-DWITH_TLS_PSK=yes \
-DDOCUMENTATION=no \
-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
$(@D) && \
make -j $(MAKETHREADS) && \
touch $(@)
$(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.installed: $(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.built | $(DCDBDEPLOYPATH)
@echo "Installing Mosquitto library..."
cd $(@D)/build && make install && touch $(@)
$(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.built: $(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.patched
@echo "Building Boost..."
@ if [ "$(ARCH)" = "arm" ]; then \
echo " using gcc : arm : $(CROSS_COMPILE)g++ ; " > $(@D)/tools/build/src/user-config.jam; \
fi
cd $(@D) && ./bootstrap.sh --prefix=$(DCDBDEPLOYPATH) --with-libraries=atomic,chrono,date_time,exception,filesystem,log,program_options,random,regex,system,thread,timer && \
./b2 stage && touch $(@)
$(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.installed: $(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/.built
cd $(@D) && ./b2 -j $(MAKETHREADS) --no-cmake-config install && touch $(@)
$(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.built: $(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.patched
@echo "Building libuv..."
mkdir -p $(@D)/build
cd $(@D)/build && \
CC=$(FULL_CC) CXX=$(FULL_CXX) cmake $(CMAKE_CROSS_FLAGS) \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
.. && \
make -j $(MAKETHREADS) && touch $(@)
$(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.installed: $(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.built | $(DCDBDEPLOYPATH)
@echo "Installing libuv..."
cd $(@D)/build && make install && touch $(@)
$(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.built: $(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.patched $(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.built $(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION)/.built
@echo "Building cpp-driver..."
mkdir -p $(@D)/build
cd $(@D)/build && \
CC=$(FULL_CC) CXX=$(FULL_CXX) cmake $(CMAKE_CROSS_FLAGS) \
-DOPENSSL_ROOT_DIR=$(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION) \
-DLIBUV_ROOT_DIR=$(DCDBDEPSPATH)/libuv-v$(LIBUV_VERSION) \
-DCASS_BUILD_EXAMPLES=NO \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
-DCMAKE_EXE_LINKER_FLAGS="-L$(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/stage/lib -lboost_random" \
-DCMAKE_SHARED_LINKER_FLAGS="-L$(DCDBDEPSPATH)/boost_$(BOOST_VERSION_U)/stage/lib -lboost_random" \
.. && \
make -j $(MAKETHREADS) && touch $(@)
$(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.installed: $(DCDBDEPSPATH)/cpp-driver-$(CPPDRV_VERSION)/.built | $(DCDBDEPLOYPATH)
@echo "Installing cpp-driver..."
cd $(@D)/build && make install && touch $(@)
$(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.built: $(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.patched
@touch $(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.built
$(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.installed: $(DCDBDEPSPATH)/apache-cassandra-$(CASSANDRA_VERSION)/.built | $(DCDBDEPLOYPATH)
@echo ""
@echo "Staging and configuring Cassandra..."
@rsync -rlptD $(@D)/ $(DCDBDEPLOYPATH)/cassandra
@$(eval P := $(shell echo "$(DCDBDEPLOYPATH)" | sed 's/\//\\\//g'))
@sed -i.original -e 's/\/var\/lib\/cassandra/$(P)\/var\/lib\/cassandra/g' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*cluster_name:.*/cluster_name:\ '\''$(CASSANDRA_CLUSTER_NAME)'\''/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*flush_largest_memtables_at:.*/flush_largest_memtables_at:\ $(CASSANDRA_FLUSH_LARGEST_MEMTABLES_AT)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*reduce_cache_sizes_at:.*/reduce_cache_sizes_at:\ $(CASSANDRA_REDUCE_CACHE_SIZES_AT)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*reduce_cache_capacity_to:.*/reduce_cache_capacity_to:\ $(CASSANDRA_REDUCE_CACHE_CAPACITY_TO)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*partitioner:.*/partitioner:\ $(CASSANDRA_PARTITIONER)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*commitlog_total_space_in_mb:.*/commitlog_total_space_in_mb: $(CASSANDRA_COMMITLOG_TOTAL_SPACE_IN_MB)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*commitlog_segment_size_in_mb:.*/commitlog_segment_size_in_mb: $(CASSANDRA_COMMITLOG_SEGMENT_SIZE_IN_MB)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*tombstone_warn_threshold:.*/tombstone_warn_threshold: $(CASSANDRA_TOMBSTONE_WARN_THRESHOLD)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@sed -i -e 's/.*tombstone_failure_threshold:.*/tombstone_failure_threshold: $(CASSANDRA_TOMBSTONE_FAILURE_THRESHOLD)/' $(DCDBDEPLOYPATH)/cassandra/conf/cassandra.yaml
@touch $@
$(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/.built: $(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/.patched
@echo ""