-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
132 lines (99 loc) · 3.48 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
include config.mk
SRC = src
OBJ = obj
BIN = bin
DOC = doc
DEB = debug
TESTS_NAME = tests
SHARED_DIR = shared
SRC_CTL = ${SRC}/potctl.c ${SRC}/utils.c ${SRC}/client.c ${SRC}/socket.c ${SRC}/timer.c ${SRC}/pidfile.c
SRC_D = ${SRC}/timer.c ${SRC}/potd.c ${SRC}/utils.c ${SRC}/socket.c ${SRC}/pidfile.c
SRC_TUI = ${SRC}/potui.c ${SRC}/timer.c ${SRC}/utils.c ${SRC}/socket.c ${SRC}/client.c ${SRC}/ncurses-utils.c ${SRC}/pidfile.c
OBJ_CTL = $(patsubst $(SRC)/%.c,$(OBJ)/%.o,$(SRC_CTL))
OBJ_D = $(patsubst $(SRC)/%.c,$(OBJ)/%.o,$(SRC_D))
OBJ_TUI = $(patsubst $(SRC)/%.c,$(OBJ)/%.o,$(SRC_TUI))
OBJ_CTL_DEB = $(patsubst $(SRC)/%.c,$(OBJ)/%.odeb,$(SRC_CTL))
OBJ_D_DEB = $(patsubst $(SRC)/%.c,$(OBJ)/%.odeb,$(SRC_D))
OBJ_TUI_DEB = $(patsubst $(SRC)/%.c,$(OBJ)/%.odeb,$(SRC_TUI))
SRC_TESTS = ${SRC}/tests.c ${SRC}/timer.c ${SRC}/utils.c
OBJ_TESTS = $(patsubst $(SRC)/%.c,$(OBJ)/%.o,$(SRC_TESTS))
D_NAME = potd
CTL_NAME = potctl
TUI_NAME = potui
BINS_PATHS = ${BIN}/${D_NAME} ${BIN}/${CTL_NAME} ${BIN}/${TUI_NAME}
MD_DOCS = $(wildcard ${DOC}/*.md)
MAN_PAGES = $(patsubst %.md,%.1,$(MD_DOCS))
$(OBJ)/%.o: $(SRC)/%.c
mkdir -p $(OBJ)
$(CC) $(CFLAGS) -c $< -o $@
$(OBJ)/%.odeb: $(SRC)/%.c
mkdir -p $(OBJ)
$(CC) $(CFLAGS) ${DEBFLAGS} -c $< -o $@
all: options ${BINS_PATHS}
doc: ${MD_DOCS}
for man in ${MD_DOCS}; do \
pandoc $$man -s -t man -o $${man/.md}.1; \
done
test: ${DEB}/${TESTS_NAME}
@echo Running tests:
@./${DEB}/${TESTS_NAME} && echo Tests are looking good!
SHELL_CONFIGS = on-pomodoro.sh on-short-break.sh on-long-break.sh on-pause.sh on-unpause.sh
install: all install_options ${MAN_PAGES}
mkdir -p ${CONFIG_DIR}
for config in ${SHELL_CONFIGS}; do \
touch ${CONFIG_DIR}/$$config; \
chmod +x ${CONFIG_DIR}/$$config; \
done
mkdir -p ${DESTDIR}${PREFIX}/bin
for bin in ${BINS_PATHS}; do \
cp -f $$bin ${DESTDIR}${PREFIX}/bin; \
done
mkdir -p ${DESTDIR}${MANPREFIX}/man1
for man_page in ${MAN_PAGES}; do \
sed "s/VERSION/${VERSION}/g" < $$man_page > ${DESTDIR}${MANPREFIX}/man1/$$(basename $$man_page); \
done
${DEB}/${TESTS_NAME}: ${OBJ_TESTS}
mkdir -p ${DEB}
$(CC) -o ${DEB}/${TESTS_NAME} ${OBJ_TESTS}
${OBJ_CTL} ${OBJ_D} ${OBJ_TUI} ${OBJ_TESTS} ${OBJ_DEBUG}: include/signal.h config.h config.mk
install_options:
@echo potato install options:
@echo "DESTDIR = ${DESTDIR}"
@echo "PREFIX = ${PREFIX}"
@echo "MANPREFIX = ${MANPREFIX}"
@echo "CONFIG = ${CONFIG_DIR}"
options:
@echo potato build options:
@echo "CFLAGS = ${CFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}"
@echo "CC = ${CC}"
${BIN}/${D_NAME}: ${OBJ_D}
mkdir -p $(BIN)
${CC} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJ_D}
${BIN}/${CTL_NAME}: ${OBJ_CTL}
mkdir -p $(BIN)
${CC} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJ_CTL}
${BIN}/${TUI_NAME}: ${OBJ_TUI}
mkdir -p $(BIN)
${CC} ${CFLAGS} ${LDFLAGS} `pkg-config --libs --cflags ncurses` -o $@ ${OBJ_TUI}
debug: ${DEB}/${D_NAME} ${DEB}/${CTL_NAME} ${DEB}/${TUI_NAME}
${DEB}/${D_NAME}: ${OBJ_D_DEB}
mkdir -p $(DEB)
$(CC) ${CFLAGS} ${LDFLAGS} ${DEBFLAGS} -o $@ ${OBJ_D_DEB}
${DEB}/${CTL_NAME}: ${OBJ_CTL_DEB}
mkdir -p $(DEB)
$(CC) ${CFLAGS} ${LDFLAGS} ${DEBFLAGS} -o $@ ${OBJ_CTL_DEB}
${DEB}/${TUI_NAME}: ${OBJ_TUI_DEB}
mkdir -p $(DEB)
$(CC) ${CFLAGS} ${LDFLAGS} ${DEBFLAGS} `pkg-config --libs --cflags ncurses` -o $@ ${OBJ_TUI_DEB}
config.h:
cp config.def.h $@
clean:
rm $(OBJ) $(BIN) $(DEB) -rf
uninstall:
for bin in ${BINS_PATHS}; do \
rm ${DESTDIR}${PREFIX}/bin/$$(basename $$bin); \
done
for man_page in ${MAN_PAGES}; do \
rm ${DESTDIR}${MANPREFIX}/man1/$$(basename $$man_page); \
done