-
Notifications
You must be signed in to change notification settings - Fork 113
/
Makefile
226 lines (200 loc) · 8.13 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Makefile for System & Process Monitor ATOP (Linux version)
#
# Gerlof Langeveld - [email protected]
#
DESTDIR =
BINPATH = /usr/bin
SBINPATH = /usr/sbin
SCRPATH = /usr/share/atop
LOGPATH = /var/log/atop
MAN1PATH = /usr/share/man/man1
MAN5PATH = /usr/share/man/man5
MAN8PATH = /usr/share/man/man8
INIPATH = /etc/init.d
DEFPATH = /etc/default
SYSDPATH = /lib/systemd/system
CRNPATH = /etc/cron.d
ROTPATH = /etc/logrotate.d
PMPATH1 = /usr/lib/pm-utils/sleep.d
PMPATH2 = /usr/lib64/pm-utils/sleep.d
PMPATHD = /usr/lib/systemd/system-sleep
PKG_CONFIG ?= pkg-config
override CFLAGS := -O2 -I. -Wall $(shell $(PKG_CONFIG) --cflags glib-2.0) -Wmissing-prototypes -Wmissing-declarations -Wformat-security $(CFLAGS) # -DNOPERFEVENT # -DHTTPSTATS
CC_CHECK := $(shell echo | $(CC) -dM -E - | grep -q __clang__ && echo clang || echo gcc)
ifeq ($(CC_CHECK),gcc)
override CFLAGS += -Wno-stringop-truncation
endif
override LDFLAGS := $(shell $(PKG_CONFIG) --libs glib-2.0) $(LDFLAGS)
OBJMOD0 = version.o
OBJMOD1 = various.o deviate.o procdbase.o
OBJMOD2 = acctproc.o photoproc.o photosyst.o cgroups.o rawlog.o ifprop.o parseable.o
OBJMOD3 = showgeneric.o drawbar.o showlinux.o showsys.o showprocs.o
OBJMOD4 = atopsar.o netatopif.o netatopbpfif.o gpucom.o json.o utsnames.o
ALLMODS = $(OBJMOD0) $(OBJMOD1) $(OBJMOD2) $(OBJMOD3) $(OBJMOD4)
VERS = $(shell ./atop -V 2>/dev/null| sed -e 's/^[^ ]* //' -e 's/ .*//')
all: atop atopsar atopacctd atopconvert atopcat atophide
atop: atop.o $(ALLMODS) Makefile
$(CC) atop.o $(ALLMODS) -o atop -lncursesw -lz -lm -lrt $(LDFLAGS)
atopsar: atop
ln -sf atop atopsar
atopacctd: atopacctd.o netlink.o
$(CC) atopacctd.o netlink.o -o atopacctd $(LDFLAGS)
atopconvert: atopconvert.o
$(CC) atopconvert.o -o atopconvert -lz $(LDFLAGS)
atopcat: atopcat.o
$(CC) atopcat.o -o atopcat $(LDFLAGS)
atophide: atophide.o
$(CC) atophide.o -o atophide -lz $(LDFLAGS)
clean:
rm -f *.o atop atopsar atopacctd atopconvert atopcat versdate.h
distr:
rm -f *.o atop
tar czvf /tmp/atop.tar.gz *
# default install is based on systemd
#
install: genericinstall
if [ ! -d $(DESTDIR)$(SYSDPATH) ]; \
then mkdir -p $(DESTDIR)$(SYSDPATH); fi
if [ ! -d $(DESTDIR)$(PMPATHD) ]; \
then mkdir -p $(DESTDIR)$(PMPATHD); fi
#
cp atop.service $(DESTDIR)$(SYSDPATH)
chmod 0644 $(DESTDIR)$(SYSDPATH)/atop.service
cp atopgpu.service $(DESTDIR)$(SYSDPATH)
chmod 0644 $(DESTDIR)$(SYSDPATH)/atopgpu.service
cp atop-rotate.service $(DESTDIR)$(SYSDPATH)
chmod 0644 $(DESTDIR)$(SYSDPATH)/atop-rotate.service
cp atop-rotate.timer $(DESTDIR)$(SYSDPATH)
chmod 0644 $(DESTDIR)$(SYSDPATH)/atop-rotate.timer
cp atopacct.service $(DESTDIR)$(SYSDPATH)
chmod 0644 $(DESTDIR)$(SYSDPATH)/atopacct.service
cp atop-pm.sh $(DESTDIR)$(PMPATHD)
chmod 0711 $(DESTDIR)$(PMPATHD)/atop-pm.sh
#
# only when making on target system:
#
if [ -z "$(DESTDIR)" -a -f /bin/systemctl ]; \
then /bin/systemctl disable --now atop 2> /dev/null; \
/bin/systemctl disable --now atopacct 2> /dev/null; \
/bin/systemctl daemon-reload; \
/bin/systemctl enable --now atopacct; \
/bin/systemctl enable --now atop; \
/bin/systemctl enable --now atop-rotate.timer; \
fi
# explicitly use sysvinstall for System V init based systems
#
sysvinstall: genericinstall
if [ ! -d $(DESTDIR)$(INIPATH) ]; \
then mkdir -p $(DESTDIR)$(INIPATH); fi
if [ ! -d $(DESTDIR)$(SCRPATH) ]; \
then mkdir -p $(DESTDIR)$(SCRPATH); fi
if [ ! -d $(DESTDIR)$(CRNPATH) ]; \
then mkdir -p $(DESTDIR)$(CRNPATH); fi
if [ ! -d $(DESTDIR)$(ROTPATH) ]; \
then mkdir -p $(DESTDIR)$(ROTPATH); fi
#
cp atop.init $(DESTDIR)$(INIPATH)/atop
cp atopacct.init $(DESTDIR)$(INIPATH)/atopacct
cp atop.cronsysv $(DESTDIR)$(CRNPATH)/atop
cp atop.daily $(DESTDIR)$(SCRPATH)
chmod 0711 $(DESTDIR)$(SCRPATH)/atop.daily
touch $(DESTDIR)$(LOGPATH)/dummy_before
touch $(DESTDIR)$(LOGPATH)/dummy_after
#
if [ -d $(DESTDIR)$(PMPATH1) ]; \
then cp 45atoppm $(DESTDIR)$(PMPATH1); \
chmod 0711 $(DESTDIR)$(PMPATH1)/45atoppm; \
fi
if [ -d $(DESTDIR)$(PMPATH2) ]; \
then cp 45atoppm $(DESTDIR)$(PMPATH2); \
chmod 0711 $(DESTDIR)$(PMPATH2)/45atoppm; \
fi
#
#
# only when making on target system:
#
if [ -z "$(DESTDIR)" -a -f /sbin/chkconfig ]; \
then /sbin/chkconfig --del atop 2> /dev/null; \
/sbin/chkconfig --add atop; \
/sbin/chkconfig --del atopacct 2> /dev/null; \
/sbin/chkconfig --add atopacct; \
fi
if [ -z "$(DESTDIR)" -a -f /usr/sbin/update-rc.d ]; \
then update-rc.d atop defaults; \
update-rc.d atopacct defaults; \
fi
if [ -z "$(DESTDIR)" -a -f /sbin/service ]; \
then /sbin/service atopacct start; \
sleep 2; \
/sbin/service atop start; \
fi
genericinstall: atop atopacctd atopconvert atopcat atophide
if [ ! -d $(DESTDIR)$(LOGPATH) ]; \
then mkdir -p $(DESTDIR)$(LOGPATH); fi
if [ ! -d $(DESTDIR)$(DEFPATH) ]; \
then mkdir -p $(DESTDIR)$(DEFPATH); fi
if [ ! -d $(DESTDIR)$(BINPATH) ]; \
then mkdir -p $(DESTDIR)$(BINPATH); fi
if [ ! -d $(DESTDIR)$(SBINPATH) ]; \
then mkdir -p $(DESTDIR)$(SBINPATH); fi
if [ ! -d $(DESTDIR)$(MAN1PATH) ]; \
then mkdir -p $(DESTDIR)$(MAN1PATH); fi
if [ ! -d $(DESTDIR)$(MAN5PATH) ]; \
then mkdir -p $(DESTDIR)$(MAN5PATH); fi
if [ ! -d $(DESTDIR)$(MAN8PATH) ]; \
then mkdir -p $(DESTDIR)$(MAN8PATH); fi
#
touch $(DESTDIR)$(DEFPATH)/atop
chmod 644 $(DESTDIR)$(DEFPATH)/atop
#
cp atop $(DESTDIR)$(BINPATH)/atop
chmod 0711 $(DESTDIR)$(BINPATH)/atop
ln -sf atop $(DESTDIR)$(BINPATH)/atopsar
cp atopacctd $(DESTDIR)$(SBINPATH)/atopacctd
chmod 0700 $(DESTDIR)$(SBINPATH)/atopacctd
cp atopgpud $(DESTDIR)$(SBINPATH)/atopgpud
chmod 0700 $(DESTDIR)$(SBINPATH)/atopgpud
cp atop $(DESTDIR)$(BINPATH)/atop-$(VERS)
ln -sf atop-$(VERS) $(DESTDIR)$(BINPATH)/atopsar-$(VERS)
cp atopconvert $(DESTDIR)$(BINPATH)/atopconvert
chmod 0711 $(DESTDIR)$(BINPATH)/atopconvert
cp atopcat $(DESTDIR)$(BINPATH)/atopcat
chmod 0711 $(DESTDIR)$(BINPATH)/atopcat
cp atophide $(DESTDIR)$(BINPATH)/atophide
chmod 0711 $(DESTDIR)$(BINPATH)/atophide
cp man/atop.1 $(DESTDIR)$(MAN1PATH)
cp man/atopsar.1 $(DESTDIR)$(MAN1PATH)
cp man/atopconvert.1 $(DESTDIR)$(MAN1PATH)
cp man/atopcat.1 $(DESTDIR)$(MAN1PATH)
cp man/atophide.1 $(DESTDIR)$(MAN1PATH)
cp man/atoprc.5 $(DESTDIR)$(MAN5PATH)
cp man/atopacctd.8 $(DESTDIR)$(MAN8PATH)
cp man/atopgpud.8 $(DESTDIR)$(MAN8PATH)
##########################################################################
versdate.h:
./mkdate
atop.o: atop.h photoproc.h photosyst.h acctproc.h showgeneric.h
atopsar.o: atop.h photoproc.h photosyst.h
rawlog.o: atop.h photoproc.h photosyst.h rawlog.h showgeneric.h
various.o: atop.h acctproc.h
ifprop.o: atop.h photosyst.h ifprop.h
parseable.o: atop.h photoproc.h photosyst.h cgroups.h parseable.h
deviate.o: atop.h photoproc.h photosyst.h
procdbase.o: atop.h photoproc.h
acctproc.o: atop.h photoproc.h atopacctd.h acctproc.h netatop.h
netatopif.o: atop.h photoproc.h netatopd.h netatop.h
netatopbpfif.o: atop.h photoproc.h netatop.h
photoproc.o: atop.h photoproc.h
photosyst.o: atop.h photosyst.h
cgroups.o: atop.h cgroups.h
showgeneric.o: atop.h photoproc.h photosyst.h cgroups.h showgeneric.h showlinux.h
showlinux.o: atop.h photoproc.h photosyst.h cgroups.h showgeneric.h showlinux.h
showsys.o: atop.h photoproc.h photosyst.h showgeneric.h
showprocs.o: atop.h photoproc.h photosyst.h cgroups.h showgeneric.h showlinux.h
drawbar.o: atop.h photosyst.h showgeneric.h
version.o: version.c version.h versdate.h
gpucom.o: atop.h photoproc.h photosyst.h
atopacctd.o: atop.h photoproc.h acctproc.h atopacctd.h version.h versdate.h
atopconvert.o: atop.h photoproc.h photosyst.h rawlog.h
atopcat.o: atop.h rawlog.h
atophide.o: atop.h photoproc.h photosyst.h rawlog.h