2 # Kmscon - Global Makefile
3 # Copyright (c) 2012-2013 David Herrmann <dh.herrmann@googlemail.com>
7 # Library Version Numbers
23 # Global Configurations and Initializations
26 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
27 AM_MAKEFLAGS = --no-print-directory
28 AUTOMAKE_OPTIONS = color-tests
29 AM_DISTCHECK_CONFIGURE_FLAGS = --enable-all
41 docs/kmsconvt@.service \
42 docs/pc/libeloop.pc.in \
43 docs/pc/libuvt.pc.in \
44 docs/pc/libuterm.pc.in \
45 docs/sym/libeloop.sym \
49 pkgconfigdir = $(libdir)/pkgconfig
61 moduledir = $(libdir)/kmscon
66 # Make all files include "config.h" by default. This shouldn't cause any
67 # problems and we cannot forget to include it anymore.
69 # Also make the linker discard all unused symbols.
71 # When compiling in debug mode, we enable debug symbols so debugging with gdb
72 # is easier. If optimizations are disabled, we pass -O0 to the compiler.
73 # Otherwise, we use standard optimizations -O2.
81 -fdiagnostics-show-option \
82 -fno-strict-aliasing \
88 -DBUILD_MODULE_DIR='"$(moduledir)"' \
89 -include $(top_builddir)/config.h \
101 if BUILD_ENABLE_OPTIMIZATIONS
109 # The file ./src/shl_githead.c contains a constant "shl_git_head" which is
110 # defined to the string returned by "git describe". We need to adjust this
111 # string for every build and correctly rebuild any sources that depend on it.
112 # Therefore, you should use this file rarely as it causes rebuilds on every
115 # We have a helper-script ./src/genversion.sh that takes as argument the source
116 # file and creates it if necessary. It updates it only if the new git-describe
117 # string is different to the old one. So the file is only modified on changes.
118 # Hence, we can use it as normal dependency in this Makefile.
119 # However, we need to run this script on _every_ "make" invocation before any
120 # recipy is executed. To achieve this, we use $(shell ...) and assign it to a
121 # "simply expanded" variable (:=) so the shell command is executed on
122 # variable-declaration and not during expansion.
124 # Note that we must not clean ./src/shl_githead.c ever! If we would, a
125 # distribution tarball might delete that file and have no way to recreate it.
126 # We could delete it on something like "make maintainerclean", but then again,
127 # it seems unnecessary so lets simply not clean it at all.
129 # If the helper-script is executed in a directory that is not a git-repository
130 # (like a distribution tarball) and shl_githead.c exists, then it does nothing
131 # as it expects shl_githead.c to be correctly written by "make dist".
132 # However, if shl_githead.c does not exist, it will print a warning and write
133 # an unknown random git-revision.
134 # This guarantees, that shl_githead.c is always present and has the most correct
135 # value that we can get under any conditions.
137 # The $(emptyvariable) expansion below is used for broken $(shell ...)
138 # syntax-highlighting algorithms in many existing editors.
141 EXTRA_DIST += src/genversion.sh
142 GITHEAD:=$(shell $(emptyvariable)"$(srcdir)/src/genversion.sh" "$(srcdir)/src/shl_githead.c")
145 # Binary File Compiler
146 # This target gets as input a binary file *.bin and produces an ELF/etc. output
147 # object file *.bin.o and the corresponding libtool file *.bin.lo.
148 # Note that we fake the libtool object files as there is no way to make libtool
149 # create it. The comments in the .lo file are mandatory so don't remove them!
152 CLEANFILES += src/*.bin.lo src/*.bin.o
154 src/%.bin.lo: src/%.bin
155 $(AM_V_GEN)$(LD) -r -o "src/$*.bin.o" -z noexecstack --format=binary "$<"
156 $(AM_V_at)echo "# $@ - a libtool object file" >"$@"
157 $(AM_V_at)echo "# Generated by $(shell $(LIBTOOL) --version | head -n 1)" >>"$@"
158 $(AM_V_at)echo "#" >>"$@"
159 $(AM_V_at)echo "# Please DO NOT delete this file!" >>"$@"
160 $(AM_V_at)echo "# It is necessary for linking the library." >>"$@"
161 $(AM_V_at)echo >>"$@"
162 $(AM_V_at)echo "# Name of the PIC object." >>"$@"
163 $(AM_V_at)echo "pic_object='$*.bin.o'" >>"$@"
164 $(AM_V_at)echo >>"$@"
165 $(AM_V_at)echo "# Name of the non-PIC object" >>"$@"
166 $(AM_V_at)echo "non_pic_object='$*.bin.o'" >>"$@"
167 $(AM_V_at)echo >>"$@"
170 # SHL - Static Helper Library
171 # The SHL subsystem contains several small code pieces used all over kmscon and
172 # other applications.
175 noinst_LTLIBRARIES += libshl.la
177 libshl_la_SOURCES = \
182 src/shl_hashtable.h \
194 libshl_la_CPPFLAGS = \
196 $(XKBCOMMON_CFLAGS) \
198 libshl_la_LDFLAGS = \
207 # This library contains the whole event-loop implementation of kmscon. It is
208 # compiled into a separate object to allow using it in several other programs.
211 if BUILD_ENABLE_ELOOP
212 lib_LTLIBRARIES += libeloop.la
213 include_HEADERS += src/eloop.h
214 pkgconfig_DATA += docs/pc/libeloop.pc
217 libeloop_la_SOURCES = \
221 libeloop_la_LIBADD = libshl.la
222 libeloop_la_CPPFLAGS = $(AM_CPPFLAGS)
223 EXTRA_libeloop_la_DEPENDENCIES = ${top_srcdir}/docs/sym/libeloop.sym
224 libeloop_la_LDFLAGS = \
226 -version-info $(LIBELOOP_CURRENT):$(LIBELOOP_REVISION):$(LIBELOOP_AGE) \
227 -Wl,--version-script=$(top_srcdir)/docs/sym/libeloop.sym
230 if BUILD_ENABLE_ELOOP_DBUS
231 libeloop_la_SOURCES += \
232 external/dbus-common.h \
233 external/dbus-loop.h \
235 libeloop_la_CPPFLAGS += $(DBUS_CFLAGS)
236 libeloop_la_LIBADD += $(DBUS_LIBS)
241 # Implementation of Virtual Terminals in user-space with the help of CUSE/FUSE
242 # so we can provide character-device drivers in user-space. Aims to be 100%
243 # compatible but also provides many other use-cases.
247 lib_LTLIBRARIES += libuvt.la
248 include_HEADERS += src/uvt.h
249 pkgconfig_DATA += docs/pc/libuvt.pc
252 libuvt_la_SOURCES = \
259 libuvt_la_CPPFLAGS = \
262 -DFUSE_USE_VERSION=29
266 EXTRA_libuvt_la_DEPENDENCIES = ${top_srcdir}/docs/sym/libuvt.sym
267 libuvt_la_LDFLAGS = \
269 -version-info $(LIBUVT_CURRENT):$(LIBUVT_REVISION):$(LIBUVT_AGE) \
270 -Wl,--version-script="$(top_srcdir)/docs/sym/libuvt.sym"
274 # The uterm library provides helpers to create terminals in user-space. They
275 # are not limited to text-based terminals but rather provide graphics contexts
276 # so arbitrary output can be displayed. Additionally, they provide VT
277 # abstractions and an input layer
280 if BUILD_ENABLE_UTERM
281 lib_LTLIBRARIES += libuterm.la
284 src/uterm_monitor.h \
287 pkgconfig_DATA += docs/pc/libuterm.pc
290 libuterm_la_SOURCES = \
292 src/uterm_monitor.h \
295 src/uterm_input_internal.h \
296 src/uterm_video_internal.h \
297 src/uterm_systemd_internal.h \
299 src/uterm_monitor.c \
302 src/uterm_input_uxkb.c
304 nodist_libuterm_la_SOURCES =
306 libuterm_la_CPPFLAGS = \
309 libuterm_la_LIBADD = \
313 EXTRA_libuterm_la_DEPENDENCIES = ${top_srcdir}/docs/sym/libuterm.sym
314 libuterm_la_LDFLAGS = \
316 -version-info $(LIBUTERM_CURRENT):$(LIBUTERM_REVISION):$(LIBUTERM_AGE) \
317 -Wl,--version-script="$(top_srcdir)/docs/sym/libuterm.sym"
319 if BUILD_ENABLE_MULTI_SEAT
320 libuterm_la_SOURCES += src/uterm_systemd.c
321 libuterm_la_CPPFLAGS += $(SYSTEMD_CFLAGS)
322 libuterm_la_LIBADD += $(SYSTEMD_LIBS)
325 if BUILD_ENABLE_HOTPLUG
326 libuterm_la_CPPFLAGS += $(UDEV_CFLAGS)
327 libuterm_la_LIBADD += $(UDEV_LIBS)
330 if BUILD_ENABLE_VIDEO_FBDEV
331 libuterm_la_SOURCES += \
332 src/uterm_fbdev_internal.h \
333 src/uterm_fbdev_video.c \
334 src/uterm_fbdev_render.c
337 if BUILD_ENABLE_VIDEO_DRM2D
338 libuterm_la_SOURCES += \
339 src/uterm_drm2d_internal.h \
340 src/uterm_drm2d_video.c \
341 src/uterm_drm2d_render.c
342 libuterm_la_CPPFLAGS += $(DRM_CFLAGS)
343 libuterm_la_LIBADD += $(DRM_LIBS)
346 if BUILD_ENABLE_VIDEO_DRM3D
347 noinst_PROGRAMS += genshader
348 libuterm_la_SOURCES += \
349 src/uterm_drm3d_internal.h \
350 src/uterm_drm3d_video.c \
351 src/uterm_drm3d_render.c \
353 src/static_gl_math.c \
354 src/static_gl_shader.c
355 nodist_libuterm_la_SOURCES += src/static_shaders.c
356 libuterm_la_CPPFLAGS += \
361 libuterm_la_LIBADD += \
368 # add shared sources only once
369 UTERM_DRM_SHARED_SRC = \
370 src/uterm_drm_shared_internal.h \
371 src/uterm_drm_shared.c
372 if BUILD_ENABLE_VIDEO_DRM2D
373 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
375 if BUILD_ENABLE_VIDEO_DRM3D
376 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
382 # As there is no need to modify shaders at run-time, we statically compile them
383 # into object files. As autotools would ignore them, we need to add them to
385 # The program that converts the shaders into C-source files is "genshader". It's
386 # pretty simple and just creates a string with the shader source as content.
390 $(srcdir)/src/static_fill.vert \
391 $(srcdir)/src/static_fill.frag \
392 $(srcdir)/src/static_blend.vert \
393 $(srcdir)/src/static_blend.frag \
394 $(srcdir)/src/static_blit.vert \
395 $(srcdir)/src/static_blit.frag \
396 $(srcdir)/src/static_gltex.vert \
397 $(srcdir)/src/static_gltex.frag
399 EXTRA_DIST += $(SHADERS)
400 CLEANFILES += src/static_shaders.c
401 genshader_SOURCES = src/genshader.c
403 # TODO: Using $(BUILD_EXEEXT) breaks if it doesn't equal $(EXEEXT). But stupid
404 # automake doesn't allow $(EXEEXT) so lets just rely on both being the same.
406 src/static_shaders.c: $(SHADERS) genshader$(BUILD_EXEEXT)
407 $(AM_V_GEN)./genshader$(BUILD_EXEEXT) src/static_shaders.c $(SHADERS)
409 genshader$(BUILD_EXEEXT) $(genshader_OBJECTS): CC = $(CC_FOR_BUILD)
410 genshader$(BUILD_EXEEXT) $(genshader_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
411 genshader$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
415 # This generates the unifont sources from raw hex-encoded font data.
418 UNIFONT = $(top_srcdir)/src/font_unifont_data.hex
419 UNIFONT_BIN = src/font_unifont_data.bin
420 UNIFONT_LT = src/font_unifont_data.bin.lo
422 EXTRA_DIST += $(UNIFONT)
423 CLEANFILES += $(UNIFONT_BIN)
424 genunifont_SOURCES = src/genunifont.c
426 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CC = $(CC_FOR_BUILD)
427 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
428 genunifont$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
430 $(UNIFONT_BIN): $(UNIFONT) genunifont$(BUILD_EXEEXT)
431 $(AM_V_GEN)./genunifont$(BUILD_EXEEXT) $(UNIFONT_BIN) $(UNIFONT)
437 if BUILD_ENABLE_FONT_UNIFONT
438 module_LTLIBRARIES += mod-unifont.la
439 noinst_PROGRAMS += genunifont
442 mod_unifont_la_SOURCES = \
443 src/kmscon_module_interface.h \
445 src/kmscon_mod_unifont.c
446 mod_unifont_la_LIBADD = \
449 mod_unifont_la_LDFLAGS = \
454 if BUILD_ENABLE_FONT_FREETYPE2
455 module_LTLIBRARIES += mod-freetype2.la
458 mod_freetype2_la_SOURCES = \
459 src/kmscon_module_interface.h \
460 src/font_freetype2.c \
461 src/kmscon_mod_freetype2.c
462 mod_freetype2_la_CPPFLAGS = \
464 $(FREETYPE2_CFLAGS) \
466 mod_freetype2_la_LIBADD = \
471 mod_freetype2_la_LDFLAGS = \
476 if BUILD_ENABLE_FONT_PANGO
477 module_LTLIBRARIES += mod-pango.la
480 mod_pango_la_SOURCES = \
481 src/kmscon_module_interface.h \
483 src/kmscon_mod_pango.c
484 mod_pango_la_CPPFLAGS = \
488 mod_pango_la_LIBADD = \
493 mod_pango_la_LDFLAGS = \
498 if BUILD_ENABLE_RENDERER_BBULK
499 module_LTLIBRARIES += mod-bbulk.la
502 mod_bbulk_la_SOURCES = \
503 src/kmscon_module_interface.h \
505 src/kmscon_mod_bbulk.c
506 mod_bbulk_la_LIBADD = libshl.la
507 mod_bbulk_la_LDFLAGS = \
512 if BUILD_ENABLE_RENDERER_GLTEX
513 module_LTLIBRARIES += mod-gltex.la
514 noinst_PROGRAMS += genshader
517 mod_gltex_la_SOURCES = \
518 src/kmscon_module_interface.h \
521 src/static_gl_math.c \
522 src/static_gl_shader.c \
523 src/kmscon_mod_gltex.c
524 nodist_mod_gltex_la_SOURCES = \
526 mod_gltex_la_CPPFLAGS = \
529 mod_gltex_la_LIBADD = \
532 mod_gltex_la_LDFLAGS = \
537 if BUILD_ENABLE_RENDERER_CAIRO
538 module_LTLIBRARIES += mod-cairo.la
541 mod_cairo_la_SOURCES = \
542 src/kmscon_module_interface.h \
544 src/kmscon_mod_cairo.c
545 mod_cairo_la_CPPFLAGS = \
548 mod_cairo_la_LIBADD = \
551 mod_cairo_la_LDFLAGS = \
556 if BUILD_ENABLE_RENDERER_PIXMAN
557 module_LTLIBRARIES += mod-pixman.la
560 mod_pixman_la_SOURCES = \
561 src/kmscon_module_interface.h \
563 src/kmscon_mod_pixman.c
564 mod_pixman_la_CPPFLAGS = \
567 mod_pixman_la_LIBADD = \
570 mod_pixman_la_LDFLAGS = \
577 # These are the sources for the main binaries and test programs. They mostly
578 # consists of a single source file only and include all the libraries that are
579 # built as part of kmscon.
582 if BUILD_ENABLE_KMSCON
583 bin_PROGRAMS += kmscon
589 MANPAGES += docs/man/kmscon.1
603 src/kmscon_module_interface.h \
604 src/kmscon_module.h \
605 src/kmscon_module.c \
606 src/kmscon_terminal.h \
613 nodist_kmscon_SOURCES =
617 $(XKBCOMMON_CFLAGS) \
631 if BUILD_ENABLE_SESSION_DUMMY
632 kmscon_SOURCES += src/kmscon_dummy.c
635 if BUILD_ENABLE_SESSION_TERMINAL
636 kmscon_SOURCES += src/kmscon_terminal.c
655 test_output_SOURCES = \
658 test_output_CPPFLAGS = $(test_cflags)
659 test_output_LDADD = \
666 test_vt_CPPFLAGS = $(test_cflags)
671 test_input_SOURCES = \
674 test_input_CPPFLAGS = $(test_cflags)
682 test_key_CPPFLAGS = $(test_cflags)
683 test_key_LDADD = $(test_libs)
690 EXTRA_DIST += ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,$(MANPAGES)}}}}
691 CLEANFILES += $(MANPAGES) $(MANPAGES_ALIASES) .man_fixup
693 if BUILD_HAVE_XSLTPROC
694 if BUILD_HAVE_MANPAGES_STYLESHEET
696 man_MANS += $(MANPAGES) $(MANPAGES_ALIASES)
699 --stringparam man.authors.section.enabled 0 \
700 --stringparam man.copyright.section.enabled 0 \
701 --stringparam funcsynopsis.style ansi \
702 --stringparam man.output.quietly 1 \
705 XSLTPROC_PROCESS_MAN = \
706 $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
707 $(XSLTPROC) -o "$@" $(XSLTPROC_FLAGS) $(BUILD_MANPAGES_STYLESHEET) "$<" && \
710 # Force .man_fixup if $(MANPAGES) are not built
711 .man_fixup: | $(MANPAGES)
714 $(MANPAGES_ALIASES): $(MANPAGES) .man_fixup
715 $(AM_V_GEN)if test -n "$@" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' "$@" ; fi
717 docs/man/%.1: docs/man/%.xml
718 $(XSLTPROC_PROCESS_MAN)
720 docs/man/%.3: docs/man/%.xml
721 $(XSLTPROC_PROCESS_MAN)
723 docs/man/%.5: docs/man/%.xml
724 $(XSLTPROC_PROCESS_MAN)
726 docs/man/%.7: docs/man/%.xml
727 $(XSLTPROC_PROCESS_MAN)
729 endif # BUILD_HAVE_MANPAGES_STYLESHEET
730 endif # BUILD_HAVE_XSLTPROC