Makefile 3.91 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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

18
PLUGINS = pdu sysfs ipmi bacnet
19
20
21
22
23
24
25
26
ifeq ($(OS),Darwin)
	BACNET_PORT = bsd
	LIBEXT = dylib
	LIBFLAGS = -dynamiclib -install_name
else
	BACNET_PORT = linux
	LIBEXT = so
	LIBFLAGS = -shared -Wl,-soname,
27
        PLUGINS+= perfevent
28
29
	PLUGINFLAGS = -fPIC
endif
30
PLUGIN_LIBS = $(foreach p,$(PLUGINS),libdcdbplugin_$(p).$(LIBEXT))
31
32
33
34

$(TARGET): $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.installed) $(OBJS)
	$(CXX) -o $(TARGET) $(OBJS) $(LIBS)

35
all:	$(TARGET) $(PLUGIN_LIBS) 
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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

56
57
58
59
60
61
62
install_lib: $(PLUGIN_LIBS)
	install $^ $(DCDBDEPLOYPATH)/lib/

install_conf: $(foreach p,global $(PLUGINS),config/$(p).conf) 
	install -m 644 $^ $(DCDBDEPLOYPATH)/etc/

install: $(TARGET) install_lib install_conf
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
	install $(TARGET) $(DCDBDEPLOYPATH)/bin/

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