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 # TODO: Using $(BUILD_EXEEXT) breaks if it doesn't equal $(EXEEXT). But stupid
449 # automake doesn't allow $(EXEEXT) so lets just rely on both being the same.
451 src/static_shaders.c: $(SHADERS) genshader$(BUILD_EXEEXT)
452 $(AM_V_GEN)./genshader$(BUILD_EXEEXT) src/static_shaders.c $(SHADERS)
454 genshader$(BUILD_EXEEXT) $(genshader_OBJECTS): CC = $(CC_FOR_BUILD)
455 genshader$(BUILD_EXEEXT) $(genshader_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
456 genshader$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
460 # This generates the unifont sources from raw hex-encoded font data.
463 UNIFONT = $(top_srcdir)/src/font_unifont_data.hex
464 UNIFONT_BIN = src/font_unifont_data.bin
465 UNIFONT_LT = src/font_unifont_data.bin.lo
467 EXTRA_DIST += $(UNIFONT)
468 CLEANFILES += $(UNIFONT_BIN)
469 genunifont_SOURCES = src/genunifont.c
471 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CC = $(CC_FOR_BUILD)
472 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
473 genunifont$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
475 $(UNIFONT_BIN): $(UNIFONT) genunifont$(BUILD_EXEEXT)
476 $(AM_V_GEN)./genunifont$(BUILD_EXEEXT) $(UNIFONT_BIN) $(UNIFONT)
482 if BUILD_ENABLE_FONT_UNIFONT
483 module_LTLIBRARIES += mod-unifont.la
484 noinst_PROGRAMS += genunifont
487 mod_unifont_la_SOURCES = \
488 src/kmscon_module_interface.h \
490 src/kmscon_mod_unifont.c
491 mod_unifont_la_LIBADD = \
494 mod_unifont_la_LDFLAGS = \
499 if BUILD_ENABLE_FONT_FREETYPE2
500 module_LTLIBRARIES += mod-freetype2.la
503 mod_freetype2_la_SOURCES = \
504 src/kmscon_module_interface.h \
505 src/font_freetype2.c \
506 src/kmscon_mod_freetype2.c
507 mod_freetype2_la_CPPFLAGS = \
510 mod_freetype2_la_LIBADD = \
515 mod_freetype2_la_LDFLAGS = \
520 if BUILD_ENABLE_FONT_PANGO
521 module_LTLIBRARIES += mod-pango.la
524 mod_pango_la_SOURCES = \
525 src/kmscon_module_interface.h \
527 src/kmscon_mod_pango.c
528 mod_pango_la_CPPFLAGS = \
531 mod_pango_la_LIBADD = \
536 mod_pango_la_LDFLAGS = \
541 if BUILD_ENABLE_RENDERER_BBULK
542 module_LTLIBRARIES += mod-bbulk.la
545 mod_bbulk_la_SOURCES = \
546 src/kmscon_module_interface.h \
548 src/kmscon_mod_bbulk.c
549 mod_bbulk_la_LIBADD = libshl.la
550 mod_bbulk_la_LDFLAGS = \
555 if BUILD_ENABLE_RENDERER_GLTEX
556 module_LTLIBRARIES += mod-gltex.la
557 noinst_PROGRAMS += genshader
560 mod_gltex_la_SOURCES = \
561 src/kmscon_module_interface.h \
564 src/static_gl_math.c \
565 src/static_gl_shader.c \
566 src/kmscon_mod_gltex.c
567 nodist_mod_gltex_la_SOURCES = \
569 mod_gltex_la_CPPFLAGS = \
572 mod_gltex_la_LIBADD = \
575 mod_gltex_la_LDFLAGS = \
580 if BUILD_ENABLE_RENDERER_CAIRO
581 module_LTLIBRARIES += mod-cairo.la
584 mod_cairo_la_SOURCES = \
585 src/kmscon_module_interface.h \
587 src/kmscon_mod_cairo.c
588 mod_cairo_la_CPPFLAGS = \
591 mod_cairo_la_LIBADD = \
594 mod_cairo_la_LDFLAGS = \
599 if BUILD_ENABLE_RENDERER_PIXMAN
600 module_LTLIBRARIES += mod-pixman.la
603 mod_pixman_la_SOURCES = \
604 src/kmscon_module_interface.h \
606 src/kmscon_mod_pixman.c
607 mod_pixman_la_CPPFLAGS = \
610 mod_pixman_la_LIBADD = \
613 mod_pixman_la_LDFLAGS = \
620 # These are the sources for the main binaries and test programs. They mostly
621 # consists of a single source file only and include all the libraries that are
622 # built as part of kmscon.
625 if BUILD_ENABLE_KMSCON
626 bin_PROGRAMS += kmscon
632 MANPAGES += docs/man/kmscon.1
646 src/kmscon_module_interface.h \
647 src/kmscon_module.h \
648 src/kmscon_module.c \
649 src/kmscon_terminal.h \
657 nodist_kmscon_SOURCES =
673 if BUILD_ENABLE_SESSION_DUMMY
674 kmscon_SOURCES += src/kmscon_dummy.c
677 if BUILD_ENABLE_SESSION_TERMINAL
678 kmscon_SOURCES += src/kmscon_terminal.c
679 kmscon_LDADD += libtsm.la
682 if BUILD_ENABLE_SESSION_CDEV
683 kmscon_SOURCES += src/kmscon_cdev.c
684 kmscon_CPPFLAGS += $(FUSE_CFLAGS)
685 kmscon_LDADD += $(FUSE_LIBS)
730 test_output_SOURCES = \
733 test_output_CPPFLAGS = $(test_cflags)
734 test_output_LDADD = \
741 test_vt_CPPFLAGS = $(test_cflags)
746 test_input_SOURCES = \
749 test_input_CPPFLAGS = $(test_cflags)
757 test_key_CPPFLAGS = $(test_cflags)
758 test_key_LDADD = $(test_libs)
765 EXTRA_DIST += ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,$(MANPAGES)}}}}
766 CLEANFILES += $(MANPAGES) $(MANPAGES_ALIASES) .man_fixup
768 if BUILD_HAVE_XSLTPROC
769 if BUILD_HAVE_MANPAGES_STYLESHEET
771 man_MANS += $(MANPAGES) $(MANPAGES_ALIASES)
774 --stringparam man.authors.section.enabled 0 \
775 --stringparam man.copyright.section.enabled 0 \
776 --stringparam funcsynopsis.style ansi \
777 --stringparam man.output.quietly 1 \
780 XSLTPROC_PROCESS_MAN = \
781 $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
782 $(XSLTPROC) -o "$@" $(XSLTPROC_FLAGS) $(BUILD_MANPAGES_STYLESHEET) "$<" && \
785 # Force .man_fixup if $(MANPAGES) are not built
786 .man_fixup: | $(MANPAGES)
789 $(MANPAGES_ALIASES): $(MANPAGES) .man_fixup
790 $(AM_V_GEN)if test -n "$@" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' "$@" ; fi
792 docs/man/%.1: docs/man/%.xml
793 $(XSLTPROC_PROCESS_MAN)
795 docs/man/%.3: docs/man/%.xml
796 $(XSLTPROC_PROCESS_MAN)
798 docs/man/%.5: docs/man/%.xml
799 $(XSLTPROC_PROCESS_MAN)
801 docs/man/%.7: docs/man/%.xml
802 $(XSLTPROC_PROCESS_MAN)
804 endif # BUILD_HAVE_MANPAGES_STYLESHEET
805 endif # BUILD_HAVE_XSLTPROC