uterm: input: add built-in keymap fallback
[platform/upstream/kmscon.git] / Makefile.am
1 #
2 # Kmscon - Global Makefile
3 # Copyright (c) 2012-2013 David Herrmann <dh.herrmann@googlemail.com>
4 #
5
6 #
7 # Global Configurations and Initializations
8 #
9
10 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
11 AM_MAKEFLAGS = --no-print-directory
12 AUTOMAKE_OPTIONS = color-tests
13 AM_DISTCHECK_CONFIGURE_FLAGS = --enable-all
14
15 SUBDIRS = .
16
17 .DELETE_ON_ERROR:
18
19 include_HEADERS =
20 EXTRA_DIST = \
21         README \
22         COPYING \
23         NEWS \
24         docs/kmscon.service \
25         docs/kmsconvt@.service
26 CLEANFILES =
27 pkgconfigdir = $(libdir)/pkgconfig
28 pkgconfig_DATA =
29 MANPAGES =
30 MANPAGES_ALIASES =
31 TPHONY =
32
33 bin_PROGRAMS =
34 check_PROGRAMS =
35 noinst_PROGRAMS =
36 lib_LTLIBRARIES =
37 noinst_LTLIBRARIES =
38
39 moduledir = $(libdir)/kmscon
40 module_LTLIBRARIES =
41
42 #
43 # Default CFlags
44 # Make all files include "config.h" by default. This shouldn't cause any
45 # problems and we cannot forget to include it anymore.
46 #
47 # Also make the linker discard all unused symbols.
48 #
49 # When compiling in debug mode, we enable debug symbols so debugging with gdb
50 # is easier. If optimizations are disabled, we pass -O0 to the compiler.
51 # Otherwise, we use standard optimizations -O2.
52 #
53
54 AM_CFLAGS = \
55         -Wall \
56         -pipe \
57         -fno-common \
58         -ffast-math \
59         -fdiagnostics-show-option \
60         -fno-strict-aliasing \
61         -fvisibility=hidden \
62         -ffunction-sections \
63         -fdata-sections \
64         -fstack-protector
65 AM_CPPFLAGS = \
66         -DBUILD_MODULE_DIR='"$(moduledir)"' \
67         -include $(top_builddir)/config.h \
68         -I $(srcdir)/src
69 AM_LDFLAGS = \
70         -Wl,--as-needed \
71         -Wl,--gc-sections \
72         -Wl,-z,relro \
73         -Wl,-z,now
74
75 if BUILD_ENABLE_DEBUG
76 AM_CFLAGS += -g
77 endif
78
79 if BUILD_ENABLE_OPTIMIZATIONS
80 AM_CFLAGS += -O2
81 else
82 AM_CFLAGS += -O0
83 endif
84
85 #
86 # GIT-HEAD helper
87 # The file ./src/shl_githead.c contains a constant "shl_git_head" which is
88 # defined to the string returned by "git describe". We need to adjust this
89 # string for every build and correctly rebuild any sources that depend on it.
90 # Therefore, you should use this file rarely as it causes rebuilds on every
91 # git-commit.
92 #
93 # We have a helper-script ./src/genversion.sh that takes as argument the source
94 # file and creates it if necessary. It updates it only if the new git-describe
95 # string is different to the old one. So the file is only modified on changes.
96 # Hence, we can use it as normal dependency in this Makefile.
97 # However, we need to run this script on _every_ "make" invocation before any
98 # recipy is executed. To achieve this, we use $(shell ...) and assign it to a
99 # "simply expanded" variable (:=) so the shell command is executed on
100 # variable-declaration and not during expansion.
101 #
102 # Note that we must not clean ./src/shl_githead.c ever! If we would, a
103 # distribution tarball might delete that file and have no way to recreate it.
104 # We could delete it on something like "make maintainerclean", but then again,
105 # it seems unnecessary so lets simply not clean it at all.
106 #
107 # If the helper-script is executed in a directory that is not a git-repository
108 # (like a distribution tarball) and shl_githead.c exists, then it does nothing
109 # as it expects shl_githead.c to be correctly written by "make dist".
110 # However, if shl_githead.c does not exist, it will print a warning and write
111 # an unknown random git-revision.
112 # This guarantees, that shl_githead.c is always present and has the most correct
113 # value that we can get under any conditions.
114 #
115 # The $(emptyvariable) expansion below is used for broken $(shell ...)
116 # syntax-highlighting algorithms in many existing editors.
117 #
118
119 EXTRA_DIST += src/genversion.sh
120 GITHEAD:=$(shell $(emptyvariable)"$(srcdir)/src/genversion.sh" "$(srcdir)/src/shl_githead.c")
121
122 #
123 # Binary File Compiler
124 # This target gets as input a binary file *.bin and produces an ELF/etc. output
125 # object file *.bin.o and the corresponding libtool file *.bin.lo.
126 # Note that we fake the libtool object files as there is no way to make libtool
127 # create it. The comments in the .lo file are mandatory so don't remove them!
128 #
129
130 CLEANFILES += src/*.bin.lo src/*.bin.o
131
132 src/%.bin.lo: src/%.bin
133         $(AM_V_GEN)$(LD) -r -o "src/$*.bin.o" -z noexecstack --format=binary "$<"
134         $(AM_V_at)$(OBJCOPY) --rename-section .data=.rodata,alloc,load,readonly,data,contents "src/$*.bin.o"
135         $(AM_V_at)echo "# $@ - a libtool object file" >"$@"
136         $(AM_V_at)echo "# Generated by $(shell $(LIBTOOL) --version | head -n 1)" >>"$@"
137         $(AM_V_at)echo "#" >>"$@"
138         $(AM_V_at)echo "# Please DO NOT delete this file!" >>"$@"
139         $(AM_V_at)echo "# It is necessary for linking the library." >>"$@"
140         $(AM_V_at)echo >>"$@"
141         $(AM_V_at)echo "# Name of the PIC object." >>"$@"
142         $(AM_V_at)echo "pic_object='$*.bin.o'" >>"$@"
143         $(AM_V_at)echo >>"$@"
144         $(AM_V_at)echo "# Name of the non-PIC object" >>"$@"
145         $(AM_V_at)echo "non_pic_object='$*.bin.o'" >>"$@"
146         $(AM_V_at)echo >>"$@"
147
148 #
149 # Shader Converter
150 # We use a few built-in shader files. To reduce memory-consumption, this helper
151 # removes useless lines from the shaders before they are compiled into an object
152 # file.
153 #
154 # Following regexp are used to remove characters/lines:
155 #  ^/*.*$     Start of multi-line comment
156 #  ^ *.*$     Multi-line comment body
157 #  ^[ \t]*    Indentation whitespace
158 #  \n         Newlines
159 #
160
161 CLEANFILES += src/*.vert.bin src/*.frag.bin
162 SHADER_SED = -e 's/^\/\*.*$$//' -e 's/^ \*.*$$//' -e 's/^[ \t]*//'
163 SHADER_TR = -d "\n"
164
165 src/%.vert.bin: $(top_srcdir)/src/%.vert
166         $(AM_V_at)$(SED) $(SHADER_SED) "$<" | tr $(SHADER_TR) >"$@"
167
168 src/%.frag.bin: $(top_srcdir)/src/%.frag
169         $(AM_V_at)$(SED) $(SHADER_SED) "$<" | tr $(SHADER_TR) >"$@"
170
171 #
172 # XKB Fallback Converter
173 # We use a static built-in XKB fallback keymap. To avoid huge memory consumption
174 # we remove useless lines/characters first.
175 # We also append an ASCII 0 character so it can be used as regular C-string.
176 #
177 # Following regexp are used to remove characters/lines:
178 #   *= *           Whitespace around assignments
179 #   *, *           Whitespace around commatas
180 #   *[][{}()] *    Whitespace around braces
181 #  ^[ \t]*         Indentation whitespace
182 #  [\r\n]          Newlines
183 #
184
185 CLEANFILES += src/*.xkb.bin
186 XKB_SED = -e 's/^[ \t]*//' -e 's/ *\([,=]\) */\1/g' -e 's/ *\([][{}()]\) */\1/g'
187 XKB_TR = -d "\r\n"
188
189 src/%.xkb.bin: $(top_srcdir)/src/%.xkb
190         $(AM_V_at)$(SED) $(XKB_SED) "$<" | tr $(XKB_TR) >"$@"
191         $(AM_V_at)echo -ne "\x00" >>"$@"
192
193 #
194 # SHL - Static Helper Library
195 # The SHL subsystem contains several small code pieces used all over kmscon and
196 # other applications.
197 #
198
199 noinst_LTLIBRARIES += libshl.la
200
201 libshl_la_SOURCES = \
202         src/shl_githead.h \
203         src/shl_githead.c \
204         src/shl_dlist.h \
205         src/shl_array.h \
206         src/shl_hashtable.h \
207         external/htable.h \
208         external/htable.c \
209         src/shl_ring.h \
210         src/shl_timer.h \
211         src/shl_llog.h \
212         src/shl_log.h \
213         src/shl_log.c \
214         src/shl_hook.h \
215         src/shl_misc.h \
216         src/shl_register.h \
217         src/shl_flagset.h \
218         src/shl_gl.h \
219         src/shl_gl_math.c
220 libshl_la_CPPFLAGS = \
221         $(AM_CPPFLAGS) \
222         $(XKBCOMMON_CFLAGS) \
223         -pthread
224 libshl_la_LDFLAGS = \
225         $(AM_LDFLAGS) \
226         -pthread
227 libshl_la_LIBADD = \
228         $(AM_LIBADD) \
229         $(XKBCOMMON_LIBS)
230
231 if BUILD_HAVE_GLES2
232 libshl_la_SOURCES += src/shl_gl_shader.c
233 libshl_la_CPPFLAGS += $(GLES2_CFLAGS)
234 libshl_la_LIBADD += $(GLES2_LIBS)
235 endif
236
237 #
238 # libeloop
239 # This library contains the whole event-loop implementation of kmscon. It is
240 # compiled into a separate object to allow using it in several other programs.
241 #
242
243 noinst_LTLIBRARIES += libeloop.la
244
245 libeloop_la_SOURCES = \
246         src/eloop.h \
247         src/eloop.c
248
249 libeloop_la_LIBADD = libshl.la
250 libeloop_la_CPPFLAGS = $(AM_CPPFLAGS)
251 libeloop_la_LDFLAGS = $(AM_LDFLAGS)
252
253 #
254 # libuterm
255 # The uterm library provides helpers to create terminals in user-space. They
256 # are not limited to text-based terminals but rather provide graphics contexts
257 # so arbitrary output can be displayed. Additionally, they provide VT
258 # abstractions and an input layer
259 #
260
261 noinst_LTLIBRARIES += libuterm.la
262
263 libuterm_la_SOURCES = \
264         src/uterm_input.h \
265         src/uterm_monitor.h \
266         src/uterm_video.h \
267         src/uterm_vt.h \
268         src/uterm_input_internal.h \
269         src/uterm_video_internal.h \
270         src/uterm_systemd_internal.h \
271         src/uterm_video.c \
272         src/uterm_monitor.c \
273         src/uterm_vt.c \
274         src/uterm_input.c \
275         src/uterm_input_uxkb.c
276
277 nodist_libuterm_la_SOURCES =
278
279 libuterm_la_CPPFLAGS = \
280         $(AM_CPPFLAGS) \
281         $(UDEV_CFLAGS) \
282         $(XKBCOMMON_CFLAGS)
283 libuterm_la_LIBADD = \
284         $(UDEV_LIBS) \
285         $(XKBCOMMON_LIBS) \
286         libeloop.la \
287         libshl.la \
288         src/uterm_input_fallback.xkb.bin.lo
289 libuterm_la_LDFLAGS = \
290         $(AM_LDFLAGS)
291
292 if BUILD_ENABLE_MULTI_SEAT
293 libuterm_la_SOURCES += src/uterm_systemd.c
294 libuterm_la_CPPFLAGS += $(SYSTEMD_CFLAGS)
295 libuterm_la_LIBADD += $(SYSTEMD_LIBS)
296 endif
297
298 if BUILD_ENABLE_VIDEO_FBDEV
299 libuterm_la_SOURCES += \
300         src/uterm_fbdev_internal.h \
301         src/uterm_fbdev_video.c \
302         src/uterm_fbdev_render.c
303 endif
304
305 if BUILD_ENABLE_VIDEO_DRM2D
306 libuterm_la_SOURCES += \
307         src/uterm_drm2d_internal.h \
308         src/uterm_drm2d_video.c \
309         src/uterm_drm2d_render.c
310 libuterm_la_CPPFLAGS += $(DRM_CFLAGS)
311 libuterm_la_LIBADD += $(DRM_LIBS)
312 endif
313
314 if BUILD_ENABLE_VIDEO_DRM3D
315 libuterm_la_SOURCES += \
316         src/uterm_drm3d_internal.h \
317         src/uterm_drm3d_video.c \
318         src/uterm_drm3d_render.c
319 libuterm_la_CPPFLAGS += \
320         $(DRM_CFLAGS) \
321         $(EGL_CFLAGS) \
322         $(GBM_CFLAGS) \
323         $(GLES2_CFLAGS)
324 libuterm_la_LIBADD += \
325         $(DRM_LIBS) \
326         $(EGL_LIBS) \
327         $(GBM_LIBS) \
328         $(GLES2_LIBS) \
329         src/uterm_drm3d_blend.vert.bin.lo \
330         src/uterm_drm3d_blend.frag.bin.lo \
331         src/uterm_drm3d_blit.vert.bin.lo \
332         src/uterm_drm3d_blit.frag.bin.lo \
333         src/uterm_drm3d_fill.vert.bin.lo \
334         src/uterm_drm3d_fill.frag.bin.lo
335 endif
336
337 # add shared sources only once
338 UTERM_DRM_SHARED_SRC = \
339         src/uterm_drm_shared_internal.h \
340         src/uterm_drm_shared.c
341 if BUILD_ENABLE_VIDEO_DRM2D
342 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
343 else
344 if BUILD_ENABLE_VIDEO_DRM3D
345 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
346 endif
347 endif
348
349 #
350 # Unifont Generator
351 # This generates the unifont sources from raw hex-encoded font data.
352 #
353
354 UNIFONT = $(top_srcdir)/src/font_unifont_data.hex
355 UNIFONT_BIN = src/font_unifont_data.bin
356 UNIFONT_LT = src/font_unifont_data.bin.lo
357
358 EXTRA_DIST += $(UNIFONT)
359 CLEANFILES += $(UNIFONT_BIN)
360 genunifont_SOURCES = src/genunifont.c
361
362 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CC = $(CC_FOR_BUILD)
363 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
364 genunifont$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
365
366 $(UNIFONT_BIN): $(UNIFONT) genunifont$(BUILD_EXEEXT)
367         $(AM_V_GEN)./genunifont$(BUILD_EXEEXT) $(UNIFONT_BIN) $(UNIFONT)
368
369 #
370 # Kmscon Modules
371 #
372
373 if BUILD_ENABLE_FONT_UNIFONT
374 module_LTLIBRARIES += mod-unifont.la
375 noinst_PROGRAMS += genunifont
376 endif
377
378 mod_unifont_la_SOURCES = \
379         src/kmscon_module_interface.h \
380         src/font_unifont.c \
381         src/kmscon_mod_unifont.c
382 mod_unifont_la_LIBADD = \
383         $(UNIFONT_LT) \
384         libshl.la
385 mod_unifont_la_LDFLAGS = \
386         $(AM_LDFLAGS) \
387         -module \
388         -avoid-version
389
390 if BUILD_ENABLE_FONT_PANGO
391 module_LTLIBRARIES += mod-pango.la
392 endif
393
394 mod_pango_la_SOURCES = \
395         src/kmscon_module_interface.h \
396         src/font_pango.c \
397         src/kmscon_mod_pango.c
398 mod_pango_la_CPPFLAGS = \
399         $(AM_CPPFLAGS) \
400         $(PANGO_CFLAGS) \
401         $(TSM_CFLAGS)
402 mod_pango_la_LIBADD = \
403         $(PANGO_LIBS) \
404         $(TSM_LIBS) \
405         -lpthread \
406         libshl.la
407 mod_pango_la_LDFLAGS = \
408         $(AM_LDFLAGS) \
409         -module \
410         -avoid-version
411
412 if BUILD_ENABLE_RENDERER_BBULK
413 module_LTLIBRARIES += mod-bbulk.la
414 endif
415
416 mod_bbulk_la_SOURCES = \
417         src/kmscon_module_interface.h \
418         src/text_bbulk.c \
419         src/kmscon_mod_bbulk.c
420 mod_bbulk_la_LIBADD = libshl.la
421 mod_bbulk_la_LDFLAGS = \
422         $(AM_LDFLAGS) \
423         -module \
424         -avoid-version
425
426 if BUILD_ENABLE_RENDERER_GLTEX
427 module_LTLIBRARIES += mod-gltex.la
428 endif
429
430 mod_gltex_la_SOURCES = \
431         src/kmscon_module_interface.h \
432         src/text_gltex.c \
433         src/kmscon_mod_gltex.c
434 mod_gltex_la_CPPFLAGS = \
435         $(AM_CPPFLAGS) \
436         $(GLES2_CFLAGS)
437 mod_gltex_la_LIBADD = \
438         $(GLES2_LIBS) \
439         libshl.la \
440         src/text_gltex_atlas.vert.bin.lo \
441         src/text_gltex_atlas.frag.bin.lo
442 mod_gltex_la_LDFLAGS = \
443         $(AM_LDFLAGS) \
444         -module \
445         -avoid-version
446
447 if BUILD_ENABLE_RENDERER_PIXMAN
448 module_LTLIBRARIES += mod-pixman.la
449 endif
450
451 mod_pixman_la_SOURCES = \
452         src/kmscon_module_interface.h \
453         src/text_pixman.c \
454         src/kmscon_mod_pixman.c
455 mod_pixman_la_CPPFLAGS = \
456         $(AM_CPPFLAGS) \
457         $(PIXMAN_CFLAGS)
458 mod_pixman_la_LIBADD = \
459         $(PIXMAN_LIBS) \
460         libshl.la
461 mod_pixman_la_LDFLAGS = \
462         $(AM_LDFLAGS) \
463         -module \
464         -avoid-version
465
466 #
467 # Binaries
468 # These are the sources for the main binaries and test programs. They mostly
469 # consists of a single source file only and include all the libraries that are
470 # built as part of kmscon.
471 #
472
473 bin_PROGRAMS += kmscon
474 check_PROGRAMS += \
475         test_output \
476         test_vt \
477         test_input \
478         test_key
479 MANPAGES += docs/man/kmscon.1
480
481 kmscon_SOURCES = \
482         src/conf.h \
483         src/conf.c \
484         src/pty.h \
485         src/pty.c \
486         src/font.h \
487         src/font.c \
488         src/font_8x16.c \
489         src/text.h \
490         src/text.c \
491         src/text_bblit.c \
492         src/kmscon_module_interface.h \
493         src/kmscon_module.h \
494         src/kmscon_module.c \
495         src/kmscon_terminal.h \
496         src/kmscon_dummy.h \
497         src/kmscon_seat.h \
498         src/kmscon_seat.c \
499         src/kmscon_conf.h \
500         src/kmscon_conf.c \
501         src/kmscon_main.c
502 nodist_kmscon_SOURCES =
503
504 kmscon_CPPFLAGS = \
505         $(AM_CPPFLAGS) \
506         $(XKBCOMMON_CFLAGS) \
507         $(TSM_CFLAGS)
508 kmscon_LDADD = \
509         $(XKBCOMMON_LIBS) \
510         $(TSM_LIBS) \
511         libeloop.la \
512         libuterm.la \
513         libshl.la \
514         -lpthread \
515         -ldl
516 kmscon_LDFLAGS = \
517         $(AM_LDFLAGS) \
518         -rdynamic
519
520 if BUILD_ENABLE_SESSION_DUMMY
521 kmscon_SOURCES += src/kmscon_dummy.c
522 endif
523
524 if BUILD_ENABLE_SESSION_TERMINAL
525 kmscon_SOURCES += src/kmscon_terminal.c
526 endif
527
528 #
529 # Tests
530 #
531
532 test_sources = \
533         src/conf.h \
534         src/conf.c \
535         tests/test_include.h
536 test_cflags = \
537         $(AM_CPPFLAGS) \
538         $(XKBCOMMON_CFLAGS)
539 test_libs = \
540         $(XKBCOMMON_LIBS) \
541         libeloop.la \
542         libshl.la
543
544 test_output_SOURCES = \
545         $(test_sources) \
546         tests/test_output.c
547 test_output_CPPFLAGS = $(test_cflags)
548 test_output_LDADD = \
549         $(test_libs) \
550         libuterm.la
551
552 test_vt_SOURCES = \
553         $(test_sources) \
554         tests/test_vt.c
555 test_vt_CPPFLAGS = $(test_cflags)
556 test_vt_LDADD = \
557         $(test_libs) \
558         libuterm.la
559
560 test_input_SOURCES = \
561         $(test_sources) \
562         tests/test_input.c
563 test_input_CPPFLAGS = $(test_cflags)
564 test_input_LDADD = \
565         $(test_libs) \
566         libuterm.la
567
568 test_key_SOURCES = \
569         $(test_sources) \
570         tests/test_key.c
571 test_key_CPPFLAGS = $(test_cflags)
572 test_key_LDADD = $(test_libs)
573
574 #
575 # Manpages
576 #
577
578 man_MANS =
579 EXTRA_DIST += ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,$(MANPAGES)}}}}
580 CLEANFILES += $(MANPAGES) $(MANPAGES_ALIASES) .man_fixup
581
582 if BUILD_HAVE_XSLTPROC
583 if BUILD_HAVE_MANPAGES_STYLESHEET
584
585 man_MANS += $(MANPAGES) $(MANPAGES_ALIASES)
586
587 XSLTPROC_FLAGS = \
588         --stringparam man.authors.section.enabled 0 \
589         --stringparam man.copyright.section.enabled 0 \
590         --stringparam funcsynopsis.style ansi \
591         --stringparam man.output.quietly 1 \
592         --nonet
593
594 XSLTPROC_PROCESS_MAN = \
595         $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
596         $(XSLTPROC) -o "$@" $(XSLTPROC_FLAGS) $(BUILD_MANPAGES_STYLESHEET) "$<" && \
597         touch .man_fixup
598
599 # Force .man_fixup if $(MANPAGES) are not built
600 .man_fixup: | $(MANPAGES)
601         @touch .man_fixup
602
603 $(MANPAGES_ALIASES): $(MANPAGES) .man_fixup
604         $(AM_V_GEN)if test -n "$@" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' "$@" ; fi
605
606 docs/man/%.1: docs/man/%.xml
607         $(XSLTPROC_PROCESS_MAN)
608
609 docs/man/%.3: docs/man/%.xml
610         $(XSLTPROC_PROCESS_MAN)
611
612 docs/man/%.5: docs/man/%.xml
613         $(XSLTPROC_PROCESS_MAN)
614
615 docs/man/%.7: docs/man/%.xml
616         $(XSLTPROC_PROCESS_MAN)
617
618 endif # BUILD_HAVE_MANPAGES_STYLESHEET
619 endif # BUILD_HAVE_XSLTPROC
620
621 #
622 # Phony targets
623 #
624
625 .PHONY: $(TPHONY)
626
627 #
628 # Empty .SECONDARY target causes alle intermediate files to be treated as
629 # secondary files. That is, they don't get deleted after make finished.
630 #
631
632 .SECONDARY: