Debian Codegraph @

Makefile

raw
1 #
2 # Copyright (C) 2013-2021 Canonical, Ltd.
3 # Copyright (C) 2021-2025 Colin Ian King.
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #
19 VERSION=0.04.01
20 #
21 # Codename "Where have all my cycles gone?"
22 #
23
24 JSON_OUTPUT=y
25
26 CFLAGS += -Wall -Wextra -DVERSION='"$(VERSION)"' -O2 -g
27
28 #
29 # Pedantic flags
30 #
31 ifeq ($(PEDANTIC),1)
32 CFLAGS += -Wabi -Wcast-qual -Wfloat-equal -Wmissing-declarations \
33 -Wmissing-format-attribute -Wno-long-long -Wpacked \
34 -Wredundant-decls -Wshadow -Wno-missing-field-initializers \
35 -Wno-missing-braces -Wno-sign-compare -Wno-multichar
36 endif
37
38 LDFLAGS += -lpthread -lbsd
39 ifeq ($(JSON_OUTPUT),y)
40 LDFLAGS += -ljson-c
41 CFLAGS += -DJSON_OUTPUT
42 endif
43 ifeq ($(FNOTIFY),y)
44 CFLAGS += -DFNOTIFY
45 endif
46
47 BINDIR=/usr/bin
48 MANDIR=/usr/share/man/man8
49 BASHDIR=/usr/share/bash-completion/completions
50
51 OBJS = list.o pid.o proc.o net.o syscall.o timeval.o \
52 fnotify.o cpustat.o mem.o ctxt-switch.o health-check.o
53 ifeq ($(JSON_OUTPUT),y)
54 OBJS += json.o
55 endif
56
57 health-check: $(OBJS) Makefile
58 $(CC) $(CFLAGS) $(OBJS) -o $@ $(LDFLAGS)
59
60 health-check.8.gz: health-check.8
61 gzip -c $< > $@
62
63 cpustat.o: cpustat.c list.h json.h cpustat.h timeval.h health-check.h
64
65 ctxt-switch.o: ctxt-switch.c list.h json.h ctxt-switch.h health-check.h
66
67 fnotify.o: fnotify.c fnotify.h list.h json.h proc.h health-check.h
68
69 health-check.o: health-check.c list.h json.h pid.h proc.h syscall.h timeval.h \
70 fnotify.h cpustat.h mem.h net.h ctxt-switch.h
71
72 json.o: json.c json.h health-check.h
73
74 list.o: list.c list.h
75
76 mem.o: mem.c mem.h list.h health-check.h
77
78 net.o: net.c net.h list.h proc.h json.h health-check.h
79
80 pid.o: pid.c pid.h list.h proc.h
81
82 proc.o: proc.c list.h pid.h proc.h net.h health-check.h
83
84 syscall.o: syscall.c syscall.h proc.h json.h net.h mem.h \
85 cpustat.h fnotify.h ctxt-switch.h health-check.h
86
87 timeval.o: timeval.c timeval.h
88
89 dist:
90 rm -rf health-check-$(VERSION)
91 mkdir health-check-$(VERSION)
92 cp -rp Makefile *.c *.h .travis.yml scripts health-check.8 \
93 bash-completion COPYING README.md health-check-$(VERSION)
94 tar -Jcf health-check-$(VERSION).tar.xz health-check-$(VERSION)
95 rm -rf health-check-$(VERSION)
96
97 clean:
98 rm -f health-check health-check.o health-check.8.gz
99 rm -f health-check-$(VERSION).tar.xz
100 rm -f $(OBJS)
101
102 install: health-check health-check.8.gz
103 mkdir -p ${DESTDIR}${BINDIR}
104 cp health-check ${DESTDIR}${BINDIR}
105 mkdir -p ${DESTDIR}${MANDIR}
106 cp health-check.8.gz ${DESTDIR}${MANDIR}
107 mkdir -p ${DESTDIR}${BASHDIR}
108 cp bash-completion/health-check ${DESTDIR}${BASHDIR}