1cff9364240a0db375d2d7dec2077b29b2605b85
[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 TAG_DONE_FLAG = $(WORK_DIR)/.$(COLLECTD_TAG).done
28 BUILD_CMD = ./build.sh
29 CONFIG_CMD =
30 CONFIG_CMD += ./configure
31
32 # DPDK_DIR is the directory where DPDK shared lib is installed
33 DPDK_DIR = $(shell echo $$DPDK_DIR)
34 ifeq ($(DPDK_DIR),)
35 DPDK_DIR = /usr
36 endif
37
38 CONFIG_CMD += --enable-syslog
39 CONFIG_CMD += --enable-logfile
40 CONFIG_CMD += --with-libdpdk=$(DPDK_DIR)
41
42 .PHONY: install force_install config force_make
43
44 # install depends on make
45 force_install: force_make
46
47 all: force_make
48         @echo "Finished making $(WORK_DIR) "
49
50 config $(WORK_DIR)/Makefile: $(WORK_DIR)/configure
51         $(AT)cd $(WORK_DIR); $(CONFIG_CMD)
52         @echo "Configure done"
53
54 INSTALL_TARGET = force_install force_make
55
56 force_make: $(WORK_DIR)/Makefile
57         $(AT)cd $(WORK_DIR) && git pull $(COLLECTD_URL) $(COLLECTD_TAG)
58         @echo "git pull done"
59         $(AT)$(MAKE) -C $(WORK_DIR) $(MORE_MAKE_FLAGS)
60         @echo "Make done"
61
62 force_install:
63         $(AT)sudo $(MAKE) -C $(WORK_DIR) install
64
65 install: $(INSTALL_TARGET)
66
67 # hard way to clean and clobber
68 clean:
69         $(AT)cd $(WORK_DIR) && git clean -xfd *.o
70 clobber:
71         $(AT)rm -rf $(WORK_DIR)
72
73 # distclean is for developer who would like to keep the
74 # clone git repo, saving time to fetch again from url
75 distclean:
76         $(AT)cd $(WORK_DIR) && git clean -xfd && git checkout -f
77
78 test:
79         @echo "Make test in $(WORK_DIR) (stub) "
80
81 sanity:
82         @echo "Make sanity in $(WORK_DIR) (stub) "
83
84 .PHONY: boot
85 # boot collectd is the process to produce the script 'configure'
86 boot $(WORK_DIR)/configure:
87         @echo "booting up collectd"
88         $(AT)cd $(WORK_DIR); $(BUILD_CMD)
89         @echo "done booting collectd"
90
91 boot $(WORK_DIR)/configure: $(TAG_DONE_FLAG)
92
93 $(WORK_DIR):
94         $(AT)git clone $(COLLECTD_URL)
95
96 $(TAG_DONE_FLAG): $(WORK_DIR)
97         $(AT)cd $(WORK_DIR); git checkout $(COLLECTD_TAG)
98 ifneq ($(PATCH_FILE),)
99         $(AT)cd $(WORK_DIR); patch -p1 < ../$(PATCH_FILE)
100 endif
101         $(AT)touch $@