1 # makefile to manage collectd package
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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.
20 # Aihua Li, Huawei Technologies.
21 # Maryam Tahhan, Intel Corporation.
23 include ../mk/master.mk
24 include ../package-list.mk
27 SAMPLE_CONFIG = $(CURDIR)/collectd_sample_configs
28 TAG_DONE_FLAG = $(WORK_DIR)/.$(COLLECTD_TAG).done
29 BUILD_CMD = ./build.sh
31 CONFIG_CMD += ./configure
33 # DPDK_DIR is the directory where DPDK shared lib is installed
34 DPDK_DIR = $(shell echo $$DPDK_DIR)
39 LIBPQOS_DIR = $(shell echo $$LIBPQOS_DIR)
40 ifeq ($(LIBPQOS_DIR),)
45 CONFIG_CMD += --enable-syslog
46 CONFIG_CMD += --enable-logfile
47 CONFIG_CMD += --with-libdpdk=$(DPDK_DIR)
48 CONFIG_CMD += --with-libpqos=$(LIBPQOS_DIR)
49 CONFIG_CMD += --with-hugepages
50 CONFIG_CMD += --enable-exec
51 CONFIG_CMD += --enable-python
52 CONFIG_CMD += --enable-threshold
54 .PHONY: install force_install config force_make
56 # install depends on make
57 #force_install: force_make
60 @echo "Finished making $(WORK_DIR) "
62 config $(WORK_DIR)/Makefile: $(WORK_DIR)/configure
63 $(AT)cd $(WORK_DIR); $(CONFIG_CMD)
64 @echo "Configure done"
66 INSTALL_TARGET = force_install force_make
68 force_make: $(WORK_DIR)/Makefile
69 $(AT)cd $(WORK_DIR) && git pull $(COLLECTD_URL) $(COLLECTD_TAG)
71 $(AT) $(MAKE) -C $(WORK_DIR) $(MORE_MAKE_FLAGS)
75 $(AT)$(MAKE) -C $(WORK_DIR) install
76 $(AT)cp $(WORK_DIR)/contrib/systemd.collectd.service /etc/systemd/system/
77 $(AT)mv /etc/systemd/system/systemd.collectd.service /etc/systemd/system/collectd.service
78 $(AT)chmod +x /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/g' /etc/systemd/system/collectd.service
81 $(AT)systemctl daemon-reload
82 $(AT)sudo mkdir -p /opt/collectd/etc/collectd.conf.d
83 $(AT)sudo cp $(SAMPLE_CONFIG)/* /opt/collectd/etc/collectd.conf.d
84 $(AT)sudo ./include_config.sh
86 install: $(INSTALL_TARGET)
88 # hard way to clean and clobber
90 $(AT)cd $(WORK_DIR) && git clean -xfd *.o
92 $(AT)rm -rf $(WORK_DIR)
94 # distclean is for developer who would like to keep the
95 # clone git repo, saving time to fetch again from url
97 $(AT)cd $(WORK_DIR) && git clean -xfd && git checkout -f
100 @echo "Make test in $(WORK_DIR) (stub) "
103 @echo "Make sanity in $(WORK_DIR) (stub) "
106 # boot collectd is the process to produce the script 'configure'
107 boot $(WORK_DIR)/configure:
108 @echo "booting up collectd"
109 $(AT)cd $(WORK_DIR); $(BUILD_CMD)
110 @echo "done booting collectd"
112 boot $(WORK_DIR)/configure: $(TAG_DONE_FLAG)
115 $(AT)git clone $(COLLECTD_URL)
117 $(TAG_DONE_FLAG): $(WORK_DIR)
118 $(AT)cd $(WORK_DIR); git checkout $(COLLECTD_TAG)
119 ifneq ($(PATCH_FILE),)
120 $(AT)cd $(WORK_DIR); patch -p1 < ../$(PATCH_FILE)