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