Commit 4a04c70b authored by Michael Ott's avatar Michael Ott
Browse files

Move Makefile to main directory, add targets for dependencies, and make it compile on OSX

parent 9f210cc7
TARGET = dcdbpusher
DCDBBASEPATH ?= $(realpath $(dir $(lastword $(MAKEFILE_LIST)))/..)
DCDBCOREPATH ?= $(DCDBBASEPATH)/dcdb
BACNET-STACK_VERSION = 0.8.5
FREEIPMI_VERSION = 1.5.5
DISTFILES = 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 \
freeipmi-$(FREEIPMI_VERSION).tar.gz;http://ftp.gnu.org/gnu/freeipmi/freeipmi-1.5.5.tar.gz
DISTFILES_HASHES = bacnet-stack-0.8.5.tgz|66b69111d91432fa67a7c6c1a653434d;freeipmi-1.5.5.tar.gz|b8abfefee0b757f351d8fab777e3c1bb
include $(DCDBCOREPATH)/common.mk
CXXFLAGS = -std=c++11 -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG -O2 -g -Wall -Wno-unused-function -Wno-deprecated-declarations -Wno-unused-variable -DBOOST_LOG_DYN_LINK -I$(DCDBBASEPATH)/dcdb/include -I$(DCDBDEPLOYPATH)/include
LIBS = -L../deps/mosquitto_build/lib -L$(DCDBDEPLOYPATH)/lib/ -ldl -lmosquitto -lboost_system -lboost_thread -lboost_log_setup -lboost_log -lpthread -rdynamic
OBJS = src/dcdbpusher.o src/Configuration.o src/Sensor.o src/MQTTPusher.o
PLUGINS_BASE = libdcdbplugin_pdu libdcdbplugin_sysfs libdcdbplugin_ipmi libdcdbplugin_bacnet
ifeq ($(OS),Darwin)
BACNET_PORT = bsd
LIBEXT = dylib
LIBFLAGS = -dynamiclib -install_name
PLUGINS = $(foreach p,$(PLUGINS_BASE),$(p).dylib)
else
BACNET_PORT = linux
LIBEXT = so
LIBFLAGS = -shared -Wl,-soname,
PLUGINS+= libdcdbplugin_perfevent
PLUGINFLAGS = -fPIC
endif
PLUGINS = $(foreach p,$(PLUGINS_BASE),$(p).$(LIBEXT))
$(TARGET): $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.installed) $(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
all: $(TARGET) $(PLUGINS)
debug: CXXFLAGS += -DDEBUG
debug: all
clean:
rm -f $(PLUGINS) $(TARGET) $(shell find -name "*.o")
$(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/.installed: $(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/.patched
@echo ""
@echo "Building BACNet-Stack..."
cd $(@D) && BACNET_PORT=$(BACNET_PORT) MAKE_DEFINE=-fpic make -j $(MAKETHREADS) library && \
install $(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/lib/libbacnet.a /$(DCDBDEPLOYPATH)/lib/ && touch $(@)
$(DCDBDEPSPATH)/freeipmi-$(FREEIPMI_VERSION)/.installed: $(DCDBDEPSPATH)/freeipmi-$(FREEIPMI_VERSION)/.patched
@echo ""
@echo "Building FreeIPMI library..."
cd $(@D) && ./configure --prefix=$(DCDBDEPLOYPATH) --without-argp
cd $(@D) && make -j $(MAKETHREADS) && make install && touch $(@)
$(OBJS) : %.o : %.cpp
install: $(TARGET)
install $(TARGET) $(DCDBDEPLOYPATH)/bin/
install -m 644 $(TARGET).conf $(DCDBDEPLOYPATH)/etc
src/Sensor.o: CXXFLAGS+= $(PLUGINFLAGS)
src/sensors/%.o: CXXFLAGS+= $(PLUGINFLAGS) -I$(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/include -I$(DCDBDEPSPATH)/bacnet-stack-$(BACNET-STACK_VERSION)/ports/$(BACNET_PORT)
#src/sensors/*/%.o: %.cpp
libdcdbplugin_sysfs.$(LIBEXT): src/Sensor.o src/sensors/sysfs/SysfsSensor.o src/sensors/sysfs/SysfsConfigurator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system
libdcdbplugin_perfevent.$(LIBEXT): src/Sensor.o src/sensors/perfevent/PerfCounter.o src/sensors/perfevent/PerfeventConfigurator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system
libdcdbplugin_ipmi.$(LIBEXT): src/Sensor.o src/sensors/ipmi/IPMISensor.o src/sensors/ipmi/IPMIHost.o src/sensors/ipmi/IPMIConfigurator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system -lfreeipmi -lboost_regex
libdcdbplugin_pdu.$(LIBEXT): src/Sensor.o src/sensors/pdu/PDUSensor.o src/sensors/pdu/PDUUnit.o src/sensors/pdu/PDUConfigurator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lcrypto -lssl -lboost_log -lboost_system
libdcdbplugin_bacnet.$(LIBEXT): src/Sensor.o src/sensors/bacnet/BACnetSensor.o src/sensors/bacnet/BACnetClient.o src/sensors/bacnet/BACnetConfigurator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system -lbacnet
......@@ -114,7 +114,12 @@ bool Configuration::read() {
if (!plugin.second.empty()) {
LOG(info) << "Loading plugin \"" << plugin.second.data() << "\"...";
std::string pluginConfig; //path to config file for plugin
std::string pluginLib = "libdcdbplugin_" + plugin.second.data() + ".so.1.0"; //TODO add version information? //path to the plugin-lib
std::string pluginLib = "libdcdbplugin_" + plugin.second.data(); //TODO add version information? //path to the plugin-lib
#if __APPLE__
pluginLib+= ".dylib";
#else
pluginLib+= ".so";
#endif
BOOST_FOREACH(boost::property_tree::iptree::value_type &val, plugin.second) {
if (boost::iequals(val.first, "path")) {
......
TARGET = dcdbpusher
DCDBBASEPATH ?= $(realpath $(dir $(lastword $(MAKEFILE_LIST)))/..)
DCDBCOREPATH ?= $(DCDBBASEPATH)/dcdb
include $(realpath $(dir $(lastword $(MAKEFILE_LIST)))/../..)/dcdb/common.mk
CXXFLAGS = -std=c++0x -O2 -g -Wall -Werror -Wno-unused-local-typedefs -Wno-unknown-warning-option -Wno-deprecated-declarations -I$(DCDBDEPLOYPATH)/include -I$(DCDBBASEPATH)/include
CXXFLAGS = -std=c++11 -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG -O2 -g -Wall -Wno-unused-function -Wno-deprecated-declarations -Wno-unused-variable -DBOOST_LOG_DYN_LINK -I$(DCDBBASEPATH)/dcdb/include -I$(DCDBDEPLOYPATH)/include
PLUGINFLAGS = -fPIC -c $(CXXFLAGS)
LIBS = -L../deps/mosquitto_build/lib -L$(DCDBDEPLOYPATH)/lib/ -ldl -lmosquitto -lboost_system -lboost_thread -lboost_log_setup -lboost_log -lpthread -rdynamic
OBJS = dcdbpusher.o Configuration.o Sensor.o MQTTPusher.o
PLUGINS = libdcdbplugin_pdu.so.1.0 libdcdbplugin_perfevent.so.1.0 libdcdbplugin_sysfs.so.1.0 libdcdbplugin_ipmi.so.1.0 libdcdbplugin_bacnet.so.1.0
$(TARGET): $(PLUGINS) $(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
all: $(TARGET)
debug: CXXFLAGS += -DDEBUG
debug: $(TARGET)
clean:
rm -f *.o *.so* $(TARGET)
install: $(TARGET)
install $(TARGET) $(DCDBDEPLOYPATH)/bin/
install -m 644 $(TARGET).conf $(DCDBDEPLOYPATH)/etc
libdcdbplugin_sysfs.so.1.0:
$(CXX) $(PLUGINFLAGS) sensors/sysfs/SysfsSensor.cpp
$(CXX) $(PLUGINFLAGS) sensors/sysfs/SysfsConfigurator.cpp
$(CXX) -shared -Wl,-soname,libdcdbplugin_sysfs.so.1 -o libdcdbplugin_sysfs.so.1.0 SysfsSensor.o SysfsConfigurator.o
libdcdbplugin_perfevent.so.1.0:
$(CXX) $(PLUGINFLAGS) sensors/perfevent/PerfCounter.cpp
$(CXX) $(PLUGINFLAGS) sensors/perfevent/PerfeventConfigurator.cpp
$(CXX) -shared -Wl,-soname,libdcdbplugin_perfevent.so.1 -o libdcdbplugin_perfevent.so.1.0 PerfCounter.o PerfeventConfigurator.o
libdcdbplugin_ipmi.so.1.0:
$(CXX) $(PLUGINFLAGS) sensors/ipmi/IPMISensor.cpp
$(CXX) $(PLUGINFLAGS) sensors/ipmi/IPMIHost.cpp
$(CXX) $(PLUGINFLAGS) sensors/ipmi/IPMIConfigurator.cpp
$(CXX) -shared -Wl,-soname,libdcdbplugin_ipmi.so.1 -o libdcdbplugin_ipmi.so.1.0 IPMISensor.o IPMIHost.o IPMIConfigurator.o -L$(DCDBDEPLOYPATH)/lib/ -lfreeipmi -lboost_regex
libdcdbplugin_pdu.so.1.0:
$(CXX) $(PLUGINFLAGS) sensors/pdu/PDUSensor.cpp
$(CXX) $(PLUGINFLAGS) sensors/pdu/PDUUnit.cpp
$(CXX) $(PLUGINFLAGS) sensors/pdu/PDUConfigurator.cpp
$(CXX) -shared -Wl,-soname,libdcdbplugin_pdu.so.1 -o libdcdbplugin_pdu.so.1.0 PDUSensor.o PDUUnit.o PDUConfigurator.o -L$(DCDBDEPLOYPATH)/lib/ -lcrypto -lssl
libdcdbplugin_bacnet.so.1.0:
$(CXX) $(PLUGINFLAGS) sensors/bacnet/BACnetSensor.cpp
$(CXX) $(PLUGINFLAGS) sensors/bacnet/BACnetClient.cpp
$(CXX) $(PLUGINFLAGS) sensors/bacnet/BACnetConfigurator.cpp
$(CXX) -shared -Wl,-soname,libdcdbplugin_bacnet.so.1 -o libdcdbplugin_bacnet.so.1.0 BACnetSensor.o BACnetClient.o BACnetConfigurator.o -L$(DCDBDEPLOYPATH)/lib/ -lbacnet
......@@ -7,15 +7,15 @@
#include "BACnetClient.h"
#include "bacnetTEMP/address.h"
#include "bacnetTEMP/apdu.h"
#include "bacnetTEMP/bacapp.h"
#include "bacnetTEMP/bactext.h"
#include "bacnetTEMP/datalink.h"
#include "bacnetTEMP/npdu.h"
#include "bacnetTEMP/reject.h"
#include "bacnetTEMP/rp.h"
#include "bacnetTEMP/tsm.h"
#include "address.h"
#include "apdu.h"
#include "bacapp.h"
#include "bactext.h"
#include "datalink.h"
#include "npdu.h"
#include "reject.h"
#include "rp.h"
#include "tsm.h"
uint64_t BACnetClient::_presentValue;
uint8_t BACnetClient::_handlerTransmitBuffer[MAX_PDU];
......
......@@ -10,10 +10,9 @@
#include "../../Logging.h"
//TODO where to put bacnet?
#include "bacnetTEMP/apdu.h"
#include "bacnetTEMP/bacenum.h"
#include "bacnetTEMP/datalink.h"
#include "apdu.h"
#include "bacenum.h"
#include "datalink.h"
#include <boost/asio.hpp>
/*
......
......@@ -11,7 +11,7 @@
#include "../../Sensor.h"
#include "BACnetClient.h"
#include "bacnetTEMP/bacenum.h"
#include "bacenum.h"
class BACnetSensor: public Sensor {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment