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