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