-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
65 lines (54 loc) · 1.37 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
# Executable
EXEC=katrologger
SCREENSHOT=screenshot
RUN=/root/.katrologger/run
BIN=/usr/bin/
CONFIG=/root/.katrologger/
SYSTEMD=/etc/systemd/system/katrologger.service
# Compiler
CC=gcc
# .c sources
C_SRC=$(wildcard ./src/*.c)
# .h headers
H_SRC=$(wildcard ./src/*.h)
# Object files
OBJ=$(subst .c,.o,$(subst src,objs,$(C_SRC)))
# Flags
CC_FLAGS=-w \
-lquickmail \
-lX11
all: objFolder $(EXEC) $(SCREENSHOT)
$(EXEC): $(OBJ)
@ echo '>>> Building binary using GCC linker: $@'
$(CC) $^ -o $@ $(CC_FLAGS)
@ echo 'Finished building binary: $@'
@ echo ' '
./objs/%.o: ./src/%.c ./src/%.h
@ echo '>>> Building target using GCC compiler: $<'
$(CC) -c $< -o $@ -w
@ echo ' '
./objs/main.o: ./src/main.c $(H_SRC)
@ echo '>>> Building target using GCC compiler: $<'
$(CC) -c $< -o $@ -w
@ echo ' '
$(SCREENSHOT):
@ echo '>>> Building target using GCC compiler: $@'
$(CC) ./src/screenshot/screenshot.c -o $(RUN)/$@ -w -lcairo -lX11
@ echo 'Finished building binary: $@'
@ echo ' '
objFolder:
@ mkdir -p objs
clean:
@ rm -rf ./objs/*.o $(EXEC) $(SCREENSHOT)
@ rmdir objs
.PHONY: all clean
make install:
@ mv $(EXEC) $(BIN)
@ echo "Installing: $(EXEC) -> $(BIN)"
uninstall:
@ echo "remove binary -> $(BIN)$(EXEC)"
@ rm -f $(BIN)$(EXEC)
@ echo "remove directory -> $(CONFIG)"
@ rm -rf $(CONFIG)
@ echo "remove systemd unif-file -> $(SYSTEMD)"
@ rm -f $(SYSTEMD)