ec45f9410a96024b4936c9a55451eb2d48facbdc
[barometer.git] / src / collectd / Makefile
1 # makefile to manage collectd package
2 #
3
4 # Copyright 2016-2019 Intel Corporation and OPNFV. All rights reserved.
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 #
20 # Contributors:
21 #   Aihua Li, Huawei Technologies.
22 #   Maryam Tahhan, Intel Corporation.
23
24 include ../mk/master.mk
25 include ../package-list.mk
26
27 WORK_DIR = collectd
28 # $COLLECTD_TAG can contain "/", which is being replaced with "-" here
29 TAG_DONE_FLAG := $(WORK_DIR)/.$(subst /,-,"$(COLLECTD_TAG)").done
30 BUILD_CMD = ./build.sh
31 CONFIG_CMD =
32 CONFIG_CMD += ./configure
33
34 LIBPQOS_DIR = $(shell echo $$LIBPQOS_DIR)
35 ifeq ($(LIBPQOS_DIR),)
36 LIBPQOS_DIR = /usr
37 endif
38
39 XDG_CACHE_HOME_DIR = $(shell echo $$XDG_CACHE_HOME)
40 ifeq ($(XDG_CACHE_HOME_DIR),)
41 XDG_CACHE_HOME_DIR = $(shell echo $$HOME)
42 endif
43
44 CONFIG_CMD += --enable-syslog
45 CONFIG_CMD += --enable-logfile
46 CONFIG_CMD += --with-libpqos=$(LIBPQOS_DIR)
47 CONFIG_CMD += --enable-hugepages
48 CONFIG_CMD += --with-libjevents=/usr/local
49 CONFIG_CMD += --enable-exec
50 CONFIG_CMD += --enable-python
51 CONFIG_CMD += --enable-threshold
52 CONFIG_CMD += --enable-write_redis
53 CONFIG_CMD += --disable-perl
54 CONFIG_CMD += --with-librdkafka=/usr
55 CONFIG_CMD += --disable-lvm
56 ifdef WITH_DPDK
57 CONFIG_CMD += LIBDPDK_CFLAGS='-mssse3'
58 endif
59
60 .PHONY: install force_install config force_make
61
62 # install depends on make
63 force_install: force_make
64
65 all: force_make
66         @echo "Finished making $(WORK_DIR)"
67
68 config $(WORK_DIR)/Makefile: $(WORK_DIR)/configure
69         $(AT)cd $(WORK_DIR); $(CONFIG_CMD)
70         @echo "Configure done"
71
72 force_make: $(WORK_DIR)/Makefile
73         $(AT) $(MAKE) -C $(WORK_DIR) $(MORE_MAKE_FLAGS)
74         @echo "Make done"
75
76 force_install:
77         $(AT)$(MAKE) -C $(WORK_DIR) install
78 ifndef DOCKER
79         $(AT)cp $(WORK_DIR)/contrib/systemd.collectd.service /etc/systemd/system/
80         $(AT)mv /etc/systemd/system/systemd.collectd.service /etc/systemd/system/collectd.service
81         $(AT)sed -i -e 's/ExecStart=\/usr\/sbin\/collectd/ExecStart=\/opt\/collectd\/sbin\/collectd/g' /etc/systemd/system/collectd.service
82         $(AT)sed -i -e 's/CapabilityBoundingSet=/CapabilityBoundingSet=CAP_SETUID CAP_SETGID CAP_SYS_RAWIO CAP_SYS_ADMIN/g' /etc/systemd/system/collectd.service
83         $(AT)sed -i -e 's|Environment=\(.*\)|Environment=XDG_CACHE_HOME='$(XDG_CACHE_HOME_DIR)' \1|g' /etc/systemd/system/collectd.service
84         $(AT)systemctl daemon-reload
85 endif
86         $(AT)sudo ./ovs_pmd_stats_config.sh
87         $(AT)sudo ./snmp_mib_config.sh
88
89         @echo "Using sample configs: $(SAMPLE_CONF_VARIANT_NAME)"
90         $(AT)sudo ./include_config.sh $(SAMPLE_CONF_VARIANT_NAME)
91         @echo "Make install done"
92
93 install: force_install
94
95
96 # hard way to clean and clobber
97 clean:
98         $(AT)cd $(WORK_DIR) && git clean -xfd *.o
99 clobber:
100         $(AT)rm -rf $(WORK_DIR)
101
102 # distclean is for developer who would like to keep the
103 # clone git repo, saving time to fetch again from url
104 distclean:
105         $(AT)cd $(WORK_DIR) && git clean -xfd && git checkout -f
106
107 test:
108         @echo "Make test in $(WORK_DIR) (stub) "
109
110 sanity:
111         @echo "Make sanity in $(WORK_DIR) (stub) "
112
113 .PHONY: boot
114 # boot collectd is the process to produce the script 'configure'
115 boot $(WORK_DIR)/configure: $(TAG_DONE_FLAG)
116         @echo "booting up collectd"
117         $(AT)cd $(WORK_DIR); $(BUILD_CMD)
118         @echo "done booting collectd"
119
120 $(WORK_DIR):
121         $(AT)git clone $(COLLECTD_URL)
122
123 $(TAG_DONE_FLAG): $(WORK_DIR)
124         @echo "Checking out collectd from tag: $(COLLECTD_TAG)"
125         $(AT)cd collectd; git fetch origin $(COLLECTD_TAG); git checkout FETCH_HEAD
126 ifneq ($(PATCH_FILE),)
127         $(AT)cd $(WORK_DIR); patch -p1 < ../$(PATCH_FILE)
128 endif
129 ifeq ($(COLLECTD_USE_EXPERIMENTAL_PR), y)
130         @echo "Applying experimental pull requests"
131         $(AT)cd $(WORK_DIR); ../collectd_apply_pull_request.sh
132 endif
133         $(AT)touch $@