kmscon: add unifont 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_PANGO
380 module_LTLIBRARIES += mod-pango.la
381 endif
382
383 mod_pango_la_SOURCES = \
384         $(SHL_DLIST) \
385         $(SHL_HASHTABLE) \
386         src/kmscon_module_interface.h \
387         src/githead.h \
388         src/font_pango.c \
389         src/kmscon_mod_pango.c
390 mod_pango_la_CPPFLAGS = \
391         $(AM_CPPFLAGS) \
392         $(PANGO_CFLAGS)
393 mod_pango_la_LIBADD = \
394         $(PANGO_LIBS) \
395         -lpthread \
396         libtsm.la
397 mod_pango_la_LDFLAGS = \
398         -module \
399         -avoid-version
400
401 #
402 # Binaries
403 # These are the sources for the main binaries and test programs. They mostly
404 # consists of a single source file only and include all the libraries that are
405 # built as part of kmscon.
406 #
407
408 if BUILD_ENABLE_KMSCON
409 bin_PROGRAMS += kmscon
410 check_PROGRAMS += \
411         test_output \
412         test_vt \
413         test_input \
414         test_key
415 MANPAGES += docs/man/kmscon.1
416 endif
417
418 kmscon_SOURCES = \
419         $(SHL_DLIST) \
420         $(SHL_MISC) \
421         $(SHL_ARRAY) \
422         $(SHL_HASHTABLE) \
423         $(SHL_RING) \
424         $(SHL_TIMER) \
425         $(SHL_HOOK) \
426         $(SHL_REGISTER) \
427         src/githead.h \
428         src/conf.h \
429         src/conf.c \
430         src/log.h \
431         src/log.c \
432         src/pty.h \
433         src/pty.c \
434         src/text.h \
435         src/text.c \
436         src/kmscon_module_interface.h \
437         src/kmscon_module.h \
438         src/kmscon_module.c \
439         src/kmscon_terminal.h \
440         src/kmscon_dummy.h \
441         src/kmscon_cdev.h \
442         src/kmscon_seat.h \
443         src/kmscon_seat.c \
444         src/kmscon_conf.h \
445         src/kmscon_conf.c \
446         src/kmscon_main.c
447 nodist_kmscon_SOURCES =
448
449 kmscon_CPPFLAGS = \
450         $(AM_CPPFLAGS) \
451         $(XKBCOMMON_CFLAGS)
452 kmscon_LDADD = \
453         $(XKBCOMMON_LIBS) \
454         libeloop.la \
455         libuterm.la \
456         libfont.la \
457         -lpthread
458 kmscon_LDFLAGS = \
459         -rdynamic
460
461 if BUILD_ENABLE_SESSION_DUMMY
462 kmscon_SOURCES += src/kmscon_dummy.c
463 endif
464
465 if BUILD_ENABLE_SESSION_TERMINAL
466 kmscon_SOURCES += src/kmscon_terminal.c
467 kmscon_LDADD += libtsm.la
468 endif
469
470 if BUILD_ENABLE_SESSION_CDEV
471 kmscon_SOURCES += src/kmscon_cdev.c
472 kmscon_CPPFLAGS += $(FUSE_CFLAGS)
473 kmscon_LDADD += $(FUSE_LIBS)
474 endif
475
476 if BUILD_ENABLE_RENDERER_BBLIT
477 kmscon_SOURCES += src/text_bblit.c
478 endif
479
480 if BUILD_ENABLE_RENDERER_BBULK
481 kmscon_SOURCES += src/text_bbulk.c
482 endif
483
484 if BUILD_ENABLE_RENDERER_GLTEX
485 kmscon_SOURCES += \
486         src/text_gltex.c \
487         src/static_gl.h \
488         src/static_gl_math.c \
489         src/static_gl_shader.c
490 nodist_kmscon_SOURCES += src/static_shaders.c
491 kmscon_CPPFLAGS += $(GLES2_CFLAGS)
492 kmscon_LDADD += $(GLES2_LIBS)
493 endif
494
495 #
496 # Wayland Terminal
497 #
498
499 if BUILD_ENABLE_WLTERM
500 bin_PROGRAMS += wlterm
501 endif
502
503 wlterm_SOURCES = \
504         $(SHL_MISC) \
505         $(SHL_ARRAY) \
506         $(SHL_DLIST) \
507         $(SHL_HOOK) \
508         src/wlt_main.h \
509         src/wlt_main.c \
510         src/wlt_toolkit.h \
511         src/wlt_toolkit.c \
512         src/wlt_theme.h \
513         src/wlt_theme.c \
514         src/wlt_terminal.h \
515         src/wlt_terminal.c \
516         src/log.h \
517         src/log.c \
518         src/conf.h \
519         src/conf.c \
520         src/pty.h \
521         src/pty.c
522 wlterm_CPPFLAGS = \
523         $(AM_CPPFLAGS) \
524         $(WAYLAND_CFLAGS) \
525         $(XKBCOMMON_CFLAGS)
526 wlterm_LDADD = \
527         $(WAYLAND_LIBS) \
528         $(XKBCOMMON_LIBS) \
529         libeloop.la \
530         libtsm.la \
531         -lpthread
532
533 #
534 # Tests
535 #
536
537 test_sources = \
538         src/log.h \
539         src/log.c \
540         src/conf.h \
541         src/conf.c \
542         tests/test_include.h
543 test_cflags = \
544         $(XKBCOMMON_CFLAGS)
545 test_libs = \
546         $(XKBCOMMON_LIBS) \
547         libeloop.la
548
549 test_output_SOURCES = \
550         $(test_sources) \
551         tests/test_output.c
552 test_output_CPPFLAGS = \
553         $(AM_CPPFLAGS) \
554         $(test_cflags)
555 test_output_LDADD = \
556         $(test_libs) \
557         libuterm.la
558
559 test_vt_SOURCES = \
560         $(test_sources) \
561         tests/test_vt.c
562 test_vt_CPPFLAGS = \
563         $(AM_CPPFLAGS) \
564         $(test_cflags)
565 test_vt_LDADD = \
566         $(test_libs) \
567         libuterm.la
568
569 test_input_SOURCES = \
570         $(test_sources) \
571         tests/test_input.c
572 test_input_CPPFLAGS = \
573         $(AM_CPPFLAGS) \
574         $(test_cflags)
575 test_input_LDADD = \
576         $(test_libs) \
577         libuterm.la
578
579 test_key_SOURCES = \
580         $(test_sources) \
581         tests/test_key.c
582 test_key_CPPFLAGS = \
583         $(AM_CPPFLAGS) \
584         $(test_cflags)
585 test_key_LDADD = \
586         $(test_libs)
587
588 #
589 # Manpages
590 #
591
592 man_MANS =
593 EXTRA_DIST += ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,$(MANPAGES)}}}}
594 CLEANFILES += $(MANPAGES) $(MANPAGES_ALIASES) .man_fixup
595
596 if BUILD_HAVE_XSLTPROC
597 if BUILD_HAVE_MANPAGES_STYLESHEET
598
599 man_MANS += $(MANPAGES) $(MANPAGES_ALIASES)
600
601 XSLTPROC_FLAGS = \
602         --stringparam man.authors.section.enabled 0 \
603         --stringparam man.copyright.section.enabled 0 \
604         --stringparam funcsynopsis.style ansi \
605         --stringparam man.output.quietly 1 \
606         --nonet
607
608 XSLTPROC_PROCESS_MAN = \
609         $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
610         $(XSLTPROC) -o "$@" $(XSLTPROC_FLAGS) $(BUILD_MANPAGES_STYLESHEET) "$<" && \
611         touch .man_fixup
612
613 # Force .man_fixup if $(MANPAGES) are not built
614 .man_fixup: | $(MANPAGES)
615         @touch .man_fixup
616
617 $(MANPAGES_ALIASES): $(MANPAGES) .man_fixup
618         $(AM_V_GEN)if test -n "$@" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' "$@" ; fi
619
620 docs/man/%.1: docs/man/%.xml
621         $(XSLTPROC_PROCESS_MAN)
622
623 docs/man/%.3: docs/man/%.xml
624         $(XSLTPROC_PROCESS_MAN)
625
626 docs/man/%.5: docs/man/%.xml
627         $(XSLTPROC_PROCESS_MAN)
628
629 docs/man/%.7: docs/man/%.xml
630         $(XSLTPROC_PROCESS_MAN)
631
632 endif # BUILD_HAVE_MANPAGES_STYLESHEET
633 endif # BUILD_HAVE_XSLTPROC
634
635 #
636 # Phony targets
637 #
638
639 .PHONY: $(TPHONY)