2 # Kmscon - Global Makefile
3 # Copyright (c) 2012-2013 David Herrmann <dh.herrmann@googlemail.com>
7 # Library Version Numbers
27 # Global Configurations and Initializations
30 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
31 AM_MAKEFLAGS = --no-print-directory
32 AUTOMAKE_OPTIONS = color-tests
33 AM_DISTCHECK_CONFIGURE_FLAGS = --enable-all
45 docs/kmsconvt@.service \
46 docs/pc/libeloop.pc.in \
47 docs/pc/libtsm.pc.in \
48 docs/pc/libuvt.pc.in \
49 docs/pc/libuterm.pc.in \
50 docs/sym/libeloop.sym \
55 pkgconfigdir = $(libdir)/pkgconfig
67 moduledir = $(libdir)/kmscon
72 # Make all files include "config.h" by default. This shouldn't cause any
73 # problems and we cannot forget to include it anymore.
75 # Also make the linker discard all unused symbols.
77 # When compiling in debug mode, we enable debug symbols so debugging with gdb
78 # is easier. If optimizations are disabled, we pass -O0 to the compiler.
79 # Otherwise, we use standard optimizations -O2.
87 -fdiagnostics-show-option \
88 -fno-strict-aliasing \
94 -DBUILD_MODULE_DIR='"$(moduledir)"' \
95 -include $(top_builddir)/config.h \
103 if BUILD_ENABLE_DEBUG
107 if BUILD_ENABLE_OPTIMIZATIONS
115 # The file ./src/shl_githead.c contains a constant "shl_git_head" which is
116 # defined to the string returned by "git describe". We need to adjust this
117 # string for every build and correctly rebuild any sources that depend on it.
118 # Therefore, you should use this file rarely as it causes rebuilds on every
121 # We have a helper-script ./src/genversion.sh that takes as argument the source
122 # file and creates it if necessary. It updates it only if the new git-describe
123 # string is different to the old one. So the file is only modified on changes.
124 # Hence, we can use it as normal dependency in this Makefile.
125 # However, we need to run this script on _every_ "make" invocation before any
126 # recipy is executed. To achieve this, we use $(shell ...) and assign it to a
127 # "simply expanded" variable (:=) so the shell command is executed on
128 # variable-declaration and not during expansion.
130 # Note that we must not clean ./src/shl_githead.c ever! If we would, a
131 # distribution tarball might delete that file and have no way to recreate it.
132 # We could delete it on something like "make maintainerclean", but then again,
133 # it seems unnecessary so lets simply not clean it at all.
135 # If the helper-script is executed in a directory that is not a git-repository
136 # (like a distribution tarball) and shl_githead.c exists, then it does nothing
137 # as it expects shl_githead.c to be correctly written by "make dist".
138 # However, if shl_githead.c does not exist, it will print a warning and write
139 # an unknown random git-revision.
140 # This guarantees, that shl_githead.c is always present and has the most correct
141 # value that we can get under any conditions.
143 # The $(emptyvariable) expansion below is used for broken $(shell ...)
144 # syntax-highlighting algorithms in many existing editors.
147 EXTRA_DIST += src/genversion.sh
148 GITHEAD:=$(shell $(emptyvariable)"$(srcdir)/src/genversion.sh" "$(srcdir)/src/shl_githead.c")
151 # Binary File Compiler
152 # This target gets as input a binary file *.bin and produces an ELF/etc. output
153 # object file *.bin.o and the corresponding libtool file *.bin.lo.
154 # Note that we fake the libtool object files as there is no way to make libtool
155 # create it. The comments in the .lo file are mandatory so don't remove them!
158 CLEANFILES += src/*.bin.lo src/*.bin.o
160 src/%.bin.lo: src/%.bin
161 $(AM_V_GEN)$(LD) -r -o "src/$*.bin.o" -z noexecstack --format=binary "$<"
162 $(AM_V_at)echo "# $@ - a libtool object file" >"$@"
163 $(AM_V_at)echo "# Generated by $(shell $(LIBTOOL) --version | head -n 1)" >>"$@"
164 $(AM_V_at)echo "#" >>"$@"
165 $(AM_V_at)echo "# Please DO NOT delete this file!" >>"$@"
166 $(AM_V_at)echo "# It is necessary for linking the library." >>"$@"
167 $(AM_V_at)echo >>"$@"
168 $(AM_V_at)echo "# Name of the PIC object." >>"$@"
169 $(AM_V_at)echo "pic_object='$*.bin.o'" >>"$@"
170 $(AM_V_at)echo >>"$@"
171 $(AM_V_at)echo "# Name of the non-PIC object" >>"$@"
172 $(AM_V_at)echo "non_pic_object='$*.bin.o'" >>"$@"
173 $(AM_V_at)echo >>"$@"
176 # SHL - Static Helper Library
177 # The SHL subsystem contains several small code pieces used all over kmscon and
178 # other applications.
181 noinst_LTLIBRARIES += libshl.la
183 libshl_la_SOURCES = \
188 src/shl_hashtable.h \
200 libshl_la_CPPFLAGS = \
202 $(XKBCOMMON_CFLAGS) \
204 libshl_la_LDFLAGS = \
213 # This library contains the whole event-loop implementation of kmscon. It is
214 # compiled into a separate object to allow using it in several other programs.
217 if BUILD_ENABLE_ELOOP
218 lib_LTLIBRARIES += libeloop.la
219 include_HEADERS += src/eloop.h
220 pkgconfig_DATA += docs/pc/libeloop.pc
223 libeloop_la_SOURCES = \
227 libeloop_la_LIBADD = libshl.la
228 libeloop_la_CPPFLAGS = $(AM_CPPFLAGS)
229 EXTRA_libeloop_la_DEPENDENCIES = ${top_srcdir}/docs/sym/libeloop.sym
230 libeloop_la_LDFLAGS = \
232 -version-info $(LIBELOOP_CURRENT):$(LIBELOOP_REVISION):$(LIBELOOP_AGE) \
233 -Wl,--version-script=$(top_srcdir)/docs/sym/libeloop.sym
236 if BUILD_ENABLE_ELOOP_DBUS
237 libeloop_la_SOURCES += \
238 external/dbus-common.h \
239 external/dbus-loop.h \
241 libeloop_la_CPPFLAGS += $(DBUS_CFLAGS)
242 libeloop_la_LIBADD += $(DBUS_LIBS)
247 # The Terminal-emulator State Machine is a library that implements the whole VTE
248 # layer and everything related to it. It has no external dependencies so it can
249 # be used to implement any kind of terminal emulator or debugger.
253 lib_LTLIBRARIES += libtsm.la
258 pkgconfig_DATA += docs/pc/libtsm.pc
261 libtsm_la_SOURCES = \
268 src/tsm_vte_charsets.c \
272 libtsm_la_CPPFLAGS = \
278 EXTRA_libtsm_la_DEPENDENCIES = ${top_srcdir}/docs/sym/libtsm.sym
279 libtsm_la_LDFLAGS = \
281 -version-info $(LIBTSM_CURRENT):$(LIBTSM_REVISION):$(LIBTSM_AGE) \
282 -Wl,--version-script="$(top_srcdir)/docs/sym/libtsm.sym"
286 # Implementation of Virtual Terminals in user-space with the help of CUSE/FUSE
287 # so we can provide character-device drivers in user-space. Aims to be 100%
288 # compatible but also provides many other use-cases.
292 lib_LTLIBRARIES += libuvt.la
293 include_HEADERS += src/uvt.h
294 pkgconfig_DATA += docs/pc/libuvt.pc
297 libuvt_la_SOURCES = \
304 libuvt_la_CPPFLAGS = \
307 -DFUSE_USE_VERSION=29
311 EXTRA_libuvt_la_DEPENDENCIES = ${top_srcdir}/docs/sym/libuvt.sym
312 libuvt_la_LDFLAGS = \
314 -version-info $(LIBUVT_CURRENT):$(LIBUVT_REVISION):$(LIBUVT_AGE) \
315 -Wl,--version-script="$(top_srcdir)/docs/sym/libuvt.sym"
319 # The uterm library provides helpers to create terminals in user-space. They
320 # are not limited to text-based terminals but rather provide graphics contexts
321 # so arbitrary output can be displayed. Additionally, they provide VT
322 # abstractions and an input layer
325 if BUILD_ENABLE_UTERM
326 lib_LTLIBRARIES += libuterm.la
329 src/uterm_monitor.h \
332 pkgconfig_DATA += docs/pc/libuterm.pc
335 libuterm_la_SOURCES = \
337 src/uterm_monitor.h \
340 src/uterm_input_internal.h \
341 src/uterm_video_internal.h \
342 src/uterm_systemd_internal.h \
344 src/uterm_monitor.c \
347 src/uterm_input_uxkb.c
349 nodist_libuterm_la_SOURCES =
351 libuterm_la_CPPFLAGS = \
354 libuterm_la_LIBADD = \
358 EXTRA_libuterm_la_DEPENDENCIES = ${top_srcdir}/docs/sym/libuterm.sym
359 libuterm_la_LDFLAGS = \
361 -version-info $(LIBUTERM_CURRENT):$(LIBUTERM_REVISION):$(LIBUTERM_AGE) \
362 -Wl,--version-script="$(top_srcdir)/docs/sym/libuterm.sym"
364 if BUILD_ENABLE_MULTI_SEAT
365 libuterm_la_SOURCES += src/uterm_systemd.c
366 libuterm_la_CPPFLAGS += $(SYSTEMD_CFLAGS)
367 libuterm_la_LIBADD += $(SYSTEMD_LIBS)
370 if BUILD_ENABLE_HOTPLUG
371 libuterm_la_CPPFLAGS += $(UDEV_CFLAGS)
372 libuterm_la_LIBADD += $(UDEV_LIBS)
375 if BUILD_ENABLE_VIDEO_FBDEV
376 libuterm_la_SOURCES += \
377 src/uterm_fbdev_internal.h \
378 src/uterm_fbdev_video.c \
379 src/uterm_fbdev_render.c
382 if BUILD_ENABLE_VIDEO_DRM2D
383 libuterm_la_SOURCES += \
384 src/uterm_drm2d_internal.h \
385 src/uterm_drm2d_video.c \
386 src/uterm_drm2d_render.c
387 libuterm_la_CPPFLAGS += $(DRM_CFLAGS)
388 libuterm_la_LIBADD += $(DRM_LIBS)
391 if BUILD_ENABLE_VIDEO_DRM3D
392 noinst_PROGRAMS += genshader
393 libuterm_la_SOURCES += \
394 src/uterm_drm3d_internal.h \
395 src/uterm_drm3d_video.c \
396 src/uterm_drm3d_render.c \
398 src/static_gl_math.c \
399 src/static_gl_shader.c
400 nodist_libuterm_la_SOURCES += src/static_shaders.c
401 libuterm_la_CPPFLAGS += \
406 libuterm_la_LIBADD += \
413 # add shared sources only once
414 UTERM_DRM_SHARED_SRC = \
415 src/uterm_drm_shared_internal.h \
416 src/uterm_drm_shared.c
417 if BUILD_ENABLE_VIDEO_DRM2D
418 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
420 if BUILD_ENABLE_VIDEO_DRM3D
421 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
427 # As there is no need to modify shaders at run-time, we statically compile them
428 # into object files. As autotools would ignore them, we need to add them to
430 # The program that converts the shaders into C-source files is "genshader". It's
431 # pretty simple and just creates a string with the shader source as content.
435 $(srcdir)/src/static_fill.vert \
436 $(srcdir)/src/static_fill.frag \
437 $(srcdir)/src/static_blend.vert \
438 $(srcdir)/src/static_blend.frag \
439 $(srcdir)/src/static_blit.vert \
440 $(srcdir)/src/static_blit.frag \
441 $(srcdir)/src/static_gltex.vert \
442 $(srcdir)/src/static_gltex.frag
444 EXTRA_DIST += $(SHADERS)
445 CLEANFILES += src/static_shaders.c
446 genshader_SOURCES = src/genshader.c
448 src/static_shaders.c: $(SHADERS) genshader$(EXEEXT)
449 $(AM_V_GEN)./genshader$(EXEEXT) src/static_shaders.c $(SHADERS)
453 # This generates the unifont sources from raw hex-encoded font data.
456 UNIFONT = $(top_srcdir)/src/font_unifont_data.hex
457 UNIFONT_BIN = src/font_unifont_data.bin
458 UNIFONT_LT = src/font_unifont_data.bin.lo
460 EXTRA_DIST += $(UNIFONT)
461 CLEANFILES += $(UNIFONT_BIN)
462 genunifont_SOURCES = src/genunifont.c
464 $(UNIFONT_BIN): $(UNIFONT) genunifont$(EXEEXT)
465 $(AM_V_GEN)./genunifont$(EXEEXT) $(UNIFONT_BIN) $(UNIFONT)
471 if BUILD_ENABLE_FONT_UNIFONT
472 module_LTLIBRARIES += mod-unifont.la
473 noinst_PROGRAMS += genunifont
476 mod_unifont_la_SOURCES = \
477 src/kmscon_module_interface.h \
479 src/kmscon_mod_unifont.c
480 mod_unifont_la_LIBADD = \
483 mod_unifont_la_LDFLAGS = \
488 if BUILD_ENABLE_FONT_FREETYPE2
489 module_LTLIBRARIES += mod-freetype2.la
492 mod_freetype2_la_SOURCES = \
493 src/kmscon_module_interface.h \
494 src/font_freetype2.c \
495 src/kmscon_mod_freetype2.c
496 mod_freetype2_la_CPPFLAGS = \
499 mod_freetype2_la_LIBADD = \
504 mod_freetype2_la_LDFLAGS = \
509 if BUILD_ENABLE_FONT_PANGO
510 module_LTLIBRARIES += mod-pango.la
513 mod_pango_la_SOURCES = \
514 src/kmscon_module_interface.h \
516 src/kmscon_mod_pango.c
517 mod_pango_la_CPPFLAGS = \
520 mod_pango_la_LIBADD = \
525 mod_pango_la_LDFLAGS = \
530 if BUILD_ENABLE_RENDERER_BBULK
531 module_LTLIBRARIES += mod-bbulk.la
534 mod_bbulk_la_SOURCES = \
535 src/kmscon_module_interface.h \
537 src/kmscon_mod_bbulk.c
538 mod_bbulk_la_LIBADD = libshl.la
539 mod_bbulk_la_LDFLAGS = \
544 if BUILD_ENABLE_RENDERER_GLTEX
545 module_LTLIBRARIES += mod-gltex.la
546 noinst_PROGRAMS += genshader
549 mod_gltex_la_SOURCES = \
550 src/kmscon_module_interface.h \
553 src/static_gl_math.c \
554 src/static_gl_shader.c \
555 src/kmscon_mod_gltex.c
556 nodist_mod_gltex_la_SOURCES = \
558 mod_gltex_la_CPPFLAGS = \
561 mod_gltex_la_LIBADD = \
564 mod_gltex_la_LDFLAGS = \
569 if BUILD_ENABLE_RENDERER_CAIRO
570 module_LTLIBRARIES += mod-cairo.la
573 mod_cairo_la_SOURCES = \
574 src/kmscon_module_interface.h \
576 src/kmscon_mod_cairo.c
577 mod_cairo_la_CPPFLAGS = \
580 mod_cairo_la_LIBADD = \
583 mod_cairo_la_LDFLAGS = \
588 if BUILD_ENABLE_RENDERER_PIXMAN
589 module_LTLIBRARIES += mod-pixman.la
592 mod_pixman_la_SOURCES = \
593 src/kmscon_module_interface.h \
595 src/kmscon_mod_pixman.c
596 mod_pixman_la_CPPFLAGS = \
599 mod_pixman_la_LIBADD = \
602 mod_pixman_la_LDFLAGS = \
609 # These are the sources for the main binaries and test programs. They mostly
610 # consists of a single source file only and include all the libraries that are
611 # built as part of kmscon.
614 if BUILD_ENABLE_KMSCON
615 bin_PROGRAMS += kmscon
621 MANPAGES += docs/man/kmscon.1
635 src/kmscon_module_interface.h \
636 src/kmscon_module.h \
637 src/kmscon_module.c \
638 src/kmscon_terminal.h \
646 nodist_kmscon_SOURCES =
662 if BUILD_ENABLE_SESSION_DUMMY
663 kmscon_SOURCES += src/kmscon_dummy.c
666 if BUILD_ENABLE_SESSION_TERMINAL
667 kmscon_SOURCES += src/kmscon_terminal.c
668 kmscon_LDADD += libtsm.la
671 if BUILD_ENABLE_SESSION_CDEV
672 kmscon_SOURCES += src/kmscon_cdev.c
673 kmscon_CPPFLAGS += $(FUSE_CFLAGS)
674 kmscon_LDADD += $(FUSE_LIBS)
681 if BUILD_ENABLE_WLTERM
682 bin_PROGRAMS += wlterm
758 test_output_SOURCES = \
761 test_output_CPPFLAGS = $(test_cflags)
762 test_output_LDADD = \
769 test_vt_CPPFLAGS = $(test_cflags)
774 test_input_SOURCES = \
777 test_input_CPPFLAGS = $(test_cflags)
785 test_key_CPPFLAGS = $(test_cflags)
786 test_key_LDADD = $(test_libs)
793 EXTRA_DIST += ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,$(MANPAGES)}}}}
794 CLEANFILES += $(MANPAGES) $(MANPAGES_ALIASES) .man_fixup
796 if BUILD_HAVE_XSLTPROC
797 if BUILD_HAVE_MANPAGES_STYLESHEET
799 man_MANS += $(MANPAGES) $(MANPAGES_ALIASES)
802 --stringparam man.authors.section.enabled 0 \
803 --stringparam man.copyright.section.enabled 0 \
804 --stringparam funcsynopsis.style ansi \
805 --stringparam man.output.quietly 1 \
808 XSLTPROC_PROCESS_MAN = \
809 $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
810 $(XSLTPROC) -o "$@" $(XSLTPROC_FLAGS) $(BUILD_MANPAGES_STYLESHEET) "$<" && \
813 # Force .man_fixup if $(MANPAGES) are not built
814 .man_fixup: | $(MANPAGES)
817 $(MANPAGES_ALIASES): $(MANPAGES) .man_fixup
818 $(AM_V_GEN)if test -n "$@" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' "$@" ; fi
820 docs/man/%.1: docs/man/%.xml
821 $(XSLTPROC_PROCESS_MAN)
823 docs/man/%.3: docs/man/%.xml
824 $(XSLTPROC_PROCESS_MAN)
826 docs/man/%.5: docs/man/%.xml
827 $(XSLTPROC_PROCESS_MAN)
829 docs/man/%.7: docs/man/%.xml
830 $(XSLTPROC_PROCESS_MAN)
832 endif # BUILD_HAVE_MANPAGES_STYLESHEET
833 endif # BUILD_HAVE_XSLTPROC