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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
PLUGIN = inputdev
VERSION = 0.0.1
plugin_SOURCES = \
inputdev.cc \
inputdev.h \
plugin.cc \
modmap.cc \
modmap.h
helper_SOURCES = \
udevhelper.c
extra_SOURCES = \
COPYING \
COPYING.gpl-2 \
COPYING.gpl-3 \
Makefile \
README.txt \
contrib/96-vdrkeymap.rules \
contrib/hama-mce \
contrib/tt6400-ir \
contrib/x10-wti
LINGUAS = de
### The C++ compiler and options:
CXX ?= $(CC)
TAR ?= tar
XZ ?= xz
GPG ?= gpg
GZIP ?= gzip
MSGFMT ?= msgfmt
MSGMERGE ?= msgmerge
XGETTEXT ?= xgettext
PKG_CONFIG ?= pkg-config
GPERF ?= gperf
SED ?= sed
INSTALL ?= install
INSTALL_DATA ?= $(INSTALL) -p -m 0644
INSTALL_PLUGIN ?= $(INSTALL) -p -m 0755
INSTALL_BIN ?= $(INSTALL) -p -m 0755
MKDIR_P ?= $(INSTALL) -d -m 0755
TOUCH_C ?= touch -c
GPERF_FLAGS = -L C++ --readonly-tables --enum --ignore-case
SYSTEMD_CFLAGS = $(shell ${PKG_CONFIG} --cflags libsystemd-daemon || echo "libsystemd_missing")
SYSTEMD_LIBS = $(shell ${PKG_CONFIG} --libs libsystemd-daemon || echo "libsystemd_missing")
VDR_CFLAGS = $(shell ${PKG_CONFIG} --variable=cflags vdr)
VDR_CXXFLAGS = $(shell ${PKG_CONFIG} --variable=cxxflags vdr)
TAR_FLAGS = --owner root --group root --mode a+rX,go-w
AM_CPPFLAGS = -DPACKAGE_VERSION=\"${VERSION}\" -DSOCKET_PATH=\"${SOCKET_PATH}\" \
-D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
AM_MSGMERGEFLAGS = -U --force-po --no-wrap --no-location --backup=none -q
AM_XGETTEXTFLAGS = -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP \
--package-name=vdr-$(PLUGIN) --package-version=$(VERSION) \
--msgid-bugs-address='<see README>'
WARN_OPTS = -Wall -W -Wno-missing-field-initializers -Wextra
AM_CXXFLAGS += $(VDR_CXXFLAGS) $(WARN_OPTS)
AM_CFLAGS += $(VDR_CFLAGS) $(WARN_OPTS)
ifneq ($(USE_SYSTEMD),)
AM_CPPFLAGS += -DVDR_USE_SYSTEMD
AM_CXXFLAGS += ${SYSTEMD_CFLAGS}
LIBS += ${SYSTEMD_LIBS}
endif
prefix = /usr/local
datadir = $(prefix)/share
plugindir = $(shell ${PKG_CONFIG} --variable=libdir vdr)
udevdir = $(prefix)/lib/udev
localedir = $(datadir)/locale
vdr_PLUGINS = libvdr-$(PLUGIN).so.$(APIVERSION)
### The directory environment:
VDRDIR ?= ../../..
SOCKET_PATH = /var/run/vdr/inputdev
### Allow user defined options to overwrite defaults:
-include $(VDRDIR)/Make.global
-include $(VDRDIR)/Make.config
### The version number of VDR's plugin API (taken from VDR's "config.h"):
APIVERSION = $(shell ${PKG_CONFIG} --variable=apiversion vdr)
### The name of the distribution archive:
ARCHIVE = $(PLUGIN)-$(VERSION)
PACKAGE = vdr-$(ARCHIVE).tar
### The object files (add further files here):
_all_sources = $(plugin_SOURCES) $(helper_SOURCES) $(extra_SOURCES)
_objects = \
$(patsubst %.c,%.o,$(filter %.c,$(plugin_SOURCES))) \
$(patsubst %.cc,%.o,$(filter %.cc,$(plugin_SOURCES)))
plugin_OBJS = $(call _objects,$(plugin_SOURCES))
helper_OBJS = $(call _objects,$(helper_SOURCES))
OBJS = $(plugin_OBJS) $(helper_OBJS)
### The main target:
all: $(vdr_PLUGINS) vdr-inputdev i18n
### Implicit rules:
_buildflags = $(foreach k,CPP $1 LD, $(AM_$kFLAGS) $($kFLAGS) $($kFLAGS_$@))
%.o: %.c
$(CC) $(call _buildflags,C) -MMD -MP -c $< -o $@
%.o: %.cc
$(CC) $(call _buildflags,CXX) -MMD -MP -c $< -o $@
%.xz: %
@rm -f $@.tmp $@
$(XZ) -c < $< >$@.tmp
@mv $@.tmp $@
%.gz: %
@rm -f $@.tmp $@
$(GZIP) -c < $< >$@.tmp
@mv $@.tmp $@
po/%.mo: po/%.po
$(MSGFMT) -c -o $@ $<
-include $(OBJS:%.o=%.d)
### Internationalization (I18N):
POTFILE = po/$(PLUGIN).pot
_po_files = $(addsuffix .po,$(addprefix po/,$(LINGUAS)))
_mo_files = $(_po_files:%.po=%.mo)
_full_mo_path = $(DESTDIR)$(localedir)/$1/LC_MESSAGES/vdr-$(PLUGIN).mo
_all_inst_mo = $(foreach l,$(LINGUAS),$(call _full_mo_path,$l))
$(_all_inst_mo):$(call _full_mo_path,%): po/%.mo
$(MKDIR_P) ${@D}
$(INSTALL_DATA) $< $@
i18n: $(_mo_files)
install-i18n: $(_all_inst_mo)
%.po: $(POTFILE)
$(MSGMERGE) $(AM_MSGMERGEFLAGS) $@ $<
@$(TOUCH_C) $@
$(POTFILE): $(plugin_SOURCES)
$(XGETTEXT) $(AM_XGETTEXTFLAGS) -o $@ $^
@$(TOUCH_C) $@
### Targets:
vdr-inputdev: $(helper_SOURCES)
$(CC) $(call _buildflags,C) $^ -o $@
modmap.o: gen-keymap.h
$(vdr_PLUGINS): $(plugin_OBJS)
$(CXX) $(AM_LDFLAGS) $(LDFLAGS) $(LDFLAGS_$@) -shared -o $@ $^ $(LIBS)
_packages = $(addprefix $(PACKAGE),.xz .gz)
dist: $(_packages) $(addsuffix .asc,$(_packages))
_tar_transform = --transform='s!^!$(ARCHIVE)/!'
$(PACKAGE): $(_po_files) $(_all_sources)
$(TAR) cf $@ $(TAR_FLAGS) $(_tar_transform) $(sort $^)
%.asc: %
$(GPG) --detach-sign --armor --output $@ $<
$(DESTDIR)$(plugindir) $(DESTDIR)$(udevdir):
$(MKDIR_P) $@
install: install-i18n install-plugin install-extra
install-plugin: $(vdr_PLUGINS) | $(DESTDIR)$(plugindir)
$(INSTALL_PLUGIN) $(vdr_PLUGINS) $(DESTDIR)$(plugindir)/
install-extra: vdr-inputdev | $(DESTDIR)$(udevdir)
$(INSTALL_BIN) vdr-inputdev $(DESTDIR)$(udevdir)/
clean:
@rm -f $(OBJS) libvdr*.so libvdr*.so.* *.d *.tgz core* *~ po/*.mo po/*.pot
@rm -f vdr-inputdev
###
KEY_BLACKLIST = RESERVED\|MAX\|CNT
KEYMAP_SED = \
-e '/^\#define KEY_\($(KEY_BLACKLIST)\)$$/d' \
-e '/^\#define KEY_/{' \
-e 's/^\#define KEY_\([A-Za-z0-9_]\+\)[[:space:]]*$$/\L\1\E,KEY_\1/p' \
-e '};d'
gen-keymap.h: gen-keymap.perf
$(GPERF) $(GPERF_FLAGS) -t $< --output-file=$@
gen-keymap.perf: Makefile
rm -f $@ $@.tmp
@echo '%readonly-tables' > $@.tmp
@echo 'struct keymap_def { char const *name; unsigned int num; };' >> $@.tmp
@echo '%%' >> $@.tmp
@$(CC) $(call _buildflags,C) -imacros 'linux/input.h' -E -dN - </dev/null | \
$(SED) $(KEYMAP_SED) | sort -n >>$@.tmp
@mv $@.tmp $@
|