-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
89 lines (68 loc) · 1.82 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
# Compiler
CC = gcc
# Directories
SRCDIR = ./src
BINDIR = ./bin
CDIR = ./config
RELEASE_CONFIGDIR = /usr/share/initceptor_config
INSTALL_LOCATION = /sbin/init
# Compiler flags
CFLAGS = -Wall -I$(SRCDIR) -lcrypt -O2
# Also flags for IDE debugging
DFLAGS = -g
# And then also the strict flags
SFLAGS = -Wall -Werror -Wextra
# Source files
SRCS = $(wildcard $(SRCDIR)/*.c)
# Object files
OBJS = $(SRCS:$(SRCDIR)/%.c=$(BINDIR)/%.o)
# Executable name
EXEC = $(BINDIR)/main
# Default target
all: run
foldersdamnit: # Apparently we have github's shenanigans :/
-mkdir $(SRCDIR)
-mkdir $(BINDIR)
-mkdir $(CDIR)
-touch $(CDIR)
install:
-sudo mkdir -p $(RELEASE_CONFIGDIR)
-sudo touch $(RELEASE_CONFIGDIR)/commands.sh
-sudo cp $(CDIR)/commands.sh $(RELEASE_CONFIGDIR)/commands.sh
@echo "This will overwrite $(INSTALL_LOCATION)"
@echo "Do you want to continue? (y/n)"
@read answer; \
if [ "$$answer" = "y" ]; then \
echo "Compiling..." && \
make strict && \
echo "Copying $(EXEC) to $(INSTALL_LOCATION)..." && \
sudo rm $(INSTALL_LOCATION) && \
sudo cp $(EXEC) $(INSTALL_LOCATION) && \
echo "Adding user..." && \
if sudo useradd -r -M -N -c "Account for Initceptor" initceptor; then \
echo "Please enter a new password for initceptor." && \
sudo passwd initceptor; \
else \
echo "User already exists."; \
fi && \
echo "Installation complete!"; \
else \
echo "Installation aborted."; \
fi
$(BINDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
-make foldersdamnit
debug: $(OBJS)
$(CC) $(OBJS) $(CFLAGS) $(DFLAGS) -o $(EXEC)
clean:
rm -fv $(OBJS) $(EXEC)
compile: $(OBJS)
$(CC) $(OBJS) $(CFLAGS) -o $(EXEC)
run: strict
./$(EXEC)
sudo: strict
sudo ./$(EXEC)
strict:
# How parents see chores:
$(CC) $(SRCS) $(CFLAGS) $(SFLAGS) -o $(EXEC)
.PHONY: all debug clean compile run sudo strict foldersdamnit