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