-
Notifications
You must be signed in to change notification settings - Fork 47
/
Makefile
66 lines (50 loc) · 1.54 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
PREFIX:=/usr/
DESTDIR:=/
BINDIR:=$(DESTDIR)/$(PREFIX)/sbin/
MANDIR:=$(DESTDIR)/$(PREFIX)/share/man/man1/
PKGCONFIG = pkg-config
HAVE_PKGCONFIG = $(shell $(PKGCONFIG) --version 2>/dev/null || echo no)
ifneq ($(HAVE_PKGCONFIG),no)
HAVE_SYSTEMD = $(shell $(PKGCONFIG) --exists libsystemd && echo 1 || echo 0)
ifeq ($(HAVE_SYSTEMD),1)
CPPFLAGS += -DHAVE_SYSTEMD=1
CFLAGS += $(shell $(PKGCONFIG) --cflags libsystemd)
LDLIBS += $(shell $(PKGCONFIG) --libs libsystemd)
endif
endif
VERSION:=$(shell cat version.inc)
THD_COMPS := thd keystate trigger eventnames devices cmdsocket obey ignore uinput triggerparser
THCMD_COMPS := th-cmd cmdsocket
MAKEDEPEND = $(CC) -M -MG $(CPPFLAGS) -o $*.d $<
all: thd th-cmd man
man: thd.1 th-cmd.1
thd: $(THD_COMPS:%=%.o)
th-cmd: $(THCMD_COMPS:%=%.o)
%.1: %.pod
pod2man \
--center="Triggerhappy daemon" \
--section=1 \
--release="$(VERSION)" \
$< > $@
linux_input_defs_gen.inc:
echo "#include <linux/input.h>" | $(CC) $(CPPFLAGS) -dM -E - > $@
evtable_%.inc: linux_input_defs_gen.inc
awk '/^#define $*_/ && $$2 !~ /_(MIN_INTERESTING|MAX|CNT|VERSION)$$/ {print "EV_MAP("$$2"),"}' $< > $@
version.h: version.inc
sed -r 's!(.*)!#define TH_VERSION "\1"!' $< > $@
clean:
rm -f *.d
rm -f *.o
rm -f linux_input_defs_gen.inc
rm -f evtable_*.inc
rm -f version.h
rm -f thd th-cmd
rm -f thd.1 th-cmd.1
install: all
install -D thd $(BINDIR)/thd
install -D th-cmd $(BINDIR)/th-cmd
install -D thd.1 $(MANDIR)/thd.1
install -D th-cmd.1 $(MANDIR)/th-cmd.1
%.d : %.c
$(MAKEDEPEND)
-include $(THD_COMPS:%=%.d) $(THCMD_COMPS:%=%.d)