aboutsummaryrefslogtreecommitdiffstats
path: root/utils/keytable/Makefile.am
blob: df2b2231c7f7a32d54eb8585b5ecfac5c1545443 (plain)
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
bin_PROGRAMS = ir-keytable
man_MANS = ir-keytable.1
sysconf_DATA = rc_maps.cfg
keytablesystem_DATA = $(srcdir)/rc_keymaps/*
udevrules_DATA = 70-infrared.rules

ir_keytable_SOURCES = keytable.c parse.h ir-encode.c ir-encode.h toml.c toml.h

if HAVE_LIBELF
ir_keytable_SOURCES += bpf.c bpf_load.c bpf.h bpf_load.h
endif

ir_keytable_LDADD = @LIBINTL@
ir_keytable_LDFLAGS = $(ARGP_LIBS) $(LIBELF_LIBS)

EXTRA_DIST = 70-infrared.rules rc_keymaps rc_keymaps_userspace gen_keytables.pl ir-keytable.1 rc_maps.cfg

# custom target
install-data-local:
	$(install_sh) -d "$(DESTDIR)$(keytableuserdir)"

sync-with-kernel:
	@if [ ! -f $(KERNEL_DIR)/usr/include/linux/input-event-codes.h ]; then \
	  echo "Error you must set KERNEL_DIR to point to an extracted kernel source dir"; \
	  exit 1; \
	fi
	@echo generating $(srcdir)/parse.h
	@printf "struct parse_event {\n\tchar *name;\n\tunsigned int value;\n};\n" > $(srcdir)/parse.h

	@printf "struct parse_event events_type[] = {\n" >> $(srcdir)/parse.h
	@more $(KERNEL_DIR)/usr/include/linux/input-event-codes.h | perl -n \
	-e 'if (m/^\#define\s+(EV_[^\s]+)\s+(0x[\d\w]+|[\d]+)/) ' \
	-e '{ printf "\t{\"%s\", %s},\n",$$1,$$2 if ($$1 ne "EV_VERSION"); }' \
	>> $(srcdir)/parse.h
	@printf "\t{ NULL, 0}\n};\n" >> $(srcdir)/parse.h

	@printf "struct parse_event msc_events[] = {\n" >> $(srcdir)/parse.h
	@more $(KERNEL_DIR)/usr/include/linux/input-event-codes.h | perl -n \
	-e 'if (m/^\#define\s+(MSC_[^\s]+)\s+(0x[\d\w]+|[\d]+)/) ' \
	-e '{ printf "\t{\"%s\", %s},\n",$$1,$$2; }' \
	>> $(srcdir)/parse.h
	@printf "\t{ NULL, 0}\n};\n" >> $(srcdir)/parse.h

	@printf "struct parse_event key_events[] = {\n" >> $(srcdir)/parse.h
	@more $(KERNEL_DIR)/usr/include/linux/input-event-codes.h | perl -n \
	-e 'if (m/^\#define\s+(KEY_[^\s]+)\s+(0x[\d\w]+|[\d]+)/) ' \
	-e '{ printf "\t{\"%s\", %s},\n",$$1,$$2; }' \
	-e 'if (m/^\#define\s+(BTN_[^\s]+)\s+(0x[\d\w]+|[\d]+)/) ' \
	-e '{ printf "\t{\"%s\", %s},\n",$$1,$$2; }' \
	>> $(srcdir)/parse.h
	@printf "\t{ NULL, 0}\n};\n" >> $(srcdir)/parse.h

	@printf "struct parse_event rel_events[] = {\n" >> $(srcdir)/parse.h
	@more $(KERNEL_DIR)/usr/include/linux/input-event-codes.h | perl -n \
	-e 'if (m/^\#define\s+(REL_[^\s]+)\s+(0x[\d\w]+|[\d]+)/) ' \
	-e '{ printf "\t{\"%s\", %s},\n",$$1,$$2; }' \
	>> $(srcdir)/parse.h
	@printf "\t{ NULL, 0}\n};\n" >> $(srcdir)/parse.h

	@printf "struct parse_event abs_events[] = {\n" >> $(srcdir)/parse.h
	@more $(KERNEL_DIR)/usr/include/linux/input-event-codes.h | perl -n \
	-e 'if (m/^\#define\s+(ABS_[^\s]+)\s+(0x[\d\w]+|[\d]+)/) ' \
	-e '{ printf "\t{\"%s\", %s},\n",$$1,$$2; }' \
	>> $(srcdir)/parse.h
	@printf "\t{ NULL, 0}\n};\n" >> $(srcdir)/parse.h

	@-mkdir -p $(srcdir)/rc_keymaps
	@-rm $(srcdir)/rc_keymaps/*
	@-cp $(srcdir)/rc_keymaps_userspace/* $(srcdir)/rc_keymaps/
	@echo storing existing keymaps at $(srcdir)/rc_keymaps/
	@cd $(srcdir) && ./gen_keytables.pl $(KERNEL_DIR);

Privacy Policy