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