uterm: move input related API to uterm_input.h
[platform/upstream/kmscon.git] / Makefile.am
1 #
2 # Kmscon - Global Makefile
3 # Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
4 #
5
6 ACLOCAL_AMFLAGS = -I m4
7 SUBDIRS = \
8         .
9 include_HEADERS =
10 EXTRA_DIST = \
11         README \
12         COPYING \
13         NEWS \
14         docs/kmscon.service \
15         docs/kmsconvt@.service
16 CLEANFILES =
17 pkgconfigdir = $(libdir)/pkgconfig
18 pkgconfig_DATA =
19 MANPAGES =
20 MANPAGES_ALIASES =
21 TPHONY =
22
23 bin_PROGRAMS =
24 check_PROGRAMS =
25 noinst_PROGRAMS = \
26         genshader \
27         genunifont
28 noinst_LTLIBRARIES =
29 lib_LTLIBRARIES =
30
31 moduledir = @libdir@/kmscon
32 module_LTLIBRARIES =
33
34 #
35 # Default CFlags
36 # Make all files include "config.h" by default. This shouldn't cause any
37 # problems and we cannot forget to include it anymore.
38 #
39 # Also make the linker discard all unused symbols.
40 #
41 # When compiling in debug mode, we enable debug symbols so debugging with gdb
42 # is easier. If optimizations are disabled, we pass -O0 to the compiler.
43 # Otherwise, we use standard optimizations -O2.
44 #
45
46 AM_CFLAGS = \
47         -Wall
48 AM_CPPFLAGS = \
49         -DBUILD_MODULE_DIR='"$(moduledir)"' \
50         -include $(top_builddir)/config.h \
51         -I $(srcdir)/src
52 AM_LDFLAGS = \
53         -Wl,--as-needed
54
55 if BUILD_ENABLE_DEBUG
56 AM_CFLAGS += -g
57 endif
58
59 if BUILD_ENABLE_OPTIMIZATIONS
60 AM_CFLAGS += -O2
61 else
62 AM_CFLAGS += -O0
63 endif
64
65 #
66 # SHL - Static Helper Library
67 # The SHL subsystem contains several small code pieces used all over kmscon and
68 # other applications.
69 #
70 # Simply include $(SHL_*) in your source-file list.
71 # SHL_MISC needs xkbcommon
72 # SHL_REGISTER needs pthread
73 #
74
75 SHL_DLIST = \
76         src/shl_dlist.h
77 SHL_ARRAY = \
78         src/shl_array.h
79 SHL_HASHTABLE = \
80         src/shl_hashtable.h \
81         external/htable.h \
82         external/htable.c
83 SHL_RING = \
84         src/shl_ring.h
85 SHL_TIMER = \
86         src/shl_timer.h
87 SHL_LLOG = \
88         src/shl_llog.h
89 SHL_HOOK = \
90         src/shl_hook.h \
91         $(SHL_DLIST)
92 SHL_MISC = \
93         src/shl_misc.h
94 SHL_REGISTER = \
95         src/shl_register.h \
96         $(SHL_DLIST)
97
98 #
99 # GIT-HEAD helper
100 # The file ./src/githead.h contains a constant BUILD_GIT_HEAD which is defined
101 # to the string returned by "git describe". We need to adjust this string for
102 # every build and correctly rebuild any sources that depend on it. Therefore,
103 # you should use this file rarely as it causes rebuilds on every git-commit.
104 #
105 # We have a helper-script ./src/genversion.sh that takes as argument the header
106 # file and creates it if necessary. It updates it only if the new git-describe
107 # string is different to the old one. So the file is only modified on changes.
108 # Hence, we can use it as normal dependency in this Makefile.
109 # However, we need to run this script on _every_ "make" invocation before any
110 # recipy is executed. To achieve this, we use $(shell ...) and assign it to a
111 # "simply expanded" variable (:=) so the shell command is executed on
112 # variable-declaration and not during expansion.
113 #
114 # Note that we must not clean ./src/githead.h ever! If we would, a distribution
115 # tarball might delete that file and have no way to recreate it.
116 # We could delete it on something like "make maintainerclean", but then again,
117 # it seems unnecessary so lets simply not clean it at all.
118 #
119 # If the helper-script is executed in a directory that is not a git-repository
120 # (like a distribution tarball) and githead.h exists, then it does nothing as it
121 # expects githead.h to be correctly written by "make dist".
122 # However, if githead.h does not exist, it will print a warning and write
123 # "<unknown>" as git-revision.
124 # This guarantees, that githead.h is always present and has the most correct
125 # value that we can get under any conditions.
126 #
127 # The $(emptyvariable) expansion below is used for broken $(shell ...)
128 # syntax-highlighting algorithms in many existing editors.
129 #
130
131 EXTRA_DIST += src/genversion.sh
132 GITHEAD:=$(shell $(emptyvariable)"$(srcdir)/src/genversion.sh" "$(srcdir)/src/githead.h")
133
134 #
135 # libeloop
136 # This library contains the whole event-loop implementation of kmscon. It is
137 # compiled into a separate object to allow using it in several other programs.
138 #
139
140 if BUILD_ENABLE_ELOOP
141 lib_LTLIBRARIES += libeloop.la
142 include_HEADERS += src/eloop.h
143 pkgconfig_DATA += docs/pc/libeloop.pc
144 endif
145
146 libeloop_la_SOURCES = \
147         $(SHL_DLIST) \
148         $(SHL_LLOG) \
149         $(SHL_HOOK) \
150         src/eloop.h \
151         src/eloop.c
152
153 libeloop_la_CPPFLAGS = \
154         $(AM_CPPFLAGS)
155 libeloop_la_LIBADD =
156 libeloop_la_LDFLAGS = \
157         -version-info 1:0:0
158
159
160 if BUILD_ENABLE_ELOOP_DBUS
161 libeloop_la_SOURCES += \
162         external/dbus-common.h \
163         external/dbus-loop.h \
164         external/dbus-loop.c
165 libeloop_la_CPPFLAGS += \
166         $(DBUS_CFLAGS)
167 libeloop_la_LIBADD += \
168         $(DBUS_LIBS)
169 endif
170
171 #
172 # libtsm
173 # The Terminal-emulator State Machine is a library that implements the whole VTE
174 # layer and everything related to it. It has no external dependencies so it can
175 # be used to implement any kind of terminal emulator or debugger.
176 #
177
178 if BUILD_ENABLE_TSM
179 lib_LTLIBRARIES += \
180         libtsm.la
181 include_HEADERS += \
182         src/tsm_screen.h \
183         src/tsm_unicode.h \
184         src/tsm_vte.h
185 pkgconfig_DATA += \
186         docs/pc/libtsm.pc
187 endif
188
189 libtsm_la_SOURCES = \
190         $(SHL_LLOG) \
191         $(SHL_TIMER) \
192         $(SHL_ARRAY) \
193         $(SHL_HASHTABLE) \
194         src/tsm_screen.h \
195         src/tsm_screen.c \
196         src/tsm_unicode.h \
197         src/tsm_unicode.c \
198         src/tsm_vte.h \
199         src/tsm_vte.c \
200         src/tsm_vte_charsets.c \
201         external/wcwidth.h \
202         external/wcwidth.c
203
204 libtsm_la_CPPFLAGS = \
205         $(AM_CPPFLAGS) \
206         $(XKBCOMMON_CFLAGS)
207 libtsm_la_LDFLAGS = \
208         $(XKBCOMMON_LIBS) \
209         -version-info 1:0:0
210
211 #
212 # libuterm
213 # The uterm library provides helpers to create terminals in user-space. They
214 # are not limited to text-based terminals but rather provide graphics contexts
215 # so arbitrary output can be displayed. Additionally, they provide VT
216 # abstractions and an input layer
217 #
218
219 if BUILD_ENABLE_UTERM
220 lib_LTLIBRARIES += libuterm.la
221 include_HEADERS += \
222         src/uterm.h \
223         src/uterm_input.h \
224         src/uterm_video.h
225 pkgconfig_DATA += docs/pc/libuterm.pc
226 endif
227
228 libuterm_la_SOURCES = \
229         $(SHL_DLIST) \
230         $(SHL_HOOK) \
231         $(SHL_MISC) \
232         src/uterm.h \
233         src/uterm_input.h \
234         src/uterm_video.h \
235         src/uterm_input_internal.h \
236         src/uterm_video_internal.h \
237         src/uterm_systemd_internal.h \
238         src/uterm_video.c \
239         src/uterm_monitor.c \
240         src/uterm_vt.c \
241         src/uterm_input.c \
242         src/uterm_input_uxkb.c
243
244 nodist_libuterm_la_SOURCES =
245
246 libuterm_la_CPPFLAGS = \
247         $(AM_CPPFLAGS) \
248         $(XKBCOMMON_CFLAGS)
249 libuterm_la_LIBADD = \
250         $(XKBCOMMON_LIBS) \
251         libeloop.la
252 libuterm_la_LDFLAGS = \
253         -version-info 1:0:0
254
255 if BUILD_ENABLE_MULTI_SEAT
256 libuterm_la_SOURCES += src/uterm_systemd.c
257 libuterm_la_CPPFLAGS += $(SYSTEMD_CFLAGS)
258 libuterm_la_LIBADD += $(SYSTEMD_LIBS)
259 endif
260
261 if BUILD_ENABLE_HOTPLUG
262 libuterm_la_CPPFLAGS += $(UDEV_CFLAGS)
263 libuterm_la_LIBADD += $(UDEV_LIBS)
264 endif
265
266 if BUILD_ENABLE_VIDEO_FBDEV
267 libuterm_la_SOURCES += src/uterm_video_fbdev.c
268 endif
269
270 if BUILD_ENABLE_VIDEO_DUMB
271 libuterm_la_SOURCES += src/uterm_video_dumb.c
272 libuterm_la_CPPFLAGS += $(DRM_CFLAGS)
273 libuterm_la_LIBADD += $(DRM_LIBS)
274 endif
275
276 if BUILD_ENABLE_VIDEO_DRM
277 libuterm_la_SOURCES += \
278         src/uterm_video_drm.c \
279         src/static_gl.h \
280         src/static_gl_math.c \
281         src/static_gl_shader.c
282 nodist_libuterm_la_SOURCES += \
283         src/static_shaders.c
284 libuterm_la_CPPFLAGS += \
285         $(DRM_CFLAGS) \
286         $(EGL_CFLAGS) \
287         $(GBM_CFLAGS) \
288         $(GLES2_CFLAGS)
289 libuterm_la_LIBADD += \
290         $(DRM_LIBS) \
291         $(EGL_LIBS) \
292         $(GBM_LIBS) \
293         $(GLES2_LIBS)
294 endif
295
296 #
297 # Shaders
298 # As there is no need to modify shaders at run-time, we statically compile them
299 # into object files. As autotools would ignore them, we need to add them to
300 # EXTRA_DIST.
301 # The program that converts the shaders into C-source files is "genshader". It's
302 # pretty simple and just creates a string with the shader source as content.
303 #
304
305 SHADERS = \
306         $(srcdir)/src/static_fill.vert \
307         $(srcdir)/src/static_fill.frag \
308         $(srcdir)/src/static_blend.vert \
309         $(srcdir)/src/static_blend.frag \
310         $(srcdir)/src/static_blit.vert \
311         $(srcdir)/src/static_blit.frag \
312         $(srcdir)/src/static_gltex.vert \
313         $(srcdir)/src/static_gltex.frag
314
315 EXTRA_DIST += $(SHADERS)
316 CLEANFILES += src/static_shaders.c
317 genshader_SOURCES = src/genshader.c
318
319 src/static_shaders.c: $(SHADERS) genshader$(EXEEXT)
320         $(AM_V_GEN)./genshader$(EXEEXT) src/static_shaders.c $(SHADERS)
321
322 #
323 # Unifont Generator
324 # This generates the unifont sources from raw hex-encoded font data.
325 #
326
327 UNIFONT = src/font_unifont_data.hex
328
329 EXTRA_DIST += $(UNIFONT)
330 CLEANFILES += src/font_unifont_data.c
331 genunifont_SOURCES = src/genunifont.c
332
333 src/font_unifont_data.c: $(UNIFONT) genunifont$(EXEEXT)
334         $(AM_V_GEN)./genunifont$(EXEEXT) src/font_unifont_data.c $(UNIFONT)
335
336 #
337 # Kmscon Modules
338 #
339
340 if BUILD_ENABLE_FONT_UNIFONT
341 module_LTLIBRARIES += mod-unifont.la
342 endif
343
344 mod_unifont_la_SOURCES = \
345         src/kmscon_module_interface.h \
346         src/githead.h \
347         src/font_unifont.c \
348         src/kmscon_mod_unifont.c
349 nodist_mod_unifont_la_SOURCES = \
350         src/font_unifont_data.c
351 mod_unifont_la_LDFLAGS = \
352         -module \
353         -avoid-version
354
355 if BUILD_ENABLE_FONT_FREETYPE2
356 module_LTLIBRARIES += mod-freetype2.la
357 endif
358
359 mod_freetype2_la_SOURCES = \
360         $(SHL_DLIST) \
361         $(SHL_HASHTABLE) \
362         src/kmscon_module_interface.h \
363         src/githead.h \
364         src/font_freetype2.c \
365         src/kmscon_mod_freetype2.c
366 mod_freetype2_la_CPPFLAGS = \
367         $(AM_CPPFLAGS) \
368         $(FREETYPE2_CFLAGS)
369 mod_freetype2_la_LIBADD = \
370         $(FREETYPE2_LIBS) \
371         -lpthread \
372         libtsm.la
373 mod_freetype2_la_LDFLAGS = \
374         -module \
375         -avoid-version
376
377 if BUILD_ENABLE_FONT_PANGO
378 module_LTLIBRARIES += mod-pango.la
379 endif
380
381 mod_pango_la_SOURCES = \
382         $(SHL_DLIST) \
383         $(SHL_HASHTABLE) \
384         src/kmscon_module_interface.h \
385         src/githead.h \
386         src/font_pango.c \
387         src/kmscon_mod_pango.c
388 mod_pango_la_CPPFLAGS = \
389         $(AM_CPPFLAGS) \
390         $(PANGO_CFLAGS)
391 mod_pango_la_LIBADD = \
392         $(PANGO_LIBS) \
393         -lpthread \
394         libtsm.la
395 mod_pango_la_LDFLAGS = \
396         -module \
397         -avoid-version
398
399 if BUILD_ENABLE_RENDERER_BBULK
400 module_LTLIBRARIES += mod-bbulk.la
401 endif
402
403 mod_bbulk_la_SOURCES = \
404         src/kmscon_module_interface.h \
405         src/githead.h \
406         src/text_bbulk.c \
407         src/kmscon_mod_bbulk.c
408 mod_bbulk_la_LDFLAGS = \
409         -module \
410         -avoid-version
411
412 if BUILD_ENABLE_RENDERER_GLTEX
413 module_LTLIBRARIES += mod-gltex.la
414 endif
415
416 mod_gltex_la_SOURCES = \
417         src/kmscon_module_interface.h \
418         src/githead.h \
419         src/text_gltex.c \
420         src/static_gl.h \
421         src/static_gl_math.c \
422         src/static_gl_shader.c \
423         src/kmscon_mod_gltex.c
424 nodist_mod_gltex_la_SOURCES = \
425         src/static_shaders.c
426 mod_gltex_la_CPPFLAGS = \
427         $(AM_CPPFLAGS) \
428         $(GLES2_CFLAGS)
429 mod_gltex_la_LIBADD = \
430         $(GLES2_LIBS)
431 mod_gltex_la_LDFLAGS = \
432         -module \
433         -avoid-version
434
435 #
436 # Binaries
437 # These are the sources for the main binaries and test programs. They mostly
438 # consists of a single source file only and include all the libraries that are
439 # built as part of kmscon.
440 #
441
442 if BUILD_ENABLE_KMSCON
443 bin_PROGRAMS += kmscon
444 check_PROGRAMS += \
445         test_output \
446         test_vt \
447         test_input \
448         test_key
449 MANPAGES += docs/man/kmscon.1
450 endif
451
452 kmscon_SOURCES = \
453         $(SHL_DLIST) \
454         $(SHL_MISC) \
455         $(SHL_ARRAY) \
456         $(SHL_HASHTABLE) \
457         $(SHL_RING) \
458         $(SHL_TIMER) \
459         $(SHL_HOOK) \
460         $(SHL_REGISTER) \
461         src/githead.h \
462         src/conf.h \
463         src/conf.c \
464         src/log.h \
465         src/log.c \
466         src/pty.h \
467         src/pty.c \
468         src/font.h \
469         src/font.c \
470         src/font_8x16.c \
471         src/text.h \
472         src/text.c \
473         src/text_bblit.c \
474         src/kmscon_module_interface.h \
475         src/kmscon_module.h \
476         src/kmscon_module.c \
477         src/kmscon_terminal.h \
478         src/kmscon_dummy.h \
479         src/kmscon_cdev.h \
480         src/kmscon_seat.h \
481         src/kmscon_seat.c \
482         src/kmscon_conf.h \
483         src/kmscon_conf.c \
484         src/kmscon_main.c
485 nodist_kmscon_SOURCES =
486
487 kmscon_CPPFLAGS = \
488         $(AM_CPPFLAGS) \
489         $(XKBCOMMON_CFLAGS)
490 kmscon_LDADD = \
491         $(XKBCOMMON_LIBS) \
492         libeloop.la \
493         libuterm.la \
494         -lpthread
495 kmscon_LDFLAGS = \
496         -rdynamic
497
498 if BUILD_ENABLE_SESSION_DUMMY
499 kmscon_SOURCES += src/kmscon_dummy.c
500 endif
501
502 if BUILD_ENABLE_SESSION_TERMINAL
503 kmscon_SOURCES += src/kmscon_terminal.c
504 kmscon_LDADD += libtsm.la
505 endif
506
507 if BUILD_ENABLE_SESSION_CDEV
508 kmscon_SOURCES += src/kmscon_cdev.c
509 kmscon_CPPFLAGS += $(FUSE_CFLAGS)
510 kmscon_LDADD += $(FUSE_LIBS)
511 endif
512
513 #
514 # Wayland Terminal
515 #
516
517 if BUILD_ENABLE_WLTERM
518 bin_PROGRAMS += wlterm
519 endif
520
521 wlterm_SOURCES = \
522         $(SHL_MISC) \
523         $(SHL_ARRAY) \
524         $(SHL_DLIST) \
525         $(SHL_HOOK) \
526         src/wlt_main.h \
527         src/wlt_main.c \
528         src/wlt_toolkit.h \
529         src/wlt_toolkit.c \
530         src/wlt_theme.h \
531         src/wlt_theme.c \
532         src/wlt_terminal.h \
533         src/wlt_terminal.c \
534         src/log.h \
535         src/log.c \
536         src/conf.h \
537         src/conf.c \
538         src/pty.h \
539         src/pty.c
540 wlterm_CPPFLAGS = \
541         $(AM_CPPFLAGS) \
542         $(WAYLAND_CFLAGS) \
543         $(XKBCOMMON_CFLAGS)
544 wlterm_LDADD = \
545         $(WAYLAND_LIBS) \
546         $(XKBCOMMON_LIBS) \
547         libeloop.la \
548         libtsm.la \
549         -lpthread
550
551 #
552 # Tests
553 #
554
555 test_sources = \
556         src/log.h \
557         src/log.c \
558         src/conf.h \
559         src/conf.c \
560         tests/test_include.h
561 test_cflags = \
562         $(XKBCOMMON_CFLAGS)
563 test_libs = \
564         $(XKBCOMMON_LIBS) \
565         libeloop.la
566
567 test_output_SOURCES = \
568         $(test_sources) \
569         tests/test_output.c
570 test_output_CPPFLAGS = \
571         $(AM_CPPFLAGS) \
572         $(test_cflags)
573 test_output_LDADD = \
574         $(test_libs) \
575         libuterm.la
576
577 test_vt_SOURCES = \
578         $(test_sources) \
579         tests/test_vt.c
580 test_vt_CPPFLAGS = \
581         $(AM_CPPFLAGS) \
582         $(test_cflags)
583 test_vt_LDADD = \
584         $(test_libs) \
585         libuterm.la
586
587 test_input_SOURCES = \
588         $(test_sources) \
589         tests/test_input.c
590 test_input_CPPFLAGS = \
591         $(AM_CPPFLAGS) \
592         $(test_cflags)
593 test_input_LDADD = \
594         $(test_libs) \
595         libuterm.la
596
597 test_key_SOURCES = \
598         $(test_sources) \
599         tests/test_key.c
600 test_key_CPPFLAGS = \
601         $(AM_CPPFLAGS) \
602         $(test_cflags)
603 test_key_LDADD = \
604         $(test_libs)
605
606 #
607 # Manpages
608 #
609
610 man_MANS =
611 EXTRA_DIST += ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,$(MANPAGES)}}}}
612 CLEANFILES += $(MANPAGES) $(MANPAGES_ALIASES) .man_fixup
613
614 if BUILD_HAVE_XSLTPROC
615 if BUILD_HAVE_MANPAGES_STYLESHEET
616
617 man_MANS += $(MANPAGES) $(MANPAGES_ALIASES)
618
619 XSLTPROC_FLAGS = \
620         --stringparam man.authors.section.enabled 0 \
621         --stringparam man.copyright.section.enabled 0 \
622         --stringparam funcsynopsis.style ansi \
623         --stringparam man.output.quietly 1 \
624         --nonet
625
626 XSLTPROC_PROCESS_MAN = \
627         $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
628         $(XSLTPROC) -o "$@" $(XSLTPROC_FLAGS) $(BUILD_MANPAGES_STYLESHEET) "$<" && \
629         touch .man_fixup
630
631 # Force .man_fixup if $(MANPAGES) are not built
632 .man_fixup: | $(MANPAGES)
633         @touch .man_fixup
634
635 $(MANPAGES_ALIASES): $(MANPAGES) .man_fixup
636         $(AM_V_GEN)if test -n "$@" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' "$@" ; fi
637
638 docs/man/%.1: docs/man/%.xml
639         $(XSLTPROC_PROCESS_MAN)
640
641 docs/man/%.3: docs/man/%.xml
642         $(XSLTPROC_PROCESS_MAN)
643
644 docs/man/%.5: docs/man/%.xml
645         $(XSLTPROC_PROCESS_MAN)
646
647 docs/man/%.7: docs/man/%.xml
648         $(XSLTPROC_PROCESS_MAN)
649
650 endif # BUILD_HAVE_MANPAGES_STYLESHEET
651 endif # BUILD_HAVE_XSLTPROC
652
653 #
654 # Phony targets
655 #
656
657 .PHONY: $(TPHONY)