-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
78 lines (67 loc) · 2.15 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
# Define the directories for installation
PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin/
SHAREDIR = $(PREFIX)/share/engine-stressor
SHAREDIR_DOC = $(PREFIX)/share/doc/engine-stressor
CONFIGDIR = $(HOME)/.config/engine-stressor
# Define the list of scripts and files
SCRIPTS = cgroup \
memory \
engine \
network \
engine-operations \
disk-exhaustion/disk-exhaustion \
memory-exhaustion/memory-exhaustion \
processes \
volume \
stress \
systemd \
system \
date \
rpm \
common \
monitor \
selinux
BIN_FILE = engine-stressor
MEM_EXHAUSTION_BIN = memory-exhaustion/exhaustion-memory-engine-stressor
DOCS = README.md LICENSE SECURITY.md NOTICE
CONFIG_FILE = constants
DNF_OR_YUM:=$(shell which dnf || which yum)
# Default target
all:
@echo "Available targets: install, uninstall"
# Install target
install: installdeps
@install -d $(DESTDIR)$(SHAREDIR)
@install -d $(DESTDIR)$(SHAREDIR_DOC)
@install -d $(DESTDIR)$(BINDIR)
@install -d $(DESTDIR)$(CONFIGDIR)
@for script in $(SCRIPTS); do \
install -m 755 $$script $(DESTDIR)$(SHAREDIR); \
done
@for doc in $(DOCS); do \
install -m 644 $$doc $(DESTDIR)$(SHAREDIR_DOC); \
done
@install -m 755 $(BIN_FILE) $(DESTDIR)$(BINDIR)
@install -m 755 $(MEM_EXHAUSTION_BIN) $(DESTDIR)$(BINDIR)
@install -m 644 $(CONFIG_FILE) $(DESTDIR)$(CONFIGDIR)/$(CONFIG_FILE)
@if ! grep -q '^SHARE_DIR=$(SHAREDIR)' $(DESTDIR)$(CONFIGDIR)/$(CONFIG_FILE); then \
echo 'SHARE_DIR=$(SHAREDIR)' >> $(DESTDIR)$(CONFIGDIR)/$(CONFIG_FILE); \
fi
@echo "Installation complete via PREFIX: $(PREFIX)"
@echo " - bin: $(DESTDIR)$(BINDIR)"
@echo " - docs: $(DESTDIR)$(SHAREDIR_DOC)"
@echo " - libs: $(DESTDIR)$(SHAREDIR)"
installdeps:
@if test -x "$(DNF_OR_YUM)"; then rpm -q aardvark-dns > /dev/null 2>&1 || $(DNF_OR_YUM) -y install aardvark-dns; fi
# Uninstall target
uninstall:
@for script in $(SCRIPTS); do \
rm -f $(DESTDIR)$(SHAREDIR)/$$script; \
done
rm -rf $(DESTDIR)$(SHAREDIR)
rm -rf $(DESTDIR)$(SHAREDIR_DOC)
rm -rf $(DESTDIR)$(CONFIGDIR)
rm -f $(DESTDIR)$(BINDIR)/$(BIN_FILE)
@echo "Uninstallation complete."
.PHONY: all install uninstall