forked from n-st/collectd-plugin-intel_cpu_energy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
45 lines (37 loc) · 1.33 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
CC = gcc
CFLAGS := -Wall -DHAVE_CONFIG_H -shared -fPIC -g $(CFLAGS)
INCLUDES = -I vendor/cpu-energy-meter
LFLAGS = -L.
LIBS = -lm
SRCS = intel_cpu_energy.c $(wildcard vendor/cpu-energy-meter/*.c)
OBJS = $(SRCS:.c=.o)
PLUGIN_NAME = intel_cpu_energy
MAIN = $(PLUGIN_NAME).so
TYPE_DB = energy-type.db
all: $(MAIN)
$(MAIN): $(OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(MAIN) $(OBJS) $(LFLAGS) $(LIBS)
strip $(MAIN)
# this is a suffix replacement rule for building .o's from .c's
# it uses automatic variables $<: the name of the prerequisite of
# the rule(a .c file) and $@: the name of the target of the rule (a .o file)
# (see the gnu make manual section about automatic variables)
.c.o:
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
$(RM) $(OBJS) *~ $(MAIN)
install: $(MAIN) $(TYPE_DB)
cp $(MAIN) /usr/lib/collectd/
cp $(TYPE_DB) /etc/collectd/
echo 'LoadPlugin $(PLUGIN_NAME)' > /etc/collectd/collectd.conf.d/intel_cpu_energy.conf
echo 'TypesDB "/usr/share/collectd/types.db" "/etc/collectd/$(TYPE_DB)"' >> /etc/collectd/collectd.conf.d/intel_cpu_energy.conf
uninstall:
rm -f /usr/lib/collectd/$(MAIN)
rm -f /etc/collectd/$(TYPE_DB)
rm -f /etc/collectd/collectd.conf.d/intel_cpu_energy.conf
depend: $(SRCS)
makedepend $(INCLUDES) $^
.PHONY: format-source
format-source:
clang-format -i *.c
# DO NOT DELETE THIS LINE -- make depend needs it