2 # Kmscon - Global Makefile
3 # Copyright (c) 2012-2013 David Herrmann <dh.herrmann@googlemail.com>
7 # Library Version Numbers
15 # Global Configurations and Initializations
18 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
19 AM_MAKEFLAGS = --no-print-directory
20 AUTOMAKE_OPTIONS = color-tests
21 AM_DISTCHECK_CONFIGURE_FLAGS = --enable-all
33 docs/kmsconvt@.service \
34 docs/pc/libeloop.pc.in \
37 pkgconfigdir = $(libdir)/pkgconfig
49 moduledir = $(libdir)/kmscon
54 # Make all files include "config.h" by default. This shouldn't cause any
55 # problems and we cannot forget to include it anymore.
57 # Also make the linker discard all unused symbols.
59 # When compiling in debug mode, we enable debug symbols so debugging with gdb
60 # is easier. If optimizations are disabled, we pass -O0 to the compiler.
61 # Otherwise, we use standard optimizations -O2.
69 -fdiagnostics-show-option \
70 -fno-strict-aliasing \
76 -DBUILD_MODULE_DIR='"$(moduledir)"' \
77 -include $(top_builddir)/config.h \
89 if BUILD_ENABLE_OPTIMIZATIONS
97 # The file ./src/shl_githead.c contains a constant "shl_git_head" which is
98 # defined to the string returned by "git describe". We need to adjust this
99 # string for every build and correctly rebuild any sources that depend on it.
100 # Therefore, you should use this file rarely as it causes rebuilds on every
103 # We have a helper-script ./src/genversion.sh that takes as argument the source
104 # file and creates it if necessary. It updates it only if the new git-describe
105 # string is different to the old one. So the file is only modified on changes.
106 # Hence, we can use it as normal dependency in this Makefile.
107 # However, we need to run this script on _every_ "make" invocation before any
108 # recipy is executed. To achieve this, we use $(shell ...) and assign it to a
109 # "simply expanded" variable (:=) so the shell command is executed on
110 # variable-declaration and not during expansion.
112 # Note that we must not clean ./src/shl_githead.c ever! If we would, a
113 # distribution tarball might delete that file and have no way to recreate it.
114 # We could delete it on something like "make maintainerclean", but then again,
115 # it seems unnecessary so lets simply not clean it at all.
117 # If the helper-script is executed in a directory that is not a git-repository
118 # (like a distribution tarball) and shl_githead.c exists, then it does nothing
119 # as it expects shl_githead.c to be correctly written by "make dist".
120 # However, if shl_githead.c does not exist, it will print a warning and write
121 # an unknown random git-revision.
122 # This guarantees, that shl_githead.c is always present and has the most correct
123 # value that we can get under any conditions.
125 # The $(emptyvariable) expansion below is used for broken $(shell ...)
126 # syntax-highlighting algorithms in many existing editors.
129 EXTRA_DIST += src/genversion.sh
130 GITHEAD:=$(shell $(emptyvariable)"$(srcdir)/src/genversion.sh" "$(srcdir)/src/shl_githead.c")
133 # Binary File Compiler
134 # This target gets as input a binary file *.bin and produces an ELF/etc. output
135 # object file *.bin.o and the corresponding libtool file *.bin.lo.
136 # Note that we fake the libtool object files as there is no way to make libtool
137 # create it. The comments in the .lo file are mandatory so don't remove them!
140 CLEANFILES += src/*.bin.lo src/*.bin.o
142 src/%.bin.lo: src/%.bin
143 $(AM_V_GEN)$(LD) -r -o "src/$*.bin.o" -z noexecstack --format=binary "$<"
144 $(AM_V_at)echo "# $@ - a libtool object file" >"$@"
145 $(AM_V_at)echo "# Generated by $(shell $(LIBTOOL) --version | head -n 1)" >>"$@"
146 $(AM_V_at)echo "#" >>"$@"
147 $(AM_V_at)echo "# Please DO NOT delete this file!" >>"$@"
148 $(AM_V_at)echo "# It is necessary for linking the library." >>"$@"
149 $(AM_V_at)echo >>"$@"
150 $(AM_V_at)echo "# Name of the PIC object." >>"$@"
151 $(AM_V_at)echo "pic_object='$*.bin.o'" >>"$@"
152 $(AM_V_at)echo >>"$@"
153 $(AM_V_at)echo "# Name of the non-PIC object" >>"$@"
154 $(AM_V_at)echo "non_pic_object='$*.bin.o'" >>"$@"
155 $(AM_V_at)echo >>"$@"
158 # SHL - Static Helper Library
159 # The SHL subsystem contains several small code pieces used all over kmscon and
160 # other applications.
163 noinst_LTLIBRARIES += libshl.la
165 libshl_la_SOURCES = \
170 src/shl_hashtable.h \
182 libshl_la_CPPFLAGS = \
184 $(XKBCOMMON_CFLAGS) \
186 libshl_la_LDFLAGS = \
195 # This library contains the whole event-loop implementation of kmscon. It is
196 # compiled into a separate object to allow using it in several other programs.
199 if BUILD_ENABLE_ELOOP
200 lib_LTLIBRARIES += libeloop.la
201 include_HEADERS += src/eloop.h
202 pkgconfig_DATA += docs/pc/libeloop.pc
205 libeloop_la_SOURCES = \
209 libeloop_la_LIBADD = libshl.la
210 libeloop_la_CPPFLAGS = $(AM_CPPFLAGS)
211 EXTRA_libeloop_la_DEPENDENCIES = ${top_srcdir}/docs/sym/libeloop.sym
212 libeloop_la_LDFLAGS = \
214 -version-info $(LIBELOOP_CURRENT):$(LIBELOOP_REVISION):$(LIBELOOP_AGE) \
215 -Wl,--version-script=$(top_srcdir)/docs/sym/libeloop.sym
218 if BUILD_ENABLE_ELOOP_DBUS
219 libeloop_la_SOURCES += \
220 external/dbus-common.h \
221 external/dbus-loop.h \
223 libeloop_la_CPPFLAGS += $(DBUS_CFLAGS)
224 libeloop_la_LIBADD += $(DBUS_LIBS)
229 # The uterm library provides helpers to create terminals in user-space. They
230 # are not limited to text-based terminals but rather provide graphics contexts
231 # so arbitrary output can be displayed. Additionally, they provide VT
232 # abstractions and an input layer
235 noinst_LTLIBRARIES += libuterm.la
237 libuterm_la_SOURCES = \
239 src/uterm_monitor.h \
242 src/uterm_input_internal.h \
243 src/uterm_video_internal.h \
244 src/uterm_systemd_internal.h \
246 src/uterm_monitor.c \
249 src/uterm_input_uxkb.c
251 nodist_libuterm_la_SOURCES =
253 libuterm_la_CPPFLAGS = \
256 libuterm_la_LIBADD = \
260 libuterm_la_LDFLAGS = \
263 if BUILD_ENABLE_MULTI_SEAT
264 libuterm_la_SOURCES += src/uterm_systemd.c
265 libuterm_la_CPPFLAGS += $(SYSTEMD_CFLAGS)
266 libuterm_la_LIBADD += $(SYSTEMD_LIBS)
269 if BUILD_ENABLE_HOTPLUG
270 libuterm_la_CPPFLAGS += $(UDEV_CFLAGS)
271 libuterm_la_LIBADD += $(UDEV_LIBS)
274 if BUILD_ENABLE_VIDEO_FBDEV
275 libuterm_la_SOURCES += \
276 src/uterm_fbdev_internal.h \
277 src/uterm_fbdev_video.c \
278 src/uterm_fbdev_render.c
281 if BUILD_ENABLE_VIDEO_DRM2D
282 libuterm_la_SOURCES += \
283 src/uterm_drm2d_internal.h \
284 src/uterm_drm2d_video.c \
285 src/uterm_drm2d_render.c
286 libuterm_la_CPPFLAGS += $(DRM_CFLAGS)
287 libuterm_la_LIBADD += $(DRM_LIBS)
290 if BUILD_ENABLE_VIDEO_DRM3D
291 noinst_PROGRAMS += genshader
292 libuterm_la_SOURCES += \
293 src/uterm_drm3d_internal.h \
294 src/uterm_drm3d_video.c \
295 src/uterm_drm3d_render.c \
297 src/static_gl_math.c \
298 src/static_gl_shader.c
299 nodist_libuterm_la_SOURCES += src/static_shaders.c
300 libuterm_la_CPPFLAGS += \
305 libuterm_la_LIBADD += \
312 # add shared sources only once
313 UTERM_DRM_SHARED_SRC = \
314 src/uterm_drm_shared_internal.h \
315 src/uterm_drm_shared.c
316 if BUILD_ENABLE_VIDEO_DRM2D
317 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
319 if BUILD_ENABLE_VIDEO_DRM3D
320 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
326 # As there is no need to modify shaders at run-time, we statically compile them
327 # into object files. As autotools would ignore them, we need to add them to
329 # The program that converts the shaders into C-source files is "genshader". It's
330 # pretty simple and just creates a string with the shader source as content.
334 $(srcdir)/src/static_fill.vert \
335 $(srcdir)/src/static_fill.frag \
336 $(srcdir)/src/static_blend.vert \
337 $(srcdir)/src/static_blend.frag \
338 $(srcdir)/src/static_blit.vert \
339 $(srcdir)/src/static_blit.frag \
340 $(srcdir)/src/static_gltex.vert \
341 $(srcdir)/src/static_gltex.frag
343 EXTRA_DIST += $(SHADERS)
344 CLEANFILES += src/static_shaders.c
345 genshader_SOURCES = src/genshader.c
347 # TODO: Using $(BUILD_EXEEXT) breaks if it doesn't equal $(EXEEXT). But stupid
348 # automake doesn't allow $(EXEEXT) so lets just rely on both being the same.
350 src/static_shaders.c: $(SHADERS) genshader$(BUILD_EXEEXT)
351 $(AM_V_GEN)./genshader$(BUILD_EXEEXT) src/static_shaders.c $(SHADERS)
353 genshader$(BUILD_EXEEXT) $(genshader_OBJECTS): CC = $(CC_FOR_BUILD)
354 genshader$(BUILD_EXEEXT) $(genshader_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
355 genshader$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
359 # This generates the unifont sources from raw hex-encoded font data.
362 UNIFONT = $(top_srcdir)/src/font_unifont_data.hex
363 UNIFONT_BIN = src/font_unifont_data.bin
364 UNIFONT_LT = src/font_unifont_data.bin.lo
366 EXTRA_DIST += $(UNIFONT)
367 CLEANFILES += $(UNIFONT_BIN)
368 genunifont_SOURCES = src/genunifont.c
370 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CC = $(CC_FOR_BUILD)
371 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
372 genunifont$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
374 $(UNIFONT_BIN): $(UNIFONT) genunifont$(BUILD_EXEEXT)
375 $(AM_V_GEN)./genunifont$(BUILD_EXEEXT) $(UNIFONT_BIN) $(UNIFONT)
381 if BUILD_ENABLE_FONT_UNIFONT
382 module_LTLIBRARIES += mod-unifont.la
383 noinst_PROGRAMS += genunifont
386 mod_unifont_la_SOURCES = \
387 src/kmscon_module_interface.h \
389 src/kmscon_mod_unifont.c
390 mod_unifont_la_LIBADD = \
393 mod_unifont_la_LDFLAGS = \
398 if BUILD_ENABLE_FONT_PANGO
399 module_LTLIBRARIES += mod-pango.la
402 mod_pango_la_SOURCES = \
403 src/kmscon_module_interface.h \
405 src/kmscon_mod_pango.c
406 mod_pango_la_CPPFLAGS = \
410 mod_pango_la_LIBADD = \
415 mod_pango_la_LDFLAGS = \
420 if BUILD_ENABLE_RENDERER_BBULK
421 module_LTLIBRARIES += mod-bbulk.la
424 mod_bbulk_la_SOURCES = \
425 src/kmscon_module_interface.h \
427 src/kmscon_mod_bbulk.c
428 mod_bbulk_la_LIBADD = libshl.la
429 mod_bbulk_la_LDFLAGS = \
434 if BUILD_ENABLE_RENDERER_GLTEX
435 module_LTLIBRARIES += mod-gltex.la
436 noinst_PROGRAMS += genshader
439 mod_gltex_la_SOURCES = \
440 src/kmscon_module_interface.h \
443 src/static_gl_math.c \
444 src/static_gl_shader.c \
445 src/kmscon_mod_gltex.c
446 nodist_mod_gltex_la_SOURCES = \
448 mod_gltex_la_CPPFLAGS = \
451 mod_gltex_la_LIBADD = \
454 mod_gltex_la_LDFLAGS = \
459 if BUILD_ENABLE_RENDERER_PIXMAN
460 module_LTLIBRARIES += mod-pixman.la
463 mod_pixman_la_SOURCES = \
464 src/kmscon_module_interface.h \
466 src/kmscon_mod_pixman.c
467 mod_pixman_la_CPPFLAGS = \
470 mod_pixman_la_LIBADD = \
473 mod_pixman_la_LDFLAGS = \
480 # These are the sources for the main binaries and test programs. They mostly
481 # consists of a single source file only and include all the libraries that are
482 # built as part of kmscon.
485 if BUILD_ENABLE_KMSCON
486 bin_PROGRAMS += kmscon
492 MANPAGES += docs/man/kmscon.1
506 src/kmscon_module_interface.h \
507 src/kmscon_module.h \
508 src/kmscon_module.c \
509 src/kmscon_terminal.h \
516 nodist_kmscon_SOURCES =
520 $(XKBCOMMON_CFLAGS) \
534 if BUILD_ENABLE_SESSION_DUMMY
535 kmscon_SOURCES += src/kmscon_dummy.c
538 if BUILD_ENABLE_SESSION_TERMINAL
539 kmscon_SOURCES += src/kmscon_terminal.c
558 test_output_SOURCES = \
561 test_output_CPPFLAGS = $(test_cflags)
562 test_output_LDADD = \
569 test_vt_CPPFLAGS = $(test_cflags)
574 test_input_SOURCES = \
577 test_input_CPPFLAGS = $(test_cflags)
585 test_key_CPPFLAGS = $(test_cflags)
586 test_key_LDADD = $(test_libs)
593 EXTRA_DIST += ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,$(MANPAGES)}}}}
594 CLEANFILES += $(MANPAGES) $(MANPAGES_ALIASES) .man_fixup
596 if BUILD_HAVE_XSLTPROC
597 if BUILD_HAVE_MANPAGES_STYLESHEET
599 man_MANS += $(MANPAGES) $(MANPAGES_ALIASES)
602 --stringparam man.authors.section.enabled 0 \
603 --stringparam man.copyright.section.enabled 0 \
604 --stringparam funcsynopsis.style ansi \
605 --stringparam man.output.quietly 1 \
608 XSLTPROC_PROCESS_MAN = \
609 $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
610 $(XSLTPROC) -o "$@" $(XSLTPROC_FLAGS) $(BUILD_MANPAGES_STYLESHEET) "$<" && \
613 # Force .man_fixup if $(MANPAGES) are not built
614 .man_fixup: | $(MANPAGES)
617 $(MANPAGES_ALIASES): $(MANPAGES) .man_fixup
618 $(AM_V_GEN)if test -n "$@" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' "$@" ; fi
620 docs/man/%.1: docs/man/%.xml
621 $(XSLTPROC_PROCESS_MAN)
623 docs/man/%.3: docs/man/%.xml
624 $(XSLTPROC_PROCESS_MAN)
626 docs/man/%.5: docs/man/%.xml
627 $(XSLTPROC_PROCESS_MAN)
629 docs/man/%.7: docs/man/%.xml
630 $(XSLTPROC_PROCESS_MAN)
632 endif # BUILD_HAVE_MANPAGES_STYLESHEET
633 endif # BUILD_HAVE_XSLTPROC