-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
72 lines (54 loc) · 2.06 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
.POSIX:
NAME = caffeinated
VERSION = $(shell grep VERSION version.h | cut -d \" -f2)
PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man
SDBUS_LIB = $(shell pkgconf --libs libsystemd)
ifeq ($(SDBUS), elogind)
SDBUS_LIB = -lelogind
else ifeq ($(SDBUS), systemd)
SDBUS_LIB = -lsystemd
else ifdef SDBUS
$(error Invalid SDBUS)
endif
ifeq ($(strip $(SDBUS_LIB)), -lelogind)
SDBUS_DEFINE = -DELOGIND
SDBUS = elogind
endif
ifdef WAYLAND
WAYLAND_LIB = $(shell pkg-config --silence-errors --libs wayland-client)
WAYLAND_PROTOCOLS_DIR = $(shell pkg-config --silence-errors --variable=pkgdatadir wayland-protocols)
WAYLAND_SCANNER = $(shell pkg-config --silence-errors --variable=wayland_scanner wayland-scanner)
WAYLAND_PROTOCOL = $(WAYLAND_PROTOCOLS_DIR)/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
WAYLAND_SRC = idle-inhibit-unstable-v1-client-protocol.h idle-inhibit-unstable-v1-protocol.c
WAYLAND_DEFINE = -DWAYLAND
endif
CC = cc
LD = ld
CFLAGS = -std=c99 -pedantic -Wall -Wextra -Werror -Wno-unused-parameter -Os -s -D_GNU_SOURCE $(SDBUS_DEFINE) $(WAYLAND_DEFINE)
LDLIBS = -lbsd $(SDBUS_LIB) $(WAYLAND_LIB)
SRC = main.c version.h $(WAYLAND_SRC)
OBJ = main.o
all: $(NAME)
$(NAME): $(OBJ)
$(CC) $(LDLIBS) -o $(NAME) $(OBJ) $(WAYLAND_SRC) $(LDFLAGS)
$(OBJ): $(SRC)
idle-inhibit-unstable-v1-client-protocol.h:
$(WAYLAND_SCANNER) client-header $(WAYLAND_PROTOCOL) idle-inhibit-unstable-v1-client-protocol.h
idle-inhibit-unstable-v1-protocol.c:
$(WAYLAND_SCANNER) private-code $(WAYLAND_PROTOCOL) idle-inhibit-unstable-v1-protocol.c
clean:
@echo cleaning
$(RM) $(NAME) $(OBJ) $(WAYLAND_SRC)
install: all
@echo installing in $(DESTDIR)$(PREFIX)
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f $(NAME) $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/$(NAME)
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
sed "s/VERSION/$(VERSION)/g" < $(NAME).1 > $(DESTDIR)$(MANPREFIX)/man1/$(NAME).1
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/$(NAME).1
uninstall:
@echo removing files from $(DESTDIR)$(PREFIX)
$(RM) $(DESTDIR)$(PREFIX)/bin/$(NAME)
$(RM) $(DESTDIR)$(MANPREFIX)/man1/$(NAME).1