8eea00fd62677f35a7e7b73db306de9b34986207
[barometer.git] / src / collectd / Makefile
1 # makefile to manage collectd package
2 #
3
4 # Copyright 2016-2017 OPNFV
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 #
19 # Contributors:
20 #   Aihua Li, Huawei Technologies.
21 #   Maryam Tahhan, Intel Corporation.
22
23 include ../mk/master.mk
24 include ../package-list.mk
25
26 WORK_DIR = collectd
27 TAG_DONE_FLAG = $(WORK_DIR)/.$(COLLECTD_TAG).done
28 BUILD_CMD = ./build.sh
29 CONFIG_CMD =
30 CONFIG_CMD += ./configure
31
32 LIBPQOS_DIR = $(shell echo $$LIBPQOS_DIR)
33 ifeq ($(LIBPQOS_DIR),)
34 LIBPQOS_DIR = /usr
35 endif
36
37 XDG_CACHE_HOME_DIR = $(shell echo $$XDG_CACHE_HOME)
38 ifeq ($(XDG_CACHE_HOME_DIR),)
39 XDG_CACHE_HOME_DIR = $(shell echo $$HOME)
40 endif
41
42 CONFIG_CMD += --enable-syslog
43 CONFIG_CMD += --enable-logfile
44 CONFIG_CMD += --with-libpqos=$(LIBPQOS_DIR)
45 CONFIG_CMD += --enable-hugepages
46 CONFIG_CMD += --with-libjevents=/usr/local
47 CONFIG_CMD += --enable-exec
48 CONFIG_CMD += --enable-python
49 CONFIG_CMD += --enable-threshold
50 CONFIG_CMD += --enable-write_redis
51 CONFIG_CMD += --disable-perl
52 CONFIG_CMD += --with-librdkafka=/usr
53 CONFIG_CMD += --disable-lvm
54 ifdef WITH_DPDK
55 CONFIG_CMD += LIBDPDK_CFLAGS='-mssse3'
56 endif
57
58 .PHONY: install force_install config force_make
59
60 # install depends on make
61 force_install: force_make
62
63 all: force_make
64         @echo "Finished making $(WORK_DIR)"
65
66 config $(WORK_DIR)/Makefile: $(WORK_DIR)/configure
67         $(AT)cd $(WORK_DIR); $(CONFIG_CMD)
68         @echo "Configure done"
69
70 force_make: $(WORK_DIR)/Makefile
71         $(AT) $(MAKE) -C $(WORK_DIR) $(MORE_MAKE_FLAGS)
72         @echo "Make done"
73
74 force_install:
75         $(AT)$(MAKE) -C $(WORK_DIR) install
76 ifndef DOCKER
77         $(AT)cp $(WORK_DIR)/contrib/systemd.collectd.service /etc/systemd/system/
78         $(AT)mv /etc/systemd/system/systemd.collectd.service /etc/systemd/system/collectd.service
79         $(AT)sed -i -e 's/ExecStart=\/usr\/sbin\/collectd/ExecStart=\/opt\/collectd\/sbin\/collectd/g' /etc/systemd/system/collectd.service
80         $(AT)sed -i -e 's/CapabilityBoundingSet=/CapabilityBoundingSet=CAP_SETUID CAP_SETGID CAP_SYS_RAWIO CAP_SYS_ADMIN/g' /etc/systemd/system/collectd.service
81         $(AT)sed -i -e 's|Environment=\(.*\)|Environment=XDG_CACHE_HOME='$(XDG_CACHE_HOME_DIR)' \1|g' /etc/systemd/system/collectd.service
82         $(AT)systemctl daemon-reload
83 endif
84         $(AT)sudo ./ovs_pmd_stats_config.sh
85         $(AT)sudo ./snmp_mib_config.sh
86
87         @echo "Using sample configs: $(SAMPLE_CONF_VARIANT_NAME)"
88         $(AT)sudo ./include_config.sh $(SAMPLE_CONF_VARIANT_NAME)
89         @echo "Make install done"
90
91 install: force_install
92
93
94 # hard way to clean and clobber
95 clean:
96         $(AT)cd $(WORK_DIR) && git clean -xfd *.o
97 clobber:
98         $(AT)rm -rf $(WORK_DIR)
99
100 # distclean is for developer who would like to keep the
101 # clone git repo, saving time to fetch again from url
102 distclean:
103         $(AT)cd $(WORK_DIR) && git clean -xfd && git checkout -f
104
105 test:
106         @echo "Make test in $(WORK_DIR) (stub) "
107
108 sanity:
109         @echo "Make sanity in $(WORK_DIR) (stub) "
110
111 .PHONY: boot
112 # boot collectd is the process to produce the script 'configure'
113 boot $(WORK_DIR)/configure: $(TAG_DONE_FLAG)
114         @echo "booting up collectd"
115         $(AT)cd $(WORK_DIR); $(BUILD_CMD)
116         @echo "done booting collectd"
117
118 $(WORK_DIR):
119         $(AT)git clone $(COLLECTD_URL)
120
121 $(TAG_DONE_FLAG): $(WORK_DIR)
122         @echo "Checking out collectd from tag: $(COLLECTD_TAG)"
123         $(AT)cd collectd; git checkout $(COLLECTD_TAG)
124 ifneq ($(PATCH_FILE),)
125         $(AT)cd $(WORK_DIR); patch -p1 < ../$(PATCH_FILE)
126 endif
127 ifeq ($(COLLECTD_USE_EXPERIMENTAL_PR), y)
128         @echo "Applying experimental pull requests"
129         $(AT)cd $(WORK_DIR); ../collectd_apply_pull_request.sh
130 endif
131         $(AT)touch $@