2 # Kmscon - Global Makefile
3 # Copyright (c) 2012-2013 David Herrmann <dh.herrmann@googlemail.com>
7 # Library Version Numbers
19 # Global Configurations and Initializations
22 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
23 AM_MAKEFLAGS = --no-print-directory
24 AUTOMAKE_OPTIONS = color-tests
25 AM_DISTCHECK_CONFIGURE_FLAGS = --enable-all
37 docs/kmsconvt@.service \
38 docs/pc/libeloop.pc.in \
39 docs/pc/libuterm.pc.in \
40 docs/sym/libeloop.sym \
43 pkgconfigdir = $(libdir)/pkgconfig
55 moduledir = $(libdir)/kmscon
60 # Make all files include "config.h" by default. This shouldn't cause any
61 # problems and we cannot forget to include it anymore.
63 # Also make the linker discard all unused symbols.
65 # When compiling in debug mode, we enable debug symbols so debugging with gdb
66 # is easier. If optimizations are disabled, we pass -O0 to the compiler.
67 # Otherwise, we use standard optimizations -O2.
75 -fdiagnostics-show-option \
76 -fno-strict-aliasing \
82 -DBUILD_MODULE_DIR='"$(moduledir)"' \
83 -include $(top_builddir)/config.h \
95 if BUILD_ENABLE_OPTIMIZATIONS
103 # The file ./src/shl_githead.c contains a constant "shl_git_head" which is
104 # defined to the string returned by "git describe". We need to adjust this
105 # string for every build and correctly rebuild any sources that depend on it.
106 # Therefore, you should use this file rarely as it causes rebuilds on every
109 # We have a helper-script ./src/genversion.sh that takes as argument the source
110 # file and creates it if necessary. It updates it only if the new git-describe
111 # string is different to the old one. So the file is only modified on changes.
112 # Hence, we can use it as normal dependency in this Makefile.
113 # However, we need to run this script on _every_ "make" invocation before any
114 # recipy is executed. To achieve this, we use $(shell ...) and assign it to a
115 # "simply expanded" variable (:=) so the shell command is executed on
116 # variable-declaration and not during expansion.
118 # Note that we must not clean ./src/shl_githead.c ever! If we would, a
119 # distribution tarball might delete that file and have no way to recreate it.
120 # We could delete it on something like "make maintainerclean", but then again,
121 # it seems unnecessary so lets simply not clean it at all.
123 # If the helper-script is executed in a directory that is not a git-repository
124 # (like a distribution tarball) and shl_githead.c exists, then it does nothing
125 # as it expects shl_githead.c to be correctly written by "make dist".
126 # However, if shl_githead.c does not exist, it will print a warning and write
127 # an unknown random git-revision.
128 # This guarantees, that shl_githead.c is always present and has the most correct
129 # value that we can get under any conditions.
131 # The $(emptyvariable) expansion below is used for broken $(shell ...)
132 # syntax-highlighting algorithms in many existing editors.
135 EXTRA_DIST += src/genversion.sh
136 GITHEAD:=$(shell $(emptyvariable)"$(srcdir)/src/genversion.sh" "$(srcdir)/src/shl_githead.c")
139 # Binary File Compiler
140 # This target gets as input a binary file *.bin and produces an ELF/etc. output
141 # object file *.bin.o and the corresponding libtool file *.bin.lo.
142 # Note that we fake the libtool object files as there is no way to make libtool
143 # create it. The comments in the .lo file are mandatory so don't remove them!
146 CLEANFILES += src/*.bin.lo src/*.bin.o
148 src/%.bin.lo: src/%.bin
149 $(AM_V_GEN)$(LD) -r -o "src/$*.bin.o" -z noexecstack --format=binary "$<"
150 $(AM_V_at)echo "# $@ - a libtool object file" >"$@"
151 $(AM_V_at)echo "# Generated by $(shell $(LIBTOOL) --version | head -n 1)" >>"$@"
152 $(AM_V_at)echo "#" >>"$@"
153 $(AM_V_at)echo "# Please DO NOT delete this file!" >>"$@"
154 $(AM_V_at)echo "# It is necessary for linking the library." >>"$@"
155 $(AM_V_at)echo >>"$@"
156 $(AM_V_at)echo "# Name of the PIC object." >>"$@"
157 $(AM_V_at)echo "pic_object='$*.bin.o'" >>"$@"
158 $(AM_V_at)echo >>"$@"
159 $(AM_V_at)echo "# Name of the non-PIC object" >>"$@"
160 $(AM_V_at)echo "non_pic_object='$*.bin.o'" >>"$@"
161 $(AM_V_at)echo >>"$@"
164 # SHL - Static Helper Library
165 # The SHL subsystem contains several small code pieces used all over kmscon and
166 # other applications.
169 noinst_LTLIBRARIES += libshl.la
171 libshl_la_SOURCES = \
176 src/shl_hashtable.h \
188 libshl_la_CPPFLAGS = \
190 $(XKBCOMMON_CFLAGS) \
192 libshl_la_LDFLAGS = \
201 # This library contains the whole event-loop implementation of kmscon. It is
202 # compiled into a separate object to allow using it in several other programs.
205 if BUILD_ENABLE_ELOOP
206 lib_LTLIBRARIES += libeloop.la
207 include_HEADERS += src/eloop.h
208 pkgconfig_DATA += docs/pc/libeloop.pc
211 libeloop_la_SOURCES = \
215 libeloop_la_LIBADD = libshl.la
216 libeloop_la_CPPFLAGS = $(AM_CPPFLAGS)
217 EXTRA_libeloop_la_DEPENDENCIES = ${top_srcdir}/docs/sym/libeloop.sym
218 libeloop_la_LDFLAGS = \
220 -version-info $(LIBELOOP_CURRENT):$(LIBELOOP_REVISION):$(LIBELOOP_AGE) \
221 -Wl,--version-script=$(top_srcdir)/docs/sym/libeloop.sym
224 if BUILD_ENABLE_ELOOP_DBUS
225 libeloop_la_SOURCES += \
226 external/dbus-common.h \
227 external/dbus-loop.h \
229 libeloop_la_CPPFLAGS += $(DBUS_CFLAGS)
230 libeloop_la_LIBADD += $(DBUS_LIBS)
235 # The uterm library provides helpers to create terminals in user-space. They
236 # are not limited to text-based terminals but rather provide graphics contexts
237 # so arbitrary output can be displayed. Additionally, they provide VT
238 # abstractions and an input layer
241 if BUILD_ENABLE_UTERM
242 lib_LTLIBRARIES += libuterm.la
245 src/uterm_monitor.h \
248 pkgconfig_DATA += docs/pc/libuterm.pc
251 libuterm_la_SOURCES = \
253 src/uterm_monitor.h \
256 src/uterm_input_internal.h \
257 src/uterm_video_internal.h \
258 src/uterm_systemd_internal.h \
260 src/uterm_monitor.c \
263 src/uterm_input_uxkb.c
265 nodist_libuterm_la_SOURCES =
267 libuterm_la_CPPFLAGS = \
270 libuterm_la_LIBADD = \
274 EXTRA_libuterm_la_DEPENDENCIES = ${top_srcdir}/docs/sym/libuterm.sym
275 libuterm_la_LDFLAGS = \
277 -version-info $(LIBUTERM_CURRENT):$(LIBUTERM_REVISION):$(LIBUTERM_AGE) \
278 -Wl,--version-script="$(top_srcdir)/docs/sym/libuterm.sym"
280 if BUILD_ENABLE_MULTI_SEAT
281 libuterm_la_SOURCES += src/uterm_systemd.c
282 libuterm_la_CPPFLAGS += $(SYSTEMD_CFLAGS)
283 libuterm_la_LIBADD += $(SYSTEMD_LIBS)
286 if BUILD_ENABLE_HOTPLUG
287 libuterm_la_CPPFLAGS += $(UDEV_CFLAGS)
288 libuterm_la_LIBADD += $(UDEV_LIBS)
291 if BUILD_ENABLE_VIDEO_FBDEV
292 libuterm_la_SOURCES += \
293 src/uterm_fbdev_internal.h \
294 src/uterm_fbdev_video.c \
295 src/uterm_fbdev_render.c
298 if BUILD_ENABLE_VIDEO_DRM2D
299 libuterm_la_SOURCES += \
300 src/uterm_drm2d_internal.h \
301 src/uterm_drm2d_video.c \
302 src/uterm_drm2d_render.c
303 libuterm_la_CPPFLAGS += $(DRM_CFLAGS)
304 libuterm_la_LIBADD += $(DRM_LIBS)
307 if BUILD_ENABLE_VIDEO_DRM3D
308 noinst_PROGRAMS += genshader
309 libuterm_la_SOURCES += \
310 src/uterm_drm3d_internal.h \
311 src/uterm_drm3d_video.c \
312 src/uterm_drm3d_render.c \
314 src/static_gl_math.c \
315 src/static_gl_shader.c
316 nodist_libuterm_la_SOURCES += src/static_shaders.c
317 libuterm_la_CPPFLAGS += \
322 libuterm_la_LIBADD += \
329 # add shared sources only once
330 UTERM_DRM_SHARED_SRC = \
331 src/uterm_drm_shared_internal.h \
332 src/uterm_drm_shared.c
333 if BUILD_ENABLE_VIDEO_DRM2D
334 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
336 if BUILD_ENABLE_VIDEO_DRM3D
337 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
343 # As there is no need to modify shaders at run-time, we statically compile them
344 # into object files. As autotools would ignore them, we need to add them to
346 # The program that converts the shaders into C-source files is "genshader". It's
347 # pretty simple and just creates a string with the shader source as content.
351 $(srcdir)/src/static_fill.vert \
352 $(srcdir)/src/static_fill.frag \
353 $(srcdir)/src/static_blend.vert \
354 $(srcdir)/src/static_blend.frag \
355 $(srcdir)/src/static_blit.vert \
356 $(srcdir)/src/static_blit.frag \
357 $(srcdir)/src/static_gltex.vert \
358 $(srcdir)/src/static_gltex.frag
360 EXTRA_DIST += $(SHADERS)
361 CLEANFILES += src/static_shaders.c
362 genshader_SOURCES = src/genshader.c
364 # TODO: Using $(BUILD_EXEEXT) breaks if it doesn't equal $(EXEEXT). But stupid
365 # automake doesn't allow $(EXEEXT) so lets just rely on both being the same.
367 src/static_shaders.c: $(SHADERS) genshader$(BUILD_EXEEXT)
368 $(AM_V_GEN)./genshader$(BUILD_EXEEXT) src/static_shaders.c $(SHADERS)
370 genshader$(BUILD_EXEEXT) $(genshader_OBJECTS): CC = $(CC_FOR_BUILD)
371 genshader$(BUILD_EXEEXT) $(genshader_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
372 genshader$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
376 # This generates the unifont sources from raw hex-encoded font data.
379 UNIFONT = $(top_srcdir)/src/font_unifont_data.hex
380 UNIFONT_BIN = src/font_unifont_data.bin
381 UNIFONT_LT = src/font_unifont_data.bin.lo
383 EXTRA_DIST += $(UNIFONT)
384 CLEANFILES += $(UNIFONT_BIN)
385 genunifont_SOURCES = src/genunifont.c
387 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CC = $(CC_FOR_BUILD)
388 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
389 genunifont$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
391 $(UNIFONT_BIN): $(UNIFONT) genunifont$(BUILD_EXEEXT)
392 $(AM_V_GEN)./genunifont$(BUILD_EXEEXT) $(UNIFONT_BIN) $(UNIFONT)
398 if BUILD_ENABLE_FONT_UNIFONT
399 module_LTLIBRARIES += mod-unifont.la
400 noinst_PROGRAMS += genunifont
403 mod_unifont_la_SOURCES = \
404 src/kmscon_module_interface.h \
406 src/kmscon_mod_unifont.c
407 mod_unifont_la_LIBADD = \
410 mod_unifont_la_LDFLAGS = \
415 if BUILD_ENABLE_FONT_PANGO
416 module_LTLIBRARIES += mod-pango.la
419 mod_pango_la_SOURCES = \
420 src/kmscon_module_interface.h \
422 src/kmscon_mod_pango.c
423 mod_pango_la_CPPFLAGS = \
427 mod_pango_la_LIBADD = \
432 mod_pango_la_LDFLAGS = \
437 if BUILD_ENABLE_RENDERER_BBULK
438 module_LTLIBRARIES += mod-bbulk.la
441 mod_bbulk_la_SOURCES = \
442 src/kmscon_module_interface.h \
444 src/kmscon_mod_bbulk.c
445 mod_bbulk_la_LIBADD = libshl.la
446 mod_bbulk_la_LDFLAGS = \
451 if BUILD_ENABLE_RENDERER_GLTEX
452 module_LTLIBRARIES += mod-gltex.la
453 noinst_PROGRAMS += genshader
456 mod_gltex_la_SOURCES = \
457 src/kmscon_module_interface.h \
460 src/static_gl_math.c \
461 src/static_gl_shader.c \
462 src/kmscon_mod_gltex.c
463 nodist_mod_gltex_la_SOURCES = \
465 mod_gltex_la_CPPFLAGS = \
468 mod_gltex_la_LIBADD = \
471 mod_gltex_la_LDFLAGS = \
476 if BUILD_ENABLE_RENDERER_PIXMAN
477 module_LTLIBRARIES += mod-pixman.la
480 mod_pixman_la_SOURCES = \
481 src/kmscon_module_interface.h \
483 src/kmscon_mod_pixman.c
484 mod_pixman_la_CPPFLAGS = \
487 mod_pixman_la_LIBADD = \
490 mod_pixman_la_LDFLAGS = \
497 # These are the sources for the main binaries and test programs. They mostly
498 # consists of a single source file only and include all the libraries that are
499 # built as part of kmscon.
502 if BUILD_ENABLE_KMSCON
503 bin_PROGRAMS += kmscon
509 MANPAGES += docs/man/kmscon.1
523 src/kmscon_module_interface.h \
524 src/kmscon_module.h \
525 src/kmscon_module.c \
526 src/kmscon_terminal.h \
533 nodist_kmscon_SOURCES =
537 $(XKBCOMMON_CFLAGS) \
551 if BUILD_ENABLE_SESSION_DUMMY
552 kmscon_SOURCES += src/kmscon_dummy.c
555 if BUILD_ENABLE_SESSION_TERMINAL
556 kmscon_SOURCES += src/kmscon_terminal.c
575 test_output_SOURCES = \
578 test_output_CPPFLAGS = $(test_cflags)
579 test_output_LDADD = \
586 test_vt_CPPFLAGS = $(test_cflags)
591 test_input_SOURCES = \
594 test_input_CPPFLAGS = $(test_cflags)
602 test_key_CPPFLAGS = $(test_cflags)
603 test_key_LDADD = $(test_libs)
610 EXTRA_DIST += ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,$(MANPAGES)}}}}
611 CLEANFILES += $(MANPAGES) $(MANPAGES_ALIASES) .man_fixup
613 if BUILD_HAVE_XSLTPROC
614 if BUILD_HAVE_MANPAGES_STYLESHEET
616 man_MANS += $(MANPAGES) $(MANPAGES_ALIASES)
619 --stringparam man.authors.section.enabled 0 \
620 --stringparam man.copyright.section.enabled 0 \
621 --stringparam funcsynopsis.style ansi \
622 --stringparam man.output.quietly 1 \
625 XSLTPROC_PROCESS_MAN = \
626 $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
627 $(XSLTPROC) -o "$@" $(XSLTPROC_FLAGS) $(BUILD_MANPAGES_STYLESHEET) "$<" && \
630 # Force .man_fixup if $(MANPAGES) are not built
631 .man_fixup: | $(MANPAGES)
634 $(MANPAGES_ALIASES): $(MANPAGES) .man_fixup
635 $(AM_V_GEN)if test -n "$@" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' "$@" ; fi
637 docs/man/%.1: docs/man/%.xml
638 $(XSLTPROC_PROCESS_MAN)
640 docs/man/%.3: docs/man/%.xml
641 $(XSLTPROC_PROCESS_MAN)
643 docs/man/%.5: docs/man/%.xml
644 $(XSLTPROC_PROCESS_MAN)
646 docs/man/%.7: docs/man/%.xml
647 $(XSLTPROC_PROCESS_MAN)
649 endif # BUILD_HAVE_MANPAGES_STYLESHEET
650 endif # BUILD_HAVE_XSLTPROC