a17d1571204d4a5b9185ecfb36eda7cbb3a1e94b
[barometer.git] / src / collectd / Makefile
1 # makefile to manage collectd package
2 #
3
4 # Copyright 2016 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 SAMPLE_CONFIG = $(CURDIR)/collectd_sample_configs
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
39 CONFIG_CMD += --enable-syslog
40 CONFIG_CMD += --enable-logfile
41 CONFIG_CMD += --with-libpqos=$(LIBPQOS_DIR)
42 CONFIG_CMD += --with-hugepages
43 CONFIG_CMD += --enable-exec
44 CONFIG_CMD += --enable-python
45 CONFIG_CMD += --enable-threshold
46
47 .PHONY: install force_install config force_make
48
49 # install depends on make
50 #force_install: force_make
51
52 all: force_make
53         @echo "Finished making $(WORK_DIR) "
54
55 config $(WORK_DIR)/Makefile: $(WORK_DIR)/configure
56         $(AT)cd $(WORK_DIR); $(CONFIG_CMD)
57         @echo "Configure done"
58
59 INSTALL_TARGET = force_install force_make
60
61 force_make: $(WORK_DIR)/Makefile
62         $(AT)cd $(WORK_DIR) && git pull $(COLLECTD_URL) $(COLLECTD_TAG)
63         @echo "git pull done"
64         $(AT) $(MAKE) -C $(WORK_DIR) $(MORE_MAKE_FLAGS)
65         @echo "Make done"
66
67 force_install:
68         $(AT)$(MAKE) -C $(WORK_DIR) install
69         $(AT)cp $(WORK_DIR)/contrib/systemd.collectd.service /etc/systemd/system/
70         $(AT)mv /etc/systemd/system/systemd.collectd.service /etc/systemd/system/collectd.service
71         $(AT)chmod +x /etc/systemd/system/collectd.service
72         $(AT)sed -i -e 's/ExecStart=\/usr\/sbin\/collectd/ExecStart=\/opt\/collectd\/sbin\/collectd/g' /etc/systemd/system/collectd.service
73         $(AT)sed -i -e 's/CapabilityBoundingSet=/CapabilityBoundingSet=CAP_SETUID CAP_SETGID/g' /etc/systemd/system/collectd.service
74         $(AT)systemctl daemon-reload
75         $(AT)sudo mkdir -p /opt/collectd/etc/collectd.conf.d
76         $(AT)sudo cp $(SAMPLE_CONFIG)/* /opt/collectd/etc/collectd.conf.d
77         $(AT)sudo ./include_config.sh
78
79 install: $(INSTALL_TARGET)
80
81 # hard way to clean and clobber
82 clean:
83         $(AT)cd $(WORK_DIR) && git clean -xfd *.o
84 clobber:
85         $(AT)rm -rf $(WORK_DIR)
86
87 # distclean is for developer who would like to keep the
88 # clone git repo, saving time to fetch again from url
89 distclean:
90         $(AT)cd $(WORK_DIR) && git clean -xfd && git checkout -f
91
92 test:
93         @echo "Make test in $(WORK_DIR) (stub) "
94
95 sanity:
96         @echo "Make sanity in $(WORK_DIR) (stub) "
97
98 .PHONY: boot
99 # boot collectd is the process to produce the script 'configure'
100 boot $(WORK_DIR)/configure:
101         @echo "booting up collectd"
102         $(AT)cd $(WORK_DIR); $(BUILD_CMD)
103         @echo "done booting collectd"
104
105 boot $(WORK_DIR)/configure: $(TAG_DONE_FLAG)
106
107 $(WORK_DIR):
108         $(AT)git clone $(COLLECTD_URL)
109
110 $(TAG_DONE_FLAG): $(WORK_DIR)
111         $(AT)cd $(WORK_DIR); git checkout $(COLLECTD_TAG)
112 ifneq ($(PATCH_FILE),)
113         $(AT)cd $(WORK_DIR); patch -p1 < ../$(PATCH_FILE)
114 endif
115         $(AT)touch $@