2 # Kmscon - Global Makefile
3 # Copyright (c) 2012-2013 David Herrmann <dh.herrmann@googlemail.com>
7 # Global Configurations and Initializations
10 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
11 AM_MAKEFLAGS = --no-print-directory
12 AUTOMAKE_OPTIONS = color-tests
13 AM_DISTCHECK_CONFIGURE_FLAGS = --enable-all
25 docs/kmsconvt@.service
27 pkgconfigdir = $(libdir)/pkgconfig
39 moduledir = $(libdir)/kmscon
44 # Make all files include "config.h" by default. This shouldn't cause any
45 # problems and we cannot forget to include it anymore.
47 # Also make the linker discard all unused symbols.
49 # When compiling in debug mode, we enable debug symbols so debugging with gdb
50 # is easier. If optimizations are disabled, we pass -O0 to the compiler.
51 # Otherwise, we use standard optimizations -O2.
59 -fdiagnostics-show-option \
60 -fno-strict-aliasing \
66 -DBUILD_MODULE_DIR='"$(moduledir)"' \
67 -include $(top_builddir)/config.h \
79 if BUILD_ENABLE_OPTIMIZATIONS
87 # The file ./src/shl_githead.c contains a constant "shl_git_head" which is
88 # defined to the string returned by "git describe". We need to adjust this
89 # string for every build and correctly rebuild any sources that depend on it.
90 # Therefore, you should use this file rarely as it causes rebuilds on every
93 # We have a helper-script ./src/genversion.sh that takes as argument the source
94 # file and creates it if necessary. It updates it only if the new git-describe
95 # string is different to the old one. So the file is only modified on changes.
96 # Hence, we can use it as normal dependency in this Makefile.
97 # However, we need to run this script on _every_ "make" invocation before any
98 # recipy is executed. To achieve this, we use $(shell ...) and assign it to a
99 # "simply expanded" variable (:=) so the shell command is executed on
100 # variable-declaration and not during expansion.
102 # Note that we must not clean ./src/shl_githead.c ever! If we would, a
103 # distribution tarball might delete that file and have no way to recreate it.
104 # We could delete it on something like "make maintainerclean", but then again,
105 # it seems unnecessary so lets simply not clean it at all.
107 # If the helper-script is executed in a directory that is not a git-repository
108 # (like a distribution tarball) and shl_githead.c exists, then it does nothing
109 # as it expects shl_githead.c to be correctly written by "make dist".
110 # However, if shl_githead.c does not exist, it will print a warning and write
111 # an unknown random git-revision.
112 # This guarantees, that shl_githead.c is always present and has the most correct
113 # value that we can get under any conditions.
115 # The $(emptyvariable) expansion below is used for broken $(shell ...)
116 # syntax-highlighting algorithms in many existing editors.
119 EXTRA_DIST += src/genversion.sh
120 GITHEAD:=$(shell $(emptyvariable)"$(srcdir)/src/genversion.sh" "$(srcdir)/src/shl_githead.c")
123 # Binary File Compiler
124 # This target gets as input a binary file *.bin and produces an ELF/etc. output
125 # object file *.bin.o and the corresponding libtool file *.bin.lo.
126 # Note that we fake the libtool object files as there is no way to make libtool
127 # create it. The comments in the .lo file are mandatory so don't remove them!
130 CLEANFILES += src/*.bin.lo src/*.bin.o
132 src/%.bin.lo: src/%.bin
133 $(AM_V_GEN)$(LD) -r -o "src/$*.bin.o" -z noexecstack --format=binary "$<"
134 $(AM_V_at)echo "# $@ - a libtool object file" >"$@"
135 $(AM_V_at)echo "# Generated by $(shell $(LIBTOOL) --version | head -n 1)" >>"$@"
136 $(AM_V_at)echo "#" >>"$@"
137 $(AM_V_at)echo "# Please DO NOT delete this file!" >>"$@"
138 $(AM_V_at)echo "# It is necessary for linking the library." >>"$@"
139 $(AM_V_at)echo >>"$@"
140 $(AM_V_at)echo "# Name of the PIC object." >>"$@"
141 $(AM_V_at)echo "pic_object='$*.bin.o'" >>"$@"
142 $(AM_V_at)echo >>"$@"
143 $(AM_V_at)echo "# Name of the non-PIC object" >>"$@"
144 $(AM_V_at)echo "non_pic_object='$*.bin.o'" >>"$@"
145 $(AM_V_at)echo >>"$@"
148 # SHL - Static Helper Library
149 # The SHL subsystem contains several small code pieces used all over kmscon and
150 # other applications.
153 noinst_LTLIBRARIES += libshl.la
155 libshl_la_SOURCES = \
160 src/shl_hashtable.h \
172 libshl_la_CPPFLAGS = \
174 $(XKBCOMMON_CFLAGS) \
176 libshl_la_LDFLAGS = \
185 # This library contains the whole event-loop implementation of kmscon. It is
186 # compiled into a separate object to allow using it in several other programs.
189 noinst_LTLIBRARIES += libeloop.la
191 libeloop_la_SOURCES = \
195 libeloop_la_LIBADD = libshl.la
196 libeloop_la_CPPFLAGS = $(AM_CPPFLAGS)
197 libeloop_la_LDFLAGS = $(AM_LDFLAGS)
201 # The uterm library provides helpers to create terminals in user-space. They
202 # are not limited to text-based terminals but rather provide graphics contexts
203 # so arbitrary output can be displayed. Additionally, they provide VT
204 # abstractions and an input layer
207 noinst_LTLIBRARIES += libuterm.la
209 libuterm_la_SOURCES = \
211 src/uterm_monitor.h \
214 src/uterm_input_internal.h \
215 src/uterm_video_internal.h \
216 src/uterm_systemd_internal.h \
218 src/uterm_monitor.c \
221 src/uterm_input_uxkb.c
223 nodist_libuterm_la_SOURCES =
225 libuterm_la_CPPFLAGS = \
229 libuterm_la_LIBADD = \
234 libuterm_la_LDFLAGS = \
237 if BUILD_ENABLE_MULTI_SEAT
238 libuterm_la_SOURCES += src/uterm_systemd.c
239 libuterm_la_CPPFLAGS += $(SYSTEMD_CFLAGS)
240 libuterm_la_LIBADD += $(SYSTEMD_LIBS)
243 if BUILD_ENABLE_VIDEO_FBDEV
244 libuterm_la_SOURCES += \
245 src/uterm_fbdev_internal.h \
246 src/uterm_fbdev_video.c \
247 src/uterm_fbdev_render.c
250 if BUILD_ENABLE_VIDEO_DRM2D
251 libuterm_la_SOURCES += \
252 src/uterm_drm2d_internal.h \
253 src/uterm_drm2d_video.c \
254 src/uterm_drm2d_render.c
255 libuterm_la_CPPFLAGS += $(DRM_CFLAGS)
256 libuterm_la_LIBADD += $(DRM_LIBS)
259 if BUILD_ENABLE_VIDEO_DRM3D
260 noinst_PROGRAMS += genshader
261 libuterm_la_SOURCES += \
262 src/uterm_drm3d_internal.h \
263 src/uterm_drm3d_video.c \
264 src/uterm_drm3d_render.c \
266 src/static_gl_math.c \
267 src/static_gl_shader.c
268 nodist_libuterm_la_SOURCES += src/static_shaders.c
269 libuterm_la_CPPFLAGS += \
274 libuterm_la_LIBADD += \
281 # add shared sources only once
282 UTERM_DRM_SHARED_SRC = \
283 src/uterm_drm_shared_internal.h \
284 src/uterm_drm_shared.c
285 if BUILD_ENABLE_VIDEO_DRM2D
286 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
288 if BUILD_ENABLE_VIDEO_DRM3D
289 libuterm_la_SOURCES += $(UTERM_DRM_SHARED_SRC)
295 # As there is no need to modify shaders at run-time, we statically compile them
296 # into object files. As autotools would ignore them, we need to add them to
298 # The program that converts the shaders into C-source files is "genshader". It's
299 # pretty simple and just creates a string with the shader source as content.
303 $(srcdir)/src/static_fill.vert \
304 $(srcdir)/src/static_fill.frag \
305 $(srcdir)/src/static_blend.vert \
306 $(srcdir)/src/static_blend.frag \
307 $(srcdir)/src/static_blit.vert \
308 $(srcdir)/src/static_blit.frag \
309 $(srcdir)/src/static_gltex.vert \
310 $(srcdir)/src/static_gltex.frag
312 EXTRA_DIST += $(SHADERS)
313 CLEANFILES += src/static_shaders.c
314 genshader_SOURCES = src/genshader.c
316 # TODO: Using $(BUILD_EXEEXT) breaks if it doesn't equal $(EXEEXT). But stupid
317 # automake doesn't allow $(EXEEXT) so lets just rely on both being the same.
319 src/static_shaders.c: $(SHADERS) genshader$(BUILD_EXEEXT)
320 $(AM_V_GEN)./genshader$(BUILD_EXEEXT) src/static_shaders.c $(SHADERS)
322 genshader$(BUILD_EXEEXT) $(genshader_OBJECTS): CC = $(CC_FOR_BUILD)
323 genshader$(BUILD_EXEEXT) $(genshader_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
324 genshader$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
328 # This generates the unifont sources from raw hex-encoded font data.
331 UNIFONT = $(top_srcdir)/src/font_unifont_data.hex
332 UNIFONT_BIN = src/font_unifont_data.bin
333 UNIFONT_LT = src/font_unifont_data.bin.lo
335 EXTRA_DIST += $(UNIFONT)
336 CLEANFILES += $(UNIFONT_BIN)
337 genunifont_SOURCES = src/genunifont.c
339 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CC = $(CC_FOR_BUILD)
340 genunifont$(BUILD_EXEEXT) $(genunifont_OBJECTS): CFLAGS = $(CFLAGS_FOR_BUILD)
341 genunifont$(BUILD_EXEEXT): LDFLAGS = $(LDFLAGS_FOR_BUILD)
343 $(UNIFONT_BIN): $(UNIFONT) genunifont$(BUILD_EXEEXT)
344 $(AM_V_GEN)./genunifont$(BUILD_EXEEXT) $(UNIFONT_BIN) $(UNIFONT)
350 if BUILD_ENABLE_FONT_UNIFONT
351 module_LTLIBRARIES += mod-unifont.la
352 noinst_PROGRAMS += genunifont
355 mod_unifont_la_SOURCES = \
356 src/kmscon_module_interface.h \
358 src/kmscon_mod_unifont.c
359 mod_unifont_la_LIBADD = \
362 mod_unifont_la_LDFLAGS = \
367 if BUILD_ENABLE_FONT_PANGO
368 module_LTLIBRARIES += mod-pango.la
371 mod_pango_la_SOURCES = \
372 src/kmscon_module_interface.h \
374 src/kmscon_mod_pango.c
375 mod_pango_la_CPPFLAGS = \
379 mod_pango_la_LIBADD = \
384 mod_pango_la_LDFLAGS = \
389 if BUILD_ENABLE_RENDERER_BBULK
390 module_LTLIBRARIES += mod-bbulk.la
393 mod_bbulk_la_SOURCES = \
394 src/kmscon_module_interface.h \
396 src/kmscon_mod_bbulk.c
397 mod_bbulk_la_LIBADD = libshl.la
398 mod_bbulk_la_LDFLAGS = \
403 if BUILD_ENABLE_RENDERER_GLTEX
404 module_LTLIBRARIES += mod-gltex.la
405 noinst_PROGRAMS += genshader
408 mod_gltex_la_SOURCES = \
409 src/kmscon_module_interface.h \
412 src/static_gl_math.c \
413 src/static_gl_shader.c \
414 src/kmscon_mod_gltex.c
415 nodist_mod_gltex_la_SOURCES = \
417 mod_gltex_la_CPPFLAGS = \
420 mod_gltex_la_LIBADD = \
423 mod_gltex_la_LDFLAGS = \
428 if BUILD_ENABLE_RENDERER_PIXMAN
429 module_LTLIBRARIES += mod-pixman.la
432 mod_pixman_la_SOURCES = \
433 src/kmscon_module_interface.h \
435 src/kmscon_mod_pixman.c
436 mod_pixman_la_CPPFLAGS = \
439 mod_pixman_la_LIBADD = \
442 mod_pixman_la_LDFLAGS = \
449 # These are the sources for the main binaries and test programs. They mostly
450 # consists of a single source file only and include all the libraries that are
451 # built as part of kmscon.
454 bin_PROGRAMS += kmscon
460 MANPAGES += docs/man/kmscon.1
473 src/kmscon_module_interface.h \
474 src/kmscon_module.h \
475 src/kmscon_module.c \
476 src/kmscon_terminal.h \
483 nodist_kmscon_SOURCES =
487 $(XKBCOMMON_CFLAGS) \
501 if BUILD_ENABLE_SESSION_DUMMY
502 kmscon_SOURCES += src/kmscon_dummy.c
505 if BUILD_ENABLE_SESSION_TERMINAL
506 kmscon_SOURCES += src/kmscon_terminal.c
525 test_output_SOURCES = \
528 test_output_CPPFLAGS = $(test_cflags)
529 test_output_LDADD = \
536 test_vt_CPPFLAGS = $(test_cflags)
541 test_input_SOURCES = \
544 test_input_CPPFLAGS = $(test_cflags)
552 test_key_CPPFLAGS = $(test_cflags)
553 test_key_LDADD = $(test_libs)
560 EXTRA_DIST += ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,$(MANPAGES)}}}}
561 CLEANFILES += $(MANPAGES) $(MANPAGES_ALIASES) .man_fixup
563 if BUILD_HAVE_XSLTPROC
564 if BUILD_HAVE_MANPAGES_STYLESHEET
566 man_MANS += $(MANPAGES) $(MANPAGES_ALIASES)
569 --stringparam man.authors.section.enabled 0 \
570 --stringparam man.copyright.section.enabled 0 \
571 --stringparam funcsynopsis.style ansi \
572 --stringparam man.output.quietly 1 \
575 XSLTPROC_PROCESS_MAN = \
576 $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
577 $(XSLTPROC) -o "$@" $(XSLTPROC_FLAGS) $(BUILD_MANPAGES_STYLESHEET) "$<" && \
580 # Force .man_fixup if $(MANPAGES) are not built
581 .man_fixup: | $(MANPAGES)
584 $(MANPAGES_ALIASES): $(MANPAGES) .man_fixup
585 $(AM_V_GEN)if test -n "$@" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' "$@" ; fi
587 docs/man/%.1: docs/man/%.xml
588 $(XSLTPROC_PROCESS_MAN)
590 docs/man/%.3: docs/man/%.xml
591 $(XSLTPROC_PROCESS_MAN)
593 docs/man/%.5: docs/man/%.xml
594 $(XSLTPROC_PROCESS_MAN)
596 docs/man/%.7: docs/man/%.xml
597 $(XSLTPROC_PROCESS_MAN)
599 endif # BUILD_HAVE_MANPAGES_STYLESHEET
600 endif # BUILD_HAVE_XSLTPROC