kmscon: add cairo-renderer module
[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_input.h \
223         src/uterm_monitor.h \
224         src/uterm_video.h \
225         src/uterm_vt.h
226 pkgconfig_DATA += docs/pc/libuterm.pc
227 endif
228
229 libuterm_la_SOURCES = \
230         $(SHL_DLIST) \
231         $(SHL_HOOK) \
232         $(SHL_MISC) \
233         $(SHL_TIMER) \
234         src/uterm_input.h \
235         src/uterm_monitor.h \
236         src/uterm_video.h \
237         src/uterm_vt.h \
238         src/uterm_input_internal.h \
239         src/uterm_video_internal.h \
240         src/uterm_systemd_internal.h \
241         src/uterm_video.c \
242         src/uterm_monitor.c \
243         src/uterm_vt.c \
244         src/uterm_input.c \
245         src/uterm_input_uxkb.c
246
247 nodist_libuterm_la_SOURCES =
248
249 libuterm_la_CPPFLAGS = \
250         $(AM_CPPFLAGS) \
251         $(XKBCOMMON_CFLAGS)
252 libuterm_la_LIBADD = \
253         $(XKBCOMMON_LIBS) \
254         libeloop.la
255 libuterm_la_LDFLAGS = \
256         -version-info 1:0:0
257
258 if BUILD_ENABLE_MULTI_SEAT
259 libuterm_la_SOURCES += src/uterm_systemd.c
260 libuterm_la_CPPFLAGS += $(SYSTEMD_CFLAGS)
261 libuterm_la_LIBADD += $(SYSTEMD_LIBS)
262 endif
263
264 if BUILD_ENABLE_HOTPLUG
265 libuterm_la_CPPFLAGS += $(UDEV_CFLAGS)
266 libuterm_la_LIBADD += $(UDEV_LIBS)
267 endif
268
269 if BUILD_ENABLE_VIDEO_FBDEV
270 libuterm_la_SOURCES += \
271         src/uterm_fbdev_internal.h \
272         src/uterm_fbdev_video.c \
273         src/uterm_fbdev_render.c
274 endif
275
276 if BUILD_ENABLE_VIDEO_DUMB
277 libuterm_la_SOURCES += src/uterm_video_dumb.c
278 libuterm_la_CPPFLAGS += $(DRM_CFLAGS)
279 libuterm_la_LIBADD += $(DRM_LIBS)
280 endif
281
282 if BUILD_ENABLE_VIDEO_DRM
283 libuterm_la_SOURCES += \
284         src/uterm_video_drm.c \
285         src/static_gl.h \
286         src/static_gl_math.c \
287         src/static_gl_shader.c
288 nodist_libuterm_la_SOURCES += \
289         src/static_shaders.c
290 libuterm_la_CPPFLAGS += \
291         $(DRM_CFLAGS) \
292         $(EGL_CFLAGS) \
293         $(GBM_CFLAGS) \
294         $(GLES2_CFLAGS)
295 libuterm_la_LIBADD += \
296         $(DRM_LIBS) \
297         $(EGL_LIBS) \
298         $(GBM_LIBS) \
299         $(GLES2_LIBS)
300 endif
301
302 # add shared sources only once
303 UTERM_DRM_SHARED_SRC = \
304         src/uterm_drm_shared_internal.h \
305         src/uterm_drm_shared.c
306 if BUILD_ENABLE_VIDEO_DUMB
307 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
308 else
309 if BUILD_ENABLE_VIDEO_DRM
310 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
311 endif
312 endif
313
314 #
315 # Shaders
316 # As there is no need to modify shaders at run-time, we statically compile them
317 # into object files. As autotools would ignore them, we need to add them to
318 # EXTRA_DIST.
319 # The program that converts the shaders into C-source files is "genshader". It's
320 # pretty simple and just creates a string with the shader source as content.
321 #
322
323 SHADERS = \
324         $(srcdir)/src/static_fill.vert \
325         $(srcdir)/src/static_fill.frag \
326         $(srcdir)/src/static_blend.vert \
327         $(srcdir)/src/static_blend.frag \
328         $(srcdir)/src/static_blit.vert \
329         $(srcdir)/src/static_blit.frag \
330         $(srcdir)/src/static_gltex.vert \
331         $(srcdir)/src/static_gltex.frag
332
333 EXTRA_DIST += $(SHADERS)
334 CLEANFILES += src/static_shaders.c
335 genshader_SOURCES = src/genshader.c
336
337 src/static_shaders.c: $(SHADERS) genshader$(EXEEXT)
338         $(AM_V_GEN)./genshader$(EXEEXT) src/static_shaders.c $(SHADERS)
339
340 #
341 # Unifont Generator
342 # This generates the unifont sources from raw hex-encoded font data.
343 #
344
345 UNIFONT = src/font_unifont_data.hex
346
347 EXTRA_DIST += $(UNIFONT)
348 CLEANFILES += src/font_unifont_data.c
349 genunifont_SOURCES = src/genunifont.c
350
351 src/font_unifont_data.c: $(UNIFONT) genunifont$(EXEEXT)
352         $(AM_V_GEN)./genunifont$(EXEEXT) src/font_unifont_data.c $(UNIFONT)
353
354 #
355 # Kmscon Modules
356 #
357
358 if BUILD_ENABLE_FONT_UNIFONT
359 module_LTLIBRARIES += mod-unifont.la
360 endif
361
362 mod_unifont_la_SOURCES = \
363         src/kmscon_module_interface.h \
364         src/githead.h \
365         src/font_unifont.c \
366         src/kmscon_mod_unifont.c
367 nodist_mod_unifont_la_SOURCES = \
368         src/font_unifont_data.c
369 mod_unifont_la_LDFLAGS = \
370         -module \
371         -avoid-version
372
373 if BUILD_ENABLE_FONT_FREETYPE2
374 module_LTLIBRARIES += mod-freetype2.la
375 endif
376
377 mod_freetype2_la_SOURCES = \
378         $(SHL_DLIST) \
379         $(SHL_HASHTABLE) \
380         src/kmscon_module_interface.h \
381         src/githead.h \
382         src/font_freetype2.c \
383         src/kmscon_mod_freetype2.c
384 mod_freetype2_la_CPPFLAGS = \
385         $(AM_CPPFLAGS) \
386         $(FREETYPE2_CFLAGS)
387 mod_freetype2_la_LIBADD = \
388         $(FREETYPE2_LIBS) \
389         -lpthread \
390         libtsm.la
391 mod_freetype2_la_LDFLAGS = \
392         -module \
393         -avoid-version
394
395 if BUILD_ENABLE_FONT_PANGO
396 module_LTLIBRARIES += mod-pango.la
397 endif
398
399 mod_pango_la_SOURCES = \
400         $(SHL_DLIST) \
401         $(SHL_HASHTABLE) \
402         src/kmscon_module_interface.h \
403         src/githead.h \
404         src/font_pango.c \
405         src/kmscon_mod_pango.c
406 mod_pango_la_CPPFLAGS = \
407         $(AM_CPPFLAGS) \
408         $(PANGO_CFLAGS)
409 mod_pango_la_LIBADD = \
410         $(PANGO_LIBS) \
411         -lpthread \
412         libtsm.la
413 mod_pango_la_LDFLAGS = \
414         -module \
415         -avoid-version
416
417 if BUILD_ENABLE_RENDERER_BBULK
418 module_LTLIBRARIES += mod-bbulk.la
419 endif
420
421 mod_bbulk_la_SOURCES = \
422         src/kmscon_module_interface.h \
423         src/githead.h \
424         src/text_bbulk.c \
425         src/kmscon_mod_bbulk.c
426 mod_bbulk_la_LDFLAGS = \
427         -module \
428         -avoid-version
429
430 if BUILD_ENABLE_RENDERER_GLTEX
431 module_LTLIBRARIES += mod-gltex.la
432 endif
433
434 mod_gltex_la_SOURCES = \
435         src/kmscon_module_interface.h \
436         src/githead.h \
437         src/text_gltex.c \
438         src/static_gl.h \
439         src/static_gl_math.c \
440         src/static_gl_shader.c \
441         src/kmscon_mod_gltex.c
442 nodist_mod_gltex_la_SOURCES = \
443         src/static_shaders.c
444 mod_gltex_la_CPPFLAGS = \
445         $(AM_CPPFLAGS) \
446         $(GLES2_CFLAGS)
447 mod_gltex_la_LIBADD = \
448         $(GLES2_LIBS)
449 mod_gltex_la_LDFLAGS = \
450         -module \
451         -avoid-version
452
453 if BUILD_ENABLE_RENDERER_CAIRO
454 module_LTLIBRARIES += mod-cairo.la
455 endif
456
457 mod_cairo_la_SOURCES = \
458         src/kmscon_module_interface.h \
459         src/githead.h \
460         src/text_cairo.c \
461         src/kmscon_mod_cairo.c
462 mod_cairo_la_CPPFLAGS = \
463         $(AM_CPPFLAGS) \
464         $(CAIRO_CFLAGS)
465 mod_cairo_la_LIBADD = \
466         $(CAIRO_LIBS)
467 mod_cairo_la_LDFLAGS = \
468         -module \
469         -avoid-version
470
471 #
472 # Binaries
473 # These are the sources for the main binaries and test programs. They mostly
474 # consists of a single source file only and include all the libraries that are
475 # built as part of kmscon.
476 #
477
478 if BUILD_ENABLE_KMSCON
479 bin_PROGRAMS += kmscon
480 check_PROGRAMS += \
481         test_output \
482         test_vt \
483         test_input \
484         test_key
485 MANPAGES += docs/man/kmscon.1
486 endif
487
488 kmscon_SOURCES = \
489         $(SHL_DLIST) \
490         $(SHL_MISC) \
491         $(SHL_ARRAY) \
492         $(SHL_HASHTABLE) \
493         $(SHL_RING) \
494         $(SHL_TIMER) \
495         $(SHL_HOOK) \
496         $(SHL_REGISTER) \
497         src/githead.h \
498         src/conf.h \
499         src/conf.c \
500         src/log.h \
501         src/log.c \
502         src/pty.h \
503         src/pty.c \
504         src/font.h \
505         src/font.c \
506         src/font_8x16.c \
507         src/text.h \
508         src/text.c \
509         src/text_bblit.c \
510         src/kmscon_module_interface.h \
511         src/kmscon_module.h \
512         src/kmscon_module.c \
513         src/kmscon_terminal.h \
514         src/kmscon_dummy.h \
515         src/kmscon_cdev.h \
516         src/kmscon_seat.h \
517         src/kmscon_seat.c \
518         src/kmscon_conf.h \
519         src/kmscon_conf.c \
520         src/kmscon_main.c
521 nodist_kmscon_SOURCES =
522
523 kmscon_CPPFLAGS = \
524         $(AM_CPPFLAGS) \
525         $(XKBCOMMON_CFLAGS)
526 kmscon_LDADD = \
527         $(XKBCOMMON_LIBS) \
528         libeloop.la \
529         libuterm.la \
530         -lpthread \
531         -ldl
532 kmscon_LDFLAGS = \
533         -rdynamic
534
535 if BUILD_ENABLE_SESSION_DUMMY
536 kmscon_SOURCES += src/kmscon_dummy.c
537 endif
538
539 if BUILD_ENABLE_SESSION_TERMINAL
540 kmscon_SOURCES += src/kmscon_terminal.c
541 kmscon_LDADD += libtsm.la
542 endif
543
544 if BUILD_ENABLE_SESSION_CDEV
545 kmscon_SOURCES += src/kmscon_cdev.c
546 kmscon_CPPFLAGS += $(FUSE_CFLAGS)
547 kmscon_LDADD += $(FUSE_LIBS)
548 endif
549
550 #
551 # Wayland Terminal
552 #
553
554 if BUILD_ENABLE_WLTERM
555 bin_PROGRAMS += wlterm
556 endif
557
558 wlterm_SOURCES = \
559         $(SHL_MISC) \
560         $(SHL_ARRAY) \
561         $(SHL_DLIST) \
562         $(SHL_HOOK) \
563         src/wlt_main.h \
564         src/wlt_main.c \
565         src/wlt_toolkit.h \
566         src/wlt_toolkit.c \
567         src/wlt_theme.h \
568         src/wlt_theme.c \
569         src/wlt_terminal.h \
570         src/wlt_terminal.c \
571         src/log.h \
572         src/log.c \
573         src/conf.h \
574         src/conf.c \
575         src/pty.h \
576         src/pty.c
577 wlterm_CPPFLAGS = \
578         $(AM_CPPFLAGS) \
579         $(WAYLAND_CFLAGS) \
580         $(XKBCOMMON_CFLAGS)
581 wlterm_LDADD = \
582         $(WAYLAND_LIBS) \
583         $(XKBCOMMON_LIBS) \
584         libeloop.la \
585         libtsm.la \
586         -lpthread
587
588 #
589 # Tests
590 #
591
592 test_sources = \
593         src/log.h \
594         src/log.c \
595         src/conf.h \
596         src/conf.c \
597         tests/test_include.h
598 test_cflags = \
599         $(XKBCOMMON_CFLAGS)
600 test_libs = \
601         $(XKBCOMMON_LIBS) \
602         libeloop.la
603
604 test_output_SOURCES = \
605         $(test_sources) \
606         tests/test_output.c
607 test_output_CPPFLAGS = \
608         $(AM_CPPFLAGS) \
609         $(test_cflags)
610 test_output_LDADD = \
611         $(test_libs) \
612         libuterm.la
613
614 test_vt_SOURCES = \
615         $(test_sources) \
616         tests/test_vt.c
617 test_vt_CPPFLAGS = \
618         $(AM_CPPFLAGS) \
619         $(test_cflags)
620 test_vt_LDADD = \
621         $(test_libs) \
622         libuterm.la
623
624 test_input_SOURCES = \
625         $(test_sources) \
626         tests/test_input.c
627 test_input_CPPFLAGS = \
628         $(AM_CPPFLAGS) \
629         $(test_cflags)
630 test_input_LDADD = \
631         $(test_libs) \
632         libuterm.la
633
634 test_key_SOURCES = \
635         $(test_sources) \
636         tests/test_key.c
637 test_key_CPPFLAGS = \
638         $(AM_CPPFLAGS) \
639         $(test_cflags)
640 test_key_LDADD = \
641         $(test_libs)
642
643 #
644 # Manpages
645 #
646
647 man_MANS =
648 EXTRA_DIST += ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,$(MANPAGES)}}}}
649 CLEANFILES += $(MANPAGES) $(MANPAGES_ALIASES) .man_fixup
650
651 if BUILD_HAVE_XSLTPROC
652 if BUILD_HAVE_MANPAGES_STYLESHEET
653
654 man_MANS += $(MANPAGES) $(MANPAGES_ALIASES)
655
656 XSLTPROC_FLAGS = \
657         --stringparam man.authors.section.enabled 0 \
658         --stringparam man.copyright.section.enabled 0 \
659         --stringparam funcsynopsis.style ansi \
660         --stringparam man.output.quietly 1 \
661         --nonet
662
663 XSLTPROC_PROCESS_MAN = \
664         $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
665         $(XSLTPROC) -o "$@" $(XSLTPROC_FLAGS) $(BUILD_MANPAGES_STYLESHEET) "$<" && \
666         touch .man_fixup
667
668 # Force .man_fixup if $(MANPAGES) are not built
669 .man_fixup: | $(MANPAGES)
670         @touch .man_fixup
671
672 $(MANPAGES_ALIASES): $(MANPAGES) .man_fixup
673         $(AM_V_GEN)if test -n "$@" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' "$@" ; fi
674
675 docs/man/%.1: docs/man/%.xml
676         $(XSLTPROC_PROCESS_MAN)
677
678 docs/man/%.3: docs/man/%.xml
679         $(XSLTPROC_PROCESS_MAN)
680
681 docs/man/%.5: docs/man/%.xml
682         $(XSLTPROC_PROCESS_MAN)
683
684 docs/man/%.7: docs/man/%.xml
685         $(XSLTPROC_PROCESS_MAN)
686
687 endif # BUILD_HAVE_MANPAGES_STYLESHEET
688 endif # BUILD_HAVE_XSLTPROC
689
690 #
691 # Phony targets
692 #
693
694 .PHONY: $(TPHONY)